【问题标题】:Using Global Contrast Normalization - Python pylearn2使用全局对比度归一化 - Python pylearn2
【发布时间】:2015-07-21 21:36:04
【问题描述】:

我正在尝试将我的图像输入到此方法中,但是当我尝试绘制图像时,它完全变黑了。

我尝试只输入一张图像并输入整个 MNIST 数据集。 结果一样。

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 变黑了。

我做错了什么?

【问题讨论】:

    标签: python global contrast pylearn


    【解决方案1】:

    您是否尝试过在不乘以 255 的情况下可视化图像? 即,

    import matplotlib.pyplot as plt
    
    img = img_gcn[:, 0]
    img = img.reshape(28, 28, order='F')    
    plt.imshow(img, cmap=plt.get_cmap('gray'))
    

    我认为该程序应该可行。

    【讨论】:

    • img_gcn = global_contrast_normalize(data) #img_gcn = global_contrast_normalize(img0) ##img_gcn_1 = Image.fromarray(img_gcn[1,1:].reshape((28,28)).astype('uint8 ')*255) ##img_gcn_1.show() iimg = img_gcn[:, 0] img = img.reshape(28, 28, order='F') plt.imshow(img, cmap=plt.get_cmap('灰色')) img = img.reshape(28, 28, order='F') ValueError: 新数组的总大小必须不变
    • img 尝试调整大小后的尺寸是多少?
    • img.shape= (42000L,) .................... .....从这里打印: img = img_gcn[:, 0] print "img.shape= ",img.shape img = img.reshape(28, 28, order='F') plt.imshow(img, cmap=plt.get_cmap('灰色'))
    • 这很好用:#GCN# data_to_gcn = data[:,1:] img_gcn = global_contrast_normalize(data_to_gcn) img = img_gcn[0,:] img = img.reshape(28, 28, order= 'F') plt.imshow(img, cmap=plt.get_cmap('gray')) plt.show() 但是当我尝试使用 imageFromArray 时,它会变黑
    • #GCN# data_to_gcn = data[:,1:] img_gcn = global_contrast_normalize(data_to_gcn) img = img_gcn[0,:] img = img.reshape(28, 28, order='F') plt.imshow(img, cmap=plt.get_cmap('gray')) #Works plt.show() #Fails im = Image.fromarray(img) im.show()
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-05
    • 1970-01-01
    • 2011-11-17
    • 1970-01-01
    • 2017-08-31
    • 1970-01-01
    • 2015-12-01
    相关资源
    最近更新 更多