Public Member Functions | Private Member Functions | Private Attributes

casa::ImageProfileFit Class Reference

Class to fit profiles in images. More...

#include <ImageProfileFit.h>

List of all members.

Public Member Functions

 ImageProfileFit ()
 Constructor.
 ~ImageProfileFit ()
 Destructor.
 ImageProfileFit (const ImageProfileFit &other)
 Copy constructor.
ImageProfileFitoperator= (const ImageProfileFit &other)
 Assignment operator.
void setData (const ImageInterface< Float > &image, const ImageRegion &region, uInt profileAxis, Bool average=True)
 Set data via an image.
void setData (const ImageInterface< Float > &image, const ImageInterface< Float > &sigma, const ImageRegion &region, uInt profileAxis, Bool average=True)
void setData (const ImageInterface< Float > &image, uInt profileAxis, Bool average=True)
void setData (const ImageInterface< Float > &image, const ImageInterface< Float > &sigma, uInt profileAxis, Bool average=True)
void setData (const CoordinateSystem &cSys, uInt ProfileAxis, const Quantum< Vector< Float > > &x, const Quantum< Vector< Float > > &y, const Vector< Float > &sigma, Bool isAbs, const String &doppler)
 Set the data directly, and provide a coordinate system and specify the profile axis in the coordinate system.
void setData (const CoordinateSystem &cSys, uInt ProfileAxis, const Quantum< Vector< Float > > &x, const Quantum< Vector< Float > > &y, const Vector< Bool > &mask, const Vector< Float > &sigma, Bool isAbs, const String &doppler)
Bool estimate (uInt nMax=0)
 Makes an estimate from the set data.
uInt addElements (const RecordInterface &estimate)
 Decode the Glish record holding SpectralElements and add them to the fitter.
Bool getList (RecordInterface &rec, Bool xAbsOut, const String &xUnitOut, const String &dopplerOut)
 Gets the internal SpectralElements (either estimate or fit depending on what function you called last) into a record.
SpectralList getList () const
 Gets the internal SpectralElements (either estimate or fit depending on what function you called last) into a SpectralList Only returns False if the field is already defined.
void reset ()
 Reset the internal list of SpectralElements to null.
uInt nElements ()
 Return number of SpectralElements set.
Bool fit (Int order=-1)
 Do the fit of the averaged profile.
void fit (Bool fillRecord, RecordInterface &rec, Bool xAbsRec, const String &xUnitRec, const String &dopplerRec, ImageInterface< Float > *pFit, ImageInterface< Float > *pResid, Int order=-1)
 Fit all profiles with shapes + optional polynomial in the region and write out images.
void residual (Vector< Float > &resid, const Vector< Float > &x) const
 Find the residuals (fit or estimate) of the averaged profile.
void residual (Vector< Float > &resid) const
void model (Vector< Float > &model, const Vector< Float > &x) const
 Find the model (fit or estimate) of the averaged profile.
void model (Vector< Float > &model) const

Private Member Functions

void collapse (Vector< Float > &profile, Vector< Bool > &mask, uInt profileAxis, const MaskedLattice< Float > &lat) const
SpectralElement convertSpectralElement (const SpectralElement &elIn, Bool xAbsIn, Bool xAbsOut, const String &xUnitIn, const String &xUnitOut, const String &dopplerIn, const String &dopplerOut, const String &yUnitIn, const String &yUnitOut)
 Convert SE.
void convertGaussianElementX (SpectralElement &el, CoordinateSystem &cSys, uInt profileAxis, Bool absIn, Bool absOut, const String &unitIn, const String &unitOut, const String &dopplerIn, const String &dopplerOut)
 Convert Gaussian model x-units when data source is an image.
SpectralList filterList (const SpectralList &listIn) const
Bool getElements (RecordInterface &rec, Bool xAbsOut, const String &xUnitOut, const String &dopplerOut, const SpectralList &list)
void setData (const ImageInterface< Float > *&pSigma, const ImageInterface< Float > &image, const Slicer &sl, Bool average)

Private Attributes

ImageInterface< Float > * itsImagePtr
 Images holding data and weights.
ImageInterface< Float > * itsSigmaImagePtr
Bool itsFitDone
Quantum< Vector< Float > > itsX
 Holds the abcissa, ordinate and mask.
Quantum< Vector< Float > > itsY
Vector< BoolitsMask
Vector< FloatitsSigma
SpectralFititsSpectralFitPtr
 The fitters.
SpectralFit itsSpectralFitter
CoordinateSystem itsCoords
 The coordinate system if the data source was an image itsProfileAxis specified the profile axis in the image Will be -1 if data source was just vectors.
Int itsProfileAxis
String itsDoppler
 If the data source was an image, these give the doppler type (if any) and x-unit IF an estimate was specified by the user via function addElements.
Bool itsXAbs
Bool itsFitRegion

Detailed Description

Class to fit profiles in images.

Intended use:

Public interface

Synopsis

The Record used to contain models/fits is as follows. Other fields will be ignored.

    Field                     Type             Description
   -----------------------------------------------------------
    xabs                      Bool              Are the x-values absolute or 
                                                relative to the reference pixel
    xunit                     String            The x unit 
    yunit                     String            The y unit
    doppler                   String            doppler type ('radio', 'optical', 'true' etc)
                                                Only required if x unit consistent with m/s
    elements                  Record            Holds SpectralElement descriptions.  
    elements[i]               Record            There will be N of these where N is the
                                                number of spectral elements.  Each elements[i]
                                                holds a record description that SpectralElement::fromRecord
                                                can read or writes
            .type             String            Type of SE (gaussian, polynomial, etc)
            .parameters       Vector<Double>    The parameters of the element.
            .errors           Vector<Double>    The errors of parameters of the element.
            .fixed            Vector<Bool>      Says whether parameter is going to be held fixed when fitting
                                                This field is not used by SpectralElement.  If its
                                                not there, all parameters are fitted for.

Example

Definition at line 103 of file ImageProfileFit.h.


Constructor & Destructor Documentation

casa::ImageProfileFit::ImageProfileFit (  )  [explicit]

Constructor.

casa::ImageProfileFit::~ImageProfileFit (  ) 

Destructor.

casa::ImageProfileFit::ImageProfileFit ( const ImageProfileFit other  ) 

Copy constructor.

Uses copy semantics.


Member Function Documentation

uInt casa::ImageProfileFit::addElements ( const RecordInterface estimate  ) 

Decode the Glish record holding SpectralElements and add them to the fitter.

Absolute pixel coordinate units are assumed to be 1-rel on input. Return the number of the element added.

void casa::ImageProfileFit::collapse ( Vector< Float > &  profile,
Vector< Bool > &  mask,
uInt  profileAxis,
const MaskedLattice< Float > &  lat 
) const [private]
void casa::ImageProfileFit::convertGaussianElementX ( SpectralElement el,
CoordinateSystem cSys,
uInt  profileAxis,
Bool  absIn,
Bool  absOut,
const String unitIn,
const String unitOut,
const String dopplerIn,
const String dopplerOut 
) [private]

Convert Gaussian model x-units when data source is an image.

SpectralElement casa::ImageProfileFit::convertSpectralElement ( const SpectralElement elIn,
Bool  xAbsIn,
Bool  xAbsOut,
const String xUnitIn,
const String xUnitOut,
const String dopplerIn,
const String dopplerOut,
const String yUnitIn,
const String yUnitOut 
) [private]

Convert SE.

Bool casa::ImageProfileFit::estimate ( uInt  nMax = 0  ) 

Makes an estimate from the set data.

This means it generates SpectralElements holding the estimate, and replaces all elements you might have put in place with function addElement. Returns False if it can't find any elements.

SpectralList casa::ImageProfileFit::filterList ( const SpectralList listIn  )  const [private]
Bool casa::ImageProfileFit::fit ( Int  order = -1  ) 

Do the fit of the averaged profile.

Specify the order of the baseline you would also like to fit for.

void casa::ImageProfileFit::fit ( Bool  fillRecord,
RecordInterface rec,
Bool  xAbsRec,
const String xUnitRec,
const String dopplerRec,
ImageInterface< Float > *  pFit,
ImageInterface< Float > *  pResid,
Int  order = -1 
)

Fit all profiles with shapes + optional polynomial in the region and write out images.

If fillRecord is True, the output record is filled with the the parameters of every fit. This can get VERY large so use with care. If the output images have a writable mask, the input mask is transferred to the output.

Bool casa::ImageProfileFit::getElements ( RecordInterface rec,
Bool  xAbsOut,
const String xUnitOut,
const String dopplerOut,
const SpectralList list 
) [private]
Bool casa::ImageProfileFit::getList ( RecordInterface rec,
Bool  xAbsOut,
const String xUnitOut,
const String dopplerOut 
)

Gets the internal SpectralElements (either estimate or fit depending on what function you called last) into a record.

Only returns False if the field is already defined. Absolute pixel coordinate units are 1-rel on output.

SpectralList casa::ImageProfileFit::getList (  )  const

Gets the internal SpectralElements (either estimate or fit depending on what function you called last) into a SpectralList Only returns False if the field is already defined.

Absolute pixel coordinate units are 1-rel on output.

void casa::ImageProfileFit::model ( Vector< Float > &  model,
const Vector< Float > &  x 
) const

Find the model (fit or estimate) of the averaged profile.

void casa::ImageProfileFit::model ( Vector< Float > &  model  )  const
uInt casa::ImageProfileFit::nElements (  ) 

Return number of SpectralElements set.

ImageProfileFit& casa::ImageProfileFit::operator= ( const ImageProfileFit other  ) 

Assignment operator.

Uses copy semantics.

void casa::ImageProfileFit::reset (  ) 

Reset the internal list of SpectralElements to null.

void casa::ImageProfileFit::residual ( Vector< Float > &  resid,
const Vector< Float > &  x 
) const

Find the residuals (fit or estimate) of the averaged profile.

void casa::ImageProfileFit::residual ( Vector< Float > &  resid  )  const
void casa::ImageProfileFit::setData ( const ImageInterface< Float > &  image,
const ImageInterface< Float > &  sigma,
uInt  profileAxis,
Bool  average = True 
)
void casa::ImageProfileFit::setData ( const ImageInterface< Float > &  image,
const ImageRegion region,
uInt  profileAxis,
Bool  average = True 
)

Set data via an image.

profileAxis specifies the profile pixel axis. You can either average the data over all other axes in the image (average=True) or fit all profiles in the image.

void casa::ImageProfileFit::setData ( const ImageInterface< Float > &  image,
const ImageInterface< Float > &  sigma,
const ImageRegion region,
uInt  profileAxis,
Bool  average = True 
)
void casa::ImageProfileFit::setData ( const ImageInterface< Float > *&  pSigma,
const ImageInterface< Float > &  image,
const Slicer sl,
Bool  average 
) [private]
void casa::ImageProfileFit::setData ( const CoordinateSystem cSys,
uInt  ProfileAxis,
const Quantum< Vector< Float > > &  x,
const Quantum< Vector< Float > > &  y,
const Vector< Bool > &  mask,
const Vector< Float > &  sigma,
Bool  isAbs,
const String doppler 
)
void casa::ImageProfileFit::setData ( const CoordinateSystem cSys,
uInt  ProfileAxis,
const Quantum< Vector< Float > > &  x,
const Quantum< Vector< Float > > &  y,
const Vector< Float > &  sigma,
Bool  isAbs,
const String doppler 
)

Set the data directly, and provide a coordinate system and specify the profile axis in the coordinate system.

The x-units can be 'pix'. If absolute they must be 0-rel pixels. isAbs specifies whether the coordinates are absolute or relative to the reference pixel. If the weights vector, sigma is of zero length, it is treated as all unity.

void casa::ImageProfileFit::setData ( const ImageInterface< Float > &  image,
uInt  profileAxis,
Bool  average = True 
)

Member Data Documentation

The coordinate system if the data source was an image itsProfileAxis specified the profile axis in the image Will be -1 if data source was just vectors.

Definition at line 252 of file ImageProfileFit.h.

If the data source was an image, these give the doppler type (if any) and x-unit IF an estimate was specified by the user via function addElements.

They are used in function getElements so that the output record has the same units.

Definition at line 260 of file ImageProfileFit.h.

Definition at line 234 of file ImageProfileFit.h.

Definition at line 262 of file ImageProfileFit.h.

Images holding data and weights.

Will be set only if fitting all profiles in region

Definition at line 231 of file ImageProfileFit.h.

Definition at line 240 of file ImageProfileFit.h.

Definition at line 253 of file ImageProfileFit.h.

Definition at line 241 of file ImageProfileFit.h.

Definition at line 232 of file ImageProfileFit.h.

The fitters.

The first one does not have a polynomial in it The second one may.

Definition at line 245 of file ImageProfileFit.h.

Definition at line 246 of file ImageProfileFit.h.

Holds the abcissa, ordinate and mask.

x-units will be pixels if data source is an image, else as specified in setData

Definition at line 239 of file ImageProfileFit.h.

Definition at line 261 of file ImageProfileFit.h.

Definition at line 239 of file ImageProfileFit.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines