92 template<
typename T>
class Image;
93 template<
typename T>
class FFT;
99 #define TIFF_UINT16_T unsigned short 102 #ifndef TIFF_UINT32_T 103 #define TIFF_UINT32_T unsigned int 110 template<
typename T> Image<T>
operator*(
const T& aValue,
111 const Image<T>& anImage);
114 template<
typename T> Image<T>
operator/(
const T& aValue,
115 const Image<T>& anImage);
118 template<
typename T> Image<T>
operator+(
const T& aValue,
119 const Image<T>& anImage);
122 template<
typename T> Image<T>
operator-(
const T& aValue,
123 const Image<T>& anImage);
126 template<
typename T> Image<T>
log(
const Image<T>& anImage);
129 template<
typename T> Image<T>
abs(
const Image<T>& anImage);
138 template<
typename T> Image<T>
gauss2D(
unsigned int aSize,
double aSigmaValue);
147 template<
typename T>
class Image
164 Image(
const Image<T>& anImage);
173 Image(
const char* aFileName);
182 Image(
const std::string& aFileName);
197 Image(
const T* apData,
199 unsigned int aHeight,
200 unsigned int aNumberOfSlices = 1,
201 const VEC3& aVoxelSize =
VEC3(1, 1, 1));
216 Image(
unsigned int aWidth,
217 unsigned int aHeight,
218 unsigned int aNumberOfSlices = 1,
220 const VEC3& aVoxelSize =
VEC3(1, 1, 1));
235 void makeBlank(
const T& aDefaultColour = 0);
257 unsigned int aHeight,
258 unsigned int aDepth)
const;
270 void setPixel(
unsigned int i,
unsigned int j,
unsigned int k, T aValue);
282 T&
getPixel(
unsigned int i,
unsigned int j,
unsigned int k = 0);
294 const T&
getPixel(
unsigned int i,
unsigned int j,
unsigned int k = 0)
const;
306 T&
getPixelValue(
unsigned int i,
unsigned int j,
unsigned int k = 0);
320 unsigned int k = 0)
const;
334 unsigned int k = 0)
const;
343 T&
operator()(
unsigned int i,
unsigned int j,
unsigned int k);
346 const T&
operator()(
unsigned int i,
unsigned int j,
unsigned int k)
const;
356 Image<T>&
operator=(
const Image<T>& anImage);
422 const double& aPixelHeight = 0.0,
423 const double& aPixelDepth = 0.0);
477 bool aRunOnGPUFlag =
true)
const;
480 Image<unsigned char>
threshold(
const T& aLowerThreshold,
const T& aUpperThreshold,
481 unsigned char anInValue,
482 unsigned char anOutValue,
483 bool aRunOnGPUFlag =
true)
const;
485 Image<T>
convolution1D(
const std::vector<float>& aKernel)
const;
489 Image<unsigned char>
opening(
unsigned int aRadius)
const;
490 Image<unsigned char>
closing(
unsigned int aRadius)
const;
498 Image<unsigned char>
threshold(
const T& aThreshold,
499 unsigned char aValueIn = 1,
500 unsigned char aValueOut = 0)
const;
503 Image<unsigned char>
threshold(
const T& aLowerThreshold,
504 const T& aUpperThreshold,
505 unsigned char aValueIn = 1,
506 unsigned char aValueOut = 0)
const;
521 void load(
const char* aFileName);
524 void load(
const std::string& aFileName);
534 int aFirstSliceIndex,
536 int anIncrementIndex = 1);
540 int aFirstSliceIndex,
542 int anIncrementIndex = 1);
554 void loadASCII(
const std::string& aFileName);
557 void loadASCII(
const char* aFileName,
unsigned int aWidth,
unsigned int aHeight,
unsigned int aDepth,
const VEC3& aVoxelSize);
560 void loadASCII(
const std::string& aFileName,
unsigned int aWidth,
unsigned int aHeight,
unsigned int aDepth,
const VEC3& aVoxelSize);
563 void loadMHD(
const char* aFileName);
566 void loadMHD(
const std::string& aFileName);
569 void loadMHA(
const char* aFileName);
572 void loadMHA(
const std::string& aFileName);
575 unsigned int sizeOf(
const char* anElementType)
const;
577 unsigned int sizeOf(
const std::string& anElementType)
const;
579 void loadRAW(
const char* aFileName,
581 unsigned int aHeight,
582 unsigned int aNumberOfSlices = 1,
583 bool aChangeEndianessFlag =
false,
584 const char* anElementType = 0);
587 void loadRAW(
const std::string& aFileName,
589 unsigned int aHeight,
590 unsigned int aNumberOfSlices = 1,
591 bool aChangeEndianessFlag =
false,
592 const std::string& anElementType =
"");
607 void save(
const char* aFileName,
608 bool anInvertLUTFlag =
false,
609 const char* aComment =
"",
610 bool useDeflateCompressionIfPossible =
false)
const;
625 void save(
const std::string& aFileName,
626 bool anInvertLUTFlag =
false,
627 const std::string& aComment =
"",
628 bool useDeflateCompressionIfPossible =
false)
const;
637 void savePGM(
const char* aFileName)
const;
646 void savePGM(
const std::string& aFileName)
const;
656 void saveRaw(
const char* aFileName,
bool useDeflateCompressionIfPossible)
const;
666 void saveRaw(
const std::string& aFileName,
bool useDeflateCompressionIfPossible)
const;
676 void saveRAW(
const char* aFileName,
bool useDeflateCompressionIfPossible)
const;
686 void saveRAW(
const std::string& aFileName,
bool useDeflateCompressionIfPossible)
const;
695 void saveASCII(
const char* aFileName)
const;
704 void saveASCII(
const std::string& aFileName)
const;
714 void saveMHD(
const char* aFileName,
715 bool useDeflateCompressionIfPossible =
false)
const;
725 void saveMHD(
const std::string& aFileName,
726 bool useDeflateCompressionIfPossible =
false)
const;
736 void saveMHA(
const char* aFileName,
737 bool useDeflateCompressionIfPossible =
false)
const;
747 void saveMHA(
const std::string& aFileName,
748 bool useDeflateCompressionIfPossible =
false)
const;
759 void saveDCM(
const char* aFileName,
760 bool anInvertLUTFlag =
false,
761 const char* aComment =
"")
const;
772 void saveDCM(
const std::string& aFileName,
773 bool anInvertLUTFlag =
false,
774 const std::string& aComment =
"")
const;
784 void saveTIFF(
const char* aFileName,
785 bool anInvertLUTFlag =
false)
const;
795 void saveTIFF(
const std::string& aFileName,
796 bool anInvertLUTFlag =
false)
const;
807 bool useDeflateCompressionIfPossible =
false)
const;
818 bool useDeflateCompressionIfPossible =
false)
const;
829 bool operator==(
const Image<T>& anImage)
const;
840 bool operator!=(
const Image<T>& anImage)
const;
890 Image<T>&
operator+=(
const Image<T>& anImage);
900 Image<T>&
operator-=(
const Image<T>& anImage);
910 Image<T>&
operator*=(
const Image<T>& anImage);
920 Image<T>&
operator/=(
const Image<T>& anImage);
1012 Image<T>
abs()
const;
1015 Image<T>
log()
const;
1036 double computeSAE(
const Image<T>& anImage)
const;
1039 double computeMAE(
const Image<T>& anImage)
const;
1042 double computeSSE(
const Image<T>& anImage)
const;
1045 double computeMSE(
const Image<T>& anImage)
const;
1048 double computeRMSE(
const Image<T>& anImage)
const;
1051 double computeNCC(
const Image<T>& anImage)
const;
1060 Image<T>
resize(
unsigned int aNewWidth,
1061 unsigned int aNewHeightunsigned,
1062 unsigned int aNewNumberOfSlices)
const;
1065 Image<T>
rotate(
float anAngleInDegrees)
const;
1069 unsigned int aNewHeight,
1070 unsigned int aNewNumberOfSlices)
const;
1075 double aLastAngle)
const;
1096 const T& aSecondThresholdValue = 0,
1097 bool aTwoThresholdFlag =
false,
1098 unsigned char aVerboseLevel = 0)
const;
1112 T aThreshold = -1000,
1113 unsigned char aVerboseLevel = 0)
const;
1177 void loadMetaHeader(
const char* aFileName);
1180 void loadMetaHeader(
const std::string& aFileName);
1183 void loadRAW(std::ifstream& anInputStream,
1184 unsigned int aWidth,
1185 unsigned int aHeight,
1186 unsigned int aNumberOfSlices,
1187 bool aChangeEndianessFlag,
1188 const char* aFileName,
1189 const char* anElementType
1193 void saveMetaHeader(
const char* aFileName,
bool useDeflateCompressionIfPossible)
const;
1196 void saveMetaHeader(
const std::string& aFileName,
bool useDeflateCompressionIfPossible)
const;
1200 void addTag(
double aValue,
1201 unsigned int anAddress1,
1202 unsigned int anAddress2,
1203 gdcm::File& aFile)
const;
1206 void addTag(
const char* aValue,
1207 unsigned int anAddress1,
1208 unsigned int anAddress2,
1209 gdcm::File& aFile)
const;
1212 void addTag(
const std::string& aValue,
1213 unsigned int anAddress1,
1214 unsigned int anAddress2,
1215 gdcm::File& aFile)
const;
void destroy()
Release the memory.
void savePGM(const char *aFileName) const
Save the image in a PGM file.
void loadSeries(const char *aPattern, int aFirstSliceIndex, int aLastSliceIndex, int anIncrementIndex=1)
T getMaxValue() const
Compute the maximum pixel value in the image.
void saveTIFF(const char *aFileName, bool anInvertLUTFlag=false) const
Save the image in a TIFF file.
void saveASCII(const char *aFileName) const
Save the image in an ASCII file.
double getAverage() const
Image< T > convolution1D(const std::vector< float > &aKernel) const
Image< unsigned char > threshold(const T &aLowerThreshold, const T &aUpperThreshold, unsigned char anInValue, unsigned char anOutValue, bool aRunOnGPUFlag=true) const
T & operator()(unsigned int i, unsigned int j, unsigned int k)
Image< T > operator+(const T &aValue, const Image< T > &anImage)
PolygonMesh marchingCubes(const T &aFirstThresholdValue, const T &aSecondThresholdValue=0, bool aTwoThresholdFlag=false, unsigned char aVerboseLevel=0) const
T & getPixel(unsigned int i, unsigned int j, unsigned int k=0)
Accessor on a pixel value.
void loadMHA(const char *aFileName)
Image< T > log(const Image< T > &anImage)
Image operator*(const Image< T > &anImage) const
Multiplication operator. Add anImage.
void load(const char *aFileName)
bool operator==(const Image< T > &anImage) const
Operator Equal to.
Image< T > rotate(float anAngleInDegrees) const
void loadUsingITK(const char *aFileName)
void loadASCII(const char *aFileName)
gVirtualXRay::FFT< T > getFFT() const
VEC3 m_spacing
The space between two successive pixels.
Image()
Default constructor.
void transferHostToDevice()
Image operator-(const Image< T > &anImage) const
Subtraction operator. Add anImage.
Image operator!() const
Negation operator. Compute the negative of the current image.
void convertVoxelsToCubes(std::map< T, PolygonMesh > &aPolygonMeshSet, T aThreshold=-1000, unsigned char aVerboseLevel=0) const
Convert every voxel into a cube.
Sinogram is a class to reconstruct images from a sinogram.
Image< T > operator/(const T &aValue, const Image< T > &anImage)
Image< float > getIsoTropic() const
void destroyOpenGLTexture()
static unsigned int g_vbo_type
Class to handle a greyscale image.
Image operator/(const Image< T > &anImage) const
Division operator. Add anImage.
T * getRawData()
Accessor on the raw data.
double computeSSE(const Image< T > &anImage) const
void save(const char *aFileName, bool anInvertLUTFlag=false, const char *aComment="", bool useDeflateCompressionIfPossible=false) const
Save the image in a file.
Image< T > & operator=(const Image< T > &anImage)
Assignment operator (also called copy operator).
T & operator[](unsigned anIndex)
static unsigned int g_mesh_type
const VEC3 & getSpacing() const
void saveDCM(const char *aFileName, bool anInvertLUTFlag=false, const char *aComment="") const
Save the image in a DICOM file.
void saveRAW(const char *aFileName, bool useDeflateCompressionIfPossible) const
Save the image in a Raw file.
gVirtualXRay::Sinogram< T > radonTransform(double aFirstAngle, double anAngleStep, double aLastAngle) const
PolygonMesh is a class to handle polygon (triangles) meshes.
Image is a class to manage a greyscale image.
void saveUsingITK(const char *aFileName, bool useDeflateCompressionIfPossible=false) const
Save the image in a file using ITK.
Image normalized() const
Normalize the image between 0 and 1.
void allocateHostMemory()
void transferDeviceToHost()
Image< T > & operator-=(const Image< T > &anImage)
Subraction assignment operator. Add anImage.
unsigned int getHeight() const
Number of pixels along the vertical axis.
void setPixel(unsigned int i, unsigned int j, unsigned int k, T aValue)
Set a pixel.
bool operator!=(const Image< T > &anImage) const
Operator Not equal to.
Image constantPadFilter(const T &aPadValue) const
unsigned int sizeOf(const char *anElementType) const
Image< T > resize(unsigned int aNewWidth, unsigned int aNewHeightunsigned, unsigned int aNewNumberOfSlices) const
Vec3< RATIONAL_NUMBER > VEC3
Type of data used to store 3D vectors.
VEC3 getPixelPosition(unsigned int i, unsigned int j, unsigned int k=0) const
Accessor on a pixel position.
Image< T > convolution2D(const Image< float > &aKernel) const
unsigned int getDepth() const
Number of pixels along the Z axis.
Image< T > & operator+=(const Image< T > &anImage)
Addition assignment operator. Add anImage.
double computeRMSE(const Image< T > &anImage) const
unsigned int m_number_of_slices
Number of slices.
Image< float > antiAliasBinaryImageFilter(double aMaximumRMSChange, unsigned int aNumberOfIterations, double aVariance) const
void loadMHD(const char *aFileName)
unsigned int m_width
Number of pixel along the horizontal axis.
Image getROI(unsigned int i, unsigned int j, unsigned int k, unsigned int aWidth, unsigned int aHeight, unsigned int aDepth) const
Compute a region of interest (ROI).
unsigned int m_texture_id
OpenGL texture ID.
Image< T > setCanvasSize(unsigned int aNewWidth, unsigned int aNewHeight, unsigned int aNewNumberOfSlices) const
Image< T > transpose() const
Image< T > operator-(const T &aValue, const Image< T > &anImage)
T getMinValue() const
Compute the minimum pixel value in the image.
double computeMAE(const Image< T > &anImage) const
Image< T > convertHU2mu(double anEnergy) const
unsigned int getWidth() const
Number of pixels along the horizontal axis.
Image< T > abs(const Image< T > &anImage)
Image< unsigned char > closing(unsigned int aRadius) const
Image< T > & operator/=(const Image< T > &anImage)
Division assignment operator. Add anImage.
void loadRAW(const char *aFileName, unsigned int aWidth, unsigned int aHeight, unsigned int aNumberOfSlices=1, bool aChangeEndianessFlag=false, const char *anElementType=0)
void setSpacing(const VEC3 &aPixelSize)
Image normalised() const
Normalise the image between 0 and 1.
Image< T > gauss2D(unsigned int aSize, double aSigmaValue)
Image< T > flipVertically() const
double getStandardDeviation() const
double computeMSE(const Image< T > &anImage) const
unsigned int getTextureId() const
FFT is a class to compute the FFT of a greyscale image.
Image< T > flipHorizontally() const
Image< T > & operator*=(const Image< T > &anImage)
Multiplication assignment operator. Add anImage.
Image< unsigned char > opening(unsigned int aRadius) const
double getVariance() const
double computeNCC(const Image< T > &anImage) const
unsigned int m_height
Number of pixel along the vertical axis.
void makeBlank(const T &aDefaultColour=0)
Replace all the pixels of an image with a default value.
Image shiftScaleFilter(double aShiftValue, double aScaleValue, bool aRunOnGPUFlag=true) const
Image< T > operator*(const T &aValue, const Image< T > &anImage)
std::string getPixelType(const std::string &aFileName)
Image operator+(const Image< T > &anImage) const
Addition operator. Add anImage.
VEC3 VertexInterp(const T &aThresholdValue, const VEC3 &p0, const VEC3 &p1, const T &v0, const T &v1) const
T * m_p_image
The pixel data.
void saveRaw(const char *aFileName, bool useDeflateCompressionIfPossible) const
Save the image in a Raw file.
T & getPixelValue(unsigned int i, unsigned int j, unsigned int k=0)
Accessor on a pixel value.
void saveMHD(const char *aFileName, bool useDeflateCompressionIfPossible=false) const
Save the image in a MHD+RAW file.
void loadDicomSeries(const char *aDirectory)
double computeSAE(const Image< T > &anImage) const
void saveMHA(const char *aFileName, bool useDeflateCompressionIfPossible=false) const
Save the image in a MHA+RAW file.