[Tutor] Python Image library

Tiger12506 keridee at jayco.net
Thu Jul 19 01:38:45 CEST 2007


You know the height and the width of the image, no?

So you know that every 'width' number of pixels will start a new row.
So if you wanted say the fifth row down, second pixel, how would you find 
it?

The 1st line:  'width' number of pixels
The 2nd line: 'width' number of pixels
The 3rd line: 'width number of pixels
The 4th line: 'width' number of pixels
The 5th line: 2 pixels in from the left

Add those up ~  width+width+width+width+2
Or  4*width+2

That number is the index to use to get the pixel at coords (2,5)
so

pixel = getdata()
pixel[4*width+2]

For this example.
Work out a more general solution for yourself please.

JS

> getdata() returns a flattened list, [n]
>
>
> but i am not sure how to access it.
>
> when I want to get rgb from a window of 100,200,
>
> get data starts from 0    (0~99, 0~199)
>
> the point of  x,y = 2, 1
>
> do I put in
>
> pixel[100]   ?
>
>
> it's actually not the case  @_@
>
> what should I put in ?



More information about the Tutor mailing list