Re: Get min and max values from a multiband image according to pixel locations of classification image [message #82055] |
Sat, 17 November 2012 07:53 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> class1Pixels = Where(classifiedImage EQ class1, count)
> IF count GT 0 THEN BEGIN
> class1Min = minImage[class1Pixels]
> class1Max = maxImage[class1Pixels]
> ENDIF
If your images are large, it is often MUCH faster
to use the Histogram command to locate classified
pixels. Assume, for example, that in your classified
image, the three classes are labeled with 1, 2, and 3.
Then:
h = Histogram(classifiedImage, BinSize=1B, Reverse_Indices=ri)
class1Pixels = Reverse_Indices(ri, 1, COUNT=cnt1)
class2Pixels = Reverse_Indices(ri, 2, COUNT=cnt2)
Etc.
You can find Reverse_Indices here:
http://www.idlcoyote.com/programs/reverse_indices.pro
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
Re: Get min and max values from a multiband image according to pixel locations of classification image [message #82056 is a reply to message #82055] |
Sat, 17 November 2012 07:40  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Dry in water writes:
>
> Hello all,
>
> I have a question to solve following issue.
> I have two images. One is a multiband image with 7bands. Another is an classifiction image with 3 classes. The classes named by class1 to class3. I'd like to obtain a single max/min values from a multiband image according to pixel locations of each classes (class1, class2, class3) of classification image. Could you help me for this?
>
> Thank you very much
Get the MIN and MAX values of the band interleaved image:
minImage = Min(image, DIMENSION=3, Max=MaxImage)
Locate class pixels:
class1Pixels = Where(classifiedImage EQ class1, count)
IF count GT 0 THEN BEGIN
class1Min = minImage[class1Pixels]
class1Max = maxImage[class1Pixels]
ENDIF
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|