Using Global Contrast Normalization - Python pylearn2

亡梦爱人 提交于 2019-12-12 03:46:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!