[Tutor] Numpy unexpected result: subtraction of cell values

Carnell, James E jecarnell at saintfrancis.com
Mon Jan 11 19:20:50 CET 2010

I'm sure this is easy, but I am having a difficult time finding the
right search terms to find it on the Internet. Any help much

3 dimensional array(x,y,rgb) which is a PIL image into a numpy array
using 'asarray' function.

I want to subtract the Red Value in an array cell from a neighboring Red
Value cell.

>>> pictArray[39][4]           		#pixel at 39 4
array([150, 140, 120], dtype=unint8)

>>> pictArray[39][5] 			#pixel at 39 5
array([160, 150, 120], dtype=unint8)

>>> pictArray[39][4][0]			#red pixel

>>> pictArray[39][5[0]			#neighboring red pixel

>>> pictArray[39][4] - pictArray[39][5] )
246  # <---------------  ???  vs -10

How do I get the number -10? Does this have to do with the dtype?

Thanks in advance, 

James Carnell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100111/d72693fa/attachment.htm>

More information about the Tutor mailing list