# [Tutor] Numpy unexpected result: subtraction of cell values

Marc Tompkins marc.tompkins at gmail.com
Mon Jan 11 21:01:38 CET 2010

```On Mon, Jan 11, 2010 at 11:02 AM, Carnell, James E <
jecarnell at saintfrancis.com> wrote:

>
> >
> > 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
> > appreciated.
> >
> > 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
> > 150
> >
> > >>> pictArray[39][5[0]                  #neighboring red pixel
> > 160
> >
> > >>> pictArray[39][4][0] - pictArray[39][5][0]
> > 246  # <---------------  ???  vs -10
> >
> > How do I get the number -10? Does this have to do with the dtype?
> >
>
> It looks like you're re-typing from your terminal window into your Compose
> window... your life (and ours!) will be simpler if you just cut and paste.
>
>         - sorry I am at work and due to security reasons can't plug a
> thumb drive in for copying copde from my laptop. I have corrected the values
> above.
>
>         - pictArray[39][4][0] - pictArray[39][5][0] = 246  is where I am
> getting stuck
>
>
> Silly of me not to have noticed, but those are UNsigned 8-bit integers,
which means values 0-255.  -10 wraps around to 246.

> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>

--
www.fsrtechnologies.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100111/347773fc/attachment.htm>
```