pmSource.h

Go to the documentation of this file.
00001 /* @file  pmSource.h
00002  *
00003  * @author EAM, IfA; GLG, MHPCC
00004  *
00005  * @version $Revision: 1.10 $ $Name:  $
00006  * @date $Date: 2007/01/24 02:54:15 $
00007  * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
00008  */
00009 
00010 # ifndef PM_SOURCE_H
00011 # define PM_SOURCE_H
00012 
00013 /// @addtogroup Objects Object Detection / Analysis Functions
00014 /// @{
00015 
00016 /**
00017  * In the object analysis process, we will use specific mask values to mark the
00018  * image pixels. The following structure defines the relevant mask values.
00019  *
00020  * XXX: This is probably a bad solution: we will want to set mask values
00021  * outside of the PSPHOT code.  Perhaps we can set up a registered set of mask
00022  * values with specific meanings that other functions can add to or define?
00023  
00024  * XXX We will only use the PM_MASK_xxx mask values
00025 typedef enum {
00026     PM_SOURCE_MASK_CLEAR     = 0x00,
00027     PM_SOURCE_MASK_INVALID   = 0x01,
00028     PM_SOURCE_MASK_SATURATED = 0x02,
00029     PM_SOURCE_MASK_MARKED    = 0x08,
00030 } psphotMaskValues;
00031 */
00032 
00033 /** pmSourceType enumeration
00034  *
00035  * A given source may be identified as most-likely to be one of several source
00036  * types. The pmSource entry pmSourceType defines the current best-guess for this
00037  * source.
00038  *
00039  * XXX: The values given below are currently illustrative and will require
00040  * some modification as the source classification code is developed. (TBD)
00041  *
00042  */
00043 typedef enum {
00044     PM_SOURCE_TYPE_UNKNOWN,  ///< a cosmic-ray
00045     PM_SOURCE_TYPE_DEFECT,  ///< a cosmic-ray
00046     PM_SOURCE_TYPE_SATURATED,  ///< random saturated pixels
00047     PM_SOURCE_TYPE_STAR,  ///< a good-quality star
00048     PM_SOURCE_TYPE_EXTENDED,  ///< an extended object (eg, galaxy)
00049 } pmSourceType;
00050 
00051 typedef enum {
00052     PM_SOURCE_MODE_DEFAULT    = 0x0000, ///<
00053     PM_SOURCE_MODE_PSFMODEL   = 0x0001, ///<
00054     PM_SOURCE_MODE_EXTMODEL   = 0x0002, ///<
00055     PM_SOURCE_MODE_SUBTRACTED = 0x0004, ///<
00056     PM_SOURCE_MODE_FITTED     = 0x0008, ///<
00057     PM_SOURCE_MODE_FAIL       = 0x0010, ///<
00058     PM_SOURCE_MODE_POOR       = 0x0020, ///<
00059     PM_SOURCE_MODE_PAIR       = 0x0040, ///<
00060     PM_SOURCE_MODE_PSFSTAR    = 0x0080, ///<
00061     PM_SOURCE_MODE_SATSTAR    = 0x0100, ///<
00062     PM_SOURCE_MODE_BLEND      = 0x0200, ///<
00063     PM_SOURCE_MODE_LINEAR     = 0x0400, ///<
00064     PM_SOURCE_MODE_TEMPSUB    = 0x0800, ///< XXX get me a better name!
00065     PM_SOURCE_MODE_EXTERNAL   = 0x1000, ///< XXX get me a better name!
00066 } pmSourceMode;
00067 
00068 /** pmSource data structure
00069  *
00070  *  This source has the capacity for several types of measurements. The
00071  *  simplest measurement of a source is the location and flux of the peak pixel
00072  *  associated with the source:
00073  *
00074  */
00075 typedef struct
00076 {
00077     const int id;   ///< Unique ID for object
00078     pmPeak *peak;   ///< Description of peak pixel.
00079     psImage *pixels;   ///< Rectangular region including object pixels.
00080     psImage *weight;   ///< Image variance.
00081     psImage *mask;   ///< Mask which marks pixels associated with objects.
00082     pmMoments *moments;   ///< Basic moments measure for the object.
00083     pmModel *modelPSF;   ///< PSF Model fit (parameters and type)
00084     pmModel *modelEXT;   ///< EXT (floating) Model fit (parameters and type).
00085     pmSourceType type;   ///< Best identification of object.
00086     pmSourceMode mode;   ///< Best identification of object.
00087     psArray *blends;
00088     float psfMag;   ///< calculated from flux in modelPsf
00089     float extMag;   ///< calculated from flux in modelEXT
00090     float errMag;   ///< error in psfMag OR extMag (depending on type)
00091     float apMag;   ///< apMag corresponding to psfMag or extMag (depending on type)
00092     float pixWeight;   // model-weighted coverage of valid pixels
00093     psRegion region;   // area on image covered by selected pixels
00094     float sky, skyErr;   //?< The sky and its error at the center of the object
00095 }
00096 pmSource;
00097 
00098 /** pmPSFClump data structure
00099  *
00100  * A collection of object moment measurements can be used to determine
00101  * approximate object classes. The key to this analysis is the location and
00102  * statistics (in the second-moment plane,
00103  *
00104  */
00105 typedef struct
00106 {
00107     float X;
00108     float dX;
00109     float Y;
00110     float dY;
00111 }
00112 pmPSFClump;
00113 
00114 
00115 /** pmSourceAlloc()
00116  *
00117  */
00118 pmSource  *pmSourceAlloc();
00119 
00120 /** pmSourceCopy()
00121  *
00122  */
00123 pmSource  *pmSourceCopy(pmSource *source);
00124 
00125 // free just the pixels for a source, keeping derived data
00126 void pmSourceFreePixels(pmSource *source);
00127 
00128 bool pmIsSource(const psPtr ptr);
00129 
00130 /** pmSourceDefinePixels()
00131  *
00132  * Define psImage subarrays for the source located at coordinates x,y on the
00133  * image set defined by readout. The pixels defined by this operation consist of
00134  * a square window (of full width 2Radius+1) centered on the pixel which contains
00135  * the given coordinate, in the frame of the readout. The window is defined to
00136  * have limits which are valid within the boundary of the readout image, thus if
00137  * the radius would fall outside the image pixels, the subimage is truncated to
00138  * only consist of valid pixels. If readout->mask or readout->weight are not
00139  * NULL, matching subimages are defined for those images as well. This function
00140  * fails if no valid pixels can be defined (x or y less than Radius, for
00141  * example). This function should be used to define a region of interest around a
00142  * source, including both source and sky pixels.
00143  *
00144  */
00145 bool pmSourceDefinePixels(
00146     pmSource *mySource,                 ///< source to be re-defined
00147     const pmReadout *readout,  ///< base the source on this readout
00148     psF32 x,                            ///< center coords of source
00149     psF32 y,                            ///< center coords of source
00150     psF32 Radius                        ///< size of box on source
00151 );
00152 
00153 bool pmSourceRedefinePixels (
00154     pmSource *mySource,   ///< source to be re-defined
00155     const pmReadout *readout,   ///< base the source on this readout
00156     psF32 x,     ///< center coords of source
00157     psF32 y,      ///< center coords of source
00158     psF32 Radius   ///< size of box on source
00159 );
00160 
00161 /** pmSourcePSFClump()
00162  *
00163  * We use the source moments to make an initial, approximate source
00164  * classification, and as part of the information needed to build a PSF model for
00165  * the image. As long as the PSF shape does not vary excessively across the
00166  * image, the sources which are represented by a PSF (the start) will have very
00167  * similar second moments. The function pmSourcePSFClump searches a collection of
00168  * sources with measured moments for a group with moments which are all very
00169  * similar. The function returns a pmPSFClump structure, representing the
00170  * centroid and size of the clump in the sigma_x, sigma_y second-moment plane.
00171  *
00172  * The goal is to identify and characterize the stellar clump within the
00173  * sigma_x, sigma_y second-moment plane.  To do this, an image is constructed to
00174  * represent this plane.  The units of sigma_x and sigma_y are in image pixels. A
00175  * pixel in this analysis image represents 0.1 pixels in the input image. The
00176  * dimensions of the image need only be 10 pixels. The peak pixel in this image
00177  * (above a threshold of half of the image maximum) is found. The coordinates of
00178  * this peak pixel represent the 2D mode of the sigma_x, sigma_y distribution.
00179  * The sources with sigma_x, sigma_y within 0.2 pixels of this value are then
00180  *  * used to calculate the median and standard deviation of the sigma_x, sigma_y
00181  * values. These resulting values are returned via the pmPSFClump structure.
00182  *
00183  * The return value indicates the success (TRUE) of the operation.
00184  *
00185  * XXX: Limit the S/N of the candidate sources (part of Metadata)? (TBD).
00186  * XXX: Save the clump parameters on the Metadata (TBD)
00187  *
00188  */
00189 pmPSFClump pmSourcePSFClump(
00190     psArray *source,   ///< The input pmSource
00191     psMetadata *metadata  ///< Contains classification parameters
00192 );
00193 
00194 
00195 /** pmSourceRoughClass()
00196  *
00197  * Based on the specified data values, make a guess at the source
00198  * classification. The sources are provides as a psArray of pmSource entries.
00199  * Definable parameters needed to make the classification are provided to the
00200  * routine with the psMetadata structure. The rules (in SDRS) refer to values which
00201  * can be extracted from the metadata using the given keywords. Except as noted,
00202  * the data type for these parameters are psF32.
00203  *
00204  */
00205 bool pmSourceRoughClass(
00206     psArray *source,   ///< The input pmSource
00207     psMetadata *metadata,  ///< Contains classification parameters
00208     pmPSFClump clump   ///< Statistics about the PSF clump
00209 );
00210 
00211 
00212 /** pmSourceMoments()
00213  *
00214  * Measure source moments for the given source, using the value of
00215  * source.moments.sky provided as the local background value and the peak
00216  * coordinates as the initial source location. The resulting moment values are
00217  * applied to the source.moments entry, and the source is returned. The moments
00218  * are measured within the given circular radius of the source.peak coordinates.
00219  * The return value indicates the success (TRUE) of the operation.
00220  *
00221  */
00222 bool pmSourceMoments(
00223     pmSource *source,   ///< The input pmSource for which moments will be computed
00224     float radius   ///< Use a circle of pixels around the peak
00225 );
00226 
00227 
00228 // select the model used for this source
00229 pmModel *pmSourceSelectModel (pmSource *source);
00230 
00231 /// @}
00232 # endif /* PM_SOURCE_H */

Generated on Fri Feb 2 22:35:28 2007 for Pan-STARRS Module Library by  doxygen 1.5.1