> I have to find the local maxima in an image surface. Is there a more
> elegant/efficient method than simply comparing each pixel to its
Comparing each pixel to his 8 neighbors is not sufficient, because
local maxima can have a size of several pixels that form a plateau.
Here is the morphological way for computing maxima on gray-level
Let "rec" be a reconstruction function (geodesic dilations until
stability, often realized in a queue-based manner in order to be fast),
G0 the original image and B0 the result.
B0=threshold(G0-rec(G0-1,G0), 1, 1)
- "G0-1" is an image, which you obtain by decrementing all the pixels
of G0 by 1
- "rec(G0-1,G0)" will give an image that has the same values as G0 for
all pixels excepting the local maxima
- the following subtraction and thresholding will give the final result
as a binary image.
Calculation time depends mostly on the reconstruction algorithm, and
queue-based reconstruction depends on the image information. To give
you an idea: it is about 200ms for a 640x480 gray (8 bits) level image
on a 500MHz computer with our image analysis system Qlisp.