[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

details BrightnessContrastFunctor< PixelType > Class Template Reference VIGRA

Adjust brightness and contrast of an image. More...

#include <vigra/transformimage.hxx>

Public Types

typedef PixelType argument_type
 
typedef PixelType result_type
 
typedef PixelType value_type
 

Public Member Functions

 BrightnessContrastFunctor (promote_type brightness, promote_type contrast, argument_type const &min, argument_type const &max)
 
result_type operator() (argument_type const &v) const
 

Detailed Description

template<class PixelType>
class vigra::BrightnessContrastFunctor< PixelType >

Adjust brightness and contrast of an image.

This functor applies a gamma correction to each pixel in order to modify the brightness of the image. To the result of the gamma correction, another transform is applied that modifies the contrast. The brightness and contrast parameters must be positive. Values greater than 1 will increase image brightness or contrast respectively, values smaller than 1 decrease them. A value of exactly 1 will have no effect. If contrast is set to 1, the result is equivalent to that of the GammaFunctor with gamma = 1./brightness.

For RGBValue's, the transforms are applied component-wise. The pixel values are assumed to lie between the given minimum and maximum values (in case of RGB, this is again understood component-wise). In case of unsigned char, min and max default to 0 and 255 respectively. Precisely, the following transform is applied to each PixelValue:

\[ \begin{array}{rcl} V_1 & = & \frac{PixelValue - min}{max - min} \\ V_2 & = & V_1^\frac{1}{brightness} \\ V_3 & = & 2 V_2 - 1 \\ V_4 & = & \left\lbrace \begin{array}{l} V_3^\frac{1}{contrast} \mbox{\rm \quad if } V_3 \ge 0 \\ - (-V_3)^\frac{1}{contrast} \mbox{\rm \quad otherwise} \end{array} \right. \\ Result & = & \frac{V_4 + 1}{2} (max - min) + min \end{array} \]

If the PixelType is unsigned char, a look-up-table is used for faster computation.

Traits defined:

FunctorTraits::isUnaryFunctor is true (VigraTrueType)

Usage:

#include <vigra/transformimage.hxx>
Namespace: vigra

vigra::BImage bimage(width, height);
double brightness, contrast;
...
vigra::transformImage(srcImageRange(bimage), destImage(bimage),
vigra::FImage fimage(width, height);
...
vigra::FindMinMax<float> minmax;
vigra::inspectImage(srcImageRange(fimage), minmax);
vigra::transformImage(srcImageRange(fimage), destImage(fimage),
vigra::BrightnessContrastFunctor<float>(brightness, contrast, minmax.min, minmax.max));

Required Interface:

Scalar types: must be a linear algebra (+, - *, NumericTraits), strict weakly ordered (<), and pow() must be defined.

RGB values: the component type must meet the above requirements.

Member Typedef Documentation

typedef PixelType argument_type

the functor's argument type

typedef PixelType result_type

the functor's result type

typedef PixelType value_type
Deprecated:
use argument_type and result_type

Constructor & Destructor Documentation

BrightnessContrastFunctor ( promote_type  brightness,
promote_type  contrast,
argument_type const &  min,
argument_type const &  max 
)

Init functor for argument range [min, max]. brightness and contrast values > 1 will increase brightness and contrast, < 1 will decrease them, and == 1 means no change.

Member Function Documentation

result_type operator() ( argument_type const &  v) const

Calculate modified gray or color value


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

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de)
Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany

html generated using doxygen and Python
vigra 1.11.1 (Fri May 19 2017)