comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: efficient comparing 1D and 3D arrays
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: efficient comparing 1D and 3D arrays [message #60909 is a reply to message #60678] Wed, 11 June 2008 13:46 Go to previous messageGo to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
Jelle wrote:
> On Jun 11, 5:37 pm, Jean H <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
> wrote:
>> Hi,
>> Yes you can...do something like:
>> minVals = [15,30,12] ;Min val in each band
>> maxVals = [75,80,60] ;Max val in each band
>>
>> allMin = rebin(minVals, nb,nl,ns) ;repeat the min band value for every
>> pixels in each band
>> allMax = rebin(maxVals, nb,nl,ns)
>>
>> goodPixels = where(imgData gt allMin and imgData lt allMax)
>>
>> ==> returns the indexes of imgData that satisfy the condition in EVERY band.
>>
>> Jean
>
> :( unfortunately it does not return the indices I was hoping for. It
> returns an array with between 0 and 75 elements, for each individual
> element. So it tells me for which pixel which band matches. This I
> *could* of course use to calculate the array_indices, subset by only
> row/colum indices and reverse back into 1D positional elements, make
> uniq() and then create the layer, but I am hoping there is a fell
> swoop with which I can do this in one step; a way to create a [ns, nl]
> bytearr with 0/1 to match the condition that each band for that bixel
> falls within the desired range...
>
>
> J

Ok, I advise you to read the histogram tutorial on David's website to
fully understand the following:


nb=3
ns=5
nl=5
imgData = fix(randomu(seed,nb,nl,ns)*100)

minVals = [15,30,12] ;Min val in each band
maxVals = [75,80,60] ;Max val in each band

allMin = rebin(minVals, nb,nl,ns) ;repeat the min band value for every
pixels in each band
allMax = rebin(maxVals, nb,nl,ns)

goodPixelsPerBand = where(imgData gt allMin and imgData lt allMax)

tmp = where(histogram(goodPixelsPerBand/nb, min=0, R=ri) eq nb)
;==>make sure nb is an integer, NOT a float!!!

Divide the subscript by NB to "remove" the dimension of the band. Then,
do an histogram on it. If you have NB times an entry, it means these
pixels satisfy the condition in all NB bands. Keep track or the
reverse_indices to find out which entry in goodPixelsPerBand satisfied
the conditions.

goodPixels = goodPixelsPerBand[ri[ri[tmp]]]
;get back to the original indices. Since you only query on ri[tmp], you
will only get the first index in GoodPixelsPerBand that satisfy all
condition (i.e. not the index in every band)...
---
Now, there might be another solution with total() on goodPixelsPerBand/NB

Jean
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: How to add tie point information for ENVI in IDL?
Next Topic: Re: Filling a contour

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 02:18:19 PDT 2025

Total time taken to generate the page: 0.16092 seconds