00001 /** @file pmObjects.h 00002 * 00003 * This file will ... 00004 * 00005 * @author GLG, MHPCC 00006 * 00007 * @version $Revision: 1.7.2.1 $ $Name: rel5_1 $ 00008 * @date $Date: 2005/04/06 19:34:06 $ 00009 * 00010 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 00011 * 00012 */ 00013 00014 #if !defined(PM_OBJECTS_H) 00015 #define PM_OBJECTS_H 00016 00017 #if HAVE_CONFIG_H 00018 #include <config.h> 00019 #endif 00020 00021 #include<stdio.h> 00022 #include<math.h> 00023 #include "pslib.h" 00024 00025 typedef enum { 00026 PM_PEAK_LONE, ///< Isolated peak. 00027 PM_PEAK_EDGE, ///< Peak on edge. 00028 PM_PEAK_FLAT, ///< Peak has equal-value neighbors. 00029 PM_PEAK_UNDEF ///< Undefined. 00030 } psPeakType; 00031 00032 typedef struct 00033 { 00034 psS32 x; ///< X-coordinate of peak pixel. 00035 psS32 y; ///< Y-coordinate of peak pixel. 00036 psF32 counts; ///< Value of peak pixel (above sky?). 00037 psPeakType class; ///< Description of peak. 00038 } 00039 psPeak; 00040 00041 typedef struct 00042 { 00043 psF32 x; ///< X-coord of centroid. 00044 psF32 y; ///< Y-coord of centroid. 00045 psF32 Sx; ///< x-second moment. 00046 psF32 Sy; ///< y-second moment. 00047 psF32 Sxy; ///< xy cross moment. 00048 psF32 Sum; ///< Pixel sum above sky (background). 00049 psF32 Peak; ///< Peak counts above sky. 00050 psF32 Sky; ///< Sky level (background). 00051 psS32 nPixels; ///< Number of pixels used. 00052 } 00053 psMoments; 00054 00055 typedef enum { 00056 PS_MODEL_GAUSS, ///< Regular 2-D Gaussian 00057 PS_MODEL_PGAUSS, ///< Psuedo 2-D Gaussian 00058 PS_MODEL_TWIST_GAUSS, ///< 2-D Twisted Gaussian 00059 PS_MODEL_WAUSS, ///< 2-D Waussian 00060 PS_MODEL_SERSIC, ///< Sersic 00061 PS_MODEL_SERSIC_CORE, ///< Sersic Core 00062 PS_MODEL_UNDEFINED ///< Undefined 00063 } psModelType; 00064 00065 // XXX: It will be better if params, and dparams, were psVectors. 00066 typedef struct 00067 { 00068 psModelType type; ///< Model to be used. 00069 psS32 Nparams; ///< Number of parameters. 00070 psF32 *params; ///< Paramater values. 00071 psF32 *dparams; ///< Parameter errors. 00072 psF32 chisq; ///< Fit chi-squared. 00073 } 00074 psModel; 00075 00076 // XXX: What is this enum? 00077 typedef enum { 00078 PS_SOURCE_PSFSTAR, 00079 PS_SOURCE_GALAXY, 00080 PS_SOURCE_DEFECT, 00081 PS_SOURCE_SATURATED, 00082 PS_SOURCE_SATSTAR, 00083 PS_SOURCE_FAINTSTAR, 00084 PS_SOURCE_BRIGHTSTAR, 00085 PS_SOURCE_OTHER 00086 } psSourceType; 00087 00088 typedef struct 00089 { 00090 psPeak *peak; ///< Description of peak pixel. 00091 psImage *pixels; ///< Rectangular region including object pixels. 00092 psImage *mask; ///< Mask which marks pixels associated with objects. 00093 psMoments *moments; ///< Basic moments measure for the object. 00094 psModel *models; ///< Model parameters and type. 00095 psSourceType type; ///< Best identification of object. 00096 } 00097 psSource; 00098 00099 psPeak *pmPeakAlloc(psS32 x, ///< Row-coordinate in image space 00100 psS32 y, ///< Col-coordinate in image space 00101 psF32 counts, ///< The value of the peak pixel 00102 psPeakType class ///< The type of peak pixel 00103 ); 00104 00105 psMoments *pmMomentsAlloc(); 00106 psModel *pmModelAlloc(psModelType type); 00107 psSource *pmSourceAlloc(); 00108 00109 /****************************************************************************** 00110 pmFindVectorPeaks(vector, threshold): Find all local peaks in the given vector 00111 above the given threshold. Returns a vector of type PS_TYPE_U32 containing 00112 the location (x value) of all peaks. 00113 *****************************************************************************/ 00114 psVector *pmFindVectorPeaks(const psVector *vector, ///< The input vector (psF32) 00115 psF32 threshold ///< Threshold above which to find a peak 00116 ); 00117 00118 /****************************************************************************** 00119 pmFindImagePeaks(image, threshold): Find all local peaks in the given psImage 00120 above the given threshold. Returns a psList containing the location (x/y 00121 value) of all peaks. 00122 *****************************************************************************/ 00123 psList *pmFindImagePeaks(const psImage *image, ///< The input image where peaks will be found (psF32) 00124 psF32 threshold ///< Threshold above which to find a peak 00125 ); 00126 00127 /****************************************************************************** 00128 psCullPeaks(peaks, maxValue, valid): eliminate peaks from the psList that have 00129 a peak value above the given maximum, or fall outside the valid region. 00130 00131 XXX: Do we free the psList elements of those culled peaks? 00132 *****************************************************************************/ 00133 psList *pmCullPeaks(psList *peaks, ///< The psList of peaks to be culled 00134 psF32 maxValue, ///< Cull peaks above this value 00135 const psRegion *valid ///< Cull peaks otside this psRegion 00136 ); 00137 00138 /****************************************************************************** 00139 psSource *pmSourceLocalSky(image, peak, innerRadius, outerRadius): 00140 00141 *****************************************************************************/ 00142 psSource *pmSourceLocalSky(const psImage *image, ///< The input image (psF32) 00143 const psPeak *peak, ///< The peak for which the psSource struct is created. 00144 psStatsOptions statsOptions, ///< The statistic used in calculating the background sky 00145 psF32 innerRadius, ///< The inner radius of the suqare annulus for calculating sky 00146 psF32 outerRadius ///< The outer radius of the suqare annulus for calculating sky 00147 ); 00148 00149 /****************************************************************************** 00150 *****************************************************************************/ 00151 psSource *pmSourceMoments(psSource *source, ///< The input psSource for which moments will be computed 00152 psF32 radius ///< Use a circle of pixels around the peak 00153 ); 00154 00155 /****************************************************************************** 00156 pmSourceRoughClass(pmArray *source, psMetaDeta *metadata): make a guess at the 00157 source classification. 00158 *****************************************************************************/ 00159 bool pmSourceRoughClass(psArray *source, ///< The input psSource 00160 psMetadata *metadata ///< Contains classification parameters 00161 ); 00162 /****************************************************************************** 00163 pmSourceSetPixelCircle(source, image, radius) 00164 *****************************************************************************/ 00165 bool pmSourceSetPixelCircle(psSource *source, ///< The input psSource 00166 const psImage *image, ///< The input image (psF32) 00167 psF32 radius ///< The radius of the circle 00168 ); 00169 00170 /****************************************************************************** 00171 *****************************************************************************/ 00172 bool pmSourceModelGuess(psSource *source, ///< The input psSource 00173 const psImage *image, ///< The input image (psF32) 00174 psModelType model ///< The type of model to be created. 00175 ); 00176 00177 /****************************************************************************** 00178 *****************************************************************************/ 00179 typedef enum { 00180 PS_CONTOUR_CRUDE, 00181 } pmContourType; 00182 00183 psArray *pmSourceContour(psSource *source, ///< The input psSource 00184 const psImage *image, ///< The input image (psF32) (this arg should be removed) 00185 psF32 level, ///< The level of the contour 00186 pmContourType mode ///< Currently this must be PS_CONTOUR_CRUDE 00187 ); 00188 00189 /****************************************************************************** 00190 *****************************************************************************/ 00191 bool pmSourceFitModel(psSource *source, ///< The input psSource 00192 const psImage *image ///< The input image (psF32) 00193 ); 00194 00195 /****************************************************************************** 00196 *****************************************************************************/ 00197 bool pmSourceAddModel(psImage *image, ///< The opuut image (psF32) 00198 psSource *source, ///< The input psSource 00199 bool center ///< A boolean flag that determines whether pixels are centered 00200 ); 00201 00202 /****************************************************************************** 00203 *****************************************************************************/ 00204 bool pmSourceSubModel(psImage *image, ///< The output image (psF32) 00205 psSource *source, ///< The input psSource 00206 bool center ///< A boolean flag that determines whether pixels are centered 00207 ); 00208 00209 /****************************************************************************** 00210 XXX: Why only *x argument? 00211 *****************************************************************************/ 00212 psF32 pmMinLM_Gauss2D(psVector *deriv, ///< A possibly-NULL structure for the output derivatives 00213 psVector *params, ///< A psVector which holds the parameters of this function 00214 psVector *x ///< A psVector which holds the row/col coordinate 00215 ); 00216 00217 /****************************************************************************** 00218 XXX: Why only *x argument? 00219 *****************************************************************************/ 00220 psF32 pmMinLM_PsuedoGauss2D(psVector *deriv, ///< A possibly-NULL structure for the output derivatives 00221 psVector *params, ///< A psVector which holds the parameters of this function 00222 psVector *x ///< A psVector which holds the row/col coordinate 00223 ); 00224 00225 /****************************************************************************** 00226 *****************************************************************************/ 00227 psF32 pmMinLM_Wauss2D(psVector *deriv, ///< A possibly-NULL structure for the output derivatives 00228 psVector *params, ///< A psVector which holds the parameters of this function 00229 psVector *x ///< A psVector which holds the row/col coordinate 00230 ); 00231 00232 /****************************************************************************** 00233 *****************************************************************************/ 00234 psF32 pmMinLM_TwistGauss2D(psVector *deriv, ///< A possibly-NULL structure for the output derivatives 00235 psVector *params, ///< A psVector which holds the parameters of this function 00236 psVector *x ///< A psVector which holds the row/col coordinate 00237 ); 00238 00239 /****************************************************************************** 00240 *****************************************************************************/ 00241 psF32 pmMinLM_Sersic(psVector *deriv, ///< A possibly-NULL structure for the output derivatives 00242 psVector *params, ///< A psVector which holds the parameters of this function 00243 psVector *x ///< A psVector which holds the row/col coordinate 00244 ); 00245 00246 /****************************************************************************** 00247 *****************************************************************************/ 00248 psF32 pmMinLM_SersicCore(psVector *deriv, ///< A possibly-NULL structure for the output derivatives 00249 psVector *params, ///< A psVector which holds the parameters of this function 00250 psVector *x ///< A psVector which holds the row/col coordinate 00251 ); 00252 00253 /****************************************************************************** 00254 *****************************************************************************/ 00255 psF32 pmMinLM_PsuedoSersic(psVector *deriv, ///< A possibly-NULL structure for the output derivatives 00256 psVector *params, ///< A psVector which holds the parameters of this function 00257 psVector *x ///< A psVector which holds the row/col coordinate 00258 ); 00259 00260 00261 #endif
1.3.9.1