NAME
nst_find_peaks - find intensity peaks in image
PROTOTYPE
int nst_find_peaks( int iDx, int iDy, int iNum, int iDist, void *pvImg, int iMode, int *piW, float *pfW, int *piX, int *piY)
ARGUMENTS
- int iDx
- image width
- int iDy
- image height
- int iNum
- nr of peaks to find
- int iDist
- minimal distance required
- void *pvImg
- the image
- int iMode
- iMode=0 if pvImg is float array, iMode=1, if pvImg is unsigned char array
- int *piW
- workspace array of dim iDy
- float *pfW
- workspace array of dim iDy
- int *piX
- x-locations of peaks found
- int *piY
- y-locations of peaks found
DESCRIPTION:
Finds the maximally iNum strongest intensity peaks in image
pfImg that have a minimal pairwise separation of iDist.
For iDist=0, the iNum maximal values are returned.
For iDist>0, the peaks are selected from the subset of
pixels that have no neighbors (in their 4-pixel
von-Neumann neighborhood) with larger values.
In this case, the set of returned peaks
usually will differ from the iNum maximal values.
RETURN VALUE:
The number of peaks that could be found (their locations
are written into piX[] and piY[])
NOTES:
Since the algorithm scans from bottom to top and from left
to right, it will always prefer in a group of
equally bright peaks that are located within a radius of iDist
the peak that is lowest left.
The algorithm compares the pixel
values in the von-Neumann neighborhood of the peak against
the center value; the peak is rejected, if any of the four
neighbors is larger.
ALGORITHM:
Basically, first the brightest pixel is located and a disk
of radius iDist is cut out. Then the brightest pixel in
the remaining pixel set is located and so on.
To avoid the necessity of
iNum full scans through the entire image, the
computation is organized as follows:
Let D0..Dk be disks of radius iDist centered around
peaks 0..k.
Let Mk = image without points in D0..Dk-1
The algorithm maintains two auxiliary arrays piW[] and pfW[]
such that after k peaks have been found, (piW[j],j) is for
each line j the location of the maximum value
pfW[j] in that pixel subset of the line that is farther than
iDist to any already detected peak.
When a new peak with center (x,y) is added, piW[y] and pfW[y] are
updated in the following way:
Update y:
pfW[y] = max_i(I(i,y)) in i<x-iDist or x+iDist<i
and (i,y) farther than iDist from any already
found peak.
piW[y] = i where the above maximum is attained
The next center is found by j0=argmax pfW[j] i0=piW[j0] and
accepting, when farther than iDist from all centers found so
far, updating pfW,piW for line j0 otherwise.
In this way, the computation is reduced from a brute force
iNum*iDx*iDy to roughly iDx*iDy + iNum*iNum
FILE
/local/homes/rhaschke/nst7/man/../o.linx86//../foldersrc/nst_pixel.c