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 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Non maxima supression [message #51582] Mon, 27 November 2006 13:01
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
Re: Non maxima supression [message #51585 is a reply to message #51582] Mon, 27 November 2006 11:09 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Charudatta Phatak writes:

> 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?

Can you use any of the lessons learned in this "maximum value
array resampling" article:

http//www.dfanning.com/idl_way/maxresample.html

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Wed Oct 08 19:34:21 PDT 2025

Total time taken to generate the page: 0.00653 seconds