[Image-SIG] Reversed X an Y when convering PIL images to NumPy arrays

Yury V. Zaytsev yury at shurup.com
Mon Apr 19 16:07:46 CEST 2010


Is it normal when I execute the following code I get the red dot at X =
200, Y = 100 on the plot?! I would have expected to be able to address
pixels in the resulting array in a usual p[X, Y] format.

I might be blind, but I haven't found anything in the documentation.
Actually I have found out about the possibility to interface with Numpy
itself at some blog: http://effbot.org/zone/pil-changes-116.htm .

import Image
import numpy as np
import pylab as pyl

if __name__ == "__main__":

    img_name = 'ch43_roi.tiff'
    img = Image.open(img_name)

    a = np.asarray(img)

    p = a.copy()
    p[100, 200] = (255, 0, 0)


Sincerely yours,
Yury V. Zaytsev

More information about the Image-SIG mailing list