DGtal 2.0.0
Loading...
Searching...
No Matches
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.
typedef DefaultConstImageRange< SelfConstRange
typedef DefaultImageRange< SelfRange

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CImage< TImageContainer >))
 Checking concepts.
 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.
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:

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

◆ 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 :
147 {
148 defaultValue = 0;
149#ifdef DEBUG_VERBOSE
150 trace.warning() << "ImageAdapter Ctor fromRef " << std::endl;
151#endif
152 }
Aim: implements an image adapter with a given domain (i.e. a subdomain) and 3 functors : g for domain...
const TFunctorVm1 * myFVm1
ImageContainer * myImagePtr
Alias on the image container.
const Domain * mySubDomainPtr
const TFunctorV * myFV
const TFunctorD * myFD

References defaultValue, myFD, myFV, myFVm1, myImagePtr, mySubDomainPtr, and DGtal::trace.

Referenced by ImageAdapter(), and operator=().

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

References ImageAdapter().

◆ ~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.

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

◆ 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

Returns a reference to the underlying image domain.

Returns
a reference to the domain.

Definition at line 199 of file ImageAdapter.h.

200 {
201 return (*mySubDomainPtr);
202 }

References mySubDomainPtr.

Referenced by operator()(), and setValue().

◆ 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

Definition at line 307 of file ImageAdapter.h.

308 {
309 return defaultValue;
310 }

References defaultValue.

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

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

239 {
240 ASSERT(this->domain().isInside(aPoint));
241
242 typename TImageContainer::Point point = myFD->operator()(aPoint);
243 if (myImagePtr->domain().isInside(point))
244 return myFV->operator()(myImagePtr->operator()(point));
245 else
246 return defaultValue;
247 }
const Domain & domain() const

References aPoint, defaultValue, domain(), myFD, myFV, and myImagePtr.

◆ 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

Assignment.

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

Definition at line 165 of file ImageAdapter.h.

166 {
167#ifdef DEBUG_VERBOSE
168 trace.warning() << "ImageAdapter assignment " << std::endl;
169#endif
170 if (&other != this)
171 {
174 myFD = other.myFD;
175 myFV = other.myFV;
178 }
179 return *this;
180 }

References defaultValue, ImageAdapter(), myFD, myFV, myFVm1, myImagePtr, mySubDomainPtr, and DGtal::trace.

◆ 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

◆ 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 {
305 }

References 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

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

262 {
263 ASSERT(this->domain().isInside(aPoint));
264
265 myImagePtr->setValue(myFD->operator()(aPoint), myFVm1->operator()(aValue));
266 }

References aPoint, domain(), myFD, myFVm1, and myImagePtr.

Field Documentation

◆ defaultValue

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

Default value returned when point transformed by image functor does not belongs to image. Initial value is 0.

Definition at line 353 of file ImageAdapter.h.

Referenced by getDefaultValue(), ImageAdapter(), operator()(), operator=(), and setDefaultValue().

◆ 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

Aliasing pointer on the underlying Domain functor

Definition at line 337 of file ImageAdapter.h.

Referenced by ImageAdapter(), operator()(), operator=(), and setValue().

◆ 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

Aliasing pointer on the underlying Value functor

Definition at line 342 of file ImageAdapter.h.

Referenced by ImageAdapter(), operator()(), and operator=().

◆ 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

Aliasing pointer on the underlying "m-1" Value functor

Definition at line 347 of file ImageAdapter.h.

Referenced by ImageAdapter(), operator=(), and setValue().

◆ myImagePtr

template<typename TImageContainer, typename TNewDomain, typename TFunctorD, typename TNewValue, typename TFunctorV, typename TFunctorVm1>
ImageContainer* DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::myImagePtr
protected

Alias on the image container.

Definition at line 327 of file ImageAdapter.h.

Referenced by getPointer(), ImageAdapter(), isValid(), operator()(), operator=(), and setValue().

◆ 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 image SubDomain

Definition at line 332 of file ImageAdapter.h.

Referenced by domain(), ImageAdapter(), and operator=().


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