问题
Im attempting to input my image to this method, but when i try to draw the image, it comes totally black.
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()
The second image, which is img_gcn_1 comes blacked.
What am i doing wrong?
回答1:
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.
来源:https://stackoverflow.com/questions/31550056/using-global-contrast-normalization-python-pylearn2