| 1 | /** @file pmObjects.h
|
|---|
| 2 | *
|
|---|
| 3 | * This file will ...
|
|---|
| 4 | *
|
|---|
| 5 | * @author GLG, MHPCC
|
|---|
| 6 | *
|
|---|
| 7 | * @version $Revision: 1.7.2.1 $ $Name: rel5_1 $
|
|---|
| 8 | * @date $Date: 2005/04/06 19:34:06 $
|
|---|
| 9 | *
|
|---|
| 10 | * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
|
|---|
| 11 | *
|
|---|
| 12 | */
|
|---|
| 13 |
|
|---|
| 14 | #if !defined(PM_OBJECTS_H)
|
|---|
| 15 | #define PM_OBJECTS_H
|
|---|
| 16 |
|
|---|
| 17 | #if HAVE_CONFIG_H
|
|---|
| 18 | #include <config.h>
|
|---|
| 19 | #endif
|
|---|
| 20 |
|
|---|
| 21 | #include<stdio.h>
|
|---|
| 22 | #include<math.h>
|
|---|
| 23 | #include "pslib.h"
|
|---|
| 24 |
|
|---|
| 25 | typedef enum {
|
|---|
| 26 | PM_PEAK_LONE, ///< Isolated peak.
|
|---|
| 27 | PM_PEAK_EDGE, ///< Peak on edge.
|
|---|
| 28 | PM_PEAK_FLAT, ///< Peak has equal-value neighbors.
|
|---|
| 29 | PM_PEAK_UNDEF ///< Undefined.
|
|---|
| 30 | } psPeakType;
|
|---|
| 31 |
|
|---|
| 32 | typedef struct
|
|---|
| 33 | {
|
|---|
| 34 | psS32 x; ///< X-coordinate of peak pixel.
|
|---|
| 35 | psS32 y; ///< Y-coordinate of peak pixel.
|
|---|
| 36 | psF32 counts; ///< Value of peak pixel (above sky?).
|
|---|
| 37 | psPeakType class; ///< Description of peak.
|
|---|
| 38 | }
|
|---|
| 39 | psPeak;
|
|---|
| 40 |
|
|---|
| 41 | typedef struct
|
|---|
| 42 | {
|
|---|
| 43 | psF32 x; ///< X-coord of centroid.
|
|---|
| 44 | psF32 y; ///< Y-coord of centroid.
|
|---|
| 45 | psF32 Sx; ///< x-second moment.
|
|---|
| 46 | psF32 Sy; ///< y-second moment.
|
|---|
| 47 | psF32 Sxy; ///< xy cross moment.
|
|---|
| 48 | psF32 Sum; ///< Pixel sum above sky (background).
|
|---|
| 49 | psF32 Peak; ///< Peak counts above sky.
|
|---|
| 50 | psF32 Sky; ///< Sky level (background).
|
|---|
| 51 | psS32 nPixels; ///< Number of pixels used.
|
|---|
| 52 | }
|
|---|
| 53 | psMoments;
|
|---|
| 54 |
|
|---|
| 55 | typedef enum {
|
|---|
| 56 | PS_MODEL_GAUSS, ///< Regular 2-D Gaussian
|
|---|
| 57 | PS_MODEL_PGAUSS, ///< Psuedo 2-D Gaussian
|
|---|
| 58 | PS_MODEL_TWIST_GAUSS, ///< 2-D Twisted Gaussian
|
|---|
| 59 | PS_MODEL_WAUSS, ///< 2-D Waussian
|
|---|
| 60 | PS_MODEL_SERSIC, ///< Sersic
|
|---|
| 61 | PS_MODEL_SERSIC_CORE, ///< Sersic Core
|
|---|
| 62 | PS_MODEL_UNDEFINED ///< Undefined
|
|---|
| 63 | } psModelType;
|
|---|
| 64 |
|
|---|
| 65 | // XXX: It will be better if params, and dparams, were psVectors.
|
|---|
| 66 | typedef struct
|
|---|
| 67 | {
|
|---|
| 68 | psModelType type; ///< Model to be used.
|
|---|
| 69 | psVector *params; ///< Paramater values.
|
|---|
| 70 | psVector *dparams; ///< Parameter errors.
|
|---|
| 71 | psF32 chisq; ///< Fit chi-squared.
|
|---|
| 72 | psS32 nDOF; ///< number of degrees of freedom
|
|---|
| 73 | psS32 nIter; ///< number of iterations to reach min
|
|---|
| 74 | }
|
|---|
| 75 | psModel;
|
|---|
| 76 |
|
|---|
| 77 | // XXX: What is this enum?
|
|---|
| 78 | typedef enum {
|
|---|
| 79 | PS_SOURCE_PSFSTAR,
|
|---|
| 80 | PS_SOURCE_GALAXY,
|
|---|
| 81 | PS_SOURCE_DEFECT,
|
|---|
| 82 | PS_SOURCE_SATURATED,
|
|---|
| 83 | PS_SOURCE_SATSTAR,
|
|---|
| 84 | PS_SOURCE_FAINTSTAR,
|
|---|
| 85 | PS_SOURCE_BRIGHTSTAR,
|
|---|
| 86 | PS_SOURCE_OTHER
|
|---|
| 87 | } psSourceType;
|
|---|
| 88 |
|
|---|
| 89 | typedef struct
|
|---|
| 90 | {
|
|---|
| 91 | psPeak *peak; ///< Description of peak pixel.
|
|---|
| 92 | psImage *pixels; ///< Rectangular region including object pixels.
|
|---|
| 93 | psImage *mask; ///< Mask which marks pixels associated with objects.
|
|---|
| 94 | psMoments *moments; ///< Basic moments measure for the object.
|
|---|
| 95 | psModel *models; ///< Model parameters and type.
|
|---|
| 96 | psSourceType type; ///< Best identification of object.
|
|---|
| 97 | }
|
|---|
| 98 | psSource;
|
|---|
| 99 |
|
|---|
| 100 | psPeak *pmPeakAlloc(psS32 x, ///< Row-coordinate in image space
|
|---|
| 101 | psS32 y, ///< Col-coordinate in image space
|
|---|
| 102 | psF32 counts, ///< The value of the peak pixel
|
|---|
| 103 | psPeakType class ///< The type of peak pixel
|
|---|
| 104 | );
|
|---|
| 105 |
|
|---|
| 106 | psMoments *pmMomentsAlloc();
|
|---|
| 107 | psModel *pmModelAlloc(psModelType type);
|
|---|
| 108 | psSource *pmSourceAlloc();
|
|---|
| 109 |
|
|---|
| 110 | /******************************************************************************
|
|---|
| 111 | pmFindVectorPeaks(vector, threshold): Find all local peaks in the given vector
|
|---|
| 112 | above the given threshold. Returns a vector of type PS_TYPE_U32 containing
|
|---|
| 113 | the location (x value) of all peaks.
|
|---|
| 114 | *****************************************************************************/
|
|---|
| 115 | psVector *pmFindVectorPeaks(const psVector *vector, ///< The input vector (psF32)
|
|---|
| 116 | psF32 threshold ///< Threshold above which to find a peak
|
|---|
| 117 | );
|
|---|
| 118 |
|
|---|
| 119 | /******************************************************************************
|
|---|
| 120 | pmFindImagePeaks(image, threshold): Find all local peaks in the given psImage
|
|---|
| 121 | above the given threshold. Returns a psList containing the location (x/y
|
|---|
| 122 | value) of all peaks.
|
|---|
| 123 | *****************************************************************************/
|
|---|
| 124 | psArray *pmFindImagePeaks(const psImage *image, ///< The input image where peaks will be found (psF32)
|
|---|
| 125 | psF32 threshold ///< Threshold above which to find a peak
|
|---|
| 126 | );
|
|---|
| 127 |
|
|---|
| 128 | /******************************************************************************
|
|---|
| 129 | psCullPeaks(peaks, maxValue, valid): eliminate peaks from the psList that have
|
|---|
| 130 | a peak value above the given maximum, or fall outside the valid region.
|
|---|
| 131 |
|
|---|
| 132 | XXX: Do we free the psList elements of those culled peaks?
|
|---|
| 133 | *****************************************************************************/
|
|---|
| 134 | psList *pmCullPeaks(psList *peaks, ///< The psList of peaks to be culled
|
|---|
| 135 | psF32 maxValue, ///< Cull peaks above this value
|
|---|
| 136 | const psRegion *valid ///< Cull peaks otside this psRegion
|
|---|
| 137 | );
|
|---|
| 138 |
|
|---|
| 139 | /******************************************************************************
|
|---|
| 140 | psSource *pmSourceLocalSky(image, peak, innerRadius, outerRadius):
|
|---|
| 141 |
|
|---|
| 142 | *****************************************************************************/
|
|---|
| 143 | psSource *pmSourceLocalSky(const psImage *image, ///< The input image (psF32)
|
|---|
| 144 | const psPeak *peak, ///< The peak for which the psSource struct is created.
|
|---|
| 145 | psStatsOptions statsOptions, ///< The statistic used in calculating the background sky
|
|---|
| 146 | psF32 innerRadius, ///< The inner radius of the suqare annulus for calculating sky
|
|---|
| 147 | psF32 outerRadius ///< The outer radius of the suqare annulus for calculating sky
|
|---|
| 148 | );
|
|---|
| 149 |
|
|---|
| 150 | /******************************************************************************
|
|---|
| 151 | *****************************************************************************/
|
|---|
| 152 | psSource *pmSourceMoments(psSource *source, ///< The input psSource for which moments will be computed
|
|---|
| 153 | psF32 radius ///< Use a circle of pixels around the peak
|
|---|
| 154 | );
|
|---|
| 155 |
|
|---|
| 156 | /******************************************************************************
|
|---|
| 157 | pmSourceRoughClass(pmArray *source, psMetaDeta *metadata): make a guess at the
|
|---|
| 158 | source classification.
|
|---|
| 159 | *****************************************************************************/
|
|---|
| 160 | bool pmSourceRoughClass(psArray *source, ///< The input psSource
|
|---|
| 161 | psMetadata *metadata ///< Contains classification parameters
|
|---|
| 162 | );
|
|---|
| 163 | /******************************************************************************
|
|---|
| 164 | pmSourceSetPixelCircle(source, image, radius)
|
|---|
| 165 | *****************************************************************************/
|
|---|
| 166 | bool pmSourceSetPixelCircle(psSource *source, ///< The input psSource
|
|---|
| 167 | const psImage *image, ///< The input image (psF32)
|
|---|
| 168 | psF32 radius ///< The radius of the circle
|
|---|
| 169 | );
|
|---|
| 170 |
|
|---|
| 171 | /******************************************************************************
|
|---|
| 172 | *****************************************************************************/
|
|---|
| 173 | bool pmSourceModelGuess(psSource *source, ///< The input psSource
|
|---|
| 174 | const psImage *image, ///< The input image (psF32)
|
|---|
| 175 | psModelType model ///< The type of model to be created.
|
|---|
| 176 | );
|
|---|
| 177 |
|
|---|
| 178 | /******************************************************************************
|
|---|
| 179 | *****************************************************************************/
|
|---|
| 180 | typedef enum {
|
|---|
| 181 | PS_CONTOUR_CRUDE,
|
|---|
| 182 | } pmContourType;
|
|---|
| 183 |
|
|---|
| 184 | psArray *pmSourceContour(psSource *source, ///< The input psSource
|
|---|
| 185 | const psImage *image, ///< The input image (psF32) (this arg should be removed)
|
|---|
| 186 | psF32 level, ///< The level of the contour
|
|---|
| 187 | pmContourType mode ///< Currently this must be PS_CONTOUR_CRUDE
|
|---|
| 188 | );
|
|---|
| 189 |
|
|---|
| 190 | /******************************************************************************
|
|---|
| 191 | *****************************************************************************/
|
|---|
| 192 | bool pmSourceFitModel(psSource *source, ///< The input psSource
|
|---|
| 193 | const psImage *image ///< The input image (psF32)
|
|---|
| 194 | );
|
|---|
| 195 |
|
|---|
| 196 | /******************************************************************************
|
|---|
| 197 | *****************************************************************************/
|
|---|
| 198 | bool pmSourceAddModel(psImage *image, ///< The opuut image (psF32)
|
|---|
| 199 | psSource *source, ///< The input psSource
|
|---|
| 200 | bool center ///< A boolean flag that determines whether pixels are centered
|
|---|
| 201 | );
|
|---|
| 202 |
|
|---|
| 203 | /******************************************************************************
|
|---|
| 204 | *****************************************************************************/
|
|---|
| 205 | bool pmSourceSubModel(psImage *image, ///< The output image (psF32)
|
|---|
| 206 | psSource *source, ///< The input psSource
|
|---|
| 207 | bool center ///< A boolean flag that determines whether pixels are centered
|
|---|
| 208 | );
|
|---|
| 209 |
|
|---|
| 210 | /******************************************************************************
|
|---|
| 211 | XXX: Why only *x argument?
|
|---|
| 212 | XXX EAM: psMinimizeLMChi2Func returns psF64, not psF32
|
|---|
| 213 | *****************************************************************************/
|
|---|
| 214 | psF64 pmMinLM_Gauss2D(psVector *deriv, ///< A possibly-NULL structure for the output derivatives
|
|---|
| 215 | psVector *params, ///< A psVector which holds the parameters of this function
|
|---|
| 216 | psVector *x ///< A psVector which holds the row/col coordinate
|
|---|
| 217 | );
|
|---|
| 218 |
|
|---|
| 219 | /******************************************************************************
|
|---|
| 220 | XXX: Why only *x argument?
|
|---|
| 221 | *****************************************************************************/
|
|---|
| 222 | psF64 pmMinLM_PsuedoGauss2D(psVector *deriv, ///< A possibly-NULL structure for the output derivatives
|
|---|
| 223 | psVector *params, ///< A psVector which holds the parameters of this function
|
|---|
| 224 | psVector *x ///< A psVector which holds the row/col coordinate
|
|---|
| 225 | );
|
|---|
| 226 |
|
|---|
| 227 | /******************************************************************************
|
|---|
| 228 | *****************************************************************************/
|
|---|
| 229 | psF64 pmMinLM_Wauss2D(psVector *deriv, ///< A possibly-NULL structure for the output derivatives
|
|---|
| 230 | psVector *params, ///< A psVector which holds the parameters of this function
|
|---|
| 231 | psVector *x ///< A psVector which holds the row/col coordinate
|
|---|
| 232 | );
|
|---|
| 233 |
|
|---|
| 234 | /******************************************************************************
|
|---|
| 235 | *****************************************************************************/
|
|---|
| 236 | psF64 pmMinLM_TwistGauss2D(psVector *deriv, ///< A possibly-NULL structure for the output derivatives
|
|---|
| 237 | psVector *params, ///< A psVector which holds the parameters of this function
|
|---|
| 238 | psVector *x ///< A psVector which holds the row/col coordinate
|
|---|
| 239 | );
|
|---|
| 240 |
|
|---|
| 241 | /******************************************************************************
|
|---|
| 242 | *****************************************************************************/
|
|---|
| 243 | psF64 pmMinLM_Sersic(psVector *deriv, ///< A possibly-NULL structure for the output derivatives
|
|---|
| 244 | psVector *params, ///< A psVector which holds the parameters of this function
|
|---|
| 245 | psVector *x ///< A psVector which holds the row/col coordinate
|
|---|
| 246 | );
|
|---|
| 247 |
|
|---|
| 248 | /******************************************************************************
|
|---|
| 249 | *****************************************************************************/
|
|---|
| 250 | psF64 pmMinLM_SersicCore(psVector *deriv, ///< A possibly-NULL structure for the output derivatives
|
|---|
| 251 | psVector *params, ///< A psVector which holds the parameters of this function
|
|---|
| 252 | psVector *x ///< A psVector which holds the row/col coordinate
|
|---|
| 253 | );
|
|---|
| 254 |
|
|---|
| 255 | /******************************************************************************
|
|---|
| 256 | *****************************************************************************/
|
|---|
| 257 | psF64 pmMinLM_PsuedoSersic(psVector *deriv, ///< A possibly-NULL structure for the output derivatives
|
|---|
| 258 | psVector *params, ///< A psVector which holds the parameters of this function
|
|---|
| 259 | psVector *x ///< A psVector which holds the row/col coordinate
|
|---|
| 260 | );
|
|---|
| 261 |
|
|---|
| 262 |
|
|---|
| 263 | #endif
|
|---|