SMIL 1.1.1
Loading...
Searching...
No Matches

Main Image class. More...

Detailed Description

template<class T>
class smil::Image< T >

Main Image class.

Template Parameters
TImage data type (UINT8, UINT16, ...)

#include <DImage.hpp>

+ Inheritance diagram for Image< T >:
+ Collaboration diagram for Image< T >:

Public Member Functions

 Image ()
 Default constructor.
 
 Image (size_t w, size_t h, size_t d=1)
 Contruction with a given size (automatic allocation)
 
 Image (const char *fileName)
 Contruction from a file.
 
 Image (const Image< T > &rhs, bool cloneData=false)
 Copy constructor.
 
void drain (Image< T > *im, bool deleteSrc=false)
 Replace container. Drain memory from image im to this.
 
virtual const char * getTypeAsString ()
 Get the image type.
 
lineType getPixels () const
 Get the pixels as a 1D array.
 
sliceType getLines () const
 Get an array containing the start offset of each line.
 
volType getSlices () const
 Get an array containing the start offset of each slice.
 
SharedImage< T > getSlice (size_t sliceNum) const
 Get a 2D slice of a 3D image. It doesn't create an image, but returns a 2D SharedImage using the same data.
 
getPixel (size_t x, size_t y, size_t z=0) const
 Return the value of the pixel at pos x,y(,z)
 
getPixel (size_t offset) const
 Return the value of the pixel at a given offset.
 
RES_T setPixel (size_t x, size_t y, size_t z, const T &value)
 Set the value of the pixel at pos x,y,z (for 3D image)
 
RES_T setPixel (size_t x, size_t y, const T &value)
 Set the value of the pixel at pos x,y.
 
RES_T setPixel (size_t offset, const T &value)
 Set the value of the pixel at a given offset.
 
void toArray (T outArray[])
 Copy pixel values to a given array.
 
void fromArray (const T inArray[])
 Copy pixel values from a given array.
 
void toCharArray (signed char outArray[])
 Copy pixel values to a given char array.
 
void fromCharArray (const signed char inArray[])
 Copy pixel values from a given char array.
 
void toIntArray (int outArray[])
 Copy pixel values to a given int array.
 
void fromIntArray (const int inArray[])
 Copy pixel values from a given int array.
 
vector< int > toIntVector ()
 Copy pixel values to a given int vector.
 
void fromIntVector (const vector< int > inVector)
 Copy pixel values from a given int vector.
 
string toString ()
 Export pixel values to a string.
 
void fromString (string pixVals)
 Import pixel values from string.
 
virtual ImageViewer< T > * getViewer ()
 Get the image viewer (create one if needed)
 
virtual bool isVisible ()
 Check if the image is visible.
 
virtual void clone (const Image< T > &rhs)
 Clone from a given image (set same size and copy content)
 
virtual Image< T > clone (bool cloneData=true)
 Create a clone of the image (with same size and content )
 
virtual RES_T setSize (size_t w, size_t h, size_t d=1, bool doAllocate=true)
 Set the size of image.
 
virtual RES_T setSize (size_t s[3], bool doAllocate=true)
 Set the size of image.
 
virtual RES_T setSize (const BaseImage &rhs, bool doAllocate=true)
 Set the size of image.
 
virtual RES_T setSize (const vector< UINT > s, bool doAllocate=true)
 Set the size of image.
 
virtual RES_T allocate ()
 Allocate image.
 
virtual RES_T deallocate ()
 Deallocate image.
 
void printSelf (ostream &os, bool displayPixVals, bool hexaGrid=false, string indent="") const
 Print a description of the image.
 
virtual const char * getInfoString (const char *indent="") const
 Get the description of the image as a string.
 
virtual void * getVoidPointer (void)
 Get pixels as a void pointer.
 
virtual RES_T load (const char *fileName)
 Load from file.
 
virtual RES_T save (const char *fileName)
 Save to file.
 
PyObject * getNumpyArray (bool c_contigous=false)
 getNumpyArray() -
 
void fromNumpyArray (PyObject *array)
 fromNumpyArray() -
 
virtual void modified ()
 Trigger modified event (allows to force display update)
 
Image< T > & operator<< (const Image< T > &rhs)
 Copy image.
 
Image< T > & operator<< (const T &value)
 Fill image.
 
ResImage< T > operator~ () const
 Negate image.
 
ResImage< T > operator+ (const Image< T > &rhs)
 Add image.
 
ResImage< T > operator+ (const T &value)
 Add value.
 
Image< T > & operator+= (const Image< T > &rhs)
 Image addition assignment.
 
Image< T > & operator+= (const T &value)
 Value addition assignment.
 
ResImage< T > operator- (const Image< T > &rhs)
 Sub image.
 
ResImage< T > operator- (const T &value)
 Sub value.
 
Image< T > & operator-= (const Image< T > &rhs)
 Image subtraction assignment.
 
Image< T > & operator-= (const T &value)
 Value subtraction assignment.
 
ResImage< T > operator* (const Image< T > &rhs)
 Multiply by image.
 
ResImage< T > operator* (const T &value)
 Multiply by value.
 
Image< T > & operator*= (const Image< T > &rhs)
 Image multiplication assignment.
 
Image< T > & operator*= (const T &value)
 Value multiplication assignment.
 
ResImage< T > operator/ (const Image< T > &rhs)
 Divide by image.
 
ResImage< T > operator/ (const T &value)
 Divide by value.
 
Image< T > & operator/= (const Image< T > &rhs)
 Image division assignment.
 
Image< T > & operator/= (const T &value)
 Value division assignment.
 
ResImage< T > operator== (const Image< T > &rhs)
 Equal boolean operator (see equ()).
 
ResImage< T > operator!= (const Image< T > &rhs)
 Diff boolean operator (see equ()).
 
ResImage< T > operator< (const Image< T > &rhs)
 Lower boolean operator (see low())
 
ResImage< T > operator< (const T &value)
 Lower boolean operator (see low())
 
ResImage< T > operator<= (const Image< T > &rhs)
 Lower or equal boolean operator (see lowOrEqu())
 
ResImage< T > operator<= (const T &value)
 Lower or equal boolean operator (see lowOrEqu())
 
ResImage< T > operator> (const Image< T > &rhs)
 Greater boolean operator (see grt())
 
ResImage< T > operator> (const T &value)
 Greater boolean operator (see grt())
 
ResImage< T > operator>= (const Image< T > &rhs)
 Greater or equal boolean operator (see grt())
 
ResImage< T > operator>= (const T &value)
 Greater or equal boolean operator (see grt())
 
ResImage< T > operator& (const Image< T > &rhs)
 Bitwise and operator.
 
ResImage< T > operator& (const T &value)
 Bitwise and operator.
 
Image< T > & operator&= (const Image< T > &rhs)
 Bitwise and assignement.
 
Image< T > & operator&= (const T &value)
 Bitwise and assignement.
 
 operator bool ()
 Boolean operator.
 
Image< T > & operator<< (const lineType &tab)
 Import image data from an array.
 
Image< T > & operator<< (vector< T > &vect)
 Import image data from a vector.
 
Image< T > & operator>> (vector< T > &vect)
 Export image data to a vector.
 
virtual void setName (const char *_name)
 Set the name of the image.
 
virtual void show (const char *_name=NULL, bool labelImage=false)
 Show the default viewer associated with the image.
 
virtual void showLabel (const char *_name=NULL)
 Show the default viewer associated with the image using a color lookup table.
 
virtual void hide ()
 Hide image.
 
void * getVoidPointer (void)
 Get the void* data array.
 
void * getVoidPointer (void)
 Get the void* data array.
 
void * getVoidPointer ()
 Get the void* data array.
 
- Public Member Functions inherited from BaseImage
size_t getWidth () const
 Get image width.
 
size_t getHeight () const
 Get image height.
 
size_t getDepth () const
 Get image depth (Z)
 
virtual size_t getAllocatedSize () const
 Get memory size (bytes)
 
UINT getDimension () const
 Get dimension (2D or 3D)
 
void getSize (size_t *w, size_t *h, size_t *d) const
 Get image size.
 
void getSize (size_t s[3]) const
 Get image size.
 
void getSize (off_t s[3]) const
 Get image size.
 
void getSize (int s[3]) const
 Get image size.
 
size_t getPixelCount () const
 Get the number of pixels.
 
size_t getLineCount () const
 Get the number of lines.
 
size_t getSliceCount () const
 Get the number of slices(for 3D images)
 
bool isAllocated () const
 Check if the image is allocated.
 
bool areCoordsInImage (const off_t x, const off_t y, const off_t z=0) const
 areCoordsInImage() - checks if the triplet (x, y, z) in inside the image bounds.
 
bool areCoordsInImage (const size_t x, const size_t y, const size_t z=0) const
 areCoordsInImage() - checks if the triplet (x, y, z) in inside the image bounds.
 
bool isPointInImage (const IntPoint &p) const
 isPointInImage() - checks if a Point is in inside the image bounds.
 
bool isOffsetInImage (const off_t offset) const
 isOffsetInImage() - checks if a buffer offset in inside the image bounds.
 
bool isOffsetInImage (const size_t offset) const
 isOffsetInImage() - checks if a buffer offset in inside the image bounds.
 
size_t getOffsetFromCoords (size_t x, size_t y, size_t z=0) const
 Get an offset for given x,y(,z) coordinates.
 
size_t getOffsetFromPoint (IntPoint &p) const
 Get an offset for given x,y(,z) coordinates.
 
void getCoordsFromOffset (size_t off, size_t &x, size_t &y, size_t &z) const
 Get x,y(,z) coordinates for a given offset.
 
void getCoordsFromOffset (off_t off, off_t &x, off_t &y, off_t &z) const
 Get x,y(,z) coordinates for a given offset.
 
vector< size_t > getCoordsFromOffset (size_t off) const
 Get x,y(,z) coordinates for a given offset.
 

Static Public Member Functions

static T getDataTypeMin ()
 Get Maximum value of image data type.
 
static T getDataTypeMax ()
 Get Maximum value of image data type.
 

Member Function Documentation

◆ getTypeAsString()

template<class T >
virtual const char * getTypeAsString ( )
inlinevirtual

Get the image type.

Returns
The type of the image data as a string ("UINT8", "UINT16", ...)

Implements BaseImage.

◆ isVisible()

template<class T >
virtual bool isVisible ( )
virtual

Check if the image is visible.

Returns
true if the viewer is visible, false otherwise

Reimplemented from BaseImage.

◆ printSelf()

template<class T >
void printSelf ( ostream &  os,
bool  displayPixVals,
bool  hexaGrid = false,
string  indent = "" 
) const

Print a description of the image.

Parameters
[in]osOutput stream
[in]displayPixValsIf true, display pixel values
[in]hexaGridIf true (and displayPixVals is true), display pixel values as an hexahedral grid
[in]indentOptional prefix

◆ getNumpyArray()

template<class T >
PyObject * getNumpyArray ( bool  c_contigous = false)

getNumpyArray() -

Return a NumPy array containing the real image pixel values (not a copy).

Parameters
[in]c_contigous: If true, return an array corresponding to the aligment of C data (C_CONTIGOUS NumPy array flag). If false (default), return a F_CONTIGOUS array.
Returns
a pointer to the image data as a Numpy array

See Smil <-> NumPy interface for examples.

◆ fromNumpyArray()

template<class T >
void fromNumpyArray ( PyObject *  array)

fromNumpyArray() -

Copy pixel values from a given NumPy array. The image size will be derived from the array shape.

Parameters
[in]array: a Numpy array.

See Smil <-> NumPy interface for examples.

◆ operator bool()

template<class T >
operator bool ( )

Boolean operator.

Returns
true, if if every pixel has the max type value ( vol(im)==ImDtTypes<T>::max()*pixelCount )
false, otherwise

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