Image Component Library (ICL)
|
ImageRegion Structure providing region feature information. More...
#include <ImageRegion.h>
Public Member Functions | |
template<class T > | |
void | calculateBoundaryIntern (const core::Img< T > &image) const |
internal utility function More... | |
void | calculateThinnedBoundaryIntern () const |
another utility function More... | |
utils::Point | getUpperLeftPixel () const |
utility function that returns the upper left pixel of the region More... | |
ImageRegion (ImageRegionData *data=0) | |
Null-construktor. More... | |
operator bool () const | |
returns whether this image region is not null More... | |
ImageRegionData * | data () |
returns the internal data (do not use!) More... | |
const ImageRegionData * | data () const |
returns the internal data (do not use!) (const) More... | |
void | sample (core::ImgBase *image, int color) |
samples the region into a given image More... | |
void | sample (core::ImgBase *image, const std::vector< int > &channelColors) |
samples the region into a given image More... | |
int | getSize () const |
returns the pixel count of the Region More... | |
int | getVal () const |
returns the pixel value of the region More... | |
int | getID () const |
returns a unique region ID More... | |
utils::Point32f | getCOG () const |
returns the region's center of gravity More... | |
const std::vector< LineSegment > & | getLineSegments () const |
retuns the internal list of line segments More... | |
const utils::Rect & | getBoundingBox () const |
returns the region's bounding box More... | |
const RegionPCAInfo & | getPCAInfo () const |
returns information about the regions spacial PCA More... | |
const std::vector< utils::Point > & | getBoundary (bool thinned=true) const |
returns all boundary pixels of this region More... | |
int | getBoundaryPointCount (bool thinned) const |
returns the size of boundary pixel array of the ImageRegion More... | |
float | getBoundaryLength () const |
returns the estimated length of the boundary More... | |
const std::vector< utils::Point32f > & | getBoundaryCorners () const |
Approximate the region boundary by polygon structure. More... | |
float | getFormFactor () const |
returns the Form-Factor of the Region (Boundary²/4PI*utils::Size) More... | |
const std::vector< utils::Point > & | getPixels () const |
returns a list of all pixels, of this regions More... | |
void | drawTo (const core::ImgBase *image, icl64f val) const |
sets all pixel positions in given image to val in channel 0 of image More... | |
void | drawToColor (const core::ImgBase *image, const icl64f *color) const |
highlights the region in the image using the given color More... | |
const std::vector< ImageRegion > & | getSubRegions (bool directOnly=true) const |
returns a list of all fully contained image regions More... | |
const ImageRegion & | getParentRegion () const |
returns the parent regions (which might be NULL) More... | |
const std::vector< ImageRegion > & | getParentTree () const |
returns the parent region and the parent's parent and so on More... | |
const std::vector< ImageRegion > & | getNeighbours () const |
returns a list of all adjacent regions More... | |
bool | isBorderRegion () const |
returns whether this ImageRegion is adjacent to the image border More... | |
bool | contains (const utils::Point &p) const |
returns whether a given pixel position is part of the image region More... | |
void | showTree () const |
shows the region tree and neighbours (for debugging) More... | |
void | setMetaData (const utils::Any &any) const |
associates meta data with this region (also const) More... | |
const utils::Any & | getMetaData () const |
returns the meta data associated with this region More... | |
Public Attributes | |
ImageRegionData * | m_data |
Internally handled data (not shallow copied, but simply linked to the real data that is managed by the RegionDetector. More... | |
Friends | |
class | RegionDetector |
Allows the RegionDetector to access private functions/methods. More... | |
ImageRegion Structure providing region feature information.
The Region class provides several region information:
Valid ImageRegion-instances are only created by a RegionDetector instance.
Almost all features are computed on demand only. This means, that e.g. the center of gravity is only calculated if the corresponding getter-function getCOG() is called. The results of all features are automatically stored internally. By this means, all features must only be computed once, even if the corresponding getter function is called several times.
Some ImageRegion features are only available if the parent RegionDetector was set up to compute so called region graph information. From this, an ImageRegion structure can compute the following features: neighbour regions sub regions surrounding regions (parent region and parent region tree)
If one of these functions is called in a case where no region graph information is available, an exception will be thrown.
Most high level features, such as bounding boxes or PCA information, can be calculated efficiently on the underlying LineSegment structure. Only this list of boundary pixels are calculated on basis of the underlying image.
To avoid deep copies of internal region data, the ImageRegion is a very simple wrapper of an underlying data structure called ImageRegionData. Even though a pointer to this structure can be obtained using the ImageRegion::data() function, is is strongly recommended to use the ImageRegions interface only. Access to the internal structure is only for debugging.
|
inline |
Null-construktor.
void icl::cv::ImageRegion::calculateBoundaryIntern | ( | const core::Img< T > & | image | ) | const |
internal utility function
void icl::cv::ImageRegion::calculateThinnedBoundaryIntern | ( | ) | const |
another utility function
bool icl::cv::ImageRegion::contains | ( | const utils::Point & | p | ) | const |
returns whether a given pixel position is part of the image region
|
inline |
returns the internal data (do not use!)
|
inline |
returns the internal data (do not use!) (const)
void icl::cv::ImageRegion::drawTo | ( | const core::ImgBase * | image, |
icl64f | val | ||
) | const |
sets all pixel positions in given image to val in channel 0 of image
void icl::cv::ImageRegion::drawToColor | ( | const core::ImgBase * | image, |
const icl64f * | color | ||
) | const |
highlights the region in the image using the given color
please note, that color must contain at least one element for each channel in the given image
const std::vector<utils::Point>& icl::cv::ImageRegion::getBoundary | ( | bool | thinned = true | ) | const |
returns all boundary pixels of this region
const std::vector<utils::Point32f>& icl::cv::ImageRegion::getBoundaryCorners | ( | ) | const |
Approximate the region boundary by polygon structure.
float icl::cv::ImageRegion::getBoundaryLength | ( | ) | const |
returns the estimated length of the boundary
This methods gives a much better estimation of the boundary length than getBoundaryPointCount(). The change in the estimated length should be no larger than 5 to 10 % under rotation of the object.
Complexity: linear in boundary length.
int icl::cv::ImageRegion::getBoundaryPointCount | ( | bool | thinned | ) | const |
returns the size of boundary pixel array of the ImageRegion
const utils::Rect& icl::cv::ImageRegion::getBoundingBox | ( | ) | const |
returns the region's bounding box
utils::Point32f icl::cv::ImageRegion::getCOG | ( | ) | const |
returns the region's center of gravity
float icl::cv::ImageRegion::getFormFactor | ( | ) | const |
returns the Form-Factor of the Region (Boundary²/4PI*utils::Size)
Please note that the formfactor for smaller regions is always a bit higher as expected for an ideal regions. This problem occurs due to using a 4-neighbourhood for calculating the boundary length of an ImageRegion;
The form factor formula is designed in that way, that an ideal circly has a formfactor of 1 and all other – less round – regions have a higher form factor:
int icl::cv::ImageRegion::getID | ( | ) | const |
returns a unique region ID
const std::vector<LineSegment>& icl::cv::ImageRegion::getLineSegments | ( | ) | const |
retuns the internal list of line segments
const utils::Any& icl::cv::ImageRegion::getMetaData | ( | ) | const |
returns the meta data associated with this region
const std::vector<ImageRegion>& icl::cv::ImageRegion::getNeighbours | ( | ) | const |
returns a list of all adjacent regions
This function is only provided if region graph information is available (see Region Graph Information)
const ImageRegion& icl::cv::ImageRegion::getParentRegion | ( | ) | const |
returns the parent regions (which might be NULL)
This function is only provided if region graph information is available (see Region Graph Information)
const std::vector<ImageRegion>& icl::cv::ImageRegion::getParentTree | ( | ) | const |
returns the parent region and the parent's parent and so on
If a parent is null, the list ends immediately. In particular, this list can be empty This function is only provided if region graph information is available (see Region Graph Information)
const RegionPCAInfo& icl::cv::ImageRegion::getPCAInfo | ( | ) | const |
returns information about the regions spacial PCA
const std::vector<utils::Point>& icl::cv::ImageRegion::getPixels | ( | ) | const |
returns a list of all pixels, of this regions
Most of the time, this is very unefficient. It is strongly recommended to use getLineSegments() instead
int icl::cv::ImageRegion::getSize | ( | ) | const |
returns the pixel count of the Region
const std::vector<ImageRegion>& icl::cv::ImageRegion::getSubRegions | ( | bool | directOnly = true | ) | const |
returns a list of all fully contained image regions
This function is only provided if region graph information is available (see Region Graph Information)
ImageRegion A contains ImageRegion B if
utils::Point icl::cv::ImageRegion::getUpperLeftPixel | ( | ) | const |
utility function that returns the upper left pixel of the region
int icl::cv::ImageRegion::getVal | ( | ) | const |
returns the pixel value of the region
bool icl::cv::ImageRegion::isBorderRegion | ( | ) | const |
returns whether this ImageRegion is adjacent to the image border
|
inline |
returns whether this image region is not null
a parent region e.g. can be null
void icl::cv::ImageRegion::sample | ( | core::ImgBase * | image, |
int | color | ||
) |
samples the region into a given image
void icl::cv::ImageRegion::sample | ( | core::ImgBase * | image, |
const std::vector< int > & | channelColors | ||
) |
samples the region into a given image
void icl::cv::ImageRegion::setMetaData | ( | const utils::Any & | any | ) | const |
associates meta data with this region (also const)
Note, this method is explicitly const since an un-const version would make the users simply copy the region before setting the meta data value. As all other properties, also the meta data is stored in the internal ImageRegionData structure. Therefore, also the meta-data is hold in the internally managed and shallowly copied data structure.
void icl::cv::ImageRegion::showTree | ( | ) | const |
shows the region tree and neighbours (for debugging)
|
friend |
Allows the RegionDetector to access private functions/methods.
ImageRegionData* icl::cv::ImageRegion::m_data |
Internally handled data (not shallow copied, but simply linked to the real data that is managed by the RegionDetector.