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

Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for domain, f for accessing point values. More...

#include <DGtal/images/ConstImageAdapter.h>

Public Types

typedef ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV > Self
 
typedef TNewDomain Domain
 
typedef TNewDomain::Point Point
 
typedef TNewValue Value
 
typedef TImageContainer ImageContainer
 Types copied from the container. More...
 
typedef DefaultConstImageRange< SelfConstRange
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CConstImage< 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 >))
 
 ConstImageAdapter (ConstAlias< ImageContainer > anImage, ConstAlias< Domain > aDomain, ConstAlias< TFunctorD > aFD, ConstAlias< TFunctorV > aFV)
 
 ConstImageAdapter (const ConstImageAdapter &other)=default
 
ConstImageAdapteroperator= (const ConstImageAdapter &other)
 
 ~ConstImageAdapter ()
 
const Domaindomain () const
 
ConstRange constRange () const
 
Value operator() (const Point &aPoint) const
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 
std::string className () const
 
const ImageContainergetPointer () const
 
void setDefaultValue (Value aValue)
 
Value getDefaultValue () const
 

Protected Attributes

const ImageContainermyImagePtr
 Alias on the image container. More...
 
const DomainmySubDomainPtr
 
const TFunctorD * myFD
 
const TFunctorV * myFV
 
Value defaultValue
 

Private Member Functions

 ConstImageAdapter ()
 

Detailed Description

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

Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for domain, f for accessing point values.

Description of template class 'ConstImageAdapter'

This class is (like Image class) a lightweight proxy on any models of CConstImage. It uses a given Domain (i.e. a subdomain) but work directly (for accessing process) thanks to an alias (i.e. a pointer) on the original Image given in argument.

ConstImageAdapter class is also a model of CConstImage.

Caution :

  • the type of value of Point for the ConstImageAdapter 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 CConstImage).
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

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.

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

Examples
images/extract2DImagesFrom3D.cpp, images/extract2DImagesFrom3DandVisu.cpp, images/extract2DSlicesImagesFrom3D.cpp, io/viewers/viewer3D-8-2DSliceImages.cpp, and io/viewers/viewer3D-8bis-2Dimages.cpp.

Definition at line 105 of file ConstImageAdapter.h.

Member Typedef Documentation

◆ ConstRange

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

Definition at line 128 of file ConstImageAdapter.h.

◆ Domain

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

Definition at line 117 of file ConstImageAdapter.h.

◆ ImageContainer

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

Types copied from the container.

Definition at line 126 of file ConstImageAdapter.h.

◆ Point

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

Definition at line 118 of file ConstImageAdapter.h.

◆ Self

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

Definition at line 111 of file ConstImageAdapter.h.

◆ Value

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

Definition at line 119 of file ConstImageAdapter.h.

Constructor & Destructor Documentation

◆ ConstImageAdapter() [1/3]

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

Definition at line 134 of file ConstImageAdapter.h.

139  :
140  myImagePtr(&anImage), mySubDomainPtr(&aDomain), myFD(&aFD), myFV(&aFV)
141  {
142  defaultValue = 0;
143 #ifdef DEBUG_VERBOSE
144  trace.warning() << "ConstImageAdapter Ctor fromRef " << std::endl;
145 #endif
146  }
const ImageContainer * myImagePtr
Alias on the image container.
std::ostream & warning()
Trace trace
Definition: Common.h:153

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

◆ ConstImageAdapter() [2/3]

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

Default copy constructor.

Parameters
otherthe object to copy.

◆ ~ConstImageAdapter()

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::~ConstImageAdapter ( )
inline

Destructor. Does nothing

Definition at line 180 of file ConstImageAdapter.h.

180 {}

◆ ConstImageAdapter() [3/3]

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::ConstImageAdapter ( )
inlineprivate

Default constructor.

Definition at line 285 of file ConstImageAdapter.h.

285  {
286 #ifdef DEBUG_VERBOSE
287  trace.warning() << "ConstImageAdapter Ctor default " << std::endl;
288 #endif
289  }

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

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT() [1/4]

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::BOOST_CONCEPT_ASSERT ( (concepts::CConstImage< TImageContainer >)  )

Checking concepts.

◆ BOOST_CONCEPT_ASSERT() [2/4]

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::BOOST_CONCEPT_ASSERT ( (concepts::CDomain< TNewDomain >)  )

◆ BOOST_CONCEPT_ASSERT() [3/4]

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::BOOST_CONCEPT_ASSERT ( (concepts::CUnaryFunctor< TFunctorD, Point, typename TImageContainer::Point >)  )

◆ BOOST_CONCEPT_ASSERT() [4/4]

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::BOOST_CONCEPT_ASSERT ( (concepts::CUnaryFunctor< TFunctorV, typename TImageContainer::Value, Value >)  )

◆ className()

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
std::string DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::className ( ) const
Returns
the style name used for drawing this object.

◆ constRange()

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
ConstRange DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::constRange ( ) const
inline

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

Returns
a range.

Definition at line 203 of file ConstImageAdapter.h.

204  {
205  return ConstRange( *this );
206  }
DefaultConstImageRange< Self > ConstRange

◆ domain()

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
const Domain& DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::domain ( ) const
inline

Returns a reference to the underlying image domain.

Returns
a reference to the domain.

Definition at line 192 of file ConstImageAdapter.h.

193  {
194  return (*mySubDomainPtr);
195  }

References DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::mySubDomainPtr.

Referenced by DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::operator()().

◆ getDefaultValue()

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
Value DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::getDefaultValue ( ) const
inline

◆ getPointer()

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
const ImageContainer* DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::getPointer ( ) const
inline

Returns the pointer on the Image container data.

Returns
a const ImagePtr.

Definition at line 260 of file ConstImageAdapter.h.

261  {
262  return myImagePtr;
263  }

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

◆ isValid()

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
bool DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::isValid ( ) const
inline

Checks the validity/consistency of the object.

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

Definition at line 244 of file ConstImageAdapter.h.

245  {
246  return (myImagePtr->isValid() );
247  }

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

◆ operator()()

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
Value DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::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 220 of file ConstImageAdapter.h.

221  {
222  ASSERT(this->domain().isInside(aPoint));
223 
224  typename TImageContainer::Point point = myFD->operator()(aPoint);
225  if (myImagePtr->domain().isInside(point))
226  return myFV->operator()(myImagePtr->operator()(point));
227  else
228  return defaultValue;
229  }
const Domain & domain() const
const Point aPoint(3, 4)

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

◆ operator=()

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
ConstImageAdapter& DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::operator= ( const ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV > &  other)
inline

Assignment.

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

Definition at line 159 of file ConstImageAdapter.h.

160  {
161 #ifdef DEBUG_VERBOSE
162  trace.warning() << "ConstImageAdapter 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  defaultValue = other.defaultValue;
171  }
172  return *this;
173  }

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

◆ selfDisplay()

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
void DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::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 >
void DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::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 270 of file ConstImageAdapter.h.

271  {
272  defaultValue = aValue;
273  }

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

Field Documentation

◆ defaultValue

◆ myFD

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
const TFunctorD* DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::myFD
protected

◆ myFV

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
const TFunctorV* DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::myFV
protected

◆ myImagePtr

◆ mySubDomainPtr

template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
const Domain* DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::mySubDomainPtr
protected

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