[Numpy-discussion] asarray() and PIL

Sebastian Haase seb.haase at gmail.com
Wed May 27 11:20:46 EDT 2009


On Wed, May 27, 2009 at 5:12 PM, cp <lubensch.proletariat.inc at gmail.com> wrote:
> Hi,
> I'm using PIL for image processing, but lately I also try numpy for the
> flexibility and superior speed it offers. The first thing I noticed is that for
> an RGB image with height=1600 and width=1900 while
>
> img=Image.open('something.tif')
> img.size
> (1900,1600)
>
> then
>
> arr=asarray(img)
> arr.shape
> (1600,1900,3)
>
> This means that the array-image has 1600 color channels, 1900 image pixel rows
> and 3 image pixel columns. Why is that?
> if I reshape with
>
> arr.reshape(3,1900,1600)
>
You should look into transpose if you prefer the the colors to be on
the first axis instead of the last one -- that's what I like to do.

Regards,
Sebastian Haase



More information about the NumPy-Discussion mailing list