latest version v1.9 - last update 10 Apr 2010 |
The contrast gradient is used in color or multi-spectral image as a replacement of the gray-value gradient in gray images. More...
#include <ltiColorContrastGradient.h>
Classes | |
class | parameters |
the parameters for the class gradientFunctor More... | |
Public Member Functions | |
colorContrastGradient () | |
colorContrastGradient (const parameters::eOutputFormat &format, const int gradKernelSize=0) | |
colorContrastGradient (const parameters &par) | |
colorContrastGradient (const colorContrastGradient &other) | |
virtual | ~colorContrastGradient () |
virtual const char * | getTypeName () const |
bool | apply (const image &src, channel &xOrMag, channel &yOrArg) const |
bool | apply (const channel &src, channel &xOrMag, channel &yOrArg) const |
bool | apply (const channel8 &src, channel &xOrMag, channel &yOrArg) const |
bool | apply (const channel &c1, const channel &c2, const channel &c3, channel &xOrMag, channel &yOrArg) const |
bool | apply (const channel &c1, const channel &c2, const channel &c3, channel &xOrMag, channel &yOrArg, float &maxMag) const |
bool | apply (const channel &c1, const channel &c2, channel &xOrMag, channel &yOrArg, float &maxMag) const |
bool | apply (const channel &c1, const channel &c2, const channel &c3, channel &lambdaMin, channel &lambdaMax, channel &orientation, float &maxMag) const |
colorContrastGradient & | copy (const colorContrastGradient &other) |
colorContrastGradient & | operator= (const colorContrastGradient &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
Protected Member Functions | |
bool | computeGradientPolar (const channel &c1, const channel &c2, const channel &c3, channel &gradAbs, channel &orientation, float &maxVal) const |
bool | computeGradientPolar (const channel &c1, const channel &c2, channel &gradAbs, channel &orientation, float &maxVal) const |
bool | computeGradientPolar (const channel &c1, const channel &c2, const channel &c3, channel &lambdaMin, channel &lambdaMax, channel &orientation, float &maxVal) const |
bool | computeColorGradientCart (const channel &c1, const channel &c2, channel &xchnl, channel &ychnl, float &maxVal) const |
bool | computeColorGradientCart (const channel &c1, const channel &c2, const channel &c3, channel &xchnl, channel &ychnl, float &maxVal) const |
float | magSqr (const float a, const float b) const |
The contrast gradient is used in color or multi-spectral image as a replacement of the gray-value gradient in gray images.
Here, the approach introduced in A. Cumani, "Edge Detection in Multispectral Images", Technical Report, Istituto Elettrotecnico Nazionale "Galileo Ferraris", 1989 is followed.
A more detail theoretical analysis can be found in I.R. Greenshields "Coherent computation of the multispectral maximal directional derivative" Image and Vision Computing, Vol 18. 1999, pp. 1-7
With this approach, instead of a gradient, the maximum of the contrast function for each pixel is searched. The contrast function defines the direction at the (x,y) plane at which the contrast change is maximal. It corresponds to the greater eigenvalue and corresponding eigenvector of the square of the Jacobian matrix:
As suggested in the literature, the difference between both eigenvalues should be used as contrast, and the direction of the main eigenvector as gradient direction.
with being any multi-spectral image. In this case this vector function is defined in a three dimensional color space.
Since this method uses the lti::arctanLUT class to accelerate the computation (sacrifying a little bit in angle precision, which anyway cannot be accurately determined due to the spatial quantization effects) the angles returned in the parameters::Polar mode are always possitive between 0 and 2*Pi.
lti::colorContrastGradient::colorContrastGradient | ( | ) |
default constructor
lti::colorContrastGradient::colorContrastGradient | ( | const parameters::eOutputFormat & | format, | |
const int | gradKernelSize = 0 | |||
) |
Construct a functor using gradient kernels with the specified values.
format | specify the format to be use: Cartesic or Polar | |
gradKernelSize | size for the gradient kernel to be used. |
lti::colorContrastGradient::colorContrastGradient | ( | const parameters & | par | ) |
Construct a functor using the given parameters.
lti::colorContrastGradient::colorContrastGradient | ( | const colorContrastGradient & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::colorContrastGradient::~colorContrastGradient | ( | ) | [virtual] |
destructor
bool lti::colorContrastGradient::apply | ( | const channel & | c1, | |
const channel & | c2, | |||
const channel & | c3, | |||
channel & | lambdaMin, | |||
channel & | lambdaMax, | |||
channel & | orientation, | |||
float & | maxMag | |||
) | const |
Computes the eigenvalues of the square of the Jacobian matrix of a tri-spectral image.
This method ignores the parameter format, as it makes only sense for a polar system, and also the contrastFormat parameter as it explicitely requests the computation of all eigenvalues.
c1 | first channel of the input image. | |
c2 | second channel of the input image. | |
c3 | third channel of the input image. | |
lambdaMin | the resulting minimal eigenvalues | |
lambdaMax | the resulting maximal eigenvalues | |
orientation | the angle of the main axis (diretion of the eigenvector with the greater eigenvalue) | |
maxMag | maximum contrast value found (lambdaMin-lambdaMax) |
bool lti::colorContrastGradient::apply | ( | const channel & | c1, | |
const channel & | c2, | |||
channel & | xOrMag, | |||
channel & | yOrArg, | |||
float & | maxMag | |||
) | const |
Computes the color contrast gradient of a bi-spectral image defined by the two given components.
c1 | first channel of the input image. | |
c2 | second channel of the input image. | |
xOrMag | the resulting x component or magnitude of the gradient will be left here. | |
yOrArg | the resulting y component or argument (orientation) of the gradient will be left here. | |
maxMag | if polar and cartesic modes (see parameters), the maximum magnitude of the gradient found. |
bool lti::colorContrastGradient::apply | ( | const channel & | c1, | |
const channel & | c2, | |||
const channel & | c3, | |||
channel & | xOrMag, | |||
channel & | yOrArg, | |||
float & | maxMag | |||
) | const |
Computes the color contrast gradient of a tri-spectral image defined by the three given components.
c1 | first channel of the input image. | |
c2 | second channel of the input image. | |
c3 | third channel of the input image. | |
xOrMag | the resulting x component or magnitude of the gradient will be left here. | |
yOrArg | the resulting y component or argument (orientation) of the gradient will be left here. | |
maxMag | if polar and cartesic modes (see parameters), the maximum magnitude of the gradient found. |
bool lti::colorContrastGradient::apply | ( | const channel & | c1, | |
const channel & | c2, | |||
const channel & | c3, | |||
channel & | xOrMag, | |||
channel & | yOrArg | |||
) | const |
Computes the color contrast gradient of a tri-spectra image defined by the three given components.
c1 | first channel of the input image. | |
c2 | second channel of the input image. | |
c3 | third channel of the input image. | |
xOrMag | the resulting x component or magnitude of the gradient will be left here. | |
yOrArg | the resulting y component or argument (orientation) of the gradient will be left here. |
bool lti::colorContrastGradient::apply | ( | const channel8 & | src, | |
channel & | xOrMag, | |||
channel & | yOrArg | |||
) | const |
Computes the (monochromatic) gradient of the given channel.
src | channel with the source data. | |
xOrMag | the resulting x component or magnitude of the gradient will be left here. | |
yOrArg | the resulting y component or argument (orientation) of the gradient will be left here. |
Reimplemented from lti::gradientFunctor.
bool lti::colorContrastGradient::apply | ( | const channel & | src, | |
channel & | xOrMag, | |||
channel & | yOrArg | |||
) | const |
Computes the (monochromatic) gradient of the given channel.
src | channel with the source data. | |
xOrMag | the resulting x component or magnitude of the gradient will be left here. | |
yOrArg | the resulting y component or argument (orientation) of the gradient will be left here. |
Reimplemented from lti::gradientFunctor.
bool lti::colorContrastGradient::apply | ( | const image & | src, | |
channel & | xOrMag, | |||
channel & | yOrArg | |||
) | const |
Computes the color contrast gradient of the given RGB image.
src | image with the source data. The image will be splitted in its R,G and B components for the analysis. | |
xOrMag | the resulting x component or magnitude of the gradient will be left here. | |
yOrArg | the resulting y component or argument (orientation) of the gradient will be left here. |
virtual functor* lti::colorContrastGradient::clone | ( | ) | const [virtual] |
returns a pointer to a clone of this functor.
Reimplemented from lti::gradientFunctor.
bool lti::colorContrastGradient::computeGradientPolar | ( | const channel & | c1, | |
const channel & | c2, | |||
const channel & | c3, | |||
channel & | lambdaMin, | |||
channel & | lambdaMax, | |||
channel & | orientation, | |||
float & | maxVal | |||
) | const [protected] |
differentiate the image in X and Y directions
c1 | first channel | |
c2 | second channel | |
c3 | third channel | |
lambdaMin | minimum eigenvalues | |
lambdaMax | maximum eigenvalues | |
orientation | the orientation map of the gradient image | |
maxVal | maximum contrast value found (lambdaMin-lambdaMax) |
colorContrastGradient& lti::colorContrastGradient::copy | ( | const colorContrastGradient & | other | ) |
copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::gradientFunctor.
const parameters& lti::colorContrastGradient::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::gradientFunctor.
virtual const char* lti::colorContrastGradient::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("colorContrastGradient")
Reimplemented from lti::gradientFunctor.
float lti::colorContrastGradient::magSqr | ( | const float | a, | |
const float | b | |||
) | const [inline, protected] |
Compute the square of the magnitude: a*a + b*b.
colorContrastGradient& lti::colorContrastGradient::operator= | ( | const colorContrastGradient & | other | ) |
alias for copy member
other | the functor to be copied |
Reimplemented from lti::gradientFunctor.