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

Classes | Functions
Functors to Transform Images

Classes

class  BrightnessContrastFunctor< PixelType >
 Adjust brightness and contrast of an image. More...
class  GammaFunctor< PixelType >
 Perform gamma correction of an image. More...
class  Threshold< SrcValueType, DestValueType >
 Threshold an image. More...
class  VectorNormFunctor< ValueType >
 A functor for computing the vector norm. More...
class  VectorNormSqFunctor< ValueType >
 A functor for computing the squared vector norm. More...

Functions

template<class Multiplier , class DestValueType >
LinearIntensityTransform
< DestValueType, Multiplier > 
linearIntensityTransform (Multiplier scale, DestValueType offset)
 Apply a linear transform to the source pixel values.
template<class SrcValueType , class DestValueType >
LinearIntensityTransform
< DestValueType, typename
NumericTraits< DestValueType >
::RealPromote > 
linearRangeMapping (SrcValueType src_min, SrcValueType src_max, DestValueType dest_min, DestValueType dest_max)
 Map a source intensity range linearly to a destination range.

Detailed Description

Note that the unary functors of the STL can also be used in connection with transformImage().


Function Documentation

LinearIntensityTransform<DestValueType, Multiplier> vigra::linearIntensityTransform ( Multiplier  scale,
DestValueType  offset 
)

Apply a linear transform to the source pixel values.

Factory function for a functor that linearly transforms the source pixel values. The functor applies the transform 'destvalue = scale * (srcvalue + offset)' to every pixel. This can, for example, be used to transform images into the visible range 0...255 or to invert an image.

If you leave out the second parameter / offset, you will get an optimized version of the functor which only scales by the given factor, however you have to make the template parameter (pixel type) explicit then.

Traits defined:

FunctorTraits::isUnaryFunctor is true (VigraTrueType)

Declaration:

    namespace vigra {
        template <class Multiplier, class DestValueType>
        LinearIntensityTransform<DestValueType, Multiplier>
        linearIntensityTransform(Multiplier scale, DestValueType offset);

        template <class DestValueType, class Multiplier>
        ScalarIntensityTransform<DestValueType, Multiplier>
        linearIntensityTransform(Multiplier scale);
    }

Usage:

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

    vigra::IImage src(width, height);
    vigra::BImage dest(width, height);
    ...
    vigra::FindMinMax<IImage::PixelType> minmax;   // functor to find range

    vigra::inspectImage(srcImageRange(src), minmax); // find original range

    // transform to range 0...255
    vigra::transformImage(srcImageRange(src), destImage(dest),
                          linearIntensityTransform(
                            255.0 / (minmax.max - minmax.min), // scaling
                          - minmax.min));                    // offset

The one-parameter version can be used like this:

    // scale from 0..255 to 0..1.0
    FImage dest(src.size());

    vigra::transformImage(srcImageRange(src), destImage(dest),
                          linearIntensityTransform<float>(1.0 / 255));

Required Interface:

The source and destination value types must be models of LinearSpace in both cases.

Examples:
invert.cxx.
LinearIntensityTransform<DestValueType, typename NumericTraits<DestValueType>::RealPromote> vigra::linearRangeMapping ( SrcValueType  src_min,
SrcValueType  src_max,
DestValueType  dest_min,
DestValueType  dest_max 
)

Map a source intensity range linearly to a destination range.

Factory function for a functor that linearly transforms the source pixel values. The functor applies the transform 'destvalue = scale * (srcvalue + offset)' to every pixel, where scale = (dest_max - dest_min) / (src_max - src_min) and offset = dest_min / scale - src_min. As a result, the pixel values src_max, src_min in the source image are mapped onto dest_max, dest_min respectively. This works for scalar as well as vector pixel types.

Declaration:

    namespace vigra {
        template <class SrcValueType, class DestValueType>
        LinearIntensityTransform<DestValueType, typename NumericTraits<DestValueType>::RealPromote>
        linearRangeMapping(SrcValueType src_min, SrcValueType src_max,
                           DestValueType dest_min, DestValueType dest_max );
    }

Usage:

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

    vigra::IImage src(width, height);
    vigra::BImage dest(width, height);
    ...
    vigra::FindMinMax<IImage::PixelType> minmax;   // functor to find range

    vigra::inspectImage(srcImageRange(src), minmax); // find original range

    // transform to range 0...255
    vigra::transformImage(srcImageRange(src), destImage(dest),
                          linearRangeTransform(
                            minmax.min, minmax.max,               // src range
                            (unsigned char)0, (unsigned char)255) // dest range
                          );

Required Interface:

The source and destination value types must be models of LinearSpace in both cases.

© 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.7.0 (Thu Aug 25 2011)