DGtal  0.9.4beta
Public Types | Public Member Functions | Protected Attributes | Private Member Functions
DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 > Class Template Reference

#include <DGtal/images/ImageAdapter.h>

Public Types

typedef ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 > Self
 
typedef TNewDomain Domain
 
typedef TNewDomain::Point Point
 
typedef TNewValue Value
 
typedef TImageContainer ImageContainer
 
typedef DefaultConstImageRange< SelfConstRange
 
typedef DefaultImageRange< SelfRange
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CImage< TImageContainer >))
 
 BOOST_CONCEPT_ASSERT ((concepts::CDomain< TNewDomain >))
 
 BOOST_CONCEPT_ASSERT ((concepts::CUnaryFunctor< TFunctorD, Point, typename TImageContainer::Point >))
 
 BOOST_CONCEPT_ASSERT ((concepts::CUnaryFunctor< TFunctorV, typename TImageContainer::Value, Value >))
 
 BOOST_CONCEPT_ASSERT ((concepts::CUnaryFunctor< TFunctorVm1, Value, typename TImageContainer::Value >))
 
 ImageAdapter (ImageContainer &anImage, ConstAlias< Domain > aDomain, ConstAlias< TFunctorD > aFD, ConstAlias< TFunctorV > aFV, ConstAlias< TFunctorVm1 > aFVm1)
 
ImageAdapteroperator= (const ImageAdapter &other)
 
 ~ImageAdapter ()
 
const Domaindomain () const
 
ConstRange constRange () const
 
Range range ()
 
Value operator() (const Point &aPoint) const
 
void setValue (const Point &aPoint, const Value &aValue)
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 
const ImageContainergetPointer () const
 
void setDefaultValue (Value aValue)
 
Value getDefaultValue () const
 

Protected Attributes

ImageContainermyImagePtr
 
const DomainmySubDomainPtr
 
const TFunctorD * myFD
 
const TFunctorV * myFV
 
const TFunctorVm1 * myFVm1
 
Value defaultValue
 

Private Member Functions

 ImageAdapter ()
 

Detailed Description

template<typename TImageContainer, typename TNewDomain, typename TFunctorD, typename TNewValue, typename TFunctorV, typename TFunctorVm1>
class DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >

Aim: implements an image adapter with a given domain (i.e. a subdomain) and 3 functors : g for domain, f for accessing point values and f-1 for writing point values.

Description of template class 'ImageAdapter'

This class is (like Image class) a lightweight proxy on ImageContainers (models of CImage). It uses a given Domain (i.e. a subdomain) but work directly (for reading and writing processes) thanks to an alias (i.e. a pointer) on the original Image given in argument.

ImageAdapter class is also a model of CImage.

Caution :

Template Parameters
TImageContaineran image container type (model of CImage).
TNewDomaina domain.
TFunctorDthe functor g that transforms the domain into another one
TNewValuethe type of value return by the functor f.
TFunctorVthe functor f that transforms the value into another one during reading process
TFunctorVm1the functor f-1 that transforms the value into another one during writing process

The values associated to accessing the point values are adapted with a functor g and a functor f given at construction so that operator() calls f(img(g(aPoint))), instead of calling directly operator() of the underlying image img.

The values associated to writing the points are adapted with a functor g and a functor f-1 given at construction so that setValue() is img.setValue(g(aPoint), f-1(aValue))

The use is the same that for ConstImageAdapter so here is the construction of a simple ConstImageAdapter that is a thresholded view of the initial scalar image:

typedef ConstImageAdapter<Image, Domain, functors::Identity, bool, DGtal::functors::Thresholder<Image::Value> > ConstImageAdapterForThresholderImage;
ConstImageAdapterForThresholderImage thresholderImage(image, domain, df, t);

NB: the underlying image as well as the 3 functors are stored in the adapter as aliasing pointer in order to avoid copies. The pointed objects must exist and must not be deleted during the use of the adapter

Definition at line 109 of file ImageAdapter.h.

Member Typedef Documentation

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
typedef DefaultConstImageRange<Self> DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::ConstRange

Definition at line 132 of file ImageAdapter.h.

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
typedef TNewDomain DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::Domain

Definition at line 121 of file ImageAdapter.h.

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
typedef TImageContainer DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::ImageContainer

Types copied from the container.

Definition at line 130 of file ImageAdapter.h.

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
typedef TNewDomain::Point DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::Point

Definition at line 122 of file ImageAdapter.h.

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
typedef DefaultImageRange<Self> DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::Range

Definition at line 133 of file ImageAdapter.h.

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
typedef ImageAdapter<TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1> DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::Self

Definition at line 115 of file ImageAdapter.h.

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
typedef TNewValue DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::Value

Definition at line 123 of file ImageAdapter.h.

Constructor & Destructor Documentation

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::ImageAdapter ( ImageContainer anImage,
ConstAlias< Domain aDomain,
ConstAlias< TFunctorD >  aFD,
ConstAlias< TFunctorV >  aFV,
ConstAlias< TFunctorVm1 >  aFVm1 
)
inline

Definition at line 139 of file ImageAdapter.h.

References DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::defaultValue, DGtal::trace, and DGtal::Trace::warning().

145  :
146  myImagePtr(&anImage), mySubDomainPtr(&aDomain), myFD(&aFD), myFV(&aFV), myFVm1(&aFVm1)
147  {
148  defaultValue = 0;
149 #ifdef DEBUG_VERBOSE
150  trace.warning() << "ImageAdapter Ctor fromRef " << std::endl;
151 #endif
152  }
Trace trace
Definition: Common.h:137
const TFunctorD * myFD
Definition: ImageAdapter.h:331
const Domain * mySubDomainPtr
Definition: ImageAdapter.h:326
ImageContainer * myImagePtr
Alias on the image container.
Definition: ImageAdapter.h:321
const TFunctorV * myFV
Definition: ImageAdapter.h:336
const TFunctorVm1 * myFVm1
Definition: ImageAdapter.h:341
std::ostream & warning()
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::~ImageAdapter ( )
inline

Destructor. Does nothing

Definition at line 181 of file ImageAdapter.h.

181 {}
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::ImageAdapter ( )
inlineprivate

Default constructor.

Definition at line 311 of file ImageAdapter.h.

References DGtal::trace, and DGtal::Trace::warning().

311  {
312 #ifdef DEBUG_VERBOSE
313  trace.warning() << "ImageAdapter Ctor default " << std::endl;
314 #endif
315  }
Trace trace
Definition: Common.h:137
std::ostream & warning()

Member Function Documentation

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::BOOST_CONCEPT_ASSERT ( (concepts::CImage< TImageContainer >)  )

Checking concepts.

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::BOOST_CONCEPT_ASSERT ( (concepts::CDomain< TNewDomain >)  )
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::BOOST_CONCEPT_ASSERT ( (concepts::CUnaryFunctor< TFunctorD, Point, typename TImageContainer::Point >)  )
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::BOOST_CONCEPT_ASSERT ( (concepts::CUnaryFunctor< TFunctorV, typename TImageContainer::Value, Value >)  )
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::BOOST_CONCEPT_ASSERT ( (concepts::CUnaryFunctor< TFunctorVm1, Value, typename TImageContainer::Value >)  )
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
ConstRange DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::constRange ( ) const
inline

Returns the range of the underlying image to iterate over its values

Returns
a range.

Definition at line 204 of file ImageAdapter.h.

205  {
206  return ConstRange( *this );
207  }
DefaultConstImageRange< Self > ConstRange
Definition: ImageAdapter.h:132
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
const Domain& DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::domain ( ) const
inline
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
Value DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::getDefaultValue ( ) const
inline
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
const ImageContainer* DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::getPointer ( ) const
inline

Returns the pointer on the Image container data.

Returns
a const ImagePtr.

Definition at line 286 of file ImageAdapter.h.

References DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myImagePtr.

287  {
288  return myImagePtr;
289  }
ImageContainer * myImagePtr
Alias on the image container.
Definition: ImageAdapter.h:321
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
bool DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::isValid ( ) const
inline

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

Definition at line 276 of file ImageAdapter.h.

References DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myImagePtr.

277  {
278  return (myImagePtr->isValid() );
279  }
ImageContainer * myImagePtr
Alias on the image container.
Definition: ImageAdapter.h:321
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
Value DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::operator() ( const Point aPoint) const
inline

Get the value of an image at a given position given by a Point.

Precondition
the point must be in the domain
Parameters
aPointthe point.
Returns
the value at aPoint.

Definition at line 232 of file ImageAdapter.h.

References DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::defaultValue, DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::domain(), DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myFD, DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myFV, and DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myImagePtr.

233  {
234  ASSERT(this->domain().isInside(aPoint));
235 
236  typename TImageContainer::Point point = myFD->operator()(aPoint);
237  if (myImagePtr->domain().isInside(point))
238  return myFV->operator()(myImagePtr->operator()(point));
239  else
240  return defaultValue;
241  }
const TFunctorD * myFD
Definition: ImageAdapter.h:331
const Domain & domain() const
Definition: ImageAdapter.h:193
ImageContainer * myImagePtr
Alias on the image container.
Definition: ImageAdapter.h:321
const TFunctorV * myFV
Definition: ImageAdapter.h:336
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
ImageAdapter& DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::operator= ( const ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 > &  other)
inline

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.

Definition at line 159 of file ImageAdapter.h.

References DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::defaultValue, DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myFD, DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myFV, DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myFVm1, DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myImagePtr, DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::mySubDomainPtr, DGtal::trace, and DGtal::Trace::warning().

160  {
161 #ifdef DEBUG_VERBOSE
162  trace.warning() << "ImageAdapter assignment " << std::endl;
163 #endif
164  if (&other != this)
165  {
166  myImagePtr = other.myImagePtr;
167  mySubDomainPtr = other.mySubDomainPtr;
168  myFD = other.myFD;
169  myFV = other.myFV;
170  myFVm1 = other.myFVm1;
171  defaultValue = other.defaultValue;
172  }
173  return *this;
174  }
Trace trace
Definition: Common.h:137
const TFunctorD * myFD
Definition: ImageAdapter.h:331
const Domain * mySubDomainPtr
Definition: ImageAdapter.h:326
ImageContainer * myImagePtr
Alias on the image container.
Definition: ImageAdapter.h:321
const TFunctorV * myFV
Definition: ImageAdapter.h:336
const TFunctorVm1 * myFVm1
Definition: ImageAdapter.h:341
std::ostream & warning()
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
Range DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::range ( )
inline

Returns the range of the underlying image to iterate over its values

Returns
a range.

Definition at line 215 of file ImageAdapter.h.

216  {
217  return Range( *this );
218  }
DefaultImageRange< Self > Range
Definition: ImageAdapter.h:133
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
void DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
void DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::setDefaultValue ( Value  aValue)
inline

Allows to define a default value returned when point transformed by domain functor does not belongs to image domain.

Definition at line 296 of file ImageAdapter.h.

References DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::defaultValue.

297  {
298  defaultValue = aValue;
299  }
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
void DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::setValue ( const Point aPoint,
const Value aValue 
)
inline

Set a value on an Image at a position specified by a Point.

Precondition
it must be a point in the image domain.
Parameters
aPointthe point.
aValuethe value.

Definition at line 255 of file ImageAdapter.h.

References DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::domain(), DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myFD, DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myFVm1, and DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myImagePtr.

256  {
257  ASSERT(this->domain().isInside(aPoint));
258 
259  myImagePtr->setValue(myFD->operator()(aPoint), myFVm1->operator()(aValue));
260  }
const TFunctorD * myFD
Definition: ImageAdapter.h:331
const Domain & domain() const
Definition: ImageAdapter.h:193
ImageContainer * myImagePtr
Alias on the image container.
Definition: ImageAdapter.h:321
const TFunctorVm1 * myFVm1
Definition: ImageAdapter.h:341

Field Documentation

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
Value DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::defaultValue
protected
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
const TFunctorD* DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myFD
protected
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
const TFunctorV* DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myFV
protected
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
const TFunctorVm1* DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myFVm1
protected
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
ImageContainer* DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myImagePtr
protected
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
const Domain* DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::mySubDomainPtr
protected

The documentation for this class was generated from the following file: