DGtal 1.4.0
Loading...
Searching...
No Matches
DGtal::ImageContainerByITKImage< TDomain, TValue > Class Template Reference

Aim: implements a model of CImageContainer using a ITK Image. More...

#include <DGtal/images/ImageContainerByITKImage.h>

Public Types

typedef TValue Value
 
typedef TDomain Domain
 
typedef ImageContainerByITKImage< TDomain, TValue > Self
 
typedef Domain::Point Point
 
typedef Domain::Vector Vector
 
typedef Domain::Dimension Dimension
 
typedef Domain::Integer Integer
 
typedef Domain::Size Size
 
typedef Point Vertex
 
typedef PointVector< dimension, double > RealPoint
 
typedef RealPoint PhysicalPoint
 
typedef itk::Image< TValue, dimensionITKImage
 
typedef itk::ImageBase< dimension >::SpacingValueType ITKSpacingValueType
 
typedef RealPoint ImageSpacing
 
typedef ITKImage::Pointer ITKImagePointer
 
typedef ITKImage::PixelContainer Container
 
typedef itk::ImageRegionConstIterator< ITKImageConstIterator
 
typedef itk::ImageRegionIterator< ITKImageIterator
 
typedef DefaultConstImageRange< SelfConstRange
 
typedef DefaultImageRange< SelfRange
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CLabel< TValue >))
 
 BOOST_CONCEPT_ASSERT ((concepts::CDomain< TDomain >))
 
 ImageContainerByITKImage (const Domain &aDomain)
 
 ImageContainerByITKImage (const ITKImagePointer &aRef)
 
 ImageContainerByITKImage (const ImageContainerByITKImage &other)
 
ImageContainerByITKImageoperator= (const ImageContainerByITKImage &other)
 
 ~ImageContainerByITKImage ()
 
void updateDomain (const Point &inputDomainShift=Point())
 
ConstRange constRange () const
 
Range range ()
 
const Containercontainer () const
 
Containercontainer ()
 
Value operator() (const Point &domainPoint) const
 
Value operator() (const ConstIterator &it) const
 
Value operator() (const Iterator &it) const
 
void setValue (const Point &domainPoint, const Value &aValue)
 
void setValue (Iterator &it, const Value &V)
 
const Domaindomain () const
 
ITKImagePointer getITKImagePointer () const
 
const PointgetDomainShift () const
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 
ConstIterator begin () const
 
Iterator begin ()
 
const ConstIterator end () const
 
Iterator end ()
 
Point getDomainPointFromIndex (const Point &indexPoint) const
 
Point getIndexFromDomainPoint (const Point &domainPoint) const
 
Point getDomainPointFromItkIndex (const typename ITKImage::IndexType &itkIndexPoint) const
 
ITKImage::IndexType getItkIndexFromDomainPoint (const Point &domainPoint) const
 
PhysicalPoint getPhysicalPointFromDomainPoint (const Point &domainPoint) const
 
Point getDomainPointFromPhysicalPoint (const PhysicalPoint &physicalPoint) const
 
PhysicalPoint getLowerBoundAsPhysicalPoint () const
 
PhysicalPoint getUpperBoundAsPhysicalPoint () const
 
ImageSpacing getImageSpacing () const
 
void setImageSpacing (const ImageSpacing &s) const
 

Static Public Attributes

static const Domain::Dimension dimension = Domain::dimension
 

Protected Member Functions

 ImageContainerByITKImage ()
 

Private Attributes

ITKImagePointer myITKImagePointer
 
Domain myDomain
 
Point myDomainShift = Point()
 

Detailed Description

template<typename TDomain, typename TValue>
class DGtal::ImageContainerByITKImage< TDomain, TValue >

Aim: implements a model of CImageContainer using a ITK Image.

Description of template class 'ImageContainerByITKImage'

Using this container, you can switch from DGtal alogrithms to ITK processing pipeline. The Ownership of the underlying ITK image is shared between the wrapper and the ITK pipeline. If the ITK image region is modified, one should manually update the domain of the wrapper. This is done by calling the updateDomain() method.

See also
testITKImage.cpp

Definition at line 93 of file ImageContainerByITKImage.h.

Member Typedef Documentation

◆ ConstIterator

template<typename TDomain , typename TValue >
typedef itk::ImageRegionConstIterator< ITKImage > DGtal::ImageContainerByITKImage< TDomain, TValue >::ConstIterator

Definition at line 122 of file ImageContainerByITKImage.h.

◆ ConstRange

template<typename TDomain , typename TValue >
typedef DefaultConstImageRange<Self> DGtal::ImageContainerByITKImage< TDomain, TValue >::ConstRange

Definition at line 125 of file ImageContainerByITKImage.h.

◆ Container

template<typename TDomain , typename TValue >
typedef ITKImage::PixelContainer DGtal::ImageContainerByITKImage< TDomain, TValue >::Container

Definition at line 121 of file ImageContainerByITKImage.h.

◆ Dimension

template<typename TDomain , typename TValue >
typedef Domain::Dimension DGtal::ImageContainerByITKImage< TDomain, TValue >::Dimension

Definition at line 110 of file ImageContainerByITKImage.h.

◆ Domain

template<typename TDomain , typename TValue >
typedef TDomain DGtal::ImageContainerByITKImage< TDomain, TValue >::Domain

Definition at line 102 of file ImageContainerByITKImage.h.

◆ ImageSpacing

template<typename TDomain , typename TValue >
typedef RealPoint DGtal::ImageContainerByITKImage< TDomain, TValue >::ImageSpacing

Definition at line 119 of file ImageContainerByITKImage.h.

◆ Integer

template<typename TDomain , typename TValue >
typedef Domain::Integer DGtal::ImageContainerByITKImage< TDomain, TValue >::Integer

Definition at line 111 of file ImageContainerByITKImage.h.

◆ Iterator

template<typename TDomain , typename TValue >
typedef itk::ImageRegionIterator< ITKImage > DGtal::ImageContainerByITKImage< TDomain, TValue >::Iterator

Definition at line 123 of file ImageContainerByITKImage.h.

◆ ITKImage

template<typename TDomain , typename TValue >
typedef itk::Image< TValue, dimension> DGtal::ImageContainerByITKImage< TDomain, TValue >::ITKImage

Definition at line 117 of file ImageContainerByITKImage.h.

◆ ITKImagePointer

template<typename TDomain , typename TValue >
typedef ITKImage::Pointer DGtal::ImageContainerByITKImage< TDomain, TValue >::ITKImagePointer

Definition at line 120 of file ImageContainerByITKImage.h.

◆ ITKSpacingValueType

template<typename TDomain , typename TValue >
typedef itk::ImageBase<dimension>::SpacingValueType DGtal::ImageContainerByITKImage< TDomain, TValue >::ITKSpacingValueType

Definition at line 118 of file ImageContainerByITKImage.h.

◆ PhysicalPoint

template<typename TDomain , typename TValue >
typedef RealPoint DGtal::ImageContainerByITKImage< TDomain, TValue >::PhysicalPoint

Definition at line 115 of file ImageContainerByITKImage.h.

◆ Point

template<typename TDomain , typename TValue >
typedef Domain::Point DGtal::ImageContainerByITKImage< TDomain, TValue >::Point

Definition at line 108 of file ImageContainerByITKImage.h.

◆ Range

template<typename TDomain , typename TValue >
typedef DefaultImageRange<Self> DGtal::ImageContainerByITKImage< TDomain, TValue >::Range

Definition at line 126 of file ImageContainerByITKImage.h.

◆ RealPoint

template<typename TDomain , typename TValue >
typedef PointVector<dimension, double> DGtal::ImageContainerByITKImage< TDomain, TValue >::RealPoint

Definition at line 114 of file ImageContainerByITKImage.h.

◆ Self

template<typename TDomain , typename TValue >
typedef ImageContainerByITKImage<TDomain, TValue> DGtal::ImageContainerByITKImage< TDomain, TValue >::Self

Definition at line 103 of file ImageContainerByITKImage.h.

◆ Size

template<typename TDomain , typename TValue >
typedef Domain::Size DGtal::ImageContainerByITKImage< TDomain, TValue >::Size

Definition at line 112 of file ImageContainerByITKImage.h.

◆ Value

template<typename TDomain , typename TValue >
typedef TValue DGtal::ImageContainerByITKImage< TDomain, TValue >::Value

Definition at line 101 of file ImageContainerByITKImage.h.

◆ Vector

template<typename TDomain , typename TValue >
typedef Domain::Vector DGtal::ImageContainerByITKImage< TDomain, TValue >::Vector

Definition at line 109 of file ImageContainerByITKImage.h.

◆ Vertex

template<typename TDomain , typename TValue >
typedef Point DGtal::ImageContainerByITKImage< TDomain, TValue >::Vertex

Definition at line 113 of file ImageContainerByITKImage.h.

Constructor & Destructor Documentation

◆ ImageContainerByITKImage() [1/4]

template<typename TDomain , typename TValue >
DGtal::ImageContainerByITKImage< TDomain, TValue >::ImageContainerByITKImage ( const Domain & aDomain)

Constructor.

Parameters
aDomainthe image domain.

◆ ImageContainerByITKImage() [2/4]

template<typename TDomain , typename TValue >
DGtal::ImageContainerByITKImage< TDomain, TValue >::ImageContainerByITKImage ( const ITKImagePointer & aRef)

Constructor.

Parameters
aRefa reference to an ITKImage

◆ ImageContainerByITKImage() [3/4]

template<typename TDomain , typename TValue >
DGtal::ImageContainerByITKImage< TDomain, TValue >::ImageContainerByITKImage ( const ImageContainerByITKImage< TDomain, TValue > & other)

Copy constructor

Parameters
otherthe object to copy.

◆ ~ImageContainerByITKImage()

template<typename TDomain , typename TValue >
DGtal::ImageContainerByITKImage< TDomain, TValue >::~ImageContainerByITKImage ( )

Destructor.

◆ ImageContainerByITKImage() [4/4]

template<typename TDomain , typename TValue >
DGtal::ImageContainerByITKImage< TDomain, TValue >::ImageContainerByITKImage ( )
protected

Constructor. Forbidden by default (protected to avoid g++ warnings).

Member Function Documentation

◆ begin() [1/2]

template<typename TDomain , typename TValue >
Iterator DGtal::ImageContainerByITKImage< TDomain, TValue >::begin ( )
inline

begin() const iterator.

Definition at line 311 of file ImageContainerByITKImage.h.

312 {
313 Iterator iter = Iterator(myITKImagePointer, myITKImagePointer->GetLargestPossibleRegion());
314 iter.GoToBegin();
315 return iter;
316 }
itk::ImageRegionIterator< ITKImage > Iterator

References DGtal::ImageContainerByITKImage< TDomain, TValue >::myITKImagePointer.

◆ begin() [2/2]

template<typename TDomain , typename TValue >
ConstIterator DGtal::ImageContainerByITKImage< TDomain, TValue >::begin ( ) const
inline

begin() const iterator.

Definition at line 299 of file ImageContainerByITKImage.h.

300 {
301 ConstIterator iter = ConstIterator(myITKImagePointer, myITKImagePointer->GetLargestPossibleRegion());
302 iter.GoToBegin();
303 return iter;
304 }
itk::ImageRegionConstIterator< ITKImage > ConstIterator
MyDigitalSurface::ConstIterator ConstIterator

References DGtal::ImageContainerByITKImage< TDomain, TValue >::myITKImagePointer.

◆ BOOST_CONCEPT_ASSERT() [1/2]

template<typename TDomain , typename TValue >
DGtal::ImageContainerByITKImage< TDomain, TValue >::BOOST_CONCEPT_ASSERT ( (concepts::CDomain< TDomain >) )

◆ BOOST_CONCEPT_ASSERT() [2/2]

template<typename TDomain , typename TValue >
DGtal::ImageContainerByITKImage< TDomain, TValue >::BOOST_CONCEPT_ASSERT ( (concepts::CLabel< TValue >) )

◆ constRange()

template<typename TDomain , typename TValue >
ConstRange DGtal::ImageContainerByITKImage< TDomain, TValue >::constRange ( ) const
inline
Returns
the range providing begin and end iterators to scan the values of image.

Definition at line 182 of file ImageContainerByITKImage.h.

183 {
184 return ConstRange(*this);
185 }
DefaultConstImageRange< Self > ConstRange

◆ container() [1/2]

template<typename TDomain , typename TValue >
Container & DGtal::ImageContainerByITKImage< TDomain, TValue >::container ( )
inline

Give access to the underlying container.

Returns
a (might be const) reference to the container.

Definition at line 208 of file ImageContainerByITKImage.h.

209 {
210 return *(myITKImagePointer->GetPixelContainer());
211 }

References DGtal::ImageContainerByITKImage< TDomain, TValue >::myITKImagePointer.

◆ container() [2/2]

template<typename TDomain , typename TValue >
const Container & DGtal::ImageContainerByITKImage< TDomain, TValue >::container ( ) const
inline

Give access to the underlying container.

Returns
a (might be const) reference to the container.

Definition at line 200 of file ImageContainerByITKImage.h.

201 {
202 return *(myITKImagePointer->GetPixelContainer());
203 }

References DGtal::ImageContainerByITKImage< TDomain, TValue >::myITKImagePointer.

◆ domain()

template<typename TDomain , typename TValue >
const Domain & DGtal::ImageContainerByITKImage< TDomain, TValue >::domain ( ) const
inline
Returns
the domain associated to the image.

Definition at line 259 of file ImageContainerByITKImage.h.

260 {
261 return myDomain;
262 }

References DGtal::ImageContainerByITKImage< TDomain, TValue >::myDomain.

◆ end() [1/2]

template<typename TDomain , typename TValue >
Iterator DGtal::ImageContainerByITKImage< TDomain, TValue >::end ( )
inline

end() iterator.

Definition at line 335 of file ImageContainerByITKImage.h.

336 {
337 Iterator iter = Iterator(myITKImagePointer, myITKImagePointer->GetLargestPossibleRegion());
338 iter.GoToEnd();
339 return iter;
340 }

References DGtal::ImageContainerByITKImage< TDomain, TValue >::myITKImagePointer.

◆ end() [2/2]

template<typename TDomain , typename TValue >
const ConstIterator DGtal::ImageContainerByITKImage< TDomain, TValue >::end ( ) const
inline

end() const iterator.

Definition at line 323 of file ImageContainerByITKImage.h.

324 {
325 ConstIterator iter = ConstIterator(myITKImagePointer, myITKImagePointer->GetLargestPossibleRegion());
326 iter.GoToEnd();
327 return iter;
328 }

References DGtal::ImageContainerByITKImage< TDomain, TValue >::myITKImagePointer.

◆ getDomainPointFromIndex()

template<typename TDomain , typename TValue >
Point DGtal::ImageContainerByITKImage< TDomain, TValue >::getDomainPointFromIndex ( const Point & indexPoint) const
inline

IndexPoint refers to a valid ITKImage::IndexPoint DomainPoint refers to a Point between lowerBound and upperBound of myDomain. They are different only when myDomainShift is different than Zero.

Parameters
indexPointa point holding valid index coordinates of the ITK image.
Returns
domainPoint a point between lowerBound and upperBound

◆ getDomainPointFromItkIndex()

template<typename TDomain , typename TValue >
Point DGtal::ImageContainerByITKImage< TDomain, TValue >::getDomainPointFromItkIndex ( const typename ITKImage::IndexType & itkIndexPoint) const
inline

The same as getDomainPointFromItkIndex and getIndexFromDomainPoint but using ITK types.

Parameters
itkIndexPointan IndexType of ITK.
Returns
domainPoint a point between lowerBound and upperBound

◆ getDomainPointFromPhysicalPoint()

template<typename TDomain , typename TValue >
Point DGtal::ImageContainerByITKImage< TDomain, TValue >::getDomainPointFromPhysicalPoint ( const PhysicalPoint & physicalPoint) const
inline

◆ getDomainShift()

template<typename TDomain , typename TValue >
const Point & DGtal::ImageContainerByITKImage< TDomain, TValue >::getDomainShift ( ) const
inline

◆ getImageSpacing()

template<typename TDomain , typename TValue >
ImageSpacing DGtal::ImageContainerByITKImage< TDomain, TValue >::getImageSpacing ( ) const
inline

Get the image spacing specific to the ITK Image.

Returns
spacing values for each dimension of the image.

◆ getIndexFromDomainPoint()

template<typename TDomain , typename TValue >
Point DGtal::ImageContainerByITKImage< TDomain, TValue >::getIndexFromDomainPoint ( const Point & domainPoint) const
inline

◆ getITKImagePointer()

template<typename TDomain , typename TValue >
ITKImagePointer DGtal::ImageContainerByITKImage< TDomain, TValue >::getITKImagePointer ( ) const
inline

Returns a copy of the itkImage smartPointer

Definition at line 268 of file ImageContainerByITKImage.h.

269 {
270 return myITKImagePointer;
271 }

References DGtal::ImageContainerByITKImage< TDomain, TValue >::myITKImagePointer.

◆ getItkIndexFromDomainPoint()

template<typename TDomain , typename TValue >
ITKImage::IndexType DGtal::ImageContainerByITKImage< TDomain, TValue >::getItkIndexFromDomainPoint ( const Point & domainPoint) const
inline

◆ getLowerBoundAsPhysicalPoint()

template<typename TDomain , typename TValue >
PhysicalPoint DGtal::ImageContainerByITKImage< TDomain, TValue >::getLowerBoundAsPhysicalPoint ( ) const
inline

Returns the lower and upper bounds as physical points. Note that the location of pixels in ITK are in the center of the square. But in DGtal a lowerBound is in the south-west corner of that square. And an upperBound is the north-east corner of the last pixel.

Returns
physical point of the location of the start index of the region.

◆ getPhysicalPointFromDomainPoint()

template<typename TDomain , typename TValue >
PhysicalPoint DGtal::ImageContainerByITKImage< TDomain, TValue >::getPhysicalPointFromDomainPoint ( const Point & domainPoint) const
inline

Get PhysicalPoints from a domain point in DGtal and viceversa.

Remember that GetOrigin() in ITK is the physical location of the index {0,0...}. Not the location of the start index of the region.

Parameters
domainPointa point holding a point in the DGtal domain. It will be converted to a valid index of the ITK image, taking into account the value of myDomainShift.
Returns
physical point of the index.

◆ getUpperBoundAsPhysicalPoint()

template<typename TDomain , typename TValue >
PhysicalPoint DGtal::ImageContainerByITKImage< TDomain, TValue >::getUpperBoundAsPhysicalPoint ( ) const
inline

◆ isValid()

template<typename TDomain , typename TValue >
bool DGtal::ImageContainerByITKImage< TDomain, TValue >::isValid ( ) const

Checks the validity/consistency of the object.

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

◆ operator()() [1/3]

template<typename TDomain , typename TValue >
Value DGtal::ImageContainerByITKImage< TDomain, TValue >::operator() ( const ConstIterator & it) const

Get the value of an image at a given position.

Parameters
itposition in the image.
Returns
the value of the point pointed by the iterator.

◆ operator()() [2/3]

template<typename TDomain , typename TValue >
Value DGtal::ImageContainerByITKImage< TDomain, TValue >::operator() ( const Iterator & it) const

Get the value of an image at a given position.

Parameters
itposition in the image.
Returns
the value of the point pointed by the iterator.

◆ operator()() [3/3]

template<typename TDomain , typename TValue >
Value DGtal::ImageContainerByITKImage< TDomain, TValue >::operator() ( const Point & domainPoint) const

Get the value of an image at a given position.

Parameters
domainPointposition in the image.
Returns
the value at indexPoint.

◆ operator=()

template<typename TDomain , typename TValue >
ImageContainerByITKImage & DGtal::ImageContainerByITKImage< TDomain, TValue >::operator= ( const ImageContainerByITKImage< TDomain, TValue > & other)

Assignment.

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

◆ range()

template<typename TDomain , typename TValue >
Range DGtal::ImageContainerByITKImage< TDomain, TValue >::range ( )
inline
Returns
the range providing begin and end iterators to scan the values of image.

Definition at line 191 of file ImageContainerByITKImage.h.

192 {
193 return Range(*this);
194 }

◆ selfDisplay()

template<typename TDomain , typename TValue >
void DGtal::ImageContainerByITKImage< TDomain, TValue >::selfDisplay ( std::ostream & out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

◆ setImageSpacing()

template<typename TDomain , typename TValue >
void DGtal::ImageContainerByITKImage< TDomain, TValue >::setImageSpacing ( const ImageSpacing & s) const
inline

Set the image spacing specific to the ITK Image.

Parameters
san image spacing point representing the spacing values of each dimension of the space.

◆ setValue() [1/2]

template<typename TDomain , typename TValue >
void DGtal::ImageContainerByITKImage< TDomain, TValue >::setValue ( const Point & domainPoint,
const Value & aValue )

Set a value on an Image at domainPoint.

Parameters
domainPointlocation of the point to associate with aValue.
aValuethe value.

◆ setValue() [2/2]

template<typename TDomain , typename TValue >
void DGtal::ImageContainerByITKImage< TDomain, TValue >::setValue ( Iterator & it,
const Value & V )

Set a value on an Image at a given position

Parameters
itlocation of the point (Iterator) to associate with aValue.
Vthe value.

◆ updateDomain()

template<typename TDomain , typename TValue >
void DGtal::ImageContainerByITKImage< TDomain, TValue >::updateDomain ( const Point & inputDomainShift = Point())

update internal domain cache. should be called after modifying underlying ITK image or to set myDomainShift.

Parameters
inputDomainShiftapplies a domainShift to the lowerBound and upperBound of myDomain.
See also
myDomainShift

Field Documentation

◆ dimension

template<typename TDomain , typename TValue >
const Domain::Dimension DGtal::ImageContainerByITKImage< TDomain, TValue >::dimension = Domain::dimension
static

Definition at line 106 of file ImageContainerByITKImage.h.

◆ myDomain

template<typename TDomain , typename TValue >
Domain DGtal::ImageContainerByITKImage< TDomain, TValue >::myDomain
private

◆ myDomainShift

template<typename TDomain , typename TValue >
Point DGtal::ImageContainerByITKImage< TDomain, TValue >::myDomainShift = Point()
private

Apply a shift in the lower and upper bounds. Useful to represent multiple images, or images with physical information, i.e with non-default Origin (see ITK for Origin, Spacing and Direction metadata)

Set it using the function updateDomain(inputDomainShift)

Please note that this is a workaround, DGtal cannot fully work in the Physical Domain. The spacing in DGtal is fixed to 1. This allows to work to represent multiple images with different Origins, but they need to have the same Spacing and Direction for the visualization to be meaningful.

Default to zero.

When is not zero, use getIndexFromDomainPoint and getDomainPointFromIndex to switch between points in the domain and indices in the itk image.

Definition at line 442 of file ImageContainerByITKImage.h.

Referenced by DGtal::ImageContainerByITKImage< TDomain, TValue >::getDomainShift().

◆ myITKImagePointer


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