DGtal  1.5.beta
DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 > Class Template Reference

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. More...

#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
 Types copied from the container. More...
 
typedef DefaultConstImageRange< SelfConstRange
 
typedef DefaultImageRange< SelfRange
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CImage< TImageContainer >))
 Checking concepts. More...
 
 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)
 
 ImageAdapter (const ImageAdapter &other)=default
 
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
 Alias on the image container. More...
 
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 :

  • the type of value of Point for the ImageAdapter Domain must also be the same than the type of value of Point for the original ImageContainer.
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);
const Domain & domain() const
Definition: ImageAdapter.h:199
Aim: A small functor with an operator () that compares one value to a threshold value according to tw...

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

◆ ConstRange

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.

◆ Domain

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.

◆ ImageContainer

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.

◆ Point

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.

◆ Range

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.

◆ Self

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.

◆ Value

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

◆ ImageAdapter() [1/3]

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.

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  }
const TFunctorVm1 * myFVm1
Definition: ImageAdapter.h:347
ImageContainer * myImagePtr
Alias on the image container.
Definition: ImageAdapter.h:327
const Domain * mySubDomainPtr
Definition: ImageAdapter.h:332
const TFunctorV * myFV
Definition: ImageAdapter.h:342
const TFunctorD * myFD
Definition: ImageAdapter.h:337
std::ostream & warning()
Trace trace
Definition: Common.h:153

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

◆ ImageAdapter() [2/3]

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV , typename TFunctorVm1 >
DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::ImageAdapter ( const ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 > &  other)
default

Default copy constructor.

Parameters
otherthe object to copy.

◆ ~ImageAdapter()

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 187 of file ImageAdapter.h.

187 {}

◆ ImageAdapter() [3/3]

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 317 of file ImageAdapter.h.

317  {
318 #ifdef DEBUG_VERBOSE
319  trace.warning() << "ImageAdapter Ctor default " << std::endl;
320 #endif
321  }

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

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT() [1/5]

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

◆ BOOST_CONCEPT_ASSERT() [2/5]

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.

◆ BOOST_CONCEPT_ASSERT() [3/5]

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

◆ BOOST_CONCEPT_ASSERT() [4/5]

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

◆ BOOST_CONCEPT_ASSERT() [5/5]

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

◆ constRange()

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 210 of file ImageAdapter.h.

211  {
212  return ConstRange( *this );
213  }
DefaultConstImageRange< Self > ConstRange
Definition: ImageAdapter.h:132

◆ domain()

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

◆ getDefaultValue()

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

◆ getPointer()

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 292 of file ImageAdapter.h.

293  {
294  return myImagePtr;
295  }

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

◆ isValid()

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 282 of file ImageAdapter.h.

283  {
284  return (myImagePtr->isValid() );
285  }

References DGtal::ImageContainerBySTLVector< TDomain, TValue >::isValid(), and DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myImagePtr.

◆ operator()()

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

◆ operator=()

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

◆ range()

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 221 of file ImageAdapter.h.

222  {
223  return Range( *this );
224  }
DefaultImageRange< Self > Range
Definition: ImageAdapter.h:133

◆ selfDisplay()

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.

◆ setDefaultValue()

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 302 of file ImageAdapter.h.

303  {
304  defaultValue = aValue;
305  }

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

◆ setValue()

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

Field Documentation

◆ defaultValue

◆ myFD

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

◆ myFV

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

◆ myFVm1

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

◆ myImagePtr

◆ mySubDomainPtr

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: