latest version v1.9 - last update 10 Apr 2010 |
This class is used to segmentate an image with a regular background. More...
#include <ltiRegionGrowing.h>
Classes | |
class | parameters |
The parameters for the class regionGrowing. More... | |
Public Member Functions | |
regionGrowing () | |
regionGrowing (const parameters &par) | |
regionGrowing (const regionGrowing &other) | |
virtual | ~regionGrowing () |
virtual const char * | getTypeName () const |
channel8 & | apply (channel8 &srcdest) const |
channel & | apply (channel &srcdest) const |
image & | apply (image &srcdest) const |
channel8 & | apply (const channel8 &src, channel8 &dest) const |
channel8 & | apply (const channel &src, channel8 &dest) const |
channel8 & | apply (const image &src, channel8 &dest) const |
regionGrowing & | copy (const regionGrowing &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
Protected Member Functions | |
bool | similar (const ubyte &neighbour, const ubyte &avrgAtSeed, const int &avrgThreshold) const |
bool | similar (const float &neighbour, const float &avrgAtSeed, const float &avrgThreshold) const |
template<class T > | |
void | mask (matrix< T > &img, const channel8 &msk, const T &background) const |
channel8 & | segmentate (const image &src, channel8 &dest) const |
channel8 & | segmentate (const channel &src, channel8 &dest) const |
This class is used to segmentate an image with a regular background.
It uses a set of seed pixels (given in the parameters) to start the region growing. To check the similarity, a comparition is done between the pixel value at the candidate position and the average value at the seed position. If the difference of these values is lower than a given threshold, the pixel will be considered as part of the growing region. It is possible to get automatically values for these thresholds if a known background region is given in the parameters.
Example:
lti::loadBMP loader; lti::image img; // the color image to be segmented lti::channel8 chnl; // the segmentation mask will be left here loader.load("img/leo040801_00_019.bmp",img); // read an image lti::regionGrowing segmenter; // segmentation functor and lti::regionGrowing::parameters param; // its parameters param.useGaussKernel = true; // use a gaussian kernel 5x5 param.localStatisticsKernelSize = 5; param.localStatisticsKernelVariance = -1; param.mode = lti::regionGrowing::parameters::UseGivenThresholds; param.averageThresholds = trgbPixel<float>(0.05,0.05,0.05); param.edgesThreshold = 0.04; // do not use all corners as seed-points, just the three following... param.seedPoints.resize(3,tpoint<float>(0,0)); param.seedPoints.at(1).y = 1.0f; param.seedPoints.at(2).x = 1.0f; param.seedPoints.at(2).y = 1.0f; // indicate the segmentation functor the user-parameters segmenter.setParameters(param); // segmentate the image and leave the segmentation in the channel segmenter.apply(img,chnl); view1.show(img); // show original image view2.show(chnl); // show the segmentation mask
lti::regionGrowing::regionGrowing | ( | ) |
Default constructor.
lti::regionGrowing::regionGrowing | ( | const parameters & | par | ) |
Default constructor with parameters.
lti::regionGrowing::regionGrowing | ( | const regionGrowing & | other | ) |
Copy constructor.
other | the object to be copied |
virtual lti::regionGrowing::~regionGrowing | ( | ) | [virtual] |
Destructor.
Operates on a copy of the given parameters.
src | image with the source data. | |
dest | channel8 where the segmentation mask will be left. This mask contains 0 for a background point and (usually) 255 for an object point. |
dest
. Operates on a copy of the given parameters.
src | channel with the source data. | |
dest | channel8 where the segmentation mask will be left. This mask contains 0 for a background point and (usually) 255 for an object point. |
dest
. Operates on a copy of the given parameters.
src | channel8 with the source data. | |
dest | channel8 where the segmentation mask will be left. This mask contains 0 for a background point and (usually) 255 for an object point. |
dest
. Operates on the given parameter.
The background-pixels will be set to black, grey or white depending on the parameter "backgroundType".
srcdest | image with the source data. The result will be left here too. |
srcdest
. Operates on the given parameter.
The background-pixels will be set to 0, 0.5 or 1.0 depending on the parameter "backgroundType".
srcdest | channel with the source data. The result will be left here too. |
srcdest
. Operates on the given parameter.
The background-pixels will be set to 0,128 or 255 depending on the parameter "backgroundType".
srcdest | channel8 with the source data. The result will be left here too. |
srcdest
. virtual functor* lti::regionGrowing::clone | ( | ) | const [virtual] |
Returns a pointer to a clone of this functor.
Reimplemented from lti::segmentation.
regionGrowing& lti::regionGrowing::copy | ( | const regionGrowing & | other | ) |
Copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::segmentation.
const parameters& lti::regionGrowing::getParameters | ( | ) | const |
Returns used parameters.
Reimplemented from lti::functor.
virtual const char* lti::regionGrowing::getTypeName | ( | ) | const [virtual] |
Returns the name of this type ("regionGrowing").
Reimplemented from lti::segmentation.
void lti::regionGrowing::mask | ( | matrix< T > & | img, | |
const channel8 & | msk, | |||
const T & | background | |||
) | const [inline, protected] |
All pixels at img for which the mask is 0 will be set to the given value.
The mask and img MUST have the same size!
References lti::genericMatrix< T >::begin(), and lti::genericMatrix< T >::end().
Operates on a copy of the given parameters.
src | image with the source data. | |
dest | the mask will be 0 for background pixels |
dest
. Operates on a copy of the given parameters.
src | image with the source data. | |
dest | the mask will be 0 for background pixels |
dest
. bool lti::regionGrowing::similar | ( | const float & | neighbour, | |
const float & | avrgAtSeed, | |||
const float & | avrgThreshold | |||
) | const [inline, protected] |
The pixel at position "neighbour" will be compared with the average value corresponding to the position "seed".
The Codition for similarity proof if the absolute value of the difference between the channel value at "neighbour" and the local average on the "seed"-position is lower than the given avrgThreshold
bool lti::regionGrowing::similar | ( | const ubyte & | neighbour, | |
const ubyte & | avrgAtSeed, | |||
const int & | avrgThreshold | |||
) | const [inline, protected] |
The pixel at position "neighbour" will be compared with the average value corresponding to the position "seed".
The Codition for similarity proof if the absolute value of the difference between the channel value at "neighbour" and the local average on the "seed"-position is lower than the given avrgThreshold
References lti::abs().