About the Image class

Note:
Some of this documentation was originally written at the time that we converted the Image class to have a ref-counted interface and moved functionality from member functions to free functions; this is the source of references to "new" and "old" styles.

Ref-counting and copy-on-write

How ref-counting works, in four parts:

Ref-counting usage syntax

Ref-counting helps avoid copies

Ref-counting helps reduce bugs

Ref-counting helps with exception safety

Ref-counting "gotchas"

Image iterators

Quick iterator review

Image iterators: normal and debug versions

template <class T>
class CheckedIterator                 // a checked iterator class
{
  TT* ptr;
  TT* start;
  TT* stop;

  // ... ++, --, <, >, <=, >=, +=, -=, all those goodies ...

  TT* operator->() const
    {
      CheckedIteratorAux::ck_range_helper(ptr, start, stop);
      return ptr;
    }
  TT& operator*() const
    {
      CheckedIteratorAux::ck_range_helper(ptr, start, stop);
      return *ptr;
    }
  TT& operator[](diff_t d) const
    {
      CheckedIteratorAux::ck_range_helper(ptr+d, start, stop);
      return ptr[d];
    }
};

template <class T>
class Image
{
public:
#ifndef INVT_MEM_DEBUG
  // ... normal iterators ...
#else

  typedef CheckedIterator<T>             iterator;
  typedef CheckedIterator<const T> const_iterator;

  const_iterator begin()  const
    { return const_iterator(impl().data(), impl().end()); }

  const_iterator end()    const
    { return const_iterator(impl().end(), impl().end()); }

  iterator beginw() { return iterator(uniq().dataw(), uniq().endw()); }
  iterator endw()   { return iterator(uniq().endw(), uniq().endw()); }

#endif
}

Free functions for image operations

File name Contents
Image/All.H #includes all other Image-related files
Image/ColorOps.H color operations: get/set components, luminance, RGB-YIQ conversions, etc.
Image/FilterOps.H lowPass*(), convolve*(), sepFilter*(), etc.
Image/MathOps.H absDiff(), average(), takeMax(), RMSerr(), etc.
Image/Omni.H all omni-directional related operations
Image/ShapeOps.H rescale(), downSize(), concat*(), dec*(), int*(), crop()
Image/Transforms.H segmentObject(), dct(), infoFFT(), etc.

Free function syntax examples

void oldFoo(const Image<float>& x)
{
  Image<float> filtered = x;
  filtered.lowPass3(true, true);
}

#include "Image/FilterOps.H"

void newFoo(const Image<float>& x)
{
  Image<float> filtered = lowPass3(x, true, true);
}
void oldFoo(const Image<PixRGB<byte> >& x)
{
  Image<float> lum;
  x.luminance(lum);
}

#include "Image/ColorOps.H"

void newFoo(const Image<PixRGB<byte> >& x)
{
  Image<float> lum = luminance(x);
}
void oldFoo(const Image<byte>& x)
{
  Image<float> smaller = x;
  smaller.rescale(x.getWidth()/2, x.getHeight()/2);
}

#include "Image/ShapeOps.H"

void newFoo(const Image<byte>& x)
{
  Image<float> smaller = rescale(x, x.getWidth()/2, x.getHeight()/2);
}

Use of std::numeric_limits

Generated on Sun May 8 08:43:02 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3