Le vendredi 17 avril 2015, oyster a écrit : > Two 8bpp(Gimp, xnview say so) graylevel png files can be downloaded > The first (ramp-gray.png) which gives right array shape is > http://bbs.blendercn.org/data/attachment/forum/201504/17/090627ejhixti8vdthdnnn.png > The second one (python-gray.png) which gives 'wrong' array shape, at > least to me, is > http://bbs.blendercn.org/data/attachment/forum/201504/16/222351w3952n3o9968m9a5.png > > [code] > from pylab import * > > imgRampPng=imread('ramp-gray.png') > print (imgRampPng.shape) #(1, 255), that is right > print (imgRampPng.min(),imgRampPng.max()) #(0.0, 0.99607843) > print () > > imgGrayPng=imread('python-gray.png') > print (imgGrayPng.shape) #(128, 128, 3), *but I suppose it should > be (128, 128)* > print (imgGrayPng.min(),imgGrayPng.max()) #(0.0, 0.98823529) > print () > Ch1=imgGrayPng[:,:,0] > Ch2=imgGrayPng[:,:,1] > Ch3=imgGrayPng[:,:,2] > print (Ch1.min(), Ch1.max()) #(0.0, 0.98823529) > print (Ch2.min(), Ch2.max()) #(0.0, 0.98823529) > print (Ch3.min(), Ch3.max()) #(0.0, 0.98823529) #that is to say, > Ch1/2/3 hold same data > print () > [/code]
Did you read my answer from yesterday ? your python-gray.png uses a color palette, the integer values stored in file are indexes to the (RGB) values given in the palette. Matplotlib is doing right in converting the indexes to the RGB values. The color palette represents here the grayscale, that's why all channel are equal. But the data is stored in the compact palette way. How were the two files produced? -- Fabrice ------------------------------------------------------------------------------ BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT Develop your own process in accordance with the BPMN 2 standard Learn Process modeling best practices with Bonita BPM through live exercises http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_ source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users