Darwin
1.10(beta)
|
Holds multiple oversegmentations for a given image. More...
Public Member Functions | |
drwnSuperpixelContainer () | |
default constructor | |
drwnSuperpixelContainer (const drwnSuperpixelContainer &container) | |
copy constructor | |
void | clear () |
clears all oversegmentations (and releases memory) | |
bool | empty () const |
returns true if their are no superpixels | |
int | size () const |
returns the number of superpixels | |
int | pixels (unsigned segId) const |
returns the number of pixels within the given superpixel | |
int | width () const |
returns the image width | |
int | height () const |
returns the image height | |
int | channels () const |
returns the maximum number of superpixels to which any pixel can belong | |
size_t | memory () const |
returns number of bytes stored (approximately) | |
virtual size_t | numBytesOnDisk () const |
number of bytes required to store object on disk or in a character stream (without compression) | |
virtual bool | write (ostream &os) const |
write the object to an output stream | |
virtual bool | read (istream &is) |
read the object from an input stream | |
void | loadSuperpixels (const char *filename) |
load superpixels from file (.png or .txt) | |
void | addSuperpixels (cv::Mat superpixels) |
add 32-bit oversegmentation (container does not clone) | |
void | copySuperpixels (const cv::Mat &superpixels) |
copy 32-bit oversegmentation (container clones argument) | |
cv::Mat | mask (unsigned segId) const |
return 8-bit mask for given superpixel | |
cv::Mat & | mask (unsigned segId, cv::Mat &m) const |
return 8-bit mask for given superpixel (use supplied matrix if given) | |
set< unsigned > | parents (int x, int y) const |
returns set of superpixel indices to which the given pixel belongs | |
set< unsigned > | neighbours (unsigned segId) const |
returns all overlapping or 8-connected superpixels to a given superpixel | |
const cv::Rect & | boundingBox (unsigned segId) const |
returns the bounding box for a superpixel | |
cv::Point | centroid (unsigned segId) const |
calculates and returns centroid for a superpixel | |
cv::Mat | intersection () const |
return 32-bit intersection of superpixels | |
int | removeSmallSuperpixels (unsigned minSize=2) |
filters small superpixels and returns number of superpixels removed | |
int | removeUnmaskedSuperpixels (const cv::Mat &mask, double areaOverlap=0.5) |
filters superpixels that do not overlap with supplied mask | |
int | removeSuperpixels (const std::set< unsigned > &segIds) |
filters superpixels matching the given set of segIds | |
cv::Mat | visualize (const cv::Mat &img, bool bColourById=false) const |
visualize superpixels | |
cv::Mat | visualize (const cv::Mat &img, const vector< cv::Scalar > &colors, double alpha=1.0) const |
visualize superpixels with specific colours | |
drwnSuperpixelContainer & | operator= (const drwnSuperpixelContainer &container) |
assignment operator | |
const cv::Mat & | operator[] (unsigned int indx) const |
access the i-th superpixel map as CV_32SC1 | |
Protected Attributes | |
vector< int > | _start |
start index for each _map | |
vector< int > | _nsegs |
number of segments in each _map | |
vector< cv::Mat > | _maps |
superpixel maps (-1 if pixel is not part of a map) | |
vector< int > | _pixels |
size of each superpixel | |
vector< cv::Rect > | _bboxes |
bounding boxes for each superpixel | |
Holds multiple oversegmentations for a given image.
The container is populated with segment maps with the same dimensions as the image. A map is an integer array, each entry corresponding to a pixel in the image. Maps can define more than one segment/superpixel. A segment is defined as all pixels (in a map) labeled with the same non-negative integer. Pixels labeled with negative integers are ignored. Maps are renumbered when added to the container. Member functions allow you to retrieve the mask of each segment/superpixel or the (renumbered) maps.
The following code snippet shows how the container can be used to iterate through different superpixels:
The class provides a drwnPersistentStorage interface. Superpixel region data is stored run-length encoded in binary format. This is useful for caching superpixel calculations. The following code snippet shows an example of this functionality.
The superpixels in stored drwnSuperpixelContainer objects can be accessed in Matlab via the mexLoadSuperpixels and mexSaveSuperpixels application wrappers.