By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,172 Members | 762 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,172 IT Pros & Developers. It's quick & easy.

A way to more efficiently process arrays

P: 1
I am a bit of a newbie to python, and would like a little advice on how to more efficiently process arrays.

I work a lot with satellite data, and have opened and read two binary images into separate 2-D arrays using numarray.fromfile. What I want to do is is test each pixel in each image for various conditions, and depending on which condition the pixel value meets, write a number to a third array which is "empty" (contains pixels whose values are 0).

Up until now I have been using a sequence of numarray.choose statements to test specific conditions. E.g.:

numarray.choose(numarray.greater(array1,0.70),(arr ay3,array2))
numarray.choose(numarray.less_equal(array2,0.30),( array3,array2))...etc...

[If array1 > 0.7 then pixel in array3 takes value of corresponding pixel in array2; If array2 <= 0.30 then pixel in array 3 takes value of array2].

However, how could I code the above if I wanted to test for BOTH conditions to be true (i.e. I want to assign pixels in array3 a specific value IF (and only if) the corresponding pixels in array1 > 0.7 AND array2 <= 0.30)??

Thanks in advance,

Andrew
Oct 13 '05 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.