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

Home » Public Forums » archive » Re: Non maxima supression
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: Non maxima supression [message #51582] Mon, 27 November 2006 13:01 Go to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
Charudatta Phatak wrote:
> Hello,
>
> I want to do a non maxima supression on a 2d array within a specified
> neighborhood of pixels. The way i am doing it right now is looping over
> all the pixels and check if the value is max in the 5x5 neighborhood. if
> it is max then keep it or else set it to zero. Is there a IDL way to do
> it faster than 2 for loops?
>
> thanx
>
> cheers,
> -cd

You can vectorize this.

neighborhood = [-9,-1,1,9] ;In this example, a Von Newman neighborhood
centered on the cell [0] of a 10 * x array. Do NOT keep the "central"
cell index.

data = ... ;your 2D array

neighborhoodIndices = neighborhood + indgen(n_elements(data)) ;If you
want to omit some pixels, like on the edge, put an array of valid
indices instead of the indgen().

neighborhoodValues = data[neighborhoodIndices]

sortedNeighbIndices = sort_ND(neighborhoodValues,1) ;Get sort_ND from
the web or from JD..

highestValue =
neighborhoodValues[sortedNeighbIndices[n_elements(neighborho od)-1, *]]

writeZeroAt = where(neighborhoodValues gt data)

data[writeZeroAt] = 0


Jean
[Message index]
 
Read Message
Read Message
Previous Topic: Gatan Digital Micrograph .dm3 files
Next Topic: Re: GUI size on different screens

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

Current Time: Sat Oct 11 12:13:07 PDT 2025

Total time taken to generate the page: 1.58824 seconds