pmObjects.h File Reference


Detailed Description

The process of finding, measuring, and classifying astronomical sources on images is one of the critical tasks of the IPP or any astronomical software system.

This file will define structures and functions related to the task of source detection and measurement. The elements defined in this section are generally low-level components which can be connected together to construct a complete object measurement suite.

Author:
GLG, MHPCC
Version:
Revision
1.2.8.1
Name
rel9_1
Date:
Date
2005/12/12 21:52:22
Copyright 2004 Maui High Performance Computing Center, University of Hawaii

Definition in file pmObjects.h.

#include <stdio.h>
#include <math.h>
#include "pslib.h"
#include "pmAstrometry.h"

Include dependency graph for pmObjects.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pmPeak
 pmPeak data structure More...
struct  pmMoments
 pmMoments data structure More...
struct  pmPSFClump
 pmPSFClump data structure More...
struct  pmModel
 pmModel data structure More...
struct  pmSource
 pmSource data structure More...

Defines

#define PM_OBJECTS_H
#define PS_MODEL_GAUSS   0
#define PS_MODEL_PGAUSS   1
#define PS_MODEL_QGAUSS   2
#define PS_MODEL_SGAUSS   3

Typedefs

typedef int pmModelType

Enumerations

enum  psphotMaskValues { PSPHOT_MASK_CLEAR = 0x00, PSPHOT_MASK_INVALID = 0x01, PSPHOT_MASK_SATURATED = 0x02, PSPHOT_MASK_MARKED = 0x08 }
 In the object analysis process, we will use specific mask values to mark the image pixels. More...
enum  pmPeakType { PM_PEAK_LONE, PM_PEAK_EDGE, PM_PEAK_FLAT, PM_PEAK_UNDEF }
 pmPeakType More...
enum  pmSourceType {
  PM_SOURCE_DEFECT, PM_SOURCE_SATURATED, PM_SOURCE_SATSTAR, PM_SOURCE_PSFSTAR, PM_SOURCE_GOODSTAR, PM_SOURCE_POOR_FIT_PSF, PM_SOURCE_FAIL_FIT_PSF, PM_SOURCE_FAINTSTAR, PM_SOURCE_GALAXY, PM_SOURCE_FAINT_GALAXY,
  PM_SOURCE_DROP_GALAXY, PM_SOURCE_FAIL_FIT_GAL, PM_SOURCE_POOR_FIT_GAL, PM_SOURCE_OTHER
}
 pmSourceType enumeration More...
enum  pmContourType { PS_CONTOUR_CRUDE, PS_CONTOUR_UNKNOWN01, PS_CONTOUR_UNKNOWN02 }
 pmContourType More...

Functions

pmPeakpmPeakAlloc (int x, int y, float counts, pmPeakType class)
 pmPeakAlloc()
pmMomentspmMomentsAlloc ()
 pmMomentsAlloc()
pmModelpmModelAlloc (pmModelType type)
 pmModelAlloc()
pmSourcepmSourceAlloc ()
 pmSourceAlloc()
psVector * pmFindVectorPeaks (const psVector *vector, float threshold)
 pmFindVectorPeaks()
psArray * pmFindImagePeaks (const psImage *image, float threshold)
 pmFindImagePeaks()
psList * pmCullPeaks (psList *peaks, float maxValue, const psRegion valid)
 pmCullPeaks()
psArray * pmPeaksSubset (psArray *peaks, float maxvalue, const psRegion valid)
 pmPeaksSubset()
bool pmSourceDefinePixels (pmSource *mySource, pmReadout *readout, psF32 x, psF32 y, psF32 Radius)
 pmSourceDefinePixels()
bool pmSourceLocalSky (pmSource *source, psStatsOptions statsOptions, float Radius)
 pmSourceLocalSky()
bool pmSourceMoments (pmSource *source, float radius)
 pmSourceMoments()
pmPSFClump pmSourcePSFClump (psArray *source, psMetadata *metadata)
 pmSourcePSFClump()
bool pmSourceRoughClass (psArray *source, psMetadata *metadata, pmPSFClump clump)
 pmSourceRoughClass()
pmModelpmSourceModelGuess (pmSource *source, pmModelType model)
 pmSourceModelGuess()
psArray * pmSourceContour (pmSource *source, const psImage *image, float level, pmContourType mode)
 pmSourceContour()
bool pmSourceFitModel (pmSource *source, pmModel *model, const bool PSF)
 pmSourceFitModel()
bool pmModelFitStatus (pmModel *model)
 pmModelFitStatus()
bool pmSourceAddModel (psImage *image, psImage *mask, pmModel *model, bool center)
 pmSourceAddModel()
bool pmSourceSubModel (psImage *image, psImage *mask, pmModel *model, bool center)
 pmSourceSubModel()
bool pmSourcePhotometry (float *fitMag, float *obsMag, pmModel *model, psImage *image, psImage *mask)
 The function returns both the magnitude of the fit, defined as -2.5log(flux), where the flux is integrated under the model, theoretically from a radius of 0 to infinity.
int pmSourceDophotType (pmSource *source)
 This function converts the source classification into the closest available approximation to the Dophot classification scheme:.
int pmSourceSextractType (pmSource *source)
 pmSourceSextractType()
bool pmSourceFitModel_v5 (pmSource *source, pmModel *model, const bool PSF)
 pmSourceFitModel_v5()
bool pmSourceFitModel_v7 (pmSource *source, pmModel *model, const bool PSF)
 pmSourceFitModel_v7()
psF32 pmModelEval (pmModel *model, psImage *image, psS32 col, psS32 row)
 pmModelEval()


Define Documentation

#define PM_OBJECTS_H
 

Definition at line 20 of file pmObjects.h.

#define PS_MODEL_GAUSS   0
 

Definition at line 121 of file pmObjects.h.

#define PS_MODEL_PGAUSS   1
 

Definition at line 122 of file pmObjects.h.

#define PS_MODEL_QGAUSS   2
 

Definition at line 123 of file pmObjects.h.

#define PS_MODEL_SGAUSS   3
 

Definition at line 124 of file pmObjects.h.


Typedef Documentation

typedef int pmModelType
 

Definition at line 120 of file pmObjects.h.


Enumeration Type Documentation

enum pmContourType
 

pmContourType

Only one type is defined at present.

Enumerator:
PS_CONTOUR_CRUDE 
PS_CONTOUR_UNKNOWN01 
PS_CONTOUR_UNKNOWN02 

Definition at line 436 of file pmObjects.h.

enum pmPeakType
 

pmPeakType

A peak pixel may have several features which may be determined when the peak is found or measured. These are specified by the pmPeakType enum. PM_PEAK_LONE represents a single pixel which is higher than its 8 immediate neighbors. The PM_PEAK_EDGE represents a peak pixel which touching the image edge. The PM_PEAK_FLAT represents a peak pixel which has more than a specific number of neighbors at the same value, within some tolarence:

Enumerator:
PM_PEAK_LONE  Isolated peak.
PM_PEAK_EDGE  Peak on edge.
PM_PEAK_FLAT  Peak has equal-value neighbors.
PM_PEAK_UNDEF  Undefined.

Definition at line 56 of file pmObjects.h.

enum pmSourceType
 

pmSourceType enumeration

A given source may be identified as most-likely to be one of several source types. The pmSource entry pmSourceType defines the current best-guess for this source.

XXX: The values given below are currently illustrative and will require some modification as the source classification code is developed. (TBD)

Enumerator:
PM_SOURCE_DEFECT  a cosmic-ray
PM_SOURCE_SATURATED  random saturated pixels
PM_SOURCE_SATSTAR  a saturated star
PM_SOURCE_PSFSTAR  a PSF star
PM_SOURCE_GOODSTAR  a good-quality star
PM_SOURCE_POOR_FIT_PSF  poor quality PSF fit
PM_SOURCE_FAIL_FIT_PSF  failed to get a good PSF fit
PM_SOURCE_FAINTSTAR  below S/N cutoff
PM_SOURCE_GALAXY  an extended object (galaxy)
PM_SOURCE_FAINT_GALAXY  a galaxy below S/N cutoff
PM_SOURCE_DROP_GALAXY  ?
PM_SOURCE_FAIL_FIT_GAL  failed on the galaxy fit
PM_SOURCE_POOR_FIT_GAL  poor quality galaxy fit
PM_SOURCE_OTHER  unidentified

Definition at line 158 of file pmObjects.h.

enum psphotMaskValues
 

In the object analysis process, we will use specific mask values to mark the image pixels.

The following structure defines the relevant mask values.

XXX: This is probably a bad solution: we will want to set mask values outside of the PSPHOT code. Perhaps we can set up a registered set of mask values with specific meanings that other functions can add to or define?

Enumerator:
PSPHOT_MASK_CLEAR 
PSPHOT_MASK_INVALID 
PSPHOT_MASK_SATURATED 
PSPHOT_MASK_MARKED 

Definition at line 38 of file pmObjects.h.


Function Documentation

psList* pmCullPeaks psList *  peaks,
float  maxValue,
const psRegion  valid
 

pmCullPeaks()

Eliminate peaks from the psList that have a peak value above the given maximum, or fall outside the valid region.

Parameters:
peaks  The psList of peaks to be culled
maxValue  Cull peaks above this value
valid  Cull peaks otside this psRegion

psArray* pmFindImagePeaks const psImage *  image,
float  threshold
 

pmFindImagePeaks()

Find all local peaks in the given image above the given threshold. This function should find all row peaks using pmFindVectorPeaks, then test each row peak and exclude peaks which are not local peaks. A peak is a local peak if it has a higher value than all 8 neighbors. If the peak has the same value as its +y neighbor or +x neighbor, it is NOT a local peak. If any other neighbors have an equal value, the peak is considered a valid peak. Note two points: first, the +x neighbor condition is already enforced by pmFindVectorPeaks. Second, these rules have the effect of making flat-topped regions have single peaks at the (+x,+y) corner. When selecting the peaks, their type must also be set. The result of this function is an array of pmPeak entries.

Parameters:
image  The input image where peaks will be found (float)
threshold  Threshold above which to find a peak

psVector* pmFindVectorPeaks const psVector *  vector,
float  threshold
 

pmFindVectorPeaks()

Find all local peaks in the given vector above the given threshold. A peak is defined as any element with a value greater than its two neighbors and with a value above the threshold. Two types of special cases must be addressed. Equal value elements: If an element has the same value as the following element, it is not considered a peak. If an element has the same value as the preceding element (but not the following), then it is considered a peak. Note that this rule (arbitrarily) identifies flat regions by their trailing edge. Edge cases: At start of the vector, the element must be higher than its neighbor. At the end of the vector, the element must be higher or equal to its neighbor. These two rules again places the peak associated with a flat region which touches the image edge at the image edge. The result of this function is a vector containing the coordinates (element number) of the detected peaks (type psU32).

Parameters:
vector  The input vector (float)
threshold  Threshold above which to find a peak

pmModel* pmModelAlloc pmModelType  type  ) 
 

pmModelAlloc()

psF32 pmModelEval pmModel model,
psImage *  image,
psS32  col,
psS32  row
 

pmModelEval()

XXX: Need descriptions

bool pmModelFitStatus pmModel model  ) 
 

pmModelFitStatus()

This function wraps the call to the model-specific function returned by pmModelFitStatusFunc_GetFunction. The model-specific function examines the model parameters, parameter errors, Chisq, S/N, and other parameters available from model to decide if the particular fit was successful or not.

XXX: Must code this.

Parameters:
model  Add comment.

pmMoments* pmMomentsAlloc  ) 
 

pmMomentsAlloc()

pmPeak* pmPeakAlloc int  x,
int  y,
float  counts,
pmPeakType  class
 

pmPeakAlloc()

Returns:
pmPeak* newly allocated pmPeak with all internal pointers set to NULL
Parameters:
x  Row-coordinate in image space
y  Col-coordinate in image space
counts  The value of the peak pixel
class  The type of peak pixel

psArray* pmPeaksSubset psArray *  peaks,
float  maxvalue,
const psRegion  valid
 

pmPeaksSubset()

Create a new peaks array, removing certain types of peaks from the input array of peaks based on the given criteria. Peaks should be eliminated if they have a peak value above the given maximum value limit or if the fall outside the valid region. The result of the function is a new array with a reduced number of peaks.

Parameters:
peaks  Add comment.
maxvalue  Add comment.
valid  Add comment.

bool pmSourceAddModel psImage *  image,
psImage *  mask,
pmModel model,
bool  center
 

pmSourceAddModel()

Add the given source model flux to/from the provided image. The boolean option center selects if the source is re-centered to the image center or if it is placed at its centroid location. The boolean option sky selects if the background sky is applied (TRUE) or not. The pixel range in the target image is at most the pixel range specified by the source.pixels image. The success status is returned.

Parameters:
image  The output image (float)
mask  The image pixel mask (valid == 0)
model  The input pmModel
center  A boolean flag that determines whether pixels are centered

pmSource* pmSourceAlloc  ) 
 

pmSourceAlloc()

psArray* pmSourceContour pmSource source,
const psImage *  image,
float  level,
pmContourType  mode
 

pmSourceContour()

Find points in a contour for the given source at the given level. If type is PM_CONTOUR_CRUDE, the contour is found by starting at the source peak, running along each pixel row until the level is crossed, then interpolating to the level coordinate for that row. This is done for each row, with the starting point determined by the midpoint of the previous row, until the starting point has a value below the contour level. The returned contour consists of two vectors giving the x and y coordinates of the contour levels. This function may be used as part of the model guess inputs. Other contour types may be specified in the future for more refined contours (TBD)

Parameters:
source  The input pmSource
image  The input image (float) (this arg should be removed)
level  The level of the contour
mode  Currently this must be PS_CONTOUR_CRUDE

bool pmSourceDefinePixels pmSource mySource,
pmReadout readout,
psF32  x,
psF32  y,
psF32  Radius
 

pmSourceDefinePixels()

Define psImage subarrays for the source located at coordinates x,y on the image set defined by readout. The pixels defined by this operation consist of a square window (of full width 2Radius+1) centered on the pixel which contains the given coordinate, in the frame of the readout. The window is defined to have limits which are valid within the boundary of the readout image, thus if the radius would fall outside the image pixels, the subimage is truncated to only consist of valid pixels. If readout->mask or readout->weight are not NULL, matching subimages are defined for those images as well. This function fails if no valid pixels can be defined (x or y less than Radius, for example). This function should be used to define a region of interest around a source, including both source and sky pixels.

XXX: must code this.

Parameters:
mySource  Add comment.
readout  Add comment.
x  Add comment.
y  Add comment.
Radius  Add comment.

int pmSourceDophotType pmSource source  ) 
 

This function converts the source classification into the closest available approximation to the Dophot classification scheme:.

PM_SOURCE_DEFECT: 8 PM_SOURCE_SATURATED: 8 PM_SOURCE_SATSTAR: 10 PM_SOURCE_PSFSTAR: 1 PM_SOURCE_GOODSTAR: 1 PM_SOURCE_POOR_FIT_PSF: 7 PM_SOURCE_FAIL_FIT_PSF: 4 PM_SOURCE_FAINTSTAR: 4 PM_SOURCE_GALAXY: 2 PM_SOURCE_FAINT_GALAXY: 2 PM_SOURCE_DROP_GALAXY: 2 PM_SOURCE_FAIL_FIT_GAL: 2 PM_SOURCE_POOR_FIT_GAL: 2 PM_SOURCE_OTHER: ?

Parameters:
source  Add comment.

bool pmSourceFitModel pmSource source,
pmModel model,
const bool  PSF
 

pmSourceFitModel()

Fit the requested model to the specified source. The starting guess for the model is given by the input source.model parameter values. The pixels of interest are specified by the source.pixelsand source.maskentries. This function calls psMinimizeLMChi2() on the image data. The function returns TRUE on success or FALSE on failure.

Parameters:
source  The input pmSource
model  model to be fitted
PSF  Treat model as PSF or FLT?

bool pmSourceFitModel_v5 pmSource source,
pmModel model,
const bool  PSF
 

pmSourceFitModel_v5()

Fit the requested model to the specified source. The starting guess for the model is given by the input source.model parameter values. The pixels of interest are specified by the source.pixelsand source.maskentries. This function calls psMinimizeLMChi2() on the image data. The function returns TRUE on success or FALSE on failure.

Parameters:
source  The input pmSource
model  model to be fitted
PSF  Treat model as PSF or FLT?

bool pmSourceFitModel_v7 pmSource source,
pmModel model,
const bool  PSF
 

pmSourceFitModel_v7()

Fit the requested model to the specified source. The starting guess for the model is given by the input source.model parameter values. The pixels of interest are specified by the source.pixelsand source.maskentries. This function calls psMinimizeLMChi2() on the image data. The function returns TRUE on success or FALSE on failure.

Parameters:
source  The input pmSource
model  model to be fitted
PSF  Treat model as PSF or FLT?

bool pmSourceLocalSky pmSource source,
psStatsOptions  statsOptions,
float  Radius
 

pmSourceLocalSky()

Measure the local sky in the vicinity of the given source. The Radius defines the square aperture in which the moments will be measured. This function assumes the source pixels have been defined, and that the value of Radius here is smaller than the value of Radius used to define the pixels. The annular region not contained within the radius defined here is used to measure the local background in the vicinity of the source. The local background measurement uses the specified statistic passed in via the statsOptions entry. This function allocates the pmMoments structure. The resulting sky is used to set the value of the pmMoments.sky element of the provided pmSource structure.

Parameters:
source  The input image (float)
statsOptions  The statistic used in calculating the background sky
Radius  The inner radius of the square annulus to exclude

pmModel* pmSourceModelGuess pmSource source,
pmModelType  model
 

pmSourceModelGuess()

Convert available data to an initial guess for the given model. This function allocates a pmModel entry for the pmSource structure based on the provided model selection. The method of defining the model parameter guesses are specified for each model below. The guess values are placed in the model parameters. The function returns TRUE on success or FALSE on failure.

Parameters:
source  The input pmSource
model  The type of model to be created.

bool pmSourceMoments pmSource source,
float  radius
 

pmSourceMoments()

Measure source moments for the given source, using the value of source.moments.sky provided as the local background value and the peak coordinates as the initial source location. The resulting moment values are applied to the source.moments entry, and the source is returned. The moments are measured within the given circular radius of the source.peak coordinates. The return value indicates the success (TRUE) of the operation.

Parameters:
source  The input pmSource for which moments will be computed
radius  Use a circle of pixels around the peak

bool pmSourcePhotometry float *  fitMag,
float *  obsMag,
pmModel model,
psImage *  image,
psImage *  mask
 

The function returns both the magnitude of the fit, defined as -2.5log(flux), where the flux is integrated under the model, theoretically from a radius of 0 to infinity.

In practice, we integrate the model beyond 50sigma. The aperture magnitude is defined as -2.5log(flux) , where the flux is summed for all pixels which are not excluded by the aperture mask. The model flux is calculated by calling the model-specific function provided by pmModelFlux_GetFunction.

XXX: must code this.

Parameters:
fitMag  integrated fit magnitude
obsMag  aperture flux magnitude
model  model used for photometry
image  image pixels to be used
mask  mask of pixels to ignore

pmPSFClump pmSourcePSFClump psArray *  source,
psMetadata *  metadata
 

pmSourcePSFClump()

We use the source moments to make an initial, approximate source classification, and as part of the information needed to build a PSF model for the image. As long as the PSF shape does not vary excessively across the image, the sources which are represented by a PSF (the start) will have very similar second moments. The function pmSourcePSFClump searches a collection of sources with measured moments for a group with moments which are all very similar. The function returns a pmPSFClump structure, representing the centroid and size of the clump in the sigma_x, sigma_y second-moment plane.

The goal is to identify and characterize the stellar clump within the sigma_x, sigma_y second-moment plane. To do this, an image is constructed to represent this plane. The units of sigma_x and sigma_y are in image pixels. A pixel in this analysis image represents 0.1 pixels in the input image. The dimensions of the image need only be 10 pixels. The peak pixel in this image (above a threshold of half of the image maximum) is found. The coordinates of this peak pixel represent the 2D mode of the sigma_x, sigma_y distribution. The sources with sigma_x, sigma_y within 0.2 pixels of this value are then * used to calculate the median and standard deviation of the sigma_x, sigma_y values. These resulting values are returned via the pmPSFClump structure.

The return value indicates the success (TRUE) of the operation.

XXX: Limit the S/N of the candidate sources (part of Metadata)? (TBD). XXX: Save the clump parameters on the Metadata (TBD)

Parameters:
source  The input pmSource
metadata  Contains classification parameters

bool pmSourceRoughClass psArray *  source,
psMetadata *  metadata,
pmPSFClump  clump
 

pmSourceRoughClass()

Based on the specified data values, make a guess at the source classification. The sources are provides as a psArray of pmSource entries. Definable parameters needed to make the classification are provided to the routine with the psMetadata structure. The rules (in SDRS) refer to values which can be extracted from the metadata using the given keywords. Except as noted, the data type for these parameters are psF32.

Parameters:
source  The input pmSource
metadata  Contains classification parameters
clump  Statistics about the PSF clump

int pmSourceSextractType pmSource source  ) 
 

pmSourceSextractType()

This function converts the source classification into the closest available approximation to the Sextractor classification scheme. the correspondence is not yet defined (TBD) .

XXX: Must code this.

Parameters:
source  Add comment.

bool pmSourceSubModel psImage *  image,
psImage *  mask,
pmModel model,
bool  center
 

pmSourceSubModel()

Subtract the given source model flux to/from the provided image. The boolean option center selects if the source is re-centered to the image center or if it is placed at its centroid location. The boolean option sky selects if the background sky is applied (TRUE) or not. The pixel range in the target image is at most the pixel range specified by the source.pixels image. The success status is returned.

Parameters:
image  The output image (float)
mask  The image pixel mask (valid == 0)
model  The input pmModel
center  A boolean flag that determines whether pixels are centered


Generated on Tue Dec 13 13:38:28 2005 for Pan-STARRS Module Library by  doxygen 1.4.5