00001 /* @file pmPeaks.h 00002 * 00003 * The process of finding, measuring, and classifying astronomical sources on 00004 * images is one of the critical tasks of the IPP or any astronomical software 00005 * system. This file will define structures and functions related to the task 00006 * of source detection and measurement. The elements defined in this section 00007 * are generally low-level components which can be connected together to 00008 * construct a complete object measurement suite. 00009 * 00010 * @author GLG, MHPCC 00011 * 00012 * @version $Revision: 1.6 $ $Name: $ 00013 * @date $Date: 2007/01/24 02:54:15 $ 00014 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 00015 */ 00016 00017 # ifndef PM_PEAKS_H 00018 # define PM_PEAKS_H 00019 00020 /// @addtogroup Objects Object Detection / Analysis Functions 00021 /// @{ 00022 00023 /** pmPeakType 00024 * 00025 * A peak pixel may have several features which may be determined when the 00026 * peak is found or measured. These are specified by the pmPeakType enum. 00027 * PM_PEAK_LONE represents a single pixel which is higher than its 8 immediate 00028 * neighbors. The PM_PEAK_EDGE represents a peak pixel which touching the image 00029 * edge. The PM_PEAK_FLAT represents a peak pixel which has more than a specific 00030 * number of neighbors at the same value, within some tolarence: 00031 * 00032 */ 00033 typedef enum { 00034 PM_PEAK_LONE, ///< Isolated peak. 00035 PM_PEAK_EDGE, ///< Peak on edge. 00036 PM_PEAK_FLAT, ///< Peak has equal-value neighbors. 00037 PM_PEAK_UNDEF ///< Undefined. 00038 } pmPeakType; 00039 00040 00041 /** pmPeak data structure 00042 * 00043 * A source has the capacity for several types of measurements. The 00044 * simplest measurement of a source is the location and flux of the peak pixel 00045 * associated with the source: 00046 * 00047 */ 00048 typedef struct 00049 { 00050 const int id; ///< Unique ID for object 00051 int x; ///< X-coordinate of peak pixel. 00052 int y; ///< Y-coordinate of peak pixel. 00053 float xf; ///< bicube fit to peak coord (x) 00054 float yf; ///< bicube fit to peak coord (y) 00055 float value; ///< level in detection image 00056 float flux; ///< level in unsmoothed sci image 00057 float SN; ///< S/N implied by detection level 00058 pmPeakType type; ///< Description of peak. 00059 } 00060 pmPeak; 00061 00062 00063 /** pmPeakAlloc() 00064 * 00065 * @return pmPeak* newly allocated pmPeak with all internal pointers set to NULL 00066 */ 00067 pmPeak *pmPeakAlloc( 00068 int x, ///< Row-coordinate in image space 00069 int y, ///< Col-coordinate in image space 00070 float counts, ///< The value of the peak pixel 00071 pmPeakType type ///< The type of peak pixel 00072 ); 00073 00074 bool pmIsPeak(const psPtr ptr); 00075 00076 /** pmFindVectorPeaks() 00077 * 00078 * Find all local peaks in the given vector above the given threshold. A peak 00079 * is defined as any element with a value greater than its two neighbors and with 00080 * a value above the threshold. Two types of special cases must be addressed. 00081 * Equal value elements: If an element has the same value as the following 00082 * element, it is not considered a peak. If an element has the same value as the 00083 * preceding element (but not the following), then it is considered a peak. Note 00084 * that this rule (arbitrarily) identifies flat regions by their trailing edge. 00085 * Edge cases: At start of the vector, the element must be higher than its 00086 * neighbor. At the end of the vector, the element must be higher or equal to its 00087 * neighbor. These two rules again places the peak associated with a flat region 00088 * which touches the image edge at the image edge. The result of this function is 00089 * a vector containing the coordinates (element number) of the detected peaks 00090 * (type psU32). 00091 * 00092 */ 00093 psVector *pmFindVectorPeaks( 00094 const psVector *vector, ///< The input vector (float) 00095 float threshold ///< Threshold above which to find a peak 00096 ); 00097 00098 00099 /** pmFindImagePeaks() 00100 * 00101 * Find all local peaks in the given image above the given threshold. This 00102 * function should find all row peaks using pmFindVectorPeaks, then test each row 00103 * peak and exclude peaks which are not local peaks. A peak is a local peak if it 00104 * has a higher value than all 8 neighbors. If the peak has the same value as its 00105 * +y neighbor or +x neighbor, it is NOT a local peak. If any other neighbors 00106 * have an equal value, the peak is considered a valid peak. Note two points: 00107 * first, the +x neighbor condition is already enforced by pmFindVectorPeaks. 00108 * Second, these rules have the effect of making flat-topped regions have single 00109 * peaks at the (+x,+y) corner. When selecting the peaks, their type must also be 00110 * set. The result of this function is an array of pmPeak entries. 00111 * 00112 */ 00113 psArray *pmFindImagePeaks( 00114 const psImage *image, ///< The input image where peaks will be found (float) 00115 float threshold ///< Threshold above which to find a peak 00116 ); 00117 00118 00119 /** pmCullPeaks() 00120 * 00121 * Eliminate peaks from the psList that have a peak value above the given 00122 * maximum, or fall outside the valid region. 00123 * 00124 */ 00125 psList *pmCullPeaks( 00126 psList *peaks, ///< The psList of peaks to be culled 00127 float maxValue, ///< Cull peaks above this value 00128 const psRegion valid ///< Cull peaks otside this psRegion 00129 ); 00130 00131 00132 /** pmPeaksSubset() 00133 * 00134 * Create a new peaks array, removing certain types of peaks from the input 00135 * array of peaks based on the given criteria. Peaks should be eliminated if they 00136 * have a peak value above the given maximum value limit or if the fall outside 00137 * the valid region. The result of the function is a new array with a reduced 00138 * number of peaks. 00139 * 00140 */ 00141 psArray *pmPeaksSubset( 00142 psArray *peaks, ///< Add comment. 00143 float maxvalue, ///< Add comment. 00144 const psRegion valid ///< Add comment. 00145 ); 00146 00147 int pmPeaksCompareAscend (const void **a, const void **b); 00148 int pmPeaksCompareDescend (const void **a, const void **b); 00149 00150 /// @} 00151 # endif /* PM_PEAKS_H */
1.5.1