Superpixel API

These classes define image superpixel data structures. Defined in src/imgproc/Region.h, src/imgproc/SLICData.h, src/imgproc/SLIC.h

class Caesar::Region : public Caesar::Blob

Public Types

enum RegionTag

Region tag enumeration.

Values:

enumerator eBkgTag
enumerator eSignalTag
enumerator eUntagged

Public Functions

Region()

Class constructor: initialize structures.

Region(std::string name)

Parametric constructor.

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

Parametric constructor.

Region(const Region &region)

Copy constructor.

virtual ~Region()

Class destructor: free allocated memory.

Region &operator=(const Region &region)

Assignment Operator.

void Copy(TObject &region) const

Copy method.

Region::RegionPars *GetParams(bool includeCurvPar = true)

Get region parameters.

int GetDistance(DistPars &distPars, Region *aRegion, bool useRobustParams = false)

Get distance squared between this and given region.

int GetAsymmDistance(DistPars &distPars, DistPars &distPars_neighbor, Region *aRegion, bool useRobustParams = false)

Get asymmetric color & space symmetric distance between this and given region.

int AddRegion(Region *aRegion, bool addPixels = true, bool copyPixels = false)

Get color & space symmetric distance among two regions.

Get color & space asymmetric distance among two regions Merge a region to this

int AddSubRegionId(long int id)

Add a sub-region id to list.

inline int GetNSubRegions()

Get number of sub-regions present in list.

inline const std::vector<long int> &GetSubRegionIds() const

Get the list of sub-region ids.

inline long int GetSubRegionId(int index)

Get sub-region id at given index.

struct RegionPars

Region pars.

class Caesar::RegionCollection : public TObject

Public Functions

inline RegionCollection()

Constructor.

inline virtual ~RegionCollection()

Destructor.

inline void Add(Region *aRegion)

Add a region to collection.

inline int GetN()

Get number of regions present in collection.

inline Region *FindRegionById(int id)

Get region by id.

inline int FindRegion(int id)

Find region (return index with given id)

inline Region *GetRegion(int index)

Get region with given index.

inline std::map<int, int> GetRegionIdMap() const

Get region map regionId>index.

inline std::map<int, int> GetRegionIndexMap() const

Get region index map (index>regionId)

class Caesar::SLICData : public TObject

Public Functions

SLICData()

Class constructor: initialize structures.

SLICData(const SLICData &data)

Copy constructor.

virtual ~SLICData()

Class destructor: free allocated memory.

SLICData &operator=(const SLICData &region)

Assignment Operator.

void Copy(TObject &region) const

Copy method.

void Clear()

Clear data.

void ClearImages()

Clear images.

void ClearRegions()

Clear regions.

int SetData(Image *img, Image *lapl_img, Image *edge_img = 0)

Set data (NB: Pointer ownership is taken by this class)

int SPGenerator(Image *img, int regionSize = 10, double regParam = 1, int minRegionSize = 10, bool useLogScaleMapping = false, Image *edgeImg = 0)

Generate a superpixel partition given the passed options.

Image *GetSegmentedImage(Image *image, int selectedTag = -1, bool normalize = false, bool binarize = false)

Get segmented image.

inline int GetNRegions() const

Get number of regions.

inline std::vector<Region*> GetRegions()

Return regions.

inline void SetRegions(std::vector<Region*> &list)

Set regions.

inline Region *GetRegion(int index)

Get region.

inline int AddRegion(Region *aRegion)

Add region.

inline long int GetRegionId(long int index)

Get region id from index (NB: No check done)

inline long int GetRegionSize(long int index)

Get region size from index (NB: No check done)

int ComputeRegionParameters()

Compute region parameters.

void RemoveEmptyRegions()

Remove regions without pixels.

inline void DeleteRegions(std::vector<size_t> const &delete_indexes)

Delete regions specified in the list (NB: No check done)

void GetRegionIdMap(std::map<long int, long int> &regionIdMap) const

Get region map regionId>index.

void GetRegionIndexMap(std::map<long int, long int> &regionIndexMap) const

Get region index map (index>regionId)

inline void SetPixelLabels(std::vector<long int> list)

Set pixel labels.

int SetPixelLabel(long int gBin, long int label, bool check = true)

Set pixel label (NB: No check done)

inline void ScalePixelLabel(long int gBin, long int scale)

Scale pixel label (NB: No check done)

inline long int GetPixelLabel(long int ix, long int iy)

Get pixel label (NB: No check is done)

inline long int GetPixelLabel(long int gBin)

Get pixel label (NB: No check is done)

inline ImgStats *GetCurvStats()

Get image curvature stats.

inline ImgStats *GetStats()

Get image stats.

inline ImgStats *GetEdgeStats()

Get image edge stats.

inline double GetScurv(long int ix, long int iy)

Get curvature pixel value (NB: No check is done!)

double GetSedge(long int ix, long int iy)

Get edgeness pixel value.

inline double GetS(long int ix, long int iy)

Get pixel value (NB: No check is done!)

inline void SetRegionId(int index, int id)

Set region id (NB: No checks performed)

inline void AddPixelToRegion(int index, Pixel *pixel)

Add pixel to region (NB: No checks performed)

class Caesar::SLICContourData : public TObject

Public Functions

inline SLICContourData()

SLIC contour data constructor.

inline virtual ~SLICContourData()

SLIC contour data destructor.

inline void ResetContour()

Reset SLIC contour.

inline void ResetList()

Reset connected regions list and clear SLIC boundary data.

class Caesar::SLICNeighborData : public TObject

Public Functions

inline SLICNeighborData()

SLIC neighbor data constructor.

inline virtual ~SLICNeighborData()

SLIC neighbor data destructor.

inline bool operator==(const SLICNeighborData &aNeighborData) const

SLIC neighbor data equality operator for comparison.

inline void Print()

Print neighbor data info.

class Caesar::SLICNeighborCollection : public TObject

Public Functions

inline SLICNeighborCollection()

SLIC neighbor collection constructor.

inline virtual ~SLICNeighborCollection()

SLIC neighbor collection destructor.

inline void Add(SLICNeighborData nn)

Add a SLIC neighbor data to collection.

inline void SortByDiss()

Sort SLIC neighbor data in collection by dissimilarity measure.

inline void SortByEdgeness()

Sort SLIC neighbor data in collection by edgeness measure.

inline void SortByTotDiss()

Sort SLIC neighbor data in collection by total dissimilarity measure.

inline int GetN()

Get number of neighbor data present in collection.

inline int FindById(int id)

Find a SLIC neighbor data in collection by id.

inline int FindByIndex(int index)

Find a SLIC neighbor data in collection by index.

inline int FindCloserByDiss()

Find the closest neighbor data in collection wrt dissimilarity.

inline int FindCloserByDissTot()

Find the closest neighbor data in collection wrt total dissimilarity.

inline std::vector<SLICNeighborData> GetNSortedByDiss(int N)

Find the closest neighbor data in collection in dissimilarity.

inline std::vector<SLICNeighborData> GetNSortedByTotDiss(int N)

Returns the number of SLIC neighbor data sorted by total dissimilarity.

inline bool IsIdAmongNClosersByDiss(int id, int N)

Check if neighbor data with given id is among the closest N in collection wrt dissimilarity measure.

inline bool IsIdAmongNClosersByTotDiss(int id, int N)

Check if neighbor data with given id is among the closest N in collection wrt total dissimilarity measure.

inline bool IsIndexAmongNClosersByDiss(int index, int N)

Check if neighbor data with given index is among the closest N in collection wrt dissimilarity measure.

inline bool IsIndexAmongNClosersByTotDiss(int index, int N)

Check if neighbor data with given index is among the closest N in collection wrt total dissimilarity measure.

inline void Print()

Print neighbor data collection info.

inline const std::vector<SLICNeighborData> &GetNeighbors() const

Returns SLIC neighbor data collection.

inline SLICNeighborData *GetNeighbor(int index)

Returns SLIC neighbor data with given index in collection.

int SetDtot(int index, double Dtot, double Dtot_n)

Set total dissimilarity info of neighbor data with the given index in collection.

class Caesar::SLICSimilarityData : public TObject

Public Functions

inline SLICSimilarityData()

SLIC similarity data constructor.

inline virtual ~SLICSimilarityData()

SLIC similarity data destructor.

class Caesar::SLIC : public TObject

Public Functions

SLIC()

Class constructor: initialize structures.

virtual ~SLIC()

Class destructor: free allocated memory.

Public Static Functions

static SLICData *SPGenerator(Image *img, int regionSize = 20, double regParam = 1, int minRegionSize = 10, bool normalizeImage = true, bool useLogScaleMapping = false, Image *laplImg = 0, Image *edgeImg = 0)

Generate superpixel partition.

static SLICContourData *ComputeBoundaryContours(SLICData *slicData)

Compute superpixel boundary contours.

static SLICSimilarityData *ComputeRegionSimilarity(SLICData *slicData, std::vector<SLICNeighborCollection> &neighbors, double beta = 0.5)

Compute region similarities.

static int FindNeighbors(std::vector<SLICNeighborCollection> &neighbors, SLICData *slicData, SLICContourData *contourData, bool get2ndNeighbors = true, int selectedTag = -1, bool includeSpatialDist = false, bool normalizeParams = true, bool useRobustParams = false, bool addCurvDist = true)

Find superpixel neighbors.

static Image *GetSegmentedImage(Image *img, std::vector<Region*> const &regions, int selectedTag = -1, bool normalize = false, bool binarize = false)

Compute segmented image given a list of tagged regions.

static int CountTaggedRegions(std::vector<Region*> const &regions, int &NSig, int &NBkg, int &NUntagged)

Count number of regions per tag.

static int TagRegions(std::vector<Region*> &regions, Image *binaryMap_bkg, Image *binaryMap_signal)

Tag regions into signal/bkg according to signal & bkg marker images.

static int ComputeRegionDistance(double &dist, double &dist_spatial, Region *region_i, Region *region_j, RegionDistNormData normPars, bool normalizeParams = true, bool useRobustParams = false, bool addCurvDist = false)

Compute distance between regions.

static int ComputeRegionAsymmDistance(double &dist, double &dist_neighbor, Region *region_i, Region *region_j, RegionDistNormData normPars, bool normalizeParams = true, bool useRobustParams = false, bool addCurvDist = false, bool addSpatialDist = false)

Compute asymmetric distance between regions.