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) |
tlColorModel::tlColorModel | ( | char * | filebase | ) |
Constructor.
filebase | basename for color model file to upload. |
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.
filebase | base name for the hitogram files. |
int tlColorModel::load | ( | char * | filebase | ) |
Load histograms from disk.
filebase | base name for the hitogram files. |
int tlColorModel::train | ( | tlImage * | image | ) |
Update the histograms based on a segmented image of either format.
image | segmented image, only pixels of the desired color are non-zero. |
Add the contribution of a single pixel from a training image to the color histogram.
image | the image containing the pixel of interest. | |
point | the location of the pixel to train on. |
Add the contribution of a number of pixels from a training image to the color histogram.
image | the image containing the pixel of interest. | |
chain | the locations of the pixels to train on. |
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.
image | the image to be filtered. | |
threshold | percentage or minimal pixel count. |
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.
image | the image to be filtered. | |
rect | portion of the image to process | |
threshold | percentage or minimal pixel count. |
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.
color | the color to test for | |
threshold | the histogram threshold value |