Name
detpeak - detection of bright peaks in an image
Synopsis
detpeak [options] image.fits [...]
Description
detpeak detects localizes bright object centroids in an
image. It takes as argument a list of FITS cube names and
outputs on stdout the center of each detected bright zone.
It is also possible to get an average pixel value for each
zone.
Bright objects are detected if and only if they contain a
peak of sufficient amplitude i.e. more than K sigmas above
the mean image value, AND if they cover a surface at least
of 3x3 pixels. To detect peaks located in a window smaller
than 3x3, there is an option to smear out the image by a
low-pass filter before applying peak detection, but of
course it has associated drawbacks.
By default, detpeak will be looking at all the signal
which is more than 2 sigmas above the average pixel value.
This value can be changed using the -s (or --sigma)
option.
In spite of calls to morphological filters, detpeak is
surprisingly faster than other usual algorithms. It should
be used as a peak position estimator more than a precise
locator, though.
Algorithm
detpeak creates first a binary map of all pixel positions
which have a value above a given threshold (by default,
average plus 2 sigmas).
A binary morphological erosion, and a dilatation are then
performed to close all regions smaller than 3x3, which
removes all isolated bad pixels.
Last, a floodfill algorithm is applied to find the geomet-
ric center of all remaining white blobs. A position and an
average pixel value are returned for each found blob, in
each image plane of each input cube.
If fine positioning is activated (-f or --finepos option),
a subsequent process is called, which requests 3 user-
defined radiuses in pixels: r1, r2, and r3. For each found
peak position in the image, a background is computed as
the mean pixel value in the ring centered on the estimated
peak position, of radiuses r2 and r3. Then a barycenter is
computed within the disk centered on the same spot, of
radius r1, using background-subtracted pixel values as
weights. This fine positioning method proves quite
reliable, but requires all peaks in the image to have more
or less the same size to fit into the circles defined by
r1, r2, r3.
Options
-s cut or --sigma cut
Use this option to change the cut level in a factor
of sigmas. The lower this value, the more bright
zones may be detected. The higher this factor is,
the less detected peaks. The default of 2.0 seems
to work fine on images having a high Signal to
Noise Ratio.
-f 'r1 r2 r3' or --finepos 'r1 r2 r3'
Fine positioning: provide three values r1 < r2 <
r3. The radiuses r2 and r3 specify a ring around
each detected point, from which an estimation of
the background is computed. A barycenter is then
computed in the disk of radius r1, using back-
ground-subtracted pixel values as weights. No
defaults are given to these parameters.
Be aware when using this position refining that it
assumes the following conditions.
All peaks are isolated, i.e. the closest distance between
2 peaks is strictly greater than 2 * r3.
There is a background zone around every peak, always
within the disk defined by r2 and r3. Otherwise, the back-
ground estimation is contaminated with peak signals.
All peaks are contained in a disk of radius r1.
-l or --smearing
This option (low-pass filter) applies a 5x5 convo-
lution with a flat kernel before trying to detect
objects. The smearing is h.PPful to detect objects
which are smaller than a 3x3 window. It increases
the number of detections, but also the number of
false detections. Bad pixels, for example, are
smeared out to a 5x5 window and detected as proper
peaks. Another issue is that 2 close peaks will be
smeared out to a single one. Most probably, the
returned result will be a barycenter of the 2
regions instead of the 2 expected centers. Because
the smearing will lower the signal in all regions,
the default sigma cut is halved when this options
is used.
--sao or -o sao
SAOimage compatible output format. See section
below.
--mag or -o mag
Magnitude output format. See section below. This is
no estimation of the stars' magnitude, but just an
average pixel value over the zone, to be used for
example as a criterion to classify objects, or for
point-pattern matching.
Output Formats
As a default, detpeak only outputs the positions in X and
Y. A typical output is:
#-----------------------------------------------
# FILE star.fits
# PLANE: 1
112.47 129.55
#-----------------------------------------------
The following options are also possible:
SAOimage compatible format. A typical output is:
% detpeak -o sao star.fits
(equivalent to: detpeak --sao star.fits)
#-----------------------------------------------
# FILE star.fits
# PLANE: 1
POINT( 112.47, 129.55)
#-----------------------------------------------
This output can be redirected to a file, and read from the
SAOimage utility, in menu Cursor/region/read.
Another option is to output the average pixel value in
each detected zone (magnitude output format). A typical
output is:
% detpeak -o mag star.fits
(equivalent to detpeak --mag star.fits)
#---------------------------------------------------------
# FILE star.fits
# PLANE: 1
112.47 129.55 0.06
#---------------------------------------------------------
Examples
> detpeak *.fits
would return all found bright positions for all planes in
all files matching *.fits in the current directory.
To find all very bright peaks (more than 5 sigmas above
the average):
> detpeak -s 5.0 *.fits
To use fine positioning in an image where all peaks are
within a disk of 5 pixels in radius, around which a back-
ground can be computed on a ring of radiuses 6 and 12 pix-
els:
> detpeak -f '5 6 12' *.fits
Files
Input files shall all comply with FITS format.
See Also
stcube, shiftadd
Bugs
Peaks located on an image edge will not be detected.
The fine positioning method makes assumptions about the
signal, which may not be fulfilled in many cases. Use it
with caution, especially when determining the radiuses r1,
r2, and r3 for background computation and weighing region.
It would be nice to find an algorithm for automatic set-
ting of the sigma threshold, instead of relying on a
default value.