Using Global Contrast Normalization - Python pylearn2

1.7k Views Asked by At

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

There are 1 best solutions below

15
On

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.