Blob Finder

These classes define blob data structure and algorithms to find blobs in image. Defined in src/imgproc/Blob.h and src/imgproc/BlobFinder.h

class Caesar::BlobFinder : public TObject

Public Functions

BlobFinder()

Class constructor: initialize structures.

virtual ~BlobFinder()

Class destructor: free allocated memory.

Public Static Functions

template<class T>
static int FindBlobs(Image *inputImg, std::vector<T*> &blobs, Image *floodImg = 0, ImgBkgData *bkgData = 0, double seedThr = 5, double mergeThr = 2.6, int minPixels = 10, bool findNegativeExcess = false, bool mergeBelowSeed = false, Image *curvMap = 0)

Find blobs.

template<class T>
static int FindBlobsMT(Image *inputImg, std::vector<T*> &blobs, Image *floodImg = 0, ImgBkgData *bkgData = 0, double seedThr = 5, double mergeThr = 2.6, int minPixels = 10, bool findNegativeExcess = false, bool mergeBelowSeed = false, Image *curvMap = 0)

Find blobs (multithreaded version)

template<class T>
static int FindBlobsST(Image *inputImg, std::vector<T*> &blobs, Image *floodImg = 0, ImgBkgData *bkgData = 0, double seedThr = 5, double mergeThr = 2.6, int minPixels = 10, bool findNegativeExcess = false, bool mergeBelowSeed = false, Image *curvMap = 0)

Find blobs (single-thread version)

static int FloodFill(Image *img, std::vector<long int> &clusterPixelIds, long int seedPixelId, double floodMinThr, double floodMaxThr)

Flood fill algorithm.

static Image *ComputeBlobMask(Image *img, double Bmaj, double Bmin, double Bpa = 0, double kernNSigmaSize = 2.5, double peakZThr = 5, double peakZMergeThr = 2.5, int minBlobSize = 5, double thrFactor = 0, int bkgEstimator = eMedianBkg, int bkgBox = 100, double bkgGridStepSize = 20)

Compute single-scale blob mask using elliptical gaus smoothing + laplacian filter map.

static Image *ComputeMultiScaleBlobMask(Image *img, double sigmaMin, double sigmaMax, double sigmaStep, double peakZThr = 5, double peakZMergeThr = 2.5, int minBlobSize = 5, double thrFactor = 0, int kernelFactor = 1, bool useLocalBkg = true, int bkgEstimator = eMedianBkg, int bkgBox = 100, double bkgGridStepSize = 20)

Compute multiscale blob mask using LoG filter maps.

static int FindBlendedBlobs(std::vector<Source*> &deblendedBlobs, std::vector<ImgPeak> &deblendedPeaks, Image *img, double sigmaMin, double sigmaMax, double sigmaStep, int minBlobSize = 5, double thrFactor = 0, int kernelFactor = 1)

Compute blob blended components.

class Caesar::Blob : public TNamed

Subclassed by Caesar::Region, Caesar::Source

Public Functions

Blob()

Class constructor: initialize structures.

Blob(std::string name)

Parametric constructor.

Blob(std::vector<Pixel*> const &pixels, std::string name = "")

Parametric constructor.

Blob(const Blob &blob)

Copy constructor.

virtual ~Blob()

Class destructor: free allocated memory.

Blob &operator=(const Blob &blob)

Assignment Operator.

void Copy(TObject &blob) const

Copy method.

inline void SetId(int id)

Set blob id.

inline void SetName(std::string name)

Set blob name.

inline bool IsAtEdge()

Is blob at image edge.

inline void SetEdgeFlag(bool choice)

Set edge flag.

inline int SetImageMetaData(ImgMetaData *data, double crpix1Offset = 0, double crpix2Offset = 0)

Set image metadata.

inline ImgMetaData *GetImageMetaData()

get image metadata

inline bool HasImageMetaData()

Set image metadata.

inline long int GetNPixels()

Get number of pixels.

inline const PixelCollection &GetPixels() const

Get pixel collection.

inline void SetPixels(PixelCollection &pixels)

Set pixel collection.

int AddPixel(Pixel *pixel, bool makeCopy = false)

Add a pixel to collection.

inline bool HasPixels()

Has pixels stored?

inline Pixel *GetPixel(int index)

Get access to pixel by index.

inline std::vector<int> GetSeedPixelIndexes()

Get access to seed pixel indexes.

inline Pixel *GetSeedPixel()

Find and return largest-significance seed pixel.

inline void MarkHaloPixels(double ZThr)

Mark pixels with significance within given thresholds as halo pixels.

int ComputeStats(bool computeRobustStats = true, bool forceRecomputing = false, bool useParallelMedian = false)

Compute stats.

inline bool HasStats()

Has stats?

inline void SetHasStats(bool value)

Has stats?

int ComputeMorphologyParams()

Compute morphology parameters.

int ComputeZernikeMoments(int order = 6)

Compute Zernike moments.

inline bool HasParameters()

Has morphology parameters computed.

inline void SetHasParameters(bool value)

Set has morphology pars.

inline double GetM1()

Get 1st pixel moment (= mean)

inline void SetM1(double value)

Set 1st pixel moment (= mean)

inline double GetM2()

Get 2nd pixel moment.

inline void SetM2(double value)

Set 2nd pixel moment.

inline double GetM3()

Get 3rd pixel moment.

inline void SetM3(double value)

Set 3rd pixel moment.

inline double GetM4()

Get 4th pixel moment.

inline void SetM4(double value)

Set 4th pixel moment.

inline double GetM1Curv()

Get 1st pixel curvature moment (= mean)

inline void SetM1Curv(double value)

Set 1st pixel curvature moment (= mean)

inline double GetM2Curv()

Get 2nd pixel curvature moment.

inline void SetM2Curv(double value)

Set 2nd pixel curvature moment.

inline double GetS()

Get pixel flux sum.

inline void SetS(double value)

Set pixel flux sum.

inline double GetSmax() const

Get pixel flux max.

inline void SetSmax(double value)

Set pixel flux max.

inline double GetSmin() const

Get pixel flux min.

inline void SetSmin(double value)

Set pixel flux min.

inline double GetSxx()

Get pixel flux XX correlation.

inline void SetSxx(double value)

Set pixel flux XX correlation.

inline double GetSyy()

Get pixel flux YY correlation.

inline void SetSyy(double value)

Get pixel flux YY correlation.

inline double GetSxy()

Get pixel flux XY correlation.

inline void SetSxy(double value)

Set pixel flux XY correlation.

inline double GetSx()

Get pixel flux sum weighted by position x.

inline void SetSx(double value)

Set pixel flux sum weighted by position x.

inline double GetSy()

Get pixel flux sum weighted by position y.

inline void SetSy(double value)

Set pixel flux sum weighted by position y.

inline long int GetSmaxPixId()

Get id of maximum flux pixel.

inline void SetSmaxPixId(long int value)

Set id of maximum flux pixel.

inline long int GetSminPixId()

Get id of minimum flux pixel.

inline void SetSminPixId(long int value)

Set id of minimum flux pixel.

inline double GetScurv()

Get pixel sum of curvature.

inline void SetScurv(double value)

Set pixel sum of curvature.

inline double GetSedge()

Get pixel sum of edgeness.

inline void SetSedge(double value)

Set pixel sum of edgeness.

inline void GetSourceRange(float &xmin, float &xmax, float &ymin, float &ymax)

Get source x-y range.

inline long int GetXmin()

Get source pixel x_min.

inline long int GetXmax()

Get source pixel x_max.

inline long int GetYmin()

Get source pixel y_min.

inline long int GetYmax()

Get source pixel y_max.

inline void SetSourceRange(float xmin, float xmax, float ymin, float ymax)

Set source x-y range.

inline void GetSourcePixelRange(long int &ixmin, long int &ixmax, long int &iymin, long int &iymax)

Get source pixel coordinate range.

inline long int GetIxMin()

Get source pixel ix_min.

inline long int GetIxMax()

Get source pixel ix_max.

inline long int GetIyMin()

Get source pixel iy_min.

inline long int GetIyMax()

Get source pixel iy_max.

inline void SetSourcePixelRange(long int ixmin, long int ixmax, long int iymin, long int iymax)

Set source pixel coordinate range.

int GetSampleStdDev(double &sigmaX, double &sigmaY, double &covXY)

Get sample source standard deviations.

inline void Print()

Dump blob info.

Image *GetImage(ImgType mode, int pixMargin = 1, bool includeHaloPixels = false)

Generate an image from source pixel.

TH2D *GetWCSHisto(ImgType mode, int pixMargin = 1, int coordSyst = -1)

Generate an image from source pixel.

Image *GetNestedBlobMask(Image *sourceImage = 0, int pixMargin = 1, double nestedBlobMinScale = 1, double nestedBlobMaxScale = 3, double nestedBlobScaleStep = 1, double nestedBlobPeakZThr = 5, double nestedBlobPeakZMergeThr = 2.5, int NMinPix = 5, double nestedBlobThrFactor = 0, double nestedBlobKernFactor = 6)

Get blob mask.

inline bool HasContours()

Has contours.

inline std::vector<Contour*> GetContours()

Return contours.

NB: Do not delete pointers.

inline Contour *GetContour(int index)

Return contour with index.

std::vector<Contour*> GetWCSContours(WCS *wcs = 0, int coordSystem = -1, double pixOffset = 0, bool computePars = false, bool castCoordsToInt = false)

Return contours converted in WCS.

Contour *GetWCSContour(int index, WCS *wcs = 0, int coordSystem = -1, double pixOffset = 0, bool computePars = false, bool castCoordsToInt = false)

Return contour with index and convert to WCS.

inline void AddContour(Contour *aContour)

Add contour.

bool IsPointOnContour(double x, double y, double tol = 1)

Is point on contour?

inline double GetBkgSum()

Get bkg sum.

inline double GetBkgRMSSum()

Get bkg rms sum.

inline void SetBkgSum(double bkg)

Set bkg sum (USED BY SERIALIZER)

inline void SetBkgRMSSum(double rms)

Set bkg rms sum (USED BY SERIALIZER)

inline bool HasBoxBkgInfo()

Check if bkg info in a box around the blob has ben set.

inline void SetHasBoxBkgInfo(bool flag)

Set has box bkg info flag (USED BY SERIALIZER)

inline double GetBoxBkg()

Get bkg estimate in a box around the blob.

inline double GetBoxBkgRMS()

Get bkg rms estimate in a box around the blob.

inline void SetBoxBkgInfo(double bkg, double rms)

Set bkg and rms estimate in a box around the blob.

inline WCS *GetWCS(int coordSystem = -1)

Get WCS from stored metadata (TO BE DEPRECATED)

Get WCS from stored metadata