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

details Algorithms to Initialize Images VIGRA

Functions

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

Detailed Description

Init images or image borders

Function Documentation

void vigra::initImage (   ...)

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

This function can be used to init the image.

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.

Function initMultiArray() implements the same functionality for arbitrary dimensional arrays. In many situations, the assignment functions of vigra::MultiArrayView offer a simpler and more readable alternative to the init functions.

Declarations:

pass 2D array views:

namespace vigra {
template <class T, class S, class VALUETYPE>
void
initImage(MultiArrayView<2, T, S> img, VALUETYPE const & v);
template <class T, class S, class FUNCTOR>
void
initImage(MultiArrayView<2, T, S> img, FUNCTOR const & v);
}

show deprecated declarations

Usage:

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

Initialize with a constant:

MultiArray<2, unsigned char> img(100, 100);
// init the image with the value 128
initImage(img, 128);
// init the interior with the value 1
initImage(img.subarray(Shape2(10), Shape2(-10)), 1);
// equivalent to
img = 128;
img.init(128);
img.subarray(Shape2(10), Shape2(-10)) = 1;

Initialize with a functor:

struct Counter {
Counter() : count(0) {}
int operator()() const { return count++; }
mutable int count;
};
MultiArray<2, int> img(100, 100);
// write the current count in every pixel
initImage(img, Counter());
// equivalent to
#include <vigra/algorithm.hxx>
linearSequence(img.begin(), img.end());

show deprecated examples

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. The functor is passed by reference, so that its internal state can be updated in each call.

Declarations:

pass 2D array views:

namespace vigra {
template <class T, class S, class FUNCTOR>
void
initImageWithFunctor(MultiArrayView<2, T, S> img, FUNCTOR & f);
}

show deprecated declarations

Usage:

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

struct Counter {
Counter() : count(0) {}
int operator()() const { return count++; }
int count;
};
MultiArray<2, int> img(100, 100);
// write the current count in every pixel
Counter counter;
initImageWithFunctor(img, counter);
// equivalent to
#include <vigra/algorithm.hxx>
linearSequence(img.begin(), img.end());

show deprecated examples

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.

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 2D array views:

namespace vigra {
template <class T, class S,
class TM, class SM,
class VALUETYPE>
void
initImageIf(MultiArrayView<2, T, S> img,
MultiArrayView<2, TM, SM> const & mask,
VALUETYPE const & v);
template <class T, class S,
class TM, class SM,
class FUNCTOR>
void
initImageIf(MultiArrayView<2, T, S> img,
MultiArrayView<2, TM, SM> const & mask,
FUNCTOR const & v);
}

show deprecated declarations

Usage:

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

MultiArray<2, RGBValue<unsigned char> > img(100, 100),
MultiArray<2, unsigned char> mask(100, 100);
... // init the ROI mask
// set the ROI to one
initImageIf(img, mask,
NumericTraits<RGBValue<unsigned char> >::one());

show deprecated examples

Examples:
voronoi.cxx.
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'.

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 2D array views:

namespace vigra {
template <class T, class S, class VALUETYPE>
void
initImageBorder(MultiArrayView<2, T, S> img,
int border_width, VALUETYPE const & v);
template <class T, class S, class FUNCTOR>
void
initImageBorder(MultiArrayView<2, T, S> img,
int border_width, FUNCTOR const & v);
}

show deprecated declarations

Usage:

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

#include <vigra/random.hxx>
MultiArray<2, int> img(100, 100);
// fill a border of 5 pixels with random numbers

show deprecated examples

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