latest version v1.9 - last update 10 Apr 2010 |
This functor is used to mask color images with labeled or unlabeled masks. More...
#include <ltiMaskImage.h>
Classes | |
class | parameters |
the parameters for the class maskImage More... | |
Public Member Functions | |
maskImage () | |
maskImage (const bool assumeLabeledMask, const bool enhanceRegionBorders=true) | |
maskImage (const parameters &par) | |
maskImage (const maskImage &other) | |
virtual | ~maskImage () |
virtual const char * | getTypeName () const |
bool | apply (const image &src, const channel8 &mask, const palette &colors, image &dest) const |
bool | apply (const image &src, const imatrix &mask, const palette &colors, image &dest) const |
bool | apply (const image &src, const channel8 &mask, image &dest) const |
bool | apply (const image &src, const imatrix &mask, image &dest) const |
maskImage & | copy (const maskImage &other) |
maskImage & | operator= (const maskImage &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
Protected Member Functions | |
void | combine (const rgbPixel &src, const rgbPixel &mask, rgbPixel &dest) const |
int | fixIdx (const int idx, const int palLastIdx) const |
bool | labeled (const image &src, const imatrix &mask, const palette &colors, image &dest) const |
bool | unlabeled (const image &src, const imatrix &mask, const palette &colors, image &dest) const |
bool | labeled (const image &src, const channel8 &mask, const palette &colors, image &dest) const |
bool | unlabeled (const image &src, const channel8 &mask, const palette &colors, image &dest) const |
This functor is used to mask color images with labeled or unlabeled masks.
You can give a color palette to indicate which colors should be used for each region. Using the alpha (or dummy) rgbPixel component in the palette entries you can specify the transparency degree of each region in the mask. This way, you can completely suppress regions (like background), leave regions complete untouched, or overlay colored patches.
Example
#include <ltiKMeansSegmentation.h> #include <ltiMaskImage.h> #include <ltiViewer.h> #include <cstdio> ... lti::image img,masked; lti::imatrix mask; // let's assume, you load a colored image into img // simple segmentation lti::kMeansSegmentation segmenter; segmenter.apply(img,mask); // get a masked image lti::maskImage masker(true); // assume labeled mask and enhance borders masker.apply(img,mask,masked); // show original image and masked one lti::viewer vieworig("Original"); lti::viewer viewmask("Masked"); vieworig.show(img); viewmask.show(masked); getchar(); // wait for ENTER key pressed
lti::maskImage::maskImage | ( | ) |
default constructor
lti::maskImage::maskImage | ( | const bool | assumeLabeledMask, | |
const bool | enhanceRegionBorders = true | |||
) |
create a functor with the specified parameter attributes
lti::maskImage::maskImage | ( | const parameters & | par | ) |
Construct a functor using the given parameters.
lti::maskImage::maskImage | ( | const maskImage & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::maskImage::~maskImage | ( | ) | [virtual] |
destructor
bool lti::maskImage::apply | ( | const image & | src, | |
const imatrix & | mask, | |||
const palette & | colors, | |||
image & | dest | |||
) | const |
Mask the src image using the given mask and colors for mask entries.
src | image with the source data. | |
mask | labeled or unlabeled mask | |
colors | color entries used to mask the image. The "dummy" entry of each pixel denotes the transparency of the color used: 0 means opaque and 255 totally transparent. The colors attribute of the parameters class will be ignored. | |
dest | destination masked image. |
bool lti::maskImage::apply | ( | const image & | src, | |
const channel8 & | mask, | |||
const palette & | colors, | |||
image & | dest | |||
) | const |
Mask the src image using the given mask and colors for mask entries.
src | image with the source data. | |
mask | labeled or unlabeled mask | |
colors | color entries used to mask the image. The "dummy" entry of each pixel denotes the transparency of the color used: 0 means opaque and 255 totally transparent. The colors attribute of the parameters class will be ignored. | |
dest | destination masked image. |
virtual functor* lti::maskImage::clone | ( | ) | const [virtual] |
returns a pointer to a clone of this functor.
Implements lti::functor.
void lti::maskImage::combine | ( | const rgbPixel & | src, | |
const rgbPixel & | mask, | |||
rgbPixel & | dest | |||
) | const [inline, protected] |
combine two pixels considering the transparency of the second one
copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::functor.
int lti::maskImage::fixIdx | ( | const int | idx, | |
const int | palLastIdx | |||
) | const [inline, protected] |
fix the index to fit into the colors
const parameters& lti::maskImage::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::functor.
virtual const char* lti::maskImage::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("maskImage")
Reimplemented from lti::functor.
bool lti::maskImage::labeled | ( | const image & | src, | |
const channel8 & | mask, | |||
const palette & | colors, | |||
image & | dest | |||
) | const [protected] |
Mask the src image using the given mask and colors for mask entries.
src | image with the source data. | |
mask | labeled or unlabeled mask | |
colors | color entries used to mask the image. The "dummy" entry of each pixel denotes the transparency of the color used: 0 means opaque and 255 totally transparent. The colors attribute of the parameters class will be ignored. | |
dest | destination masked image. |
bool lti::maskImage::labeled | ( | const image & | src, | |
const imatrix & | mask, | |||
const palette & | colors, | |||
image & | dest | |||
) | const [protected] |
Mask the src image using the given mask and colors for mask entries.
src | image with the source data. | |
mask | labeled or unlabeled mask | |
colors | color entries used to mask the image. The "dummy" entry of each pixel denotes the transparency of the color used: 0 means opaque and 255 totally transparent. The colors attribute of the parameters class will be ignored. | |
dest | destination masked image. |
bool lti::maskImage::unlabeled | ( | const image & | src, | |
const channel8 & | mask, | |||
const palette & | colors, | |||
image & | dest | |||
) | const [protected] |
Mask the src image using the given mask and colors for mask entries.
src | image with the source data. | |
mask | labeled or unlabeled mask | |
colors | color entries used to mask the image. The "dummy" entry of each pixel denotes the transparency of the color used: 0 means opaque and 255 totally transparent. The colors attribute of the parameters class will be ignored. | |
dest | destination masked image. |
bool lti::maskImage::unlabeled | ( | const image & | src, | |
const imatrix & | mask, | |||
const palette & | colors, | |||
image & | dest | |||
) | const [protected] |
Mask the src image using the given mask and colors for mask entries.
src | image with the source data. | |
mask | labeled or unlabeled mask | |
colors | color entries used to mask the image. The "dummy" entry of each pixel denotes the transparency of the color used: 0 means opaque and 255 totally transparent. The colors attribute of the parameters class will be ignored. | |
dest | destination masked image. |