latest version v1.9 - last update 10 Apr 2010 |
This simple morphological operator assumes that the input data is a binary image, i.e. More...
#include <ltiDistanceTransform.h>
Classes | |
class | parameters |
the parameters for the class distanceTransform More... | |
Public Member Functions | |
distanceTransform () | |
distanceTransform (const parameters &par) | |
distanceTransform (const distanceTransform &other) | |
virtual | ~distanceTransform () |
virtual const char * | getTypeName () const |
virtual bool | apply (channel &srcdest) const |
virtual bool | apply (channel8 &srcdest) const |
virtual bool | apply (const channel &src, channel &dest) const |
virtual bool | apply (const channel8 &src, channel8 &dest) const |
distanceTransform & | copy (const distanceTransform &other) |
distanceTransform & | operator= (const distanceTransform &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
Protected Member Functions | |
void | iteration8 (channel &chnl) const |
void | iteration4 (channel &chnl) const |
void | iteration8back (channel &chnl) const |
void | iteration4back (channel &chnl) const |
void | EDT_2D (channel &chnl) const |
bool | removeEDT (const int du, const int dv, const int dw, const int u, const int v, const int w) const |
void | voronoiEDT_2D (channel &chnl, const int dim) const |
void | EDT_1D (channel &chnl) const |
void | sedFiltering (channel &chnl, bool useEightSED) const |
void | fourSEDFiltering (channel &chnl, matrix< point > &dist) const |
void | eightSEDFiltering (channel &chnl, matrix< point > &dist) const |
This simple morphological operator assumes that the input data is a binary image, i.e.
there are values 0 and not 0. It computes the minimal distance of a pixel with not-zero value to a zero pixel.
You can choose in the parameters between a 4-Neighborhood or an 8-Neighborhood for the computations. It is also possible to compute the euclidean distance transform.
For two pixels p and q with position p(p.x,p.y) and q(q.x,q.y) following is valid:
The computation for the 4- and 8-neighborhood based distance transform is very efficient and traverses the input channel just twice: once from top to bottom and once on the opposite direction. To compute the euclidean distance transform the algorithm described in
Calvin R. Maurer Jr., Rensheng Qi, Vijay V. Raghavan: "A Linear Time Algorithm for Computing Exact Euclidean Distance Transforms of Binary Images in Arbitrary Dimensions". IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol.25, No. 2, 2003, pp. 265-270
is used.
lti::distanceTransform::distanceTransform | ( | ) |
default constructor
lti::distanceTransform::distanceTransform | ( | const parameters & | par | ) |
default constructor
lti::distanceTransform::distanceTransform | ( | const distanceTransform & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::distanceTransform::~distanceTransform | ( | ) | [virtual] |
destructor
virtual bool lti::distanceTransform::apply | ( | const channel8 & | src, | |
channel8 & | dest | |||
) | const [virtual] |
Compute the distance transform of the src channel and leave the result in dest, i.e.
calculate the minimal distance from a non-background pixel to a background pixel. It will be assumed, that all background pixels have the value zero. (any non zero value will be taken as non-background pixel).
If the size of srcdest and form of its non-background regions allow distances greater than 255 (the maximal possible representable value with a ubyte), the content of the distance transform will be invalid.
Implements lti::morphology.
Compute the distance transform of the src channel and leave the result in dest, i.e.
calculate the minimal distance from a non-background pixel to a background pixel. It will be assumed, that all background pixels have the value zero. (any non zero value will be taken as non-background pixel).
The result in the channel will contain for each pixel the distance value. This means, the usual value range from 0.0f to 1.0f is ignored in this functor, providing the distances in "pixel" units.
Implements lti::morphology.
virtual bool lti::distanceTransform::apply | ( | channel8 & | srcdest | ) | const [virtual] |
Compute the distance transform of the srcdest channel, i.e.
the minimal distance from a non-background pixel to a background pixel. It will be assumed, that all background pixels have the value zero. (any non zero value will be taken as non-background pixel).
If the size of srcdest and form of its non-background regions allow distances greater than 255 (the maximal possible representable value with a ubyte), the content of the distance transform will be invalid.
srcdest | channel8 with the source data. The result will be left here too. |
Implements lti::morphology.
virtual bool lti::distanceTransform::apply | ( | channel & | srcdest | ) | const [virtual] |
Compute the distance transform of the srcdest channel, i.e.
the minimal distance from a non-background pixel to a background pixel. It will be assumed, that all background pixels have the value 0.0f. (any non zero value will be taken as non-background pixel).
The result in the channel will contain for each pixel the distance value. This means, the usual value range from 0.0f to 1.0f is ignored in this functor, providing the distances in "pixel" units.
srcdest | channel with the source data. The result will be left here too. |
Implements lti::morphology.
virtual functor* lti::distanceTransform::clone | ( | ) | const [virtual] |
returns a pointer to a clone of this functor.
Implements lti::functor.
distanceTransform& lti::distanceTransform::copy | ( | const distanceTransform & | other | ) |
copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::morphology.
void lti::distanceTransform::EDT_1D | ( | channel & | chnl | ) | const [protected] |
Method computes ED (euclidean distance) for each row pixel of the given channel to the closest background pixel.
It assumes that a background pixel is set to 0.0f and a foreground pixel is > 0.0f. All rows without any background pixel will be set to an undefined distance (i.e. < 0.0f). The ED is computed with a fast and easy forward-backward distance propagation.
void lti::distanceTransform::EDT_2D | ( | channel & | chnl | ) | const [inline, protected] |
Method to compute ED for each column of the precomputed distance image chnl.
The chnl must be the output of a previos call to EDT_1D. Method uses the distance propagation of the function voronoiEDT_2D.
void lti::distanceTransform::eightSEDFiltering | ( | channel & | chnl, | |
matrix< point > & | dist | |||
) | const [protected] |
Calculates the 8SED distance transform.
void lti::distanceTransform::fourSEDFiltering | ( | channel & | chnl, | |
matrix< point > & | dist | |||
) | const [protected] |
Calculates the 4SED distance transform.
const parameters& lti::distanceTransform::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::morphology.
virtual const char* lti::distanceTransform::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("distanceTransform")
Reimplemented from lti::morphology.
void lti::distanceTransform::iteration4 | ( | channel & | chnl | ) | const [protected] |
iteration for distance computation using an 4-Neighborhood
void lti::distanceTransform::iteration4back | ( | channel & | chnl | ) | const [protected] |
backwards iteration for distance computation using an 4-Neighborhood
void lti::distanceTransform::iteration8 | ( | channel & | chnl | ) | const [protected] |
iteration for distance computation using an 8-Neighborhood
void lti::distanceTransform::iteration8back | ( | channel & | chnl | ) | const [protected] |
backwards iteration for distance computation using an 8-Neighborhood
distanceTransform& lti::distanceTransform::operator= | ( | const distanceTransform & | other | ) |
bool lti::distanceTransform::removeEDT | ( | const int | du, | |
const int | dv, | |||
const int | dw, | |||
const int | u, | |||
const int | v, | |||
const int | w | |||
) | const [inline, protected] |
queries some distance information for the EDT
void lti::distanceTransform::sedFiltering | ( | channel & | chnl, | |
bool | useEightSED | |||
) | const [protected] |
Method computes ED (euclidean distance) for the given channel with the 8SED or 4SED (8 or 4 point sequential euclidian distance mapping) method.
void lti::distanceTransform::voronoiEDT_2D | ( | channel & | chnl, | |
const int | dim | |||
) | const [protected] |
fast linear order computation of the accurade euclidean distance with voronoi diagrams