OpenStructure
Public Member Functions | Friends
ImageHandle Class Reference

#include <image_handle.hh>

Inherits Data.

Public Member Functions

 ImageHandle ()
 
 ImageHandle (const ImageHandle &h)
 
ImageHandleoperator= (const ImageHandle &h)
 
ImageHandle Copy (bool cc=true) const
 
ImageHandle Extract (const Extent &e) const
 
void Paste (const Data &d)
 
void Set (const ImageHandle &h)
 
void Swap (ImageHandle &h)
 
void Reset (const Extent &e, DataType type=REAL, DataDomain dom=SPATIAL)
 
bool IsValid () const
 
long MemSize () const
 
Properties interface
virtual DataType GetType () const
 
virtual DataDomain GetDomain () const
 
virtual Extent GetExtent () const
 
virtual Point GetSpatialOrigin () const
 
void SetSpatialOrigin (const Point &p)
 
void CenterSpatialOrigin ()
 
Vec3 GetAbsoluteOrigin () const
 
void SetAbsoluteOrigin (const Vec3 &c)
 
Vec3 IndexToCoord (const Point &p) const
 
Vec3 CoordToIndex (const Vec3 &c) const
 
Vec3 FractionalIndexToCoord (const Vec3 &p) const
 
Value access

All value access with these getters/setters is boundary-checked; as a consequence, reading outside of the defined region will return 0, and writing outside is silently ignored.

virtual Real GetReal (const Point &p) const
 
void SetReal (const Point &p, Real r)
 
virtual Complex GetComplex (const Point &p) const
 
void SetComplex (const Point &p, const Complex &c)
 
virtual Real GetIntpolReal (const Vec3 &v) const
 
virtual Real GetIntpolReal (const Vec2 &v) const
 
virtual Real GetIntpolReal (const Real &d) const
 
virtual Complex GetIntpolComplex (const Vec3 &v) const
 
virtual Complex GetIntpolComplex (const Vec2 &v) const
 
virtual Complex GetIntpolComplex (const Real &d) const
 
DataObserver interface

Allows (de)registration of a DataObserver as well as broadcasting a notification to all attached observers.

virtual void Attach (DataObserver *o) const
 
virtual void Detach (DataObserver *o) const
 
virtual void Notify () const
 
virtual void Notify (const Extent &e) const
 
virtual void Notify (const Point &p) const
 
DataAlgorithm interface

A collection of methods that form the main interaction between the underlying image and algorithms derived from one of the abstract algorithm classes.

void Apply (NonModAlgorithm &a) const
 
void ApplyIP (NonModAlgorithm &a) const
 
void ApplyIP (ModIPAlgorithm &a)
 
ImageHandle Apply (ModIPAlgorithm &a) const
 
void ApplyIP (const ConstModIPAlgorithm &a)
 
ImageHandle Apply (const ConstModIPAlgorithm &a) const
 
void ApplyIP (ModOPAlgorithm &a)
 
ImageHandle Apply (ModOPAlgorithm &a) const
 
void ApplyIP (const ConstModOPAlgorithm &a)
 
ImageHandle Apply (const ConstModOPAlgorithm &a) const
 
StateVisitor interface

Allows access to underlying image state via ImageStateVisitor pattern.

void StateApply (ImageStateNonModVisitorBase &v) const
 
void StateApplyIP (ImageStateModIPVisitorBase &v)
 
ImageHandle StateApply (ImageStateModIPVisitorBase &v) const
 
void StateApplyIP (const ImageStateConstModIPVisitorBase &v)
 
ImageHandle StateApply (const ImageStateConstModIPVisitorBase &v) const
 
void StateApplyIP (ImageStateModOPVisitorBase &v)
 
ImageHandle StateApply (ImageStateModOPVisitorBase &v) const
 
void StateApplyIP (const ImageStateConstModOPVisitorBase &v)
 
ImageHandle StateApply (const ImageStateConstModOPVisitorBase &v) const
 
void StateApplyIP (ImageStateMorphVisitorBase &v)
 
ImageHandle StateApply (ImageStateMorphVisitorBase &v) const
 
ExtentIterator GetIterator () const
 
Comparison

Returns true if this handle and reference handle point to the same image, false otherwise

bool operator== (const ImageHandle &ih) const
 
bool operator!= (const ImageHandle &ih) const
 
Member operators
ImageHandleoperator+= (Real v)
 
ImageHandleoperator+= (const Complex &v)
 
ImageHandleoperator-= (Real v)
 
ImageHandleoperator-= (const Complex &v)
 
ImageHandleoperator*= (Real v)
 
ImageHandleoperator*= (const Complex &v)
 
ImageHandleoperator/= (Real v)
 
ImageHandleoperator/= (const Complex &v)
 
void Reciproce ()
 
ImageHandleoperator+= (const ConstImageHandle &h)
 
ImageHandleoperator-= (const ConstImageHandle &h)
 
ImageHandleoperator*= (const ConstImageHandle &h)
 
ImageHandleoperator/= (const ConstImageHandle &h)
 
- Public Member Functions inherited from Data
 Data ()
 
virtual ~Data ()
 
void SetPixelSampling (const Vec3 &)
 
void SetPixelSampling (Real d)
 
void SetSpatialSampling (const Vec3 &)
 
void SetSpatialSampling (Real d)
 
- Public Member Functions inherited from ConstData
 ConstData ()
 
virtual ~ConstData ()
 
bool IsSpatial () const
 
bool IsFrequency () const
 
bool IsReal () const
 
bool IsComplex () const
 
Size GetSize () const
 
virtual Real OverallDifference (const ConstData &d) const
 
virtual Real NormDifference (const ConstData &d) const
 
Vec3 GetPixelSampling () const
 
Vec3 GetSpatialSampling () const
 
Vec3 GetFrequencySampling () const
 

Friends

class ConstImageHandle
 
ImageHandle DoCreateImage (const Extent &e, DataType type, DataDomain dom)
 
void test_image::test_Observer ()
 

low-level access

ImageStateBasePtr & ImageStatePtr ()
 
const ImageStateBasePtr & ImageStatePtr () const
 
 ImageHandle (const StatePtrPtr &spp)
 
virtual PixelSamplingSampling ()
 
virtual const PixelSamplingSampling () const
 
static ImageHandle Create (const Extent &e, DataType type, DataDomain dom)
 

Additional Inherited Members

- Protected Member Functions inherited from Data
 Data (const Data &d)
 
Dataoperator= (const Data &d)
 
- Protected Member Functions inherited from ConstData
void CalcIntpolWeights (Vec3 v, Real w[8], Point p[8]) const
 
 ConstData (const ConstData &d)
 
ConstDataoperator= (const ConstData &d)
 

Detailed Description

Manage shared instances of images.

An ImageHandle is used to access an underlying implementation of an image. ImageHandle uses reference counting, ie copy and assignement return a new handle which points to the same image. This makes it cheap to pass ImageHandle around as value. The resources allocated by the underlying image implementation will be freed as soon as the reference count drops to zero.

ImageHandle derives from Data and thus implements its interface. It extends it to include image specific functionality. ImageHandle does shared_ptr management of an ImageImpl instance. The observer functionality is implemented in parallel using shared_ptr as well, so that the set of observers is preserved among the shared ImageHandles.

Creating a new image is done with the CreateImage() function:

ImageHandle ih = CreateImage(Extent(Point(0,0),Size(10,10)));
ImageHandle()
Creates an empty, ie invalid handle.
ImageHandle DLLEXPORT_OST_IMG_BASE CreateImage(const Extent &ext=Extent(), DataType type=REAL, DataDomain dom=SPATIAL)
Create image from scratch.

To import and export an image from or to a file, the IOManager must be used.

All image manipulation routines are provided as algorithms, which are applied with the Apply() and ApplyIP() methods.

Definition at line 111 of file image_handle.hh.

Constructor & Destructor Documentation

◆ ImageHandle() [1/3]

Creates an empty, ie invalid handle.

The default ctor is provided for e.g. using ImageHandle in STL containers. Any attempt to use the interface of an empty ImageHandle will throw an InvalidImageHandle exception.

◆ ImageHandle() [2/3]

ImageHandle ( const ImageHandle h)

Initialize with an existing handle.

The newly created handle will share the image with the existing one

◆ ImageHandle() [3/3]

ImageHandle ( const StatePtrPtr &  spp)
protected

Initialization based on a StatePtrPtr.

Member Function Documentation

◆ Apply() [1/5]

ImageHandle Apply ( const ConstModIPAlgorithm a) const

Apply in-place const Algorithm, return new image with modifications.

The modifications will be done on a copy of this image, which is then returned.

◆ Apply() [2/5]

ImageHandle Apply ( const ConstModOPAlgorithm a) const

Apply out-of-place const Algorithm.

The image modified by the out-of-place algorithm is returned.

◆ Apply() [3/5]

ImageHandle Apply ( ModIPAlgorithm a) const

Apply in-place Algorithm, return new image with modifications.

The modifications will be done on a copy of this image, which is then returned.

◆ Apply() [4/5]

ImageHandle Apply ( ModOPAlgorithm a) const

Apply out-of-place Algorithm.

The image modified by the out-of-place algorithm is returned.

◆ Apply() [5/5]

void Apply ( NonModAlgorithm a) const
virtual

Apply a const algorithm to this image.

Calls the implemented NonModAlgorithm::Visit(const ImageHandle&) method

Implements Data.

◆ ApplyIP() [1/5]

void ApplyIP ( const ConstModIPAlgorithm a)

Apply in-place const Algorithm in-place.

◆ ApplyIP() [2/5]

void ApplyIP ( const ConstModOPAlgorithm a)

Apply out-of-place const Algorithm in-place.

The new image returned by the out-of-place algorithm will replace the current one. This replacement will of course reflect in all ImageHandle s that point to the same Image.

◆ ApplyIP() [3/5]

void ApplyIP ( ModIPAlgorithm a)

Apply in-place Algorithm in-place.

◆ ApplyIP() [4/5]

void ApplyIP ( ModOPAlgorithm a)

Apply out-of-place Algorithm in-place.

The new image returned by the out-of-place algorithm will replace the current one. This replacement will of course reflect in all ImageHandle s that point to the same Image.

◆ ApplyIP() [5/5]

void ApplyIP ( NonModAlgorithm a) const
virtual

Apply a const algorithm to this image.

This does exactly the same as ImageHandle::Apply(NonModAlgorithm &) and is provided for syntax consistency.

Implements Data.

◆ Attach()

virtual void Attach ( DataObserver o) const
virtual

Attach observer.

Implements ConstData.

◆ CenterSpatialOrigin()

void CenterSpatialOrigin ( )

set origin in center

◆ CoordToIndex()

Vec3 CoordToIndex ( const Vec3 &  c) const

Convert coordinates back to (fractional) indices.

◆ Copy()

ImageHandle Copy ( bool  cc = true) const

return a handle that manages a new instance of the image

Similar to the Clone concept, the ImageHandle that is returned points to a duplicated image instance

◆ Create()

static ImageHandle Create ( const Extent e,
DataType  type,
DataDomain  dom 
)
staticprotected

used by CreateImage factory function

◆ Detach()

virtual void Detach ( DataObserver o) const
virtual

Detach observer.

Implements ConstData.

◆ Extract()

ImageHandle Extract ( const Extent e) const

return a handle to a new image containing a partial copy

The returning domain will match the type (ie REAL or COMPLEX), but the domain will always be spatial

◆ FractionalIndexToCoord()

Vec3 FractionalIndexToCoord ( const Vec3 &  p) const

Index to coordinate conversion.

◆ GetAbsoluteOrigin()

Vec3 GetAbsoluteOrigin ( ) const

Get absolute coordinate for the spatial origin of the image.

◆ GetComplex()

virtual Complex GetComplex ( const Point p) const
virtual

Retrieve value at given Point as a Complex.

Implements ConstData.

◆ GetDomain()

virtual DataDomain GetDomain ( ) const
virtual

Return domain: SPATIAL, FREQUENCY or HALF_FREQUENCY.

Implements ConstData.

◆ GetExtent()

virtual Extent GetExtent ( ) const
virtual

retrieve Extent

The extent that is returned here is the logical extent.

Implements ConstData.

◆ GetIntpolComplex() [1/3]

virtual Complex GetIntpolComplex ( const Real d) const
virtual

Implements ConstData.

◆ GetIntpolComplex() [2/3]

virtual Complex GetIntpolComplex ( const Vec2 &  v) const
virtual

Implements ConstData.

◆ GetIntpolComplex() [3/3]

virtual Complex GetIntpolComplex ( const Vec3 &  v) const
virtual

Get interpolated complex value from 3D,2D or 1D vec.

Implements ConstData.

◆ GetIntpolReal() [1/3]

virtual Real GetIntpolReal ( const Real d) const
virtual

Implements ConstData.

◆ GetIntpolReal() [2/3]

virtual Real GetIntpolReal ( const Vec2 &  v) const
virtual

Implements ConstData.

◆ GetIntpolReal() [3/3]

virtual Real GetIntpolReal ( const Vec3 &  v) const
virtual

Get interpolated real value from 3D,2D or 1D vec.

Implements ConstData.

◆ GetIterator()

ExtentIterator GetIterator ( ) const

◆ GetReal()

virtual Real GetReal ( const Point p) const
virtual

Retrieve value at given Point as a Real.

Implements ConstData.

◆ GetSpatialOrigin()

virtual Point GetSpatialOrigin ( ) const
virtual

return spatial origin of the image

The spatial origin is independent on the current domain. It affects the FFT operations by introducing a origin-dependent phase shift for each value in the frequency domain.

Implements ConstData.

◆ GetType()

virtual DataType GetType ( ) const
virtual

Return data type: REAL or COMPLEX.

Implements ConstData.

◆ ImageStatePtr() [1/2]

ImageStateBasePtr& ImageStatePtr ( )

◆ ImageStatePtr() [2/2]

const ImageStateBasePtr& ImageStatePtr ( ) const

◆ IndexToCoord()

Vec3 IndexToCoord ( const Point p) const

Index to coordinate conversion.

◆ IsValid()

bool IsValid ( ) const

Returns true if handle is valid.

◆ MemSize()

long MemSize ( ) const

Returns size in bytes of allocated memory.

◆ Notify() [1/3]

virtual void Notify ( ) const
virtual

Notify each observer that state has changed.

Implements ConstData.

◆ Notify() [2/3]

virtual void Notify ( const Extent e) const
virtual

◆ Notify() [3/3]

virtual void Notify ( const Point p) const
virtual

◆ operator!=()

bool operator!= ( const ImageHandle ih) const

◆ operator*=() [1/3]

ImageHandle& operator*= ( const Complex v)

◆ operator*=() [2/3]

ImageHandle& operator*= ( const ConstImageHandle h)

◆ operator*=() [3/3]

ImageHandle& operator*= ( Real  v)

◆ operator+=() [1/3]

ImageHandle& operator+= ( const Complex v)

◆ operator+=() [2/3]

ImageHandle& operator+= ( const ConstImageHandle h)

◆ operator+=() [3/3]

ImageHandle& operator+= ( Real  v)

◆ operator-=() [1/3]

ImageHandle& operator-= ( const Complex v)

◆ operator-=() [2/3]

ImageHandle& operator-= ( const ConstImageHandle h)

◆ operator-=() [3/3]

ImageHandle& operator-= ( Real  v)

◆ operator/=() [1/3]

ImageHandle& operator/= ( const Complex v)

◆ operator/=() [2/3]

ImageHandle& operator/= ( const ConstImageHandle h)

◆ operator/=() [3/3]

ImageHandle& operator/= ( Real  v)

◆ operator=()

ImageHandle& operator= ( const ImageHandle h)

Assign another image based on handle.

The reference count the the previously shared images is decreased and the one of the assignee is increased

◆ operator==()

bool operator== ( const ImageHandle ih) const

◆ Paste()

void Paste ( const Data d)

pastes given data to this image, using data extent

Effectively replaces a part of the image with the values retrieved from the given data, either another image handle or a function. The region that is replaced in this image is given by the extent of the data.

◆ Reciproce()

void Reciproce ( )

◆ Reset()

void Reset ( const Extent e,
DataType  type = REAL,
DataDomain  dom = SPATIAL 
)

Reset image state to given size, type and domain.

Essentially the same as creating a new ImageHandle with CreateImage() and assigning it to an existing handle. After a call to reset, all values are zero.

This routine exhibits only weak exception safety, as the existing state is first cleared to conserve memory usage.

◆ Sampling() [1/2]

virtual PixelSampling& Sampling ( )
protectedvirtual

see Data::Sampling()

Implements ConstData.

◆ Sampling() [2/2]

virtual const PixelSampling& Sampling ( ) const
protectedvirtual

see Data::Sampling()

Implements ConstData.

◆ Set()

void Set ( const ImageHandle h)

sets content of image to that of the given one

In contrast to the assignement operator, which affects only the handle mechanism, the Set method assigns the content of the passwd handle to this one. Other image handle pointing to the same image content will therefore also be affected.

◆ SetAbsoluteOrigin()

void SetAbsoluteOrigin ( const Vec3 &  c)

Sets the absolute coordinate for the spatial origin of the image.

◆ SetComplex()

void SetComplex ( const Point p,
const Complex c 
)

Set explicit complex value.

◆ SetReal()

void SetReal ( const Point p,
Real  r 
)

Set explicit real value

See also
Spoke Pattern Example

◆ SetSpatialOrigin()

void SetSpatialOrigin ( const Point p)
virtual

set spatial origin of image

Implements Data.

◆ StateApply() [1/6]

ImageHandle StateApply ( const ImageStateConstModIPVisitorBase v) const

Applies in-place const visitor out-of-place.

◆ StateApply() [2/6]

ImageHandle StateApply ( const ImageStateConstModOPVisitorBase v) const

Applies out-of-place const visitor out-of-place.

◆ StateApply() [3/6]

ImageHandle StateApply ( ImageStateModIPVisitorBase v) const

Applies in-place visitor out-of-place.

◆ StateApply() [4/6]

ImageHandle StateApply ( ImageStateModOPVisitorBase v) const

Applies out-of-place visitor out-of-place.

◆ StateApply() [5/6]

ImageHandle StateApply ( ImageStateMorphVisitorBase v) const

Applies morph visitor out-of-place.

◆ StateApply() [6/6]

void StateApply ( ImageStateNonModVisitorBase v) const

Apply non-modifying state visitor.

◆ StateApplyIP() [1/5]

void StateApplyIP ( const ImageStateConstModIPVisitorBase v)

Applies in-place const visitor in-place.

◆ StateApplyIP() [2/5]

void StateApplyIP ( const ImageStateConstModOPVisitorBase v)

Applies out-of-place const visitor in-place.

◆ StateApplyIP() [3/5]

void StateApplyIP ( ImageStateModIPVisitorBase v)

Applies in-place visitor in-place.

◆ StateApplyIP() [4/5]

void StateApplyIP ( ImageStateModOPVisitorBase v)

Applies out-of-place visitor in-place.

◆ StateApplyIP() [5/5]

void StateApplyIP ( ImageStateMorphVisitorBase v)

Applies morph visitor in-place.

◆ Swap()

void Swap ( ImageHandle h)

swap guts with another handle

Friends And Related Function Documentation

◆ ConstImageHandle

friend class ConstImageHandle
friend

Definition at line 118 of file image_handle.hh.

◆ DoCreateImage

ImageHandle DoCreateImage ( const Extent e,
DataType  type,
DataDomain  dom 
)
friend

◆ test_image::test_Observer

void test_image::test_Observer ( )
friend

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