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::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 > Class Template Reference

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

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< TFunctorVm1, typename TImageContainer::Value, Value >))
 ImageAdapter (ImageContainer &anImage, const Domain &aDomain, const TFunctorD &aFD, const TFunctorV &aFV, const 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 typename TImageContainer::Value &aValue)
void selfDisplay (std::ostream &out) const
bool isValid () const
const ImageContainergetPointer () const

Protected Attributes

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

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

Here is the construction of a simple image adapter that is a thresholded view of the initial scalar image:

typedef ImageAdapter<VImage, Z2i::Domain, DefaultFunctor, bool, DefaultFunctor, Thresholder<VImage::Value> > MyImageAdapter2;
DefaultFunctor idD_2, idV_2;
Thresholder<VImage::Value> idVm1_2( 4 );
MyImageAdapter2 restimage2(image, domain, idD_2, idV_2, idVm1_2);

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 112 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 134 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 124 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 132 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 125 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 135 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 118 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 126 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,
const Domain aDomain,
const TFunctorD &  aFD,
const TFunctorV &  aFV,
const TFunctorVm1 &  aFVm1 
)
inline

Definition at line 141 of file ImageAdapter.h.

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

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

{}
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 288 of file ImageAdapter.h.

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

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

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 ( (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 ( (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 ( (CUnaryFunctor< TFunctorD, typename TImageContainer::Point, 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 ( (CUnaryFunctor< TFunctorVm1, typename TImageContainer::Value, 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 198 of file ImageAdapter.h.

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

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

Referenced by DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::operator()(), and DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::setValue().

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

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

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

Definition at line 268 of file ImageAdapter.h.

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

{
return (myImagePtr->isValid() );
}
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 226 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 >::myFV, and DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::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, 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 154 of file ImageAdapter.h.

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

{
#ifdef DEBUG_VERBOSE
trace.warning() << "ImageAdapter assignment " << std::endl;
#endif
if (&other != this)
{
myFD = other.myFD;
myFV = other.myFV;
myFVm1 = other.myFVm1;
}
return *this;
}
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 209 of file ImageAdapter.h.

{
return Range( *this );
}
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
inline

Writes/Displays the object on an output stream.

Parameters:
outthe output stream where the object is written.

Definition at line 57 of file ImageAdapter.ih.

{
out << "[ImageAdapter] " << (*myImagePtr);
}
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 typename TImageContainer::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 244 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.

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

Field Documentation

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

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

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

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

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

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

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

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

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

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


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