[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3. vipl: Templated Image Processing Library

Chapter summary:
Image Processing is fairly (but not very) important in Computer Vision.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1 Usage of vipl

vipl provides several image processing algorithms including mathematical morphology, smoothing, edge filtering. All of these algorithms are provided as filter classes. So there is a vipl_gaussian_convolution class, etc.

The pattern for using each filter is as follows.

 
vipl_filtering_operation<TEMPLATE TYPES> op(parameters);
op.put_in_data_ptr(src_image_ptr);
op.put_out_data_ptr(dst_image_ptr);
op.filter();

The TEMPLATE TYPES and parameters depend on the actual operation. Common template parameters include the types of the source image, the destination image, the source pixels, the destination pixels, and the pixel iterator. So a concrete use might be:

 
typedef vil_memory_image im_type;
im_type src(width,height,1,VIL_PIXEL_FORMAT_BYTE), dest;
...
vipl_gaussian_convolution<im_type,im_type,vxl_byte,vxl_byte,vipl_trivial_pixeliter> op(2.0);
op.put_in_data_ptr(&src);
op.put_out_data_ptr(&dest);
op.filter();

All of the concrete classes depend on an abstract class tree including vipl_filter<>, which automatically provides the ability to work on images that are too large to be fit into memory in one go.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.1 Available filters

The following concrete operations have been implemented so far


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.1.1 Morphological operators


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.1.2 Pixel-wise operations


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.2 FIR filters


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.3 Others


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2 Implementation of new filtering operations. (Developer topic)

It is probably easiest to follow an example. However, the basic minimum required is to override section_applyop(). It should scan through the whole section, and set the output accordingly. For example

 
template <class ImgIn,class ImgOut,class DataIn,class DataOut,class PixelItr>
bool vipl_gradient_dir <ImgIn,ImgOut,DataIn,DataOut,PixelItr> :: section_applyop()
{
  const ImgIn &in = in_data(0);
  ImgOut &out = *out_data_ptr();

  DataIn dummy = DataIn(); register double dx, dy;
  int startx = start(X_Axis());
  int starty = start(Y_Axis());
  int stopx = stop(X_Axis());
  int stopy = stop(Y_Axis());
  for (int j = starty; j < stopy; ++j)
    for (int i = startx; i < stopx; ++i)
    {
      dx = fgetpixel(in, i, j, dummy) - getpixel(in, i-1, j, dummy);
      dy = fgetpixel(in, i, j, dummy) - getpixel(in, i, j-1, dummy);
      dx = (vcl_atan2( dy, dx ) + shift()) * scale();
      fsetpixel(out, i, j, (DataOut)dx);
    }
  return true;
}

Use of the start(), stop(), X_Axis(), getpixel(), setpixel(), etc. inline functions means that your new filter will work with any image type that vipl supports.

If you need to pre-calculate something, such as an FIR filter mask, then override preop(). Tidying up can be done in postop().


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.3 Using a new image type with vipl. (Developer topic)

Following the existing code as a guide, you will need to add


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Rumpelstiltskin on November, 22 2009 using texi2html 1.78.