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

Home » Public Forums » archive » Re: find bimodal maximum in each row
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: find bimodal maximum in each row [message #74891 is a reply to message #74884] Fri, 04 February 2011 12:57 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Friday, February 4, 2011 4:02:47 AM UTC-5, vijay wrote:
> I have an array of 512x512 and for each row there is a
> bimodal like peak. I want to find this peak in each row (ex. first
> peak value 177 and second peak value 244, etc). Like that each row
> will have two different peak
> values. How to obtain these peak values for the whole array and result
> them in new array.

If you can guarantee that the peaks will not occur in the first or last column of each row, this will give you every single local maximum:

q = [[0,1,2,1,2,1,0], [1,2,0,0,2,2,0], [0,2,2,2,0,1,0]]
nx = (size(q, /dimen))[0]

; is this a local maximum? (note that the index starts at element 1,* of q)
peakp = (q[1:nx-2,*] gt q[2:nx-1,*]) and (q[0:nx-3,*] le q[1:nx-2,*])
; where is that true?
peaklocations = where(peakp)
; turn into array locations into peakp
peaklocations_xy = array_indices(peakp, peaklocations)
; increment the x coordinate because peakp is shifted one element to the right of q
peaklocations[0,*]++
; what are the values of q there?
peakvals = q[peaklocations_xy[0,*], peaklocations_xy[1,*]]

IDL> print, peaklocations_xy
2 0
4 0
1 1
5 1
3 2
5 2
IDL> print, peakvals
2
2
2
2
2
1

Note that it will pick up every single local maximum, regardless of how many there are per row.

-Jeremy.
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: How to Find Bimodal peak values in an array
Next Topic: Re: Multiple Coyote Directories

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

Current Time: Fri Oct 10 03:51:28 PDT 2025

Total time taken to generate the page: 0.95884 seconds