35 #include "Core/include/DBaseImage.h"
36 #include "Gui/include/DBaseImageViewer.h"
45 template <
class T>
class ImageViewer;
47 template <
class T>
class ResImage;
49 template <
class T>
class SharedImage;
64 Image(
size_t w,
size_t h,
size_t d = 1);
74 template <
class T2>
Image(
const Image<T2> &rhs,
bool cloneData =
false);
96 return getDataTypeAsString<T>(dum);
98 typedef typename ImDtTypes<T>::pixelType pixelType;
99 typedef typename ImDtTypes<T>::lineType lineType;
100 typedef typename ImDtTypes<T>::restrictLineType restrictLineType;
101 typedef typename ImDtTypes<T>::sliceType sliceType;
102 typedef typename ImDtTypes<T>::volType volType;
128 inline T
getPixel(
size_t x,
size_t y,
size_t z = 0)
const
130 ASSERT((x < width && y < height && z < depth),
131 "Coords out of image range", T(0));
132 return pixels[z * width * height + y * width + x];
138 ASSERT((offset < pixelCount),
"Offset out of image range", T(0));
139 return pixels[offset];
142 inline T getPixelNoCheck(
size_t offset)
const
144 return pixels[offset];
148 inline RES_T
setPixel(
size_t x,
size_t y,
size_t z,
const T &value)
150 ASSERT((x < width && y < height && z < depth),
151 "Coords out of image range", RES_ERR);
152 pixels[z * width * height + y * width + x] = value;
158 inline RES_T
setPixel(
size_t x,
size_t y,
const T &value)
164 inline RES_T
setPixel(
size_t offset,
const T &value)
166 ASSERT((offset < pixelCount),
"Offset out of image range", RES_ERR);
167 pixels[offset] = value;
172 inline void setPixelNoCheck(
size_t offset,
const T &value)
174 pixels[offset] = value;
187 return (
char *) pixels;
229 virtual RES_T
setSize(
size_t w,
size_t h,
size_t d = 1,
230 bool doAllocate =
true);
232 virtual RES_T
setSize(
size_t s[3],
bool doAllocate =
true)
234 return setSize(s[0], s[1], s[2], doAllocate);
243 virtual RES_T
setSize(
const vector<UINT> s,
bool doAllocate =
true)
246 return setSize(s[0], s[1], s[2], doAllocate);
248 return setSize(s[0], s[1], 1, doAllocate);
264 void printSelf(ostream &os,
bool displayPixVals,
bool hexaGrid =
false,
265 string indent =
"")
const;
267 virtual void printSelf(ostream &os = std::cout,
string indent =
"")
const
274 printSelf(std::cout,
false,
false, indent);
277 void printSelf(
bool displayPixVals,
bool hexaGrid =
false,
string indent =
"")
279 printSelf(std::cout, displayPixVals, hexaGrid, indent);
287 return s.str().c_str();
296 virtual RES_T
load(
const char *fileName);
297 virtual RES_T
save(
const char *fileName);
299 #if defined SWIGPYTHON && defined USE_NUMPY
343 inline T &operator[](
size_t i)
346 return this->pixels[i];
347 ERR_MSG(
"Offset out of range.");
348 return this->dumPixel;
414 Image<T> &operator|=(
const T &value);
457 RES_T restruct(
void);
459 ImageViewer<T> *viewer;
471 virtual void show(
const char *_name = NULL,
bool labelImage =
false);
477 virtual void showNormal(
const char *_name = NULL);
502 template <
class T>
Image<T> *createImage(
const T)
507 template <
class T> Image<T> *castBaseImage(BaseImage *img,
const T &)
509 ASSERT(strcmp(getDataTypeAsString<T>(), img->getTypeAsString()) == 0,
510 "Bad type for cast", NULL);
511 return reinterpret_cast<Image<T> *
>(img);
518 imOut.getViewer()->drawOverlay(imToDraw);
Base Image class.
Definition: DBaseImage.h:50
size_t getDepth() const
Get image depth (Z)
Definition: DBaseImage.h:90
size_t getWidth() const
Get image width.
Definition: DBaseImage.h:80
size_t getHeight() const
Get image height.
Definition: DBaseImage.h:85
Base Smil Object.
Definition: DBaseObject.h:52
Main Image class.
Definition: DImage.hpp:57
ResImage< T > operator+(const T &value)
Add value.
virtual RES_T save(const char *fileName)
Save to file.
virtual void * getVoidPointer(void)
Get pixels as a void pointer.
Definition: DImage.hpp:291
void fromArray(const T inArray[])
Copy pixel values from a given array.
ResImage< T > operator!=(const Image< T > &rhs)
Diff boolean operator (see equ()).
virtual void clone(const Image< T > &rhs)
Clone from a given image (set same size and copy content)
T getPixel(size_t offset) const
Return the value of the pixel at a given offset.
Definition: DImage.hpp:136
ResImage< T > operator==(const Image< T > &rhs)
Equal boolean operator (see equ()).
virtual Image< T > clone(bool cloneData=true)
Create a clone of the image (with same size and content )
Definition: DImage.hpp:222
virtual const char * getInfoString(const char *indent="") const
Get the description of the image as a string.
Definition: DImage.hpp:283
virtual RES_T load(const char *fileName)
Load from file.
static T getDataTypeMin()
Get Maximum value of image data type.
Definition: DImage.hpp:332
ResImage< T > operator*(const T &value)
Multiply by value.
ResImage< T > operator<(const Image< T > &rhs)
Lower boolean operator (see low())
void fromCharArray(const signed char inArray[])
Copy pixel values from a given char array.
void drain(Image< T > *im, bool deleteSrc=false)
Replace container. Drain memory from image im to this.
string toString()
Export pixel values to a string.
Image< T > & operator*=(const Image< T > &rhs)
Image multiplication assignment.
virtual RES_T setSize(const BaseImage &rhs, bool doAllocate=true)
Set the size of image.
Definition: DImage.hpp:237
Image< T > & operator+=(const Image< T > &rhs)
Image addition assignment.
ResImage< T > operator/(const T &value)
Divide by value.
virtual void modified()
Trigger modified event (allows to force display update)
void toArray(T outArray[])
Copy pixel values to a given array.
RES_T setPixel(size_t offset, const T &value)
Set the value of the pixel at a given offset.
Definition: DImage.hpp:164
Image< T > & operator-=(const T &value)
Value subtraction assignment.
ResImage< T > operator<=(const Image< T > &rhs)
Lower or equal boolean operator (see lowOrEqu())
static T getDataTypeMax()
Get Maximum value of image data type.
Definition: DImage.hpp:338
volType getSlices() const
Get an array containing the start offset of each slice.
Definition: DImage.hpp:117
lineType getPixels() const
Get the pixels as a 1D array.
Definition: DImage.hpp:105
sliceType getLines() const
Get an array containing the start offset of each line.
Definition: DImage.hpp:111
ResImage< T > operator&(const Image< T > &rhs)
Bitwise and operator.
virtual RES_T setSize(size_t w, size_t h, size_t d=1, bool doAllocate=true)
Set the size of image.
Image()
Default constructor.
Image< T > & operator&=(const Image< T > &rhs)
Bitwise and assignement.
ResImage< T > operator~() const
Negate image.
ResImage< T > operator>(const T &value)
Greater boolean operator (see grt())
virtual RES_T setSize(const vector< UINT > s, bool doAllocate=true)
Set the size of image.
Definition: DImage.hpp:243
ResImage< T > operator+(const Image< T > &rhs)
Add image.
Image< T > & operator+=(const T &value)
Value addition assignment.
Image(const Image< T > &rhs, bool cloneData=false)
Copy constructor.
ResImage< T > operator>=(const T &value)
Greater or equal boolean operator (see grt())
virtual void show(const char *_name=NULL, bool labelImage=false)
Show the default viewer associated with the image.
ResImage< T > operator>(const Image< T > &rhs)
Greater boolean operator (see grt())
void fromNumArray(PyObject *array)
fromNumArray() -
void toIntArray(int outArray[])
Copy pixel values to a given int array.
virtual RES_T allocate()
Allocate image.
void toCharArray(signed char outArray[])
Copy pixel values to a given char array.
virtual const char * getTypeAsString()
Get the image type.
Definition: DImage.hpp:93
Image(size_t w, size_t h, size_t d=1)
Contruction with a given size (automatic allocation)
virtual RES_T deallocate()
Deallocate image.
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)
Definition: DImage.hpp:148
virtual void showLabel(const char *_name=NULL)
Show the default viewer associated with the image using a color lookup table.
ResImage< T > operator-(const T &value)
Sub value.
ResImage< T > operator-(const Image< T > &rhs)
Sub image.
Image< T > & operator/=(const T &value)
Value division assignment.
RES_T setPixel(size_t x, size_t y, const T &value)
Set the value of the pixel at pos x,y.
Definition: DImage.hpp:158
void fromString(string pixVals)
Import pixel values from string.
ResImage< T > operator&(const T &value)
Bitwise and operator.
Image< T > & operator-=(const Image< T > &rhs)
Image subtraction assignment.
virtual ImageViewer< T > * getViewer()
Get the image viewer (create one if needed)
virtual bool isVisible()
Check if the image is visible.
void fromIntArray(const int inArray[])
Copy pixel values from a given int array.
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...
virtual void hide()
Hide image.
virtual void setName(const char *_name)
Set the name of the image.
Image(const char *fileName)
Contruction from a file.
void printSelf(ostream &os, bool displayPixVals, bool hexaGrid=false, string indent="") const
Print a description of the image.
ResImage< T > operator*(const Image< T > &rhs)
Multiply by image.
vector< int > toIntVector()
Copy pixel values to a given int vector.
PyObject * getNumArray(bool c_contigous=false)
getNumArray() -
Image< T > & operator<<(const Image< T > &rhs)
Copy image.
ResImage< T > operator>=(const Image< T > &rhs)
Greater or equal boolean operator (see grt())
Image< T > & operator*=(const T &value)
Value multiplication assignment.
T getPixel(size_t x, size_t y, size_t z=0) const
Return the value of the pixel at pos x,y(,z)
Definition: DImage.hpp:128
Image< T > & operator/=(const Image< T > &rhs)
Image division assignment.
Image< T > & operator&=(const T &value)
Bitwise and assignement.
ResImage< T > operator/(const Image< T > &rhs)
Divide by image.
Image< T > & operator>>(vector< T > &vect)
Export image data to a vector.
virtual RES_T setSize(size_t s[3], bool doAllocate=true)
Set the size of image.
Definition: DImage.hpp:232
void fromIntVector(const vector< int > inVector)
Copy pixel values from a given int vector.
Base image viewer.
Definition: DImageViewer.hpp:52
Definition: DImage.hpp:484
Image that uses an existing (1D) data pointer.
Definition: DSharedImage.hpp:51
RES_T drawOverlay(const Image< T > &imToDraw, Image< T > &imOut)
Draw overlay.
Definition: DImage.hpp:516
Definition: DTypes.hpp:88