Re: [Numpy-discussion] Help with bit arrays

2016-04-29 Thread Henrique Almeida
I agree with everything, but the unexpected are something else. The TIFF images have no colormap. The colormap that I'm referring to is the GUI colormap, used by matplotlib to draw the image (imshow parameter cmap). The problematic image format is the black and white 1-bit TIFF format. It is

Re: [Numpy-discussion] Help with bit arrays

2016-04-29 Thread Benjamin Root
What behavior is unexpected? For the (256, 256) images, matplotlib applies its default colormap to the grayscale (v1.5 and previous, that is jet, +v2.0, that will be viridis). The numpy array as loaded from PIL will never carry any additional information that came from the TIFF. As for PIL, it

Re: [Numpy-discussion] Help with bit arrays

2016-04-29 Thread Henrique Almeida
I think in any case, the result is unexpected, PIL is loading garbage from memory when loading black and white images because it sends the wrong buffer size, and matplotlib correctly loads the black and white image, but stores it in a 3D array. 2016-04-29 13:43 GMT-03:00 Henrique Almeida

Re: [Numpy-discussion] Help with bit arrays

2016-04-29 Thread Henrique Almeida
For 1 bit images, the resulting array has shape (256, 256, 4). For grayscale images, the shape is (256, 256). So the image seems to have been loaded as a color image. 2016-04-29 13:38 GMT-03:00 Benjamin Root : > What kind of array is "img"? What is its dtype and shape? > >

Re: [Numpy-discussion] Help with bit arrays

2016-04-29 Thread Benjamin Root
What kind of array is "img"? What is its dtype and shape? plt.imshow() will use the default colormap for matplotlib if the given array is just 2D. But if it is 3D (a 2D array of RGB[A] channels), then it will forego the colormap and utilize that for the colors. It knows nothing of the colormap

Re: [Numpy-discussion] Help with bit arrays

2016-04-29 Thread Henrique Almeida
Paul, yes, imread() worked for reading the black and white TIFF. The situation improved, but now, there seems to be some problem with the color map. Example code: #!/usr/bin/env python3 import numpy from matplotlib import pyplot, cm img = pyplot.imread('oi-00.tiff') pyplot.imshow(img)

Re: [Numpy-discussion] Help with bit arrays

2016-04-29 Thread Paul Hobson
Does using pyplot.imgread work? On Fri, Apr 29, 2016 at 8:27 AM, Henrique Almeida wrote: > Any help with this problem ? > > 2016-04-27 11:35 GMT-03:00 Henrique Almeida : > > Hello, what's the current status on numpy for loading bit-arrays ? > > >

Re: [Numpy-discussion] Help with bit arrays

2016-04-29 Thread Henrique Almeida
Any help with this problem ? 2016-04-27 11:35 GMT-03:00 Henrique Almeida : > Hello, what's the current status on numpy for loading bit-arrays ? > > I'm currently unable to correctly load black and white (1-bit) TIFF > images. Code example follows: > > from PIL import

[Numpy-discussion] Help with bit arrays

2016-04-27 Thread Henrique Almeida
Hello, what's the current status on numpy for loading bit-arrays ? I'm currently unable to correctly load black and white (1-bit) TIFF images. Code example follows: from PIL import Image import numpy from matplotlib import pyplot img = Image.open('oi-00.tiff') a = numpy.array(img) ^ does not