latest version v1.9 - last update 10 Apr 2010 |
Color Adaptive Clustering Algorithm. More...
#include <ltiColorACASegmentation.h>
Classes | |
class | parameters |
The parameters for the class colorACASegmentation. More... | |
Public Member Functions | |
colorACASegmentation () | |
colorACASegmentation (const parameters &par) | |
colorACASegmentation (const colorACASegmentation &other) | |
virtual | ~colorACASegmentation () |
virtual const char * | getTypeName () const |
bool | apply (image &srcdest) const |
bool | apply (const image &src, image &dest) const |
bool | apply (const image &src, imatrix &mask, image &means) const |
bool | apply (const image &src, imatrix &mask) const |
colorACASegmentation & | copy (const colorACASegmentation &other) |
colorACASegmentation & | operator= (const colorACASegmentation &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
bool | setParameters (const functor::parameters ¶m) |
Protected Member Functions | |
bool | aca (const image &src, imatrix &mask, image &means, const bool computeMeans) const |
bool | kMeansInit (const image &src, imatrix &mask) const |
bool | estimateMeans (const image &src, const imatrix &mask, std::vector< image > &means, const int windowSize, const int gridSize, const int tMin) const |
bool | interpolate (image &src, const int gridSize) const |
bool | estimateSegmentation (const image &src, const std::vector< image > &means, const float gfactor, imatrix &mask, int &cycles) const |
int | computeLabel (const image &src, const std::vector< image > &means, const imatrix &mask, const point &p, const int from, const int to, const float gfactor, int &numChanges) const |
bool | estimateSegmentationStep (const image &src, const std::vector< image > &means, const float gfactor, imatrix &mask, imatrix &nmask, int &numChanges) const |
bool | createMeanImage (const std::vector< image > &lmeans, const imatrix mask, image &means) const |
Color Adaptive Clustering Algorithm.
This functor provides a segmentation algorithm based on the Adaptive Clustering Algorithm (ACA) proposed by Thrasyvoulos N. Pappas in his paper "An adaptive clustering algorithm for image segmentation", IEEE Transactions on signal processing, vol. 40, No. 4, april 1992.
Even if in the original version the algorithm has been applied to gray valued images, the current implementation has been adapted for the segmentation of color images.
The algorithm first generates an image pyramid for the input. For the smallest image a k-Means color clustering is done, and a labeling procedure assigns to each pixel the corresponding label.
Using this first segmentation proposal and the current window size (initially the whole image) it generates a new estimation of the expected mean values for each pixel. With the new mean values compute the a-posteriori probabilities for each pixel to belong to any of the classes and compute with them a new segmentation hypothesis.
Repeat the estimation of the expected values and the new segmentation until the algorithm converges or only a small number of changes has been done in the last iteration.
Reduce the window size and begin the iterations again, until the minimum window size is reached.
Now duplicate the size of the segmentation result and use it as initialization for the next iteration using the next pyramid level.
The whole process is repeated until the highest resolution level has been analyzed.
Note that this algorithm is very slow. It is implemented to provide a comparison possibility with your own algorithms.
lti::colorACASegmentation::colorACASegmentation | ( | ) |
Default constructor.
lti::colorACASegmentation::colorACASegmentation | ( | const parameters & | par | ) |
Construct a functor using the given parameters.
lti::colorACASegmentation::colorACASegmentation | ( | const colorACASegmentation & | other | ) |
Copy constructor.
other | the object to be copied |
virtual lti::colorACASegmentation::~colorACASegmentation | ( | ) | [virtual] |
Destructor.
bool lti::colorACASegmentation::aca | ( | const image & | src, | |
imatrix & | mask, | |||
image & | means, | |||
const bool | computeMeans | |||
) | const [protected] |
Segmentates the image and computes the labeled mask, with labels between 0 and parameters::kMeansParam::numberOfColors - 1.
Additionally, the estimated mean values will be computed.
Note that the result differs from other segmentation approaches in the fact that the functor doesn't compute a palette, since the values within a region are allowed to slowly change.
src | image with the source data | |
mask | imatrix with the labels for each region | |
means | image with the estimated mean values per pixel. | |
computeMeans | compute image with means |
Segmentates the image and computes the labeled mask, with labels between 0 and parameters::kMeansParam::numberOfColors - 1.
Additionally, the estimated mean values will be computed.
Note that the result differs from other segmentation approaches in the fact that the functor doesn't compute a palette, since the values within a region are allowed to slowly change.
src | image with the source data | |
mask | imatrix with the labels for each region |
Segmentates the image and computes the labeled mask, with labels between 0 and parameters::kMeansParam::numberOfColors - 1.
Additionally, the estimated mean values will be computed.
Note that the result differs from other segmentation approaches in the fact that the functor doesn't compute a palette, since the values within a region are allowed to slowly change.
bool lti::colorACASegmentation::apply | ( | image & | srcdest | ) | const |
virtual functor* lti::colorACASegmentation::clone | ( | ) | const [virtual] |
Returns a pointer to a clone of this functor.
Reimplemented from lti::segmentation.
int lti::colorACASegmentation::computeLabel | ( | const image & | src, | |
const std::vector< image > & | means, | |||
const imatrix & | mask, | |||
const point & | p, | |||
const int | from, | |||
const int | to, | |||
const float | gfactor, | |||
int & | numChanges | |||
) | const [inline, protected] |
Compute label.
src | original image | |
means | the mean values for each label | |
mask | initial segmentation | |
p | point to be evaluated | |
from | which neighbor should be considered first | |
to | which neighbor should be considered last | |
gfactor | must be -1/2*sigma^2 | |
numChanges | number of changes taken in the iteration. |
colorACASegmentation& lti::colorACASegmentation::copy | ( | const colorACASegmentation & | other | ) |
Copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::segmentation.
bool lti::colorACASegmentation::createMeanImage | ( | const std::vector< image > & | lmeans, | |
const imatrix | mask, | |||
image & | means | |||
) | const [protected] |
Create an image containing the appropriate mean values.
bool lti::colorACASegmentation::estimateSegmentation | ( | const image & | src, | |
const std::vector< image > & | means, | |||
const float | gfactor, | |||
imatrix & | mask, | |||
int & | cycles | |||
) | const [protected] |
Estimate segmentation given the means.
bool lti::colorACASegmentation::estimateSegmentationStep | ( | const image & | src, | |
const std::vector< image > & | means, | |||
const float | gfactor, | |||
imatrix & | mask, | |||
imatrix & | nmask, | |||
int & | numChanges | |||
) | const [protected] |
Estimate segmentation given the means.
const parameters& lti::colorACASegmentation::getParameters | ( | ) | const |
Returns used parameters.
Reimplemented from lti::functor.
virtual const char* lti::colorACASegmentation::getTypeName | ( | ) | const [virtual] |
Returns the name of this type ("colorACASegmentation").
Reimplemented from lti::segmentation.
bool lti::colorACASegmentation::interpolate | ( | image & | src, | |
const int | gridSize | |||
) | const [protected] |
Interpolate all pixels not at the grid points using bilinear interpolation.
Initialize the segmentation using k-Means.
The argument mask represents the variable x in the original paper
colorACASegmentation& lti::colorACASegmentation::operator= | ( | const colorACASegmentation & | other | ) |
bool lti::colorACASegmentation::setParameters | ( | const functor::parameters & | param | ) | [virtual] |
Set the parameters.
Reimplemented from lti::functor.