Re: Get values from one image according to pixel locations of maxima on another image [message #82551] |
Sun, 23 December 2012 19:58 |
Jeremy Bailin
Messages: 618 Registered: April 2008
|
Senior Member |
|
|
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.
|
|
|
Re: Get values from one image according to pixel locations of maxima on another image [message #82563 is a reply to message #82551] |
Fri, 21 December 2012 06:34  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
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.")
|
|
|