Inheritance diagram for kmeans::KMeansSegmenter< T >:
Public Types | |
typedef Cluster< SingleFeature > | RegionProperty |
The simplest region property is a cluster of a single feature. | |
typedef std::vector< int > | Replacement |
Given a region with label i, Replacement[i] provides the new label, usually at a particular scale. | |
Public Member Functions | |
virtual LImage< int > | segment (const LImage< int > &orig) |
virtual | ~KMeansSegmenter () |
KMeansSegmenter (int min_val=0, int max_val=100, size_t number_of_clusters=16) | |
Pass in the range of values to consider in thresholding. | |
void | setOutputImageDir (const std::string &newDir) |
Pass in an empty string to turn off output. | |
void | writeGraph (const std::string &filename) const |
Write out a DOT output file (in a form that the Graphviz utility dot can read). | |
LImage< int > | getScale (size_t scale, bool rawlabels=false) const |
The different scales. | |
const Replacement & | getReplacement (size_t scale) const |
Gets the replacement at different scales. | |
size_t | getNumScales () const |
Returns the total number of scales in the segmentation. | |
Static Public Member Functions | |
static void | setMarkovWeight (float lambda) |
Set the weight of the Markov energy relative to the Discontiguity measure. | |
static void | computeRegionProperty (const LImage< int > &orig, const LImage< int > &label, vector< RegionProperty > *fillme) |
Fills in the passed in vector with a vector of computed region properties. | |
static void | computeRegionProperty (const LImage< int > &label, vector< RegionProperty > *fillme) |
Fills in the passed in vector with a vector of computed region properties. | |
Protected Member Functions | |
LImage< int > | doKMeans (const ImageAttr< T > &attr, LImage< int > *label, vector< Cluster< T > > *clusters, int iter_no=0) const |
Do K means segmentation, filling in the cluster array. | |
LImage< int > | initialize (const LImage< int > &orig, const ImageAttr< T > &attr, vector< Cluster< T > > *clusters) const |
Get an initial cut of clusters, somehow. | |
void | computeClusterAttr (const ImageAttr< T > &attr, const LImage< int > &label, vector< Cluster< T > > *clusters, bool has_K_levels=true) const |
Compute cluster attributes from the image attribute and labeling. | |
int | findBestCluster (const T ¤t, const vector< Cluster< T > > &clusters, const LImage< int > &labels, int x, int y) const |
Return label corresponding to best cluster available. | |
float | computeMeasureDistance (const Cluster< T > &cluster, const T ¤t, int x, int y) const |
Way to compute distance between a point (value,x,y) and a cluster's mean. | |
float | computeMeasureDistance (const T &other, const T ¤t) const |
Finds distance between two statistics. | |
float | computeDiscontiguityDistance (const LImage< int > &label, int x, int y, int candidate_label) const |
Way to compute discontiguity if the current label were to be changed to the candidate. | |
virtual LImage< int > | computeDetailImage (const LImage< int > &label, const ImageAttr< T > &attr, std::vector< Replacement > *replacements_list) |
This function may be over-ridden to provide a different way of selecting among the regions produced by K-means segmentation. | |
virtual void | computeReplacements (const LImage< int > &label, const ImageAttr< T > &attr, std::vector< Replacement > *replacements_list) |
This function may be over-ridden to provide a different way of choosing how to combine/replace regions at higher levels. | |
Static Protected Member Functions | |
static void | expand_segment (int x, int y, const LImage< int > &orig, LImage< int > &segimg, int label) |
Set the segimg at x,y to be label and then call this function. | |
static LImage< int > | relabel (const LImage< int > &label_img) |
Will relabel the image, removing unused labels. | |
static LImage< int > | pruneRegions (const LImage< int > &label, RegionPruner &) |
This method removes all regions that meet certain criteria. | |
Static Protected Attributes | |
static const int | Unset = -1000 |
static const int | Invalid = -2000 |
Friends | |
class | Pruner |
Classes | |
class | Pruner |
Controls pruning of regions based on size. More... |
typedef Cluster< SingleFeature > kmeans::Segmenter::RegionProperty [inherited] |
The simplest region property is a cluster of a single feature.
typedef std::vector<int> kmeans::Segmenter::Replacement [inherited] |
Given a region with label i, Replacement[i] provides the new label, usually at a particular scale.
The Replacement structure is such that replacement[i] provides the replacement label for the current label i. This replacement may be 0 or negative, which means that no replacement exists.
Reimplemented in kmeans::MergingKMSegmenter< T >.
virtual kmeans::KMeansSegmenter< T >::~KMeansSegmenter | ( | ) | [inline, virtual] |
kmeans::KMeansSegmenter< T >::KMeansSegmenter | ( | int | min_val = 0 , |
|
int | max_val = 100 , |
|||
size_t | number_of_clusters = 16 | |||
) |
Pass in the range of values to consider in thresholding.
void kmeans::KMeansSegmenter< T >::computeClusterAttr | ( | const ImageAttr< T > & | attr, | |
const LImage< int > & | label, | |||
vector< Cluster< T > > * | clusters, | |||
bool | has_K_levels = true | |||
) | const [protected] |
Compute cluster attributes from the image attribute and labeling.
During K-means, the computation is always done with K levels, but pass in false if you are using this after K-means and relabeling.
virtual LImage<int> kmeans::KMeansSegmenter< T >::computeDetailImage | ( | const LImage< int > & | label, | |
const ImageAttr< T > & | attr, | |||
std::vector< Replacement > * | replacements_list | |||
) | [protected, virtual] |
This function may be over-ridden to provide a different way of selecting among the regions produced by K-means segmentation.
label | The image with the K-means segmentation done and labels computed based on 8-neighborhood, but no selection among the regions performed. | |
attr | The attributes computed at every pixel of the image to be segmented. | |
replacements_list | The list of replacements; the first element (most detail) will be filled in here. |
float kmeans::KMeansSegmenter< T >::computeDiscontiguityDistance | ( | const LImage< int > & | label, | |
int | x, | |||
int | y, | |||
int | candidate_label | |||
) | const [protected] |
Way to compute discontiguity if the current label were to be changed to the candidate.
Returns a number between 0 and 1.
float kmeans::KMeansSegmenter< T >::computeMeasureDistance | ( | const T & | other, | |
const T & | current | |||
) | const [protected] |
Finds distance between two statistics.
float kmeans::KMeansSegmenter< T >::computeMeasureDistance | ( | const Cluster< T > & | cluster, | |
const T & | current, | |||
int | x, | |||
int | y | |||
) | const [protected] |
Way to compute distance between a point (value,x,y) and a cluster's mean.
The base class does not use the location information, but derived classes may want to. Between 0 and 1.
static void kmeans::Segmenter::computeRegionProperty | ( | const LImage< int > & | label, | |
vector< RegionProperty > * | fillme | |||
) | [static, inherited] |
Fills in the passed in vector with a vector of computed region properties.
The input label image should be a labeled image such as that returned by the segmenter. WARNING: The resulting properties will not have any of the value elements set because the original image was not passed in.
static void kmeans::Segmenter::computeRegionProperty | ( | const LImage< int > & | orig, | |
const LImage< int > & | label, | |||
vector< RegionProperty > * | fillme | |||
) | [static, inherited] |
Fills in the passed in vector with a vector of computed region properties.
The input label image should be a labeled image such as that returned by the segmenter.
virtual void kmeans::KMeansSegmenter< T >::computeReplacements | ( | const LImage< int > & | label, | |
const ImageAttr< T > & | attr, | |||
std::vector< Replacement > * | replacements_list | |||
) | [protected, virtual] |
This function may be over-ridden to provide a different way of choosing how to combine/replace regions at higher levels.
label | The image with the K-means segmentation done and labels computed based on 8-neighborhood, but no selection among the regions performed. | |
attr | The attributes computed at every pixel of the image to be segmented. | |
replacements_list | The list of replacements; the first element (most detail) should be filled already. Coarser detail will be filled in here. |
LImage<int> kmeans::KMeansSegmenter< T >::doKMeans | ( | const ImageAttr< T > & | attr, | |
LImage< int > * | label, | |||
vector< Cluster< T > > * | clusters, | |||
int | iter_no = 0 | |||
) | const [protected] |
Do K means segmentation, filling in the cluster array.
static void kmeans::Segmenter::expand_segment | ( | int | x, | |
int | y, | |||
const LImage< int > & | orig, | |||
LImage< int > & | segimg, | |||
int | label | |||
) | [static, protected, inherited] |
Set the segimg at x,y to be label and then call this function.
It will expand out segimg to all contiguous values that match
int kmeans::KMeansSegmenter< T >::findBestCluster | ( | const T & | current, | |
const vector< Cluster< T > > & | clusters, | |||
const LImage< int > & | labels, | |||
int | x, | |||
int | y | |||
) | const [protected] |
Return label corresponding to best cluster available.
size_t kmeans::KMeansSegmenter< T >::getNumScales | ( | ) | const |
Returns the total number of scales in the segmentation.
The returned values correspond to the previous call to segment()
const Replacement& kmeans::KMeansSegmenter< T >::getReplacement | ( | size_t | scale | ) | const |
Gets the replacement at different scales.
0 is the most detail, 1 is less and so on. If the scale passed in exceeeds the number of scales in the segmentation, an invalid Replacement ( .size() == 0 ) is returned.
The returned values correspond to the previous call to segment()
LImage<int> kmeans::KMeansSegmenter< T >::getScale | ( | size_t | scale, | |
bool | rawlabels = false | |||
) | const |
The different scales.
The returned values correspond to the previous call to segment()
scale | The scale to return. 0 is the most detail, 1 is less ... | |
rawlabels | If true, then no relabeling of the original image is done. If false, the labeling corresponds to that of raw_segimg. |
LImage<int> kmeans::KMeansSegmenter< T >::initialize | ( | const LImage< int > & | orig, | |
const ImageAttr< T > & | attr, | |||
vector< Cluster< T > > * | clusters | |||
) | const [protected] |
Get an initial cut of clusters, somehow.
The implementation here is to divide the measurement space (max-min) into equal parts.
static LImage<int> kmeans::Segmenter::pruneRegions | ( | const LImage< int > & | label, | |
RegionPruner & | ||||
) | [static, protected, inherited] |
This method removes all regions that meet certain criteria.
The function object RegionPruner should be provided to target the appropriate regions.
Usually, you'd want to relabel the image that you get after pruning.
static LImage<int> kmeans::Segmenter::relabel | ( | const LImage< int > & | label_img | ) | [static, protected, inherited] |
Will relabel the image, removing unused labels.
virtual LImage<int> kmeans::KMeansSegmenter< T >::segment | ( | const LImage< int > & | orig | ) | [virtual] |
Implements kmeans::Segmenter.
static void kmeans::KMeansSegmenter< T >::setMarkovWeight | ( | float | lambda | ) | [static] |
Set the weight of the Markov energy relative to the Discontiguity measure.
The default value is 0.6 and should be left alone unless you know what you are doing. If wish to change it, provide any number in the range [0,1].
This is more that "just" a static function -- you are setting it for all values of the template parameter T as well!
void kmeans::KMeansSegmenter< T >::setOutputImageDir | ( | const std::string & | newDir | ) |
Pass in an empty string to turn off output.
void kmeans::KMeansSegmenter< T >::writeGraph | ( | const std::string & | filename | ) | const |
Write out a DOT output file (in a form that the Graphviz utility dot can read).
This is a directed graph.
friend class Pruner [friend] |
const int kmeans::Segmenter::Invalid = -2000 [static, protected, inherited] |
const int kmeans::Segmenter::Unset = -1000 [static, protected, inherited] |