CVR-Lib last update 20 Sep 2009

cvr::histogramEqualization Class Reference
[Contrast Enhancement Algorithms]

Histogram equalization. More...

#include <cvrHistogramEqualization.h>

Inheritance diagram for cvr::histogramEqualization:

Inheritance graph
[legend]
Collaboration diagram for cvr::histogramEqualization:

Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 The parameters for the class cvr::histogramEqualization. More...

Public Member Functions

 histogramEqualization ()
 histogramEqualization (const parameters &params)
 histogramEqualization (const histogramEqualization &other)
virtual ~histogramEqualization ()
virtual const std::string & name () const
histogramEqualizationcopy (const histogramEqualization &other)
virtual histogramEqualizationclone () const
virtual histogramEqualizationnewInstance () const
const parametersgetParameters () 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_


Detailed Description

Histogram equalization.

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);

Constructor & Destructor Documentation

cvr::histogramEqualization::histogramEqualization (  ) 

Default constructor.

cvr::histogramEqualization::histogramEqualization ( const parameters params  ) 

Default constructor with parameters.

cvr::histogramEqualization::histogramEqualization ( const histogramEqualization other  ) 

Copy constructor.

Parameters:
other the object to be copied

virtual cvr::histogramEqualization::~histogramEqualization (  )  [virtual]

Destructor.


Member Function Documentation

bool cvr::histogramEqualization::apply ( const channel8 src,
channel8 dest 
) const [virtual]

Equalize src and leave the result in dest.

Parameters:
src the input data
dest the channel8 where the result will be left
Returns:
true if ok, false otherwise.

Implements cvr::contrastEnhancement.

bool cvr::histogramEqualization::apply ( const channel src,
channel dest 
) const [virtual]

Equalize src and leave the result in dest.

Parameters:
src the input data
dest the channel where the result will be left
Returns:
true if ok, false otherwise.

Implements cvr::contrastEnhancement.

bool cvr::histogramEqualization::apply ( channel8 srcdest  )  const [virtual]

Equalizes the values of the given matrix of ubytes (channel8s).

Returns:
true if ok, false otherwise.

Implements cvr::contrastEnhancement.

bool cvr::histogramEqualization::apply ( channel srcdest  )  const [virtual]

Equalizes the values of the given matrix of floats (channels).

Returns:
true if ok, false otherwise.

Implements cvr::contrastEnhancement.

bool cvr::histogramEqualization::apply ( const vector< ubyte > &  src,
vector< ubyte > &  dest 
) const

Generates the vector dest as the histogram equalization of the values in the vector src.

Parameters:
src the input data
dest the vector where the result will be left
Returns:
true if ok, false otherwise.

bool cvr::histogramEqualization::apply ( const vector< float > &  src,
vector< float > &  dest 
) const

Generates the vector dest as the histogram equalization of the values in the vector src.

Parameters:
src the input data
dest the fvector where the result will be left
Returns:
true if ok, false otherwise.

bool cvr::histogramEqualization::apply ( vector< ubyte > &  srcdest  )  const

Equalizes the values of the given vector of ubytes.

Returns:
true if ok, false otherwise.

bool cvr::histogramEqualization::apply ( vector< float > &  srcdest  )  const

Equalizes the values of the given vector of floats.

Returns:
true if ok, false otherwise.

bool cvr::histogramEqualization::apply ( const matrix< ubyte > &  src,
matrix< ubyte > &  dest 
) const [virtual]

Equalize src and leave the result in dest.

Parameters:
src the input data
dest the channel8 where the result will be left
Returns:
true if ok, false otherwise.

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.

Parameters:
src the input data
dest the channel where the result will be left
Returns:
true if ok, false otherwise.

Implements cvr::matrixProcessingInterface< float >.

bool cvr::histogramEqualization::apply ( matrix< ubyte > &  srcdest  )  const [virtual]

Equalizes the values of the given matrix of ubytes (channel8s).

Parameters:
srcdest Source image and result holder
Returns:
true if ok, false otherwise.

Implements cvr::matrixProcessingInterface< ubyte >.

bool cvr::histogramEqualization::apply ( matrix< float > &  srcdest  )  const [virtual]

Equalizes the values of the given matrix of floats (channels).

Parameters:
srcdest Source image and result holder
Returns:
true if ok, false otherwise.

Implements cvr::matrixProcessingInterface< float >.

virtual histogramEqualization* cvr::histogramEqualization::clone (  )  const [virtual]

Returns a pointer to a clone of this functor.

Implements cvr::contrastEnhancement.

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  ) 

Copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

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

Returns used parameters.

Reimplemented from cvr::contrastEnhancement.

virtual const std::string& cvr::histogramEqualization::name (  )  const [virtual]

Returns the name of this type.

Reimplemented from cvr::contrastEnhancement.

virtual histogramEqualization* cvr::histogramEqualization::newInstance (  )  const [virtual]

Returns a pointer to a clone of this functor.

Implements cvr::contrastEnhancement.

virtual bool cvr::histogramEqualization::updateParameters (  )  [virtual]

Initialize some frequently used constants.

Reimplemented from cvr::parametersManager.


Member Data Documentation

Precomputed constant cst = (par.cells-1)/(upper-lower);.

Referenced by getEqualized().

Shadow of parameters lowerInputLimit.

Referenced by getEqualized().

Shadow of parameters lowerInputLimit scaled by a norm of 255.

Shadow of parameters upperInputLimit.

Referenced by getEqualized().

Shadow of parameters upperInputLimit scaled by a norm of 255.


The documentation for this class was generated from the following file:

Generated on Sun Sep 20 22:08:46 2009 for CVR-Lib by Doxygen 1.5.8