TLIB documentation
 

tlColorModel Class Reference

Collaboration diagram for tlColorModel:

Collaboration graph
[legend]

List of all members.


Detailed Description

Statistical color model class.

This is a color definition class. It requires training and supports both normalized RGB and HSI format. 2D histograms of the color distribution in the given format are built based on the training data. Can be used to define any (and even multiple) color.

Public Member Functions

 tlColorModel ()
 Constructor.
 tlColorModel (char *filebase)
virtual ~tlColorModel ()
 Destructor.
int reset ()
 Reset color model.
int finalize ()
int save (char *filebase)
int load (char *filebase)
int train (tlImage *image)
int train (tlImage *image, tlPoint *point)
int train (tlImage *image, tlChain *chain)
int filter (tlImage *image, int threshold=TL_COLOR_MODEL_DETECTION_THRESHOLD)
int filter (tlImage *image, tlRect *rect, int threshold=TL_COLOR_MODEL_DETECTION_THRESHOLD)
int test (tlColor *color, int threshold=TL_COLOR_MODEL_DETECTION_THRESHOLD)


Constructor & Destructor Documentation

tlColorModel::tlColorModel ( char *  filebase  ) 

Constructor.

Parameters:
filebase basename for color model file to upload.


Member Function Documentation

int tlColorModel::finalize (  ) 

Once training is finished, call this method to scale the histogram correctly. The threshold argument for the filter() method will then be expressed in percent, as opposed to pixel count.

int tlColorModel::save ( char *  filebase  ) 

Save histograms to disk.

Parameters:
filebase base name for the hitogram files.

int tlColorModel::load ( char *  filebase  ) 

Load histograms from disk.

Parameters:
filebase base name for the hitogram files.

int tlColorModel::train ( tlImage image  ) 

Update the histograms based on a segmented image of either format.

Parameters:
image segmented image, only pixels of the desired color are non-zero.
Note:
Only the histogram of the image format is updated. User should call finalize() once training is finished.

int tlColorModel::train ( tlImage image,
tlPoint point 
)

Add the contribution of a single pixel from a training image to the color histogram.

Parameters:
image the image containing the pixel of interest.
point the location of the pixel to train on.
Note:
Only the histogram of the image format is updated. A better (and faster) way to build the color distribution is to use a pre-segmented image with train(tlImage *image). User should call finalize() once training is finished.

int tlColorModel::train ( tlImage image,
tlChain chain 
)

Add the contribution of a number of pixels from a training image to the color histogram.

Parameters:
image the image containing the pixel of interest.
chain the locations of the pixels to train on.
Note:
Only the histogram of the image format is updated. A better (and faster) way to build the color distribution is to use a pre-segmented image with train(tlImage *image). User should call finalize() once training is finished.

int tlColorModel::filter ( tlImage image,
int  threshold = TL_COLOR_MODEL_DETECTION_THRESHOLD 
)

Filter a color image using the (thresholded) color distribution contained in the histograms. That is, only pixels with color value that contribute for more than 'threshold' percent to the histogram will be kept.

Parameters:
image the image to be filtered.
threshold percentage or minimal pixel count.
Note:
Threshold represents a percentage only if finalize() is called after the training is over. Otherwise, threshold must be expressed in pixel counts.

int tlColorModel::filter ( tlImage image,
tlRect rect,
int  threshold = TL_COLOR_MODEL_DETECTION_THRESHOLD 
)

Filter a portion of a color image using the (thresholded) color distribution contained in the histograms. That is, only pixels with color value that contribute for more than 'threshold' percent to the histogram will be kept.

Parameters:
image the image to be filtered.
rect portion of the image to process
threshold percentage or minimal pixel count.
Note:
Threshold represents a percentage only if finalize() is called after the training is over. Otherwise, threshold must be expressed in pixel counts.

int tlColorModel::test ( tlColor color,
int  threshold = TL_COLOR_MODEL_DETECTION_THRESHOLD 
)

Test whether a given color accounts for more than a given threshold in the color histograms.

Parameters:
color the color to test for
threshold the histogram threshold value


The documentation for this class was generated from the following files:

TLIB documentation - generated on 7 May 2008
Please address any questions to seb@tuyphon.com
(C) 2001-2008 - S. Grange
(C) 2001-2007 - VRAI Group, EPFL
All Rights Reserved.