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 <ben.v.r...@gmail.com>:
> 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 contained in the TIFF.
>
> Ben Root
>
>
> On Fri, Apr 29, 2016 at 12:31 PM, Henrique Almeida <hdante.l...@gmail.com>
> wrote:
>>
>>  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)
>> pyplot.colorbar()
>> pyplot.show()
>>
>>  The code can open both 1-bit and 8-bit images, but only with 8 bits
>> the image is shown with the colormap colors. The 1 bit image is shown
>> as black and white.
>>
>>  The questions:
>>  1) Should Image.open() behave like pyplot.imread() ? Is this a bug in PIL
>> ?
>>  2) Why isn't the colormap working with black and white images ?
>>
>> 2016-04-29 13:06 GMT-03:00 Paul Hobson <pmhob...@gmail.com>:
>> > Does using pyplot.imgread work?
>> >
>> > On Fri, Apr 29, 2016 at 8:27 AM, Henrique Almeida
>> > <hdante.l...@gmail.com>
>> > wrote:
>> >>
>> >>  Any help with this problem ?
>> >>
>> >> 2016-04-27 11:35 GMT-03:00 Henrique Almeida <hdante.l...@gmail.com>:
>> >> >  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 work for 1-bit TIFF images
>> >> >
>> >> > PIL source shows that it incorrectly uses typestr == '|b1'. I tried
>> >> > to
>> >> > change this to '|t1', but I get :
>> >> >
>> >> > TypeError: data type "|t1" not understood
>> >> >
>> >> > My goal is to make the above code to work for black and white TIFF
>> >> > images the same way it works for grayscale images. Any help ?
>> >> _______________________________________________
>> >> NumPy-Discussion mailing list
>> >> NumPy-Discussion@scipy.org
>> >> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>> >
>> >
>> >
>> > _______________________________________________
>> > NumPy-Discussion mailing list
>> > NumPy-Discussion@scipy.org
>> > https://mail.scipy.org/mailman/listinfo/numpy-discussion
>> >
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion@scipy.org
>> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to