DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Protected Attributes | Private Member Functions
DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV > Class Template Reference

#include <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
typedef DefaultConstImageRange
< Self
ConstRange

Public Member Functions

 BOOST_CONCEPT_ASSERT ((CImage< TImageContainer >))
 BOOST_CONCEPT_ASSERT ((CDomain< TNewDomain >))
 BOOST_CONCEPT_ASSERT ((CUnaryFunctor< TFunctorD, typename TImageContainer::Point, Point >))
 BOOST_CONCEPT_ASSERT ((CUnaryFunctor< TFunctorV, typename TImageContainer::Value, Value >))
 ConstImageAdapter (ImageContainer &anImage, const Domain &aDomain, const TFunctorD &aFD, const TFunctorV &aFV)
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
const ImageContainergetPointer () const

Protected Attributes

const ImageContainermyImagePtr
const DomainmySubDomainPtr
const TFunctorD * myFD
const TFunctorV * myFV

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

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 image adapter that is a thresholded view of the initial scalar image:

DefaultFunctor g;
Thresholder<Image::Value> t( thresholdValue );
ConstImageAdapter<Image, Domain, DefaultFunctor, bool, Thresholder<Image::Value> > a(img, d, g, t);

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

Definition at line 105 of file ConstImageAdapter.h.


Member Typedef Documentation

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 127 of file ConstImageAdapter.h.

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.

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 125 of file ConstImageAdapter.h.

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.

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.

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

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

Definition at line 133 of file ConstImageAdapter.h.

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

:
myImagePtr(&anImage), mySubDomainPtr(&aDomain), myFD(&aFD), myFV(&aFV)
{
#ifdef DEBUG_VERBOSE
trace.warning() << "ConstImageAdapter Ctor fromRef " << std::endl;
#endif
}
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 166 of file ConstImageAdapter.h.

{}
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 249 of file ConstImageAdapter.h.

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

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

Member Function Documentation

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

Checking concepts.

template<typename TImageContainer, typename TNewDomain, typename TFunctorD, typename TNewValue, typename TFunctorV>
DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::BOOST_CONCEPT_ASSERT ( (CDomain< TNewDomain >)  )
template<typename TImageContainer, typename TNewDomain, typename TFunctorD, typename TNewValue, typename TFunctorV>
DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::BOOST_CONCEPT_ASSERT ( (CUnaryFunctor< TFunctorD, typename TImageContainer::Point, Point >)  )
template<typename TImageContainer, typename TNewDomain, typename TFunctorD, typename TNewValue, typename TFunctorV>
DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::BOOST_CONCEPT_ASSERT ( (CUnaryFunctor< TFunctorV, typename TImageContainer::Value, Value >)  )
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 189 of file ConstImageAdapter.h.

{
return ConstRange( *this );
}
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 178 of file ConstImageAdapter.h.

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

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

{
return (*mySubDomainPtr);
}
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 239 of file ConstImageAdapter.h.

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

{
return myImagePtr;
}
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.
the validity of the Image

Definition at line 229 of file ConstImageAdapter.h.

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

{
return (myImagePtr->isValid() );
}
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 206 of file ConstImageAdapter.h.

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

{
ASSERT(this->domain().isInside(aPoint));
return myFV->operator()(myImagePtr->operator()(myFD->operator()(aPoint)));
}
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 146 of file ConstImageAdapter.h.

References 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().

{
#ifdef DEBUG_VERBOSE
trace.warning() << "ConstImageAdapter assignment " << std::endl;
#endif
if (&other != this)
{
myFD = other.myFD;
myFV = other.myFV;
}
return *this;
}
template<typename TImageContainer , typename TNewDomain , typename TFunctorD , typename TNewValue , typename TFunctorV >
void DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::selfDisplay ( std::ostream &  out) const
inline

Writes/Displays the object on an output stream.

Parameters:
outthe output stream where the object is written.

Definition at line 57 of file ConstImageAdapter.ih.

{
out << "[ConstImageAdapter] " << (*myImagePtr);
}

Field Documentation

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

Aliasing pointer on the underlying Domain functor

Definition at line 269 of file ConstImageAdapter.h.

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

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

Aliasing pointer on the underlying Value functor

Definition at line 274 of file ConstImageAdapter.h.

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

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

Alias on the image container.

Definition at line 259 of file ConstImageAdapter.h.

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

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

The image SubDomain

Definition at line 264 of file ConstImageAdapter.h.

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


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