本文介绍了使用全局对比度标准化-Python pylearn2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将我的图像输入此方法,但是当我尝试绘制图像时,它完全变成黑色.
Im attempting to input my image to this method, but when i try to draw the image, it comes totally black.
我尝试仅输入一张图像并输入整个MNIST数据集.结果相同.
I tried inputing just one image and inputing the whole MNIST dataset.Same result.
https://github.com/lisa- lab/pylearn2/blob/master/pylearn2/expr/preprocessing.py
if GCN is True:
trainingFolder = "../inputData/converted_training/GCN/"
testingFolder = "../inputData/converted_testing/GCN/"
img0 = (data[1,1:]).reshape((28,28)).astype('uint8')*255
im = Image.fromarray(img0)
im.show()
#GCN#
img_gcn = global_contrast_normalize(data)
img_gcn_1 = Image.fromarray(img_gcn[1,1:].reshape((28,28)).astype('uint8')*255)
img_gcn_1.show()
第二张图片img_gcn_1变黑了.
The second image, which is img_gcn_1 comes blacked.
我在做什么错?
推荐答案
您是否尝试形象化图像而不乘以255? 即
Have you tried to visualize the image without multiplying by 255? i.e.,
import matplotlib.pyplot as plt
img = img_gcn[:, 0]
img = img.reshape(28, 28, order='F')
plt.imshow(img, cmap=plt.get_cmap('gray'))
我认为该程序应该有效.
I think that procedure should work.
这篇关于使用全局对比度标准化-Python pylearn2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!