36 #ifndef VIGRA_CELLIMAGE_HXX 
   37 #define VIGRA_CELLIMAGE_HXX 
   39 #include <vigra/basicimage.hxx> 
   40 #include <vigra/pixelneighborhood.hxx> 
   47 enum CellType { CellTypeRegion = 0,
 
   51                 CellTypeVertexOrLine = 4,
 
   52                 CellTypeErrorOrLine = 5 };
 
   57 typedef unsigned int CellLabel;
 
   64     friend struct CellPixelSerializer;
 
   68     CellPixel(CellType type, CellLabel label = 0)
 
   69     : typeLabel_((label << 2) | type)
 
   72     inline CellType type()
 const 
   73         { 
return (CellType)(typeLabel_ & 3); }
 
   74     inline void setType(CellType type)
 
   75         { typeLabel_ = (label() << 2) | type; }
 
   76     inline void setType(CellType type, CellLabel label)
 
   77         { typeLabel_ = label << 2 | type; }
 
   79     inline CellLabel label()
 const 
   80         { 
return typeLabel_ >> 2; }
 
   81     inline void setLabel(CellLabel label)
 
   82         { typeLabel_ = label << 2 | type(); }
 
   83     inline void setLabel(CellLabel label, CellType type)
 
   84         { typeLabel_ = label << 2 | type; }
 
   87         { 
return typeLabel_ == rhs.typeLabel_; }
 
   90         { 
return typeLabel_ != rhs.typeLabel_; }
 
   93 typedef BasicImage<CellPixel> CellImage;
 
   96     CellImageEightCirculator;
 
  101 struct CellPixelSerializer
 
  103     int operator()(CellPixel 
const &p)
 const 
  108     CellPixel operator()(
int i)
 const 
  111         result.typeLabel_ = i;
 
  119 template<
class VALUE_TYPE = CellType>
 
  122     typedef VALUE_TYPE value_type;
 
  123     typedef VALUE_TYPE result_type;
 
  125     template<
class Iterator>
 
  126     value_type operator()(
const Iterator &it)
 const 
  131     template<
class Iterator>
 
  132     void set(value_type type, 
const Iterator &it)
 const 
  138 typedef TypeAccessor<unsigned char> TypeAsByteAccessor;
 
  140 typedef TypeAccessor<> CellTypeAccessor;
 
  144     typedef CellLabel value_type;
 
  146     template<
class Iterator>
 
  147     CellLabel operator()(
const Iterator &it)
 const 
  152     template<
class Iterator>
 
  153     void set(CellLabel label, 
const Iterator &it)
 const 
  159 template<CellType type>
 
  162     typedef CellLabel value_type;
 
  164     template<
class Iterator>
 
  165     void set(CellLabel label, 
const Iterator &it)
 const 
  167         it->setLabel(label, type);
 
  171 template<CellType type>
 
  172 struct CellTypeEquals : 
public std::unary_function<CellType, bool>
 
  174     bool operator()(CellType t)
 const 
  179     template<
class Iterator>
 
  180     bool operator()(
const Iterator &it)
 const 
  182         return it->type() == type;
 
  186 struct CellMask : 
public std::unary_function<vigra::cellimage::CellPixel, bool>
 
  188     vigra::cellimage::CellPixel maskPixel_;
 
  190     CellMask(vigra::cellimage::CellPixel maskPixel)
 
  191     : maskPixel_(maskPixel)
 
  194     template<
class Iterator>
 
  195     bool operator()(
const Iterator &it)
 const 
  197         return *it == maskPixel_;
 
  204 template<
class VALUETYPE>
 
  205 struct RelabelFunctor
 
  207     typedef VALUETYPE value_type;
 
  208     typedef VALUETYPE argument_type;
 
  209     typedef VALUETYPE result_type;
 
  211     RelabelFunctor(VALUETYPE oldValue, VALUETYPE newValue)
 
  212         : oldValue_(oldValue),
 
  216     VALUETYPE operator()(VALUETYPE value)
 const 
  218         return (value == oldValue_) ? newValue_ : value;
 
  221     VALUETYPE oldValue_, newValue_;
 
  232 template <
class EndIterator, 
class Accessor, 
class Functor>
 
  233 void inspectCell(EndIterator endIterator, Accessor a, Functor & f)
 
  235     for(; endIterator.inRange(); ++endIterator)
 
  239 template <
class EndIterator, 
class Functor>
 
  240 void inspectCell(EndIterator endIterator, Functor & f)
 
  242     for(; endIterator.inRange(); ++endIterator)
 
  249 template <
class SrcEndIterator, 
class SrcAccessor,
 
  250           class DestEndIterator, 
class DestAccessor, 
class Functor>
 
  251 void transformCell(SrcEndIterator srcEndIterator, SrcAccessor sa,
 
  252                    DestEndIterator destEndIterator, DestAccessor da,
 
  255     for(; srcEndIterator.inRange(); ++srcEndIterator, ++destEndIterator)
 
  256         da.set(f(sa(srcEndIterator)), destEndIterator);
 
  259 template <
class SrcEndIterator, 
class DestEndIterator, 
class Functor>
 
  260 void transformCell(SrcEndIterator srcEndIterator,
 
  261                    DestEndIterator destEndIterator,
 
  264     for(; srcEndIterator.inRange(); ++srcEndIterator, ++destEndIterator)
 
  265         *destEndIterator = f(*srcEndIterator);
 
  272 #endif // VIGRA_CELLIMAGE_HXX 
bool operator!=(FFTWComplex< R > const &a, const FFTWComplex< R > &b)
not equal 
Definition: fftw3.hxx:841
bool operator==(FFTWComplex< R > const &a, const FFTWComplex< R > &b)
equal 
Definition: fftw3.hxx:825
Circulator that walks around a given location in a given image. 
Definition: pixelneighborhood.hxx:1037