<div class="gmail_quote">On Mon, Jan 11, 2010 at 10:20 AM, Carnell, James E <span dir="ltr"><<a href="mailto:jecarnell@saintfrancis.com">jecarnell@saintfrancis.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<br>
<p><font size="2" face="Arial">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.</font></p>
<p><font size="2" face="Arial">3 dimensional array(x,y,rgb) which is a PIL image into a numpy array using 'asarray' function.</font>
</p>
<p><font size="2" face="Arial">I want to subtract the Red Value in an array cell from a neighboring Red Value cell.</font>
</p>
<p><font size="2" face="Arial">>>> pictArray[39][4] #pixel at 39 4</font>
<br><font size="2" face="Arial">array([150, 140, 120], dtype=unint8)</font>
</p>
<p><font size="2" face="Arial">>>> pictArray[39][5] #pixel at 39 5</font>
<br><font size="2" face="Arial">array([160, 150, 120], dtype=unint8)</font>
</p>
<p><font size="2" face="Arial">>>> pictArray[39][4][0] #red pixel</font>
<br><font size="2" face="Arial">150</font>
</p>
<p><font size="2" face="Arial">>>> pictArray[39][5[0] #neighboring red pixel</font>
<br><font size="2" face="Arial">160</font>
</p>
<p><font size="2" face="Arial">>>> pictArray[39][4] - pictArray[39][5] )</font>
<br><font size="2" face="Arial">246 # <--------------- ??? vs -10</font>
</p>
<p><font size="2" face="Arial">How do I get the number -10? Does this have to do with the dtype?</font>
</p></div></blockquote><div><br>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. There are a couple of weirdnesses in what you posted - unmatched parentheses and such - that are probably just typos.<br>
<br>Anyway, assuming that what you've posted IS the same as what you're trying to do, in your last line you're trying to subtract one entire cell from another (instead of just the red value of one from the red value of the other.) I don't know where the number 246 came from, but I'm not really sure what number I would have expected anyway (matrix algebra was a LONG time ago, I'm afraid!)<br>
<br>I think what you want to do is<br><font size="2" face="Arial">>>> pictArray[39][4][0] - pictArray[39][5]</font>[0]<br><br>I'm not in a place where I can test, but I think that should do it.<br><br>--- <br>
</div></div><a href="http://www.fsrtechnologies.com">www.fsrtechnologies.com</a><br>