last update 20 Sep 2009 |
#include <cvrHistogramEqualization.h>
Classes | |
class | parameters |
The parameters for the class cvr::histogramEqualization. More... | |
Public Member Functions | |
histogramEqualization () | |
histogramEqualization (const parameters ¶ms) | |
histogramEqualization (const histogramEqualization &other) | |
virtual | ~histogramEqualization () |
virtual const std::string & | name () const |
histogramEqualization & | copy (const histogramEqualization &other) |
virtual histogramEqualization * | clone () const |
virtual histogramEqualization * | newInstance () const |
const parameters & | getParameters () const |
virtual bool | updateParameters () |
bool | apply (vector< float > &srcdest) const |
bool | apply (vector< ubyte > &srcdest) const |
bool | apply (const vector< float > &src, vector< float > &dest) const |
bool | apply (const vector< ubyte > &src, vector< ubyte > &dest) const |
Matrix processing interface | |
bool | apply (matrix< float > &srcdest) const |
bool | apply (matrix< ubyte > &srcdest) const |
bool | apply (const matrix< float > &src, matrix< float > &dest) const |
bool | apply (const matrix< ubyte > &src, matrix< ubyte > &dest) const |
Contrast enhancement interface | |
bool | apply (channel &srcdest) const |
bool | apply (channel8 &srcdest) const |
bool | apply (const channel &src, channel &dest) const |
bool | apply (const channel8 &src, channel8 &dest) const |
Partial computations | |
Following methods are public since there are applicactions that need to compute the statistics once (which are relatively expensive), and apply them at different times.
The apply() methods are implemented using these ones in the way indicated. | |
float | getEqualized (const float p, const vector< float > &lut) const |
bool | computeLUT (const matrix< float > &chnl, vector< float > &lut) const |
bool | computeLUT (const matrix< ubyte > &chnl, vector< ubyte > &lut) const |
Protected Attributes | |
float | lower_ |
float | upper_ |
float | cst_ |
int | loweru_ |
int | upperu_ |
cvr::histogramEqualization equalizes the values of the given matrices or vector within a specific input range, which at the same time is mapped to a given output range.
The number of "bins" or "cells" in the histogram can be defined by the user.
The algorithm used can be found in Sonka et. al "Image Processing, Analysis and Machine Vision" 2nd Edition, PWS Publishing, pp. 60-61
The parameters to indicate value ranges of input and output are always expected in a normalized form, i.e. in an interval from 0.0 to 1.0, where the normalization norm is obtained with typeInfo<T>::suggestedNorm().
Example using cvr::histogramEqualization
// The channel to be equalized and the result channel cvr::channel src,dest; // ... initialize channel src here ... // set parameters and construct the functor cvr::histogramEqualization::parameters param; // parameters param.cells = 256; // number of histogram bins param.lowerInputLimit=0.0; // equalizes the dark values param.upperInputLimit=0.2; // param.lowerOutputLimit=0.6; // renders the equalized values lighter param.upperOutputLimit=1.0; // cvr::histogramEqualization equalizer(param); // functor // equalizes the values within input range, maps them to the output range // and returns the partly equalized channel in dest. equalizer.apply(src,dest);
cvr::histogramEqualization::histogramEqualization | ( | ) |
Default constructor.
cvr::histogramEqualization::histogramEqualization | ( | const parameters & | params | ) |
Default constructor with parameters.
cvr::histogramEqualization::histogramEqualization | ( | const histogramEqualization & | other | ) |
virtual cvr::histogramEqualization::~histogramEqualization | ( | ) | [virtual] |
Destructor.
Equalize src and leave the result in dest.
src | the input data | |
dest | the channel8 where the result will be left |
Implements cvr::contrastEnhancement.
Equalize src and leave the result in dest.
src | the input data | |
dest | the channel where the result will be left |
Implements cvr::contrastEnhancement.
bool cvr::histogramEqualization::apply | ( | channel8 & | srcdest | ) | const [virtual] |
Equalizes the values of the given matrix of ubytes (channel8s).
Implements cvr::contrastEnhancement.
bool cvr::histogramEqualization::apply | ( | channel & | srcdest | ) | const [virtual] |
Equalizes the values of the given matrix of floats (channels).
Implements cvr::contrastEnhancement.
bool cvr::histogramEqualization::apply | ( | vector< float > & | srcdest | ) | const |
bool cvr::histogramEqualization::apply | ( | const matrix< ubyte > & | src, | |
matrix< ubyte > & | dest | |||
) | const [virtual] |
Equalize src and leave the result in dest.
src | the input data | |
dest | the channel8 where the result will be left |
Implements cvr::matrixProcessingInterface< ubyte >.
bool cvr::histogramEqualization::apply | ( | const matrix< float > & | src, | |
matrix< float > & | dest | |||
) | const [virtual] |
Equalize src and leave the result in dest.
src | the input data | |
dest | the channel where the result will be left |
Implements cvr::matrixProcessingInterface< float >.
Equalizes the values of the given matrix of ubytes (channel8s).
srcdest | Source image and result holder |
Implements cvr::matrixProcessingInterface< ubyte >.
bool cvr::histogramEqualization::apply | ( | matrix< float > & | srcdest | ) | const [virtual] |
Equalizes the values of the given matrix of floats (channels).
srcdest | Source image and result holder |
Implements cvr::matrixProcessingInterface< float >.
virtual histogramEqualization* cvr::histogramEqualization::clone | ( | ) | const [virtual] |
bool cvr::histogramEqualization::computeLUT | ( | const matrix< ubyte > & | chnl, | |
vector< ubyte > & | lut | |||
) | const |
Compute LUT.
This method computes the LUT used to equalize the histogram of a given channel8.
If you want to compute the final value q of a pixel p, then you can use something like:
channel8 chnl; // your channel // initialize chnl here ... // compute a Look-Up Table (LUT) vector<ubyte> lut; histogramEqualization histEq; histEq.computeLUT(chnl,lut); q = lut.at(p);
bool cvr::histogramEqualization::computeLUT | ( | const matrix< float > & | chnl, | |
vector< float > & | lut | |||
) | const |
Compute LUT.
This method computes the LUT used to equalize the histogram of a given floating-point channel.
If you want to compute the final value q of a pixel p, then you can use something like:
channel chnl; // your channel // initialize chnl here ... // compute a Look-Up Table (LUT) vector<float> lut; histogramEqualization histEq; histEq.computeLUT(chnl,lut); q = histEq.getEqualized(p,lut);
histogramEqualization& cvr::histogramEqualization::copy | ( | const histogramEqualization & | other | ) |
float cvr::histogramEqualization::getEqualized | ( | const float | p, | |
const vector< float > & | lut | |||
) | const [inline] |
Inline method to compute from a pixel value the index of the LUT obtained with the method computeLUT().
References cvr::genericVector< T >::at(), cst_, lower_, and upper_.
const parameters& cvr::histogramEqualization::getParameters | ( | ) | const |
virtual const std::string& cvr::histogramEqualization::name | ( | ) | const [virtual] |
virtual histogramEqualization* cvr::histogramEqualization::newInstance | ( | ) | const [virtual] |
virtual bool cvr::histogramEqualization::updateParameters | ( | ) | [virtual] |
float cvr::histogramEqualization::cst_ [protected] |
float cvr::histogramEqualization::lower_ [protected] |
int cvr::histogramEqualization::loweru_ [protected] |
Shadow of parameters lowerInputLimit scaled by a norm of 255.
float cvr::histogramEqualization::upper_ [protected] |
int cvr::histogramEqualization::upperu_ [protected] |
Shadow of parameters upperInputLimit scaled by a norm of 255.