VIGRA - VIGRA: Algorithms to Initialize Images

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

| Algorithms to Initialize Images |

## Functions
template<... >
void | initImage (...)
| Write a value to every pixel in an image or rectangular ROI.
template<... >
void | initImageBorder (...)
| Write value to the specified border pixels in the image.
template<... >
void | initImageIf (...)
| Write value to pixel in the image if mask is true.
template<... >
void | initImageWithFunctor (...)
| Write the result of a functor call to every pixel in an image or rectangular ROI.

## Detailed Description

Init images or image borders

## Function Documentation

template<... >
void vigra::initImage | ( |  | ... | ) |

Write a value to every pixel in an image or rectangular ROI.

This function can be used to init the image. It uses an accessor to access the pixel data.

The initial value can either be a constant of appropriate type (compatible with the destination's value_type), or a functor with compatible result_type. These two cases are automatically distinguished when `FunctorTraits<FUNCTOR>::isInitializer` yields `VigraTrueType`. Since the functor is passed by `const` reference, its `operator()` must be const, and its internal state may need to be `mutable`.

Declarations:

pass arguments explicitly:

        namespace vigra {
            template <class ImageIterator, class Accessor, class VALUETYPE>
            void initImage(ImageIterator upperleft, ImageIterator lowerright,
                           Accessor a, VALUETYPE const & v);

            template <class ImageIterator, class Accessor, class FUNCTOR>
            void initImage(ImageIterator upperleft, ImageIterator lowerright,
                           Accessor a, FUNCTOR const & v);
        }

use argument objects in conjunction with Argument Object Factories :

        namespace vigra {
            template <class ImageIterator, class Accessor, class VALUETYPE>
            void initImage(triple<ImageIterator, ImageIterator, Accessor> img, VALUETYPE const & v);

            template <class ImageIterator, class Accessor, class FUNCTOR>
            void initImage(triple<ImageIterator, ImageIterator, Accessor> img, FUNCTOR const & v);
        }

Usage:

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

Initialize with a constant:

        vigra::BImage img(100, 100);

        // init the image with the value 128
        vigra::initImage(destImageRange(img), 128);

Initialize with a functor:

        struct Counter {
            Counter() : count(0) {}

            int operator()() const { return count++; }

            mutable int count;
        };

        vigra::IImage img(100, 100);

        // write the current count in every pixel
        vigra::initImage(destImageRange(img), Counter());

Required Interface:

        ImageIterator upperleft, lowerright;
        ImageIterator::row_iterator ix = upperleft.rowIterator();

        Accessor accessor;
        VALUETYPE v;

        accessor.set(v, ix);

template<... >
void vigra::initImageWithFunctor | ( |  | ... | ) |

Write the result of a functor call to every pixel in an image or rectangular ROI.

This function can be used to init the image by calling the given functor for each pixel. It uses an accessor to access the pixel data. The functor is passed by reference, so that its internal state can be updated in each call.

Declarations:

pass arguments explicitly:

        namespace vigra {
            template <class ImageIterator, class Accessor, class FUNCTOR>
            void
            initImageWithFunctor(ImageIterator upperleft, ImageIterator lowerright,
                      Accessor a,  FUNCTOR & f);
        }

use argument objects in conjunction with Argument Object Factories :

        namespace vigra {
            template <class ImageIterator, class Accessor, class FUNCTOR>
            void
            initImageWithFunctor(triple<ImageIterator, ImageIterator, Accessor> img, FUNCTOR & f);
        }

Usage:

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

        struct Counter {
            Counter() : count(0) {}

            int operator()() const { return count++; }

            mutable int count;
        };

        vigra::IImage img(100, 100);

        // write the current count in every pixel
        Counter counter;
        vigra::initImageWithFunctor(destImageRange(img), counter);

Required Interface:

        ImageIterator upperleft, lowerright;
        ImageIterator::row_iterator ix = upperleft.rowIterator();

        Accessor accessor;
        Functor f;

        accessor.set(f(), ix);

template<... >
void vigra::initImageIf | ( |  | ... | ) |

Write value to pixel in the image if mask is true.

This function can be used to init a region-of-interest of the image. It uses an accessor to access the pixel data.

The initial value can either be a constant of appropriate type (compatible with the destination's value_type), or a functor with compatible result_type. These two cases are automatically distinguished when `FunctorTraits<FUNCTOR>::isInitializer` yields `VigraTrueType`. Since the functor is passed by `const` reference, its `operator()` must be const, and its internal state may need to be `mutable`.

Declarations:

pass arguments explicitly:

        namespace vigra {
            template <class ImageIterator, class Accessor,
                      class MaskImageIterator, class MaskAccessor,
                      class VALUETYPE>
            void initImageIf(ImageIterator upperleft, ImageIterator lowerright, Accessor a,
                             MaskImageIterator mask_upperleft, MaskAccessor ma,
                             VALUETYPE const & v);

            template <class ImageIterator, class Accessor,
                      class MaskImageIterator, class MaskAccessor,
                      class FUNCTOR>
            void initImageIf(ImageIterator upperleft, ImageIterator lowerright, Accessor a,
                             MaskImageIterator mask_upperleft, MaskAccessor ma,
                             FUNCTOR const & v);
        }

use argument objects in conjunction with Argument Object Factories :

        namespace vigra {
            template <class ImageIterator, class Accessor,
                      class MaskImageIterator, class MaskAccessor,
                      class VALUETYPE>
            void initImageIf(triple<ImageIterator, ImageIterator, Accessor> img,
                             pair<MaskImageIterator, MaskAccessor> mask,
                             VALUETYPE const & v);

            template <class ImageIterator, class Accessor,
                      class MaskImageIterator, class MaskAccessor,
                      class FUNCTOR>
            void initImageIf(triple<ImageIterator, ImageIterator, Accessor> img,
                             pair<MaskImageIterator, MaskAccessor> mask,
                             FUNCTOR const & v);
        }

Usage:

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

        vigra::BImage img(100, 100);
        vigra::BImage mask(100, 100);

        // zero the ROI
        vigra::initImageIf(destImageRange(img),
                    maskImage(mask),
                    vigra::NumericTraits<vigra::BImage::PixelType>::zero());

Required Interface:

        ImageIterator upperleft, lowerright;
        MaskImageIterator mask_upperleft;
        ImageIterator::row_iterator ix = upperleft.rowIterator();
        MaskImageIterator::row_iterator mx = mask_upperleft.rowIterator();

        Accessor accessor;
        MaskAccessor mask_accessor;
        VALUETYPE v;

        if(mask_accessor(mx)) accessor.set(v, ix);

template<... >
void vigra::initImageBorder | ( |  | ... | ) |

Write value to the specified border pixels in the image.

A pixel is initialized if its distance to the border is at most 'borderwidth'. It uses an accessor to access the pixel data.

The initial value can either be a constant of appropriate type (compatible with the destination's value_type), or a functor with compatible result_type. These two cases are automatically distinguished when `FunctorTraits<FUNCTOR>::isInitializer` yields `VigraTrueType`. Since the functor is passed by `const` reference, its `operator()` must be const, and its internal state may need to be `mutable`.

Declarations:

pass arguments explicitly:

        namespace vigra {
            template <class ImageIterator, class Accessor, class VALUETYPE>
            void initImageBorder(ImageIterator upperleft, ImageIterator lowerright, Accessor a,
                                 int border_width, VALUETYPE const & v);

            template <class ImageIterator, class Accessor, class FUNCTOR>
            void initImageBorder(ImageIterator upperleft, ImageIterator lowerright, Accessor a,
                                 int border_width, FUNCTOR const & v);
        }

use argument objects in conjunction with Argument Object Factories :

        namespace vigra {
            template <class ImageIterator, class Accessor, class VALUETYPE>
            void initImageBorder(triple<ImageIterator, ImageIterator, Accessor> img,
                                 int border_width, VALUETYPE const & v);

            template <class ImageIterator, class Accessor, class FUNCTOR>
            void initImageBorder(triple<ImageIterator, ImageIterator, Accessor> img,
                                 int border_width, FUNCTOR const & v);
        }

Usage:

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

        vigra::BImage img(100, 100);

        // zero a border of 5 pixel
        vigra::initImageBorder(destImageRange(img),
                        5, vigra::NumericTraits<vigra::BImage::PixelType>::zero());

Required Interface:

see initImage()

© 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.6.0 (13 Aug 2008)