Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
Re: Get values from one image according to pixel locations of maxima on another image
Dry in water writes: > I have two tiff images (named A and B). Both have 7 layers at the same dimension (4169,6289,7). First I'd like to find location of max value in A image and then I need to get the values (not max values, reall values) of B image in matrix dimension (4169, 6289) according to location of max value which found from A image in previous step. I just wrote next code to achieve this purpose. Then I wrote output tiff image. But when I display this tiff image, whole screen is black. Can you tell me what's wrong with this code? > A_max_loc=MAX(A,INDEX,DIMENSION=3) > B_val=B[INDEX] > write_tiff,'D:\Output_IDL\B_val_2000.TIF',B_val Let's see if this little experiment sheds any light: IDL> a = [2, 3, 4, 4, 2, 2, 0, 4] IDL> maxOfA = Max(a, index) IDL> Print, maxOfA 4 IDL> Print, index 2 Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ Sepore ma de ni thue. ("Perhaps thou speakest truth.")
On 12/21/12 9:05 AM, Dry in water wrote: > Hello all > > I have two tiff images (named A and B). Both have 7 layers at the same dimension (4169,6289,7). First I'd like to find location of max value in A image and then I need to get the values (not max values, reall values) of B image in matrix dimension (4169, 6289) according to location of max value which found from A image in previous step. I just wrote next code to achieve this purpose. Then I wrote output tiff image. But when I display this tiff image, whole screen is black. Can you tell me what's wrong with this code? > A_max_loc=MAX(A,INDEX,DIMENSION=3) > B_val=B[INDEX] > write_tiff,'D:\Output_IDL\B_val_2000.TIF',B_val > > Thank you so much > There's nothing obviously wrong in the code. Might there be NaNs in A? I would suggest taking a small (3x4) corner of the image and examining the values of A, B, and B_val to see if it appears to be doing what you expect. -Jeremy.