gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
Image.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2017, Dr Franck P. Vidal (franck.p.vidal@fpvidal.net),
4 http://www.fpvidal.net/
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation and/or
15 other materials provided with the distribution.
16 
17 3. Neither the name of the Bangor University nor the names of its contributors
18 may be used to endorse or promote products derived from this software without
19 specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32 */
33 
34 
35 #ifndef __Image_h
36 #define __Image_h
37 
38 
60 //******************************************************************************
61 // Include
62 //******************************************************************************
63 #ifndef NOMINMAX
64 #define NOMINMAX
65 #endif
66 
67 #include <string>
68 #include <map>
69 
70 #ifdef HAS_GDCM
71 #include <gdcmFile.h>
72 #endif
73 
74 #ifdef HAS_TIFF
75 #include <tiff.h>
76 #endif
77 
78 #ifndef __Types_h
79 #include "gVirtualXRay/Types.h"
80 #endif
81 
82 
83 //******************************************************************************
84 // namespace
85 //******************************************************************************
86 namespace gVirtualXRay {
87 
88 
89 //******************************************************************************
90 // Class/type declaration
91 //******************************************************************************
92 template<typename T> class Image;
93 template<typename T> class FFT;
94 template<typename T> class Sinogram;
95 class PolygonMesh;
96 
97 // This is needed for MacOS
98 #ifndef TIFF_UINT16_T
99 #define TIFF_UINT16_T unsigned short
100 #endif
101 
102 #ifndef TIFF_UINT32_T
103 #define TIFF_UINT32_T unsigned int
104 #endif
105 
106 
107 //******************************************************************************
108 // Function declaration
109 //******************************************************************************
110 template<typename T> Image<T> operator*(const T& aValue,
111  const Image<T>& anImage);
112 
113 
114 template<typename T> Image<T> operator/(const T& aValue,
115  const Image<T>& anImage);
116 
117 
118 template<typename T> Image<T> operator+(const T& aValue,
119  const Image<T>& anImage);
120 
121 
122 template<typename T> Image<T> operator-(const T& aValue,
123  const Image<T>& anImage);
124 
125 
126 template<typename T> Image<T> log(const Image<T>& anImage);
127 
128 
129 template<typename T> Image<T> abs(const Image<T>& anImage);
130 
131 
132 std::string getPixelType(const std::string& aFileName);
133 
134 
135 std::string getPixelType(const char* aFileName);
136 
137 
138 template<typename T> Image<T> gauss2D(unsigned int aSize, double aSigmaValue);
139 
140 
141 //==============================================================================
146 //==============================================================================
147 template<typename T> class Image
148 //------------------------------------------------------------------------------
149 {
150 //******************************************************************************
151 public:
152  //--------------------------------------------------------------------------
154  //--------------------------------------------------------------------------
155  Image();
156 
157 
158  //--------------------------------------------------------------------------
160 
163  //--------------------------------------------------------------------------
164  Image(const Image<T>& anImage);
165 
166 
167  //--------------------------------------------------------------------------
169 
172  //--------------------------------------------------------------------------
173  Image(const char* aFileName);
174 
175 
176  //--------------------------------------------------------------------------
178 
181  //--------------------------------------------------------------------------
182  Image(const std::string& aFileName);
183 
184 
185  //--------------------------------------------------------------------------
187 
196  //--------------------------------------------------------------------------
197  Image(const T* apData,
198  unsigned int aWidth,
199  unsigned int aHeight,
200  unsigned int aNumberOfSlices = 1,
201  const VEC3& aVoxelSize = VEC3(1, 1, 1));
202 
203 
204  //--------------------------------------------------------------------------
206 
215  //--------------------------------------------------------------------------
216  Image(unsigned int aWidth,
217  unsigned int aHeight,
218  unsigned int aNumberOfSlices = 1,
219  T aDefaultValue = 0,
220  const VEC3& aVoxelSize = VEC3(1, 1, 1));
221 
222 
223  //--------------------------------------------------------------------------
225  //--------------------------------------------------------------------------
226  ~Image();
227 
228 
229  //--------------------------------------------------------------------------
231 
234  //--------------------------------------------------------------------------
235  void makeBlank(const T& aDefaultColour = 0);
236 
237 
238  //--------------------------------------------------------------------------
240 
252  //--------------------------------------------------------------------------
253  Image getROI(unsigned int i,
254  unsigned int j,
255  unsigned int k,
256  unsigned int aWidth,
257  unsigned int aHeight,
258  unsigned int aDepth) const;
259 
260 
261  //--------------------------------------------------------------------------
263 
269  //--------------------------------------------------------------------------
270  void setPixel(unsigned int i, unsigned int j, unsigned int k, T aValue);
271 
272 
273  //--------------------------------------------------------------------------
275 
281  //--------------------------------------------------------------------------
282  T& getPixel(unsigned int i, unsigned int j, unsigned int k = 0);
283 
284 
285  //--------------------------------------------------------------------------
287 
293  //--------------------------------------------------------------------------
294  const T& getPixel(unsigned int i, unsigned int j, unsigned int k = 0) const;
295 
296 
297  //--------------------------------------------------------------------------
299 
305  //--------------------------------------------------------------------------
306  T& getPixelValue(unsigned int i, unsigned int j, unsigned int k = 0);
307 
308 
309  //--------------------------------------------------------------------------
311 
317  //--------------------------------------------------------------------------
318  const T& getPixelValue(unsigned int i,
319  unsigned int j,
320  unsigned int k = 0) const;
321 
322 
323  //--------------------------------------------------------------------------
325 
331  //--------------------------------------------------------------------------
332  VEC3 getPixelPosition(unsigned int i,
333  unsigned int j,
334  unsigned int k = 0) const;
335 
336 
337  T& operator[](unsigned anIndex);
338 
339 
340  const T& operator[](unsigned anIndex) const;
341 
342 
343  T& operator()(unsigned int i, unsigned int j, unsigned int k);
344 
345 
346  const T& operator()(unsigned int i, unsigned int j, unsigned int k) const;
347 
348 
349  //--------------------------------------------------------------------------
351 
355  //--------------------------------------------------------------------------
356  Image<T>& operator=(const Image<T>& anImage);
357 
358 
359  //--------------------------------------------------------------------------
361 
365  //--------------------------------------------------------------------------
366  Image<T>& operator=(const T* apImage);
367 
368 
369  //--------------------------------------------------------------------------
371  //--------------------------------------------------------------------------
372  void destroy();
373 
374 
375  //--------------------------------------------------------------------------
377 
380  //--------------------------------------------------------------------------
381  T* getRawData();
382 
383 
384  //--------------------------------------------------------------------------
386 
389  //--------------------------------------------------------------------------
390  const T* getRawData() const;
391 
392 
393  //--------------------------------------------------------------------------
395 
398  //--------------------------------------------------------------------------
399  unsigned int getWidth() const;
400 
401 
402  //--------------------------------------------------------------------------
404 
407  //--------------------------------------------------------------------------
408  unsigned int getHeight() const;
409 
410 
411  //--------------------------------------------------------------------------
413 
416  //--------------------------------------------------------------------------
417  unsigned int getDepth() const;
418 
419 
420  void setSpacing(const VEC3& aPixelSize);
421  void setSpacing(const double& aPixelWidth,
422  const double& aPixelHeight = 0.0,
423  const double& aPixelDepth = 0.0);
424 
425 
426  const VEC3& getSpacing() const;
427 
428 
429  //--------------------------------------------------------------------------
431 
434  //--------------------------------------------------------------------------
435  T getMinValue() const;
436 
437 
438  //--------------------------------------------------------------------------
440 
443  //--------------------------------------------------------------------------
444  T getMaxValue() const;
445 
446 
447  //--------------------------------------------------------------------------
449 
453  //--------------------------------------------------------------------------
454  T getMinValue(unsigned int aSliceID) const;
455 
456 
457  //--------------------------------------------------------------------------
459 
463  //--------------------------------------------------------------------------
464  T getMaxValue(unsigned int aSliceID) const;
465 
466 
467  //--------------------------------------------------------------------------
470 
474  //--------------------------------------------------------------------------
475  Image shiftScaleFilter(double aShiftValue,
476  double aScaleValue,
477  bool aRunOnGPUFlag = true) const;
478 
479 
480  Image<unsigned char> threshold(const T& aLowerThreshold, const T& aUpperThreshold,
481  unsigned char anInValue,
482  unsigned char anOutValue,
483  bool aRunOnGPUFlag = true) const;
484 
485  Image<T> convolution1D(const std::vector<float>& aKernel) const;
486  Image<T> convolution2D(const Image<float>& aKernel) const;
487  Image<T> convolution2D(const Image<double>& aKernel) const;
488 
489  Image<unsigned char> opening(unsigned int aRadius) const;
490  Image<unsigned char> closing(unsigned int aRadius) const;
491  Image<float> getIsoTropic() const;
492  Image<float> antiAliasBinaryImageFilter(double aMaximumRMSChange, unsigned int aNumberOfIterations, double aVariance) const;
493 
494 
495  Image constantPadFilter(const T& aPadValue) const;
496 
497 
498  Image<unsigned char> threshold(const T& aThreshold,
499  unsigned char aValueIn = 1,
500  unsigned char aValueOut = 0) const;
501 
502 
503  Image<unsigned char> threshold(const T& aLowerThreshold,
504  const T& aUpperThreshold,
505  unsigned char aValueIn = 1,
506  unsigned char aValueOut = 0) const;
507 
508 
509  //--------------------------------------------------------------------------
511  //--------------------------------------------------------------------------
512  Image normalised() const;
513 
514 
515  //--------------------------------------------------------------------------
517  //--------------------------------------------------------------------------
518  Image normalized() const;
519 
520 
521  void load(const char* aFileName);
522 
523 
524  void load(const std::string& aFileName);
525 
526 
527  void loadUsingITK(const char* aFileName);
528 
529 
530  void loadUsingITK(const std::string& aFileName);
531 
532 
533  void loadSeries(const char* aPattern,
534  int aFirstSliceIndex,
535  int aLastSliceIndex,
536  int anIncrementIndex = 1);
537 
538 
539  void loadSeries(const std::string& aPattern,
540  int aFirstSliceIndex,
541  int aLastSliceIndex,
542  int anIncrementIndex = 1);
543 
544 
545  void loadDicomSeries(const char* aDirectory);
546 
547 
548  void loadDicomSeries(const std::string& aDirectory);
549 
550 
551  void loadASCII(const char* aFileName);
552 
553 
554  void loadASCII(const std::string& aFileName);
555 
556 
557  void loadASCII(const char* aFileName, unsigned int aWidth, unsigned int aHeight, unsigned int aDepth, const VEC3& aVoxelSize);
558 
559 
560  void loadASCII(const std::string& aFileName, unsigned int aWidth, unsigned int aHeight, unsigned int aDepth, const VEC3& aVoxelSize);
561 
562 
563  void loadMHD(const char* aFileName);
564 
565 
566  void loadMHD(const std::string& aFileName);
567 
568 
569  void loadMHA(const char* aFileName);
570 
571 
572  void loadMHA(const std::string& aFileName);
573 
574 
575  unsigned int sizeOf(const char* anElementType) const;
576 
577  unsigned int sizeOf(const std::string& anElementType) const;
578 
579  void loadRAW(const char* aFileName,
580  unsigned int aWidth,
581  unsigned int aHeight,
582  unsigned int aNumberOfSlices = 1,
583  bool aChangeEndianessFlag = false,
584  const char* anElementType = 0);
585 
586 
587  void loadRAW(const std::string& aFileName,
588  unsigned int aWidth,
589  unsigned int aHeight,
590  unsigned int aNumberOfSlices = 1,
591  bool aChangeEndianessFlag = false,
592  const std::string& anElementType = "");
593 
594 
595  //--------------------------------------------------------------------------
597 
606  //--------------------------------------------------------------------------
607  void save(const char* aFileName,
608  bool anInvertLUTFlag = false,
609  const char* aComment = "",
610  bool useDeflateCompressionIfPossible = false) const;
611 
612 
613  //--------------------------------------------------------------------------
615 
624  //--------------------------------------------------------------------------
625  void save(const std::string& aFileName,
626  bool anInvertLUTFlag = false,
627  const std::string& aComment = "",
628  bool useDeflateCompressionIfPossible = false) const;
629 
630 
631  //--------------------------------------------------------------------------
633 
636  //--------------------------------------------------------------------------
637  void savePGM(const char* aFileName) const;
638 
639 
640  //--------------------------------------------------------------------------
642 
645  //--------------------------------------------------------------------------
646  void savePGM(const std::string& aFileName) const;
647 
648 
649  //--------------------------------------------------------------------------
651 
655  //--------------------------------------------------------------------------
656  void saveRaw(const char* aFileName, bool useDeflateCompressionIfPossible) const;
657 
658 
659  //--------------------------------------------------------------------------
661 
665  //--------------------------------------------------------------------------
666  void saveRaw(const std::string& aFileName, bool useDeflateCompressionIfPossible) const;
667 
668 
669  //--------------------------------------------------------------------------
671 
675  //--------------------------------------------------------------------------
676  void saveRAW(const char* aFileName, bool useDeflateCompressionIfPossible) const;
677 
678 
679  //--------------------------------------------------------------------------
681 
685  //--------------------------------------------------------------------------
686  void saveRAW(const std::string& aFileName, bool useDeflateCompressionIfPossible) const;
687 
688 
689  //--------------------------------------------------------------------------
691 
694  //--------------------------------------------------------------------------
695  void saveASCII(const char* aFileName) const;
696 
697 
698  //--------------------------------------------------------------------------
700 
703  //--------------------------------------------------------------------------
704  void saveASCII(const std::string& aFileName) const;
705 
706 
707  //--------------------------------------------------------------------------
709 
713  //--------------------------------------------------------------------------
714  void saveMHD(const char* aFileName,
715  bool useDeflateCompressionIfPossible = false) const;
716 
717 
718  //--------------------------------------------------------------------------
720 
724  //--------------------------------------------------------------------------
725  void saveMHD(const std::string& aFileName,
726  bool useDeflateCompressionIfPossible = false) const;
727 
728 
729  //--------------------------------------------------------------------------
731 
735  //--------------------------------------------------------------------------
736  void saveMHA(const char* aFileName,
737  bool useDeflateCompressionIfPossible = false) const;
738 
739 
740  //--------------------------------------------------------------------------
742 
746  //--------------------------------------------------------------------------
747  void saveMHA(const std::string& aFileName,
748  bool useDeflateCompressionIfPossible = false) const;
749 
750 
751  //--------------------------------------------------------------------------
753 
758  //--------------------------------------------------------------------------
759  void saveDCM(const char* aFileName,
760  bool anInvertLUTFlag = false,
761  const char* aComment = "") const;
762 
763 
764  //--------------------------------------------------------------------------
766 
771  //--------------------------------------------------------------------------
772  void saveDCM(const std::string& aFileName,
773  bool anInvertLUTFlag = false,
774  const std::string& aComment = "") const;
775 
776 
777  //--------------------------------------------------------------------------
779 
783  //--------------------------------------------------------------------------
784  void saveTIFF(const char* aFileName,
785  bool anInvertLUTFlag = false) const;
786 
787 
788  //--------------------------------------------------------------------------
790 
794  //--------------------------------------------------------------------------
795  void saveTIFF(const std::string& aFileName,
796  bool anInvertLUTFlag = false) const;
797 
798 
799  //--------------------------------------------------------------------------
801 
805  //--------------------------------------------------------------------------
806  void saveUsingITK(const char* aFileName,
807  bool useDeflateCompressionIfPossible = false) const;
808 
809 
810  //--------------------------------------------------------------------------
812 
816  //--------------------------------------------------------------------------
817  void saveUsingITK(const std::string& aFileName,
818  bool useDeflateCompressionIfPossible = false) const;
819 
820 
821  //--------------------------------------------------------------------------
823 
828  //--------------------------------------------------------------------------
829  bool operator==(const Image<T>& anImage) const;
830 
831 
832  //--------------------------------------------------------------------------
834 
839  //--------------------------------------------------------------------------
840  bool operator!=(const Image<T>& anImage) const;
841 
842 
843  //--------------------------------------------------------------------------
845 
849  //--------------------------------------------------------------------------
850  Image operator+(const Image<T>& anImage) const;
851 
852 
853  //--------------------------------------------------------------------------
855 
859  //--------------------------------------------------------------------------
860  Image operator-(const Image<T>& anImage) const;
861 
862 
863  //--------------------------------------------------------------------------
865 
869  //--------------------------------------------------------------------------
870  Image operator*(const Image<T>& anImage) const;
871 
872 
873  //--------------------------------------------------------------------------
875 
879  //--------------------------------------------------------------------------
880  Image operator/(const Image<T>& anImage) const;
881 
882 
883  //--------------------------------------------------------------------------
885 
889  //--------------------------------------------------------------------------
890  Image<T>& operator+=(const Image<T>& anImage);
891 
892 
893  //--------------------------------------------------------------------------
895 
899  //--------------------------------------------------------------------------
900  Image<T>& operator-=(const Image<T>& anImage);
901 
902 
903  //--------------------------------------------------------------------------
905 
909  //--------------------------------------------------------------------------
910  Image<T>& operator*=(const Image<T>& anImage);
911 
912 
913  //--------------------------------------------------------------------------
915 
919  //--------------------------------------------------------------------------
920  Image<T>& operator/=(const Image<T>& anImage);
921 
922 
923  //--------------------------------------------------------------------------
925 
929  //--------------------------------------------------------------------------
930  Image operator+(T aValue) const;
931 
932 
933  //--------------------------------------------------------------------------
935 
939  //--------------------------------------------------------------------------
940  Image operator-(T aValue) const;
941 
942 
943  //--------------------------------------------------------------------------
945 
949  //--------------------------------------------------------------------------
950  Image operator*(T aValue) const;
951 
952 
953  //--------------------------------------------------------------------------
955 
959  //--------------------------------------------------------------------------
960  Image operator/(T aValue) const;
961 
962 
963  //--------------------------------------------------------------------------
965 
969  //--------------------------------------------------------------------------
970  Image<T>& operator+=(T aValue);
971 
972 
973  //--------------------------------------------------------------------------
975 
979  //--------------------------------------------------------------------------
980  Image<T>& operator-=(T aValue);
981 
982 
983  //--------------------------------------------------------------------------
985 
989  //--------------------------------------------------------------------------
990  Image<T>& operator*=(T aValue);
991 
992 
993  //--------------------------------------------------------------------------
995 
999  //--------------------------------------------------------------------------
1000  Image<T>& operator/=(T aValue);
1001 
1002 
1003  //--------------------------------------------------------------------------
1005 
1008  //--------------------------------------------------------------------------
1009  Image operator!() const;
1010 
1011 
1012  Image<T> abs() const;
1013 
1014 
1015  Image<T> log() const;
1016 
1017 
1018  Image<T> flipVertically() const;
1019 
1020 
1021  Image<T> flipHorizontally() const;
1022 
1023 
1024  double getSum() const;
1025 
1026 
1027  double getAverage() const;
1028 
1029 
1030  double getVariance() const;
1031 
1032 
1033  double getStandardDeviation() const;
1034 
1035 
1036  double computeSAE(const Image<T>& anImage) const;
1037 
1038 
1039  double computeMAE(const Image<T>& anImage) const;
1040 
1041 
1042  double computeSSE(const Image<T>& anImage) const;
1043 
1044 
1045  double computeMSE(const Image<T>& anImage) const;
1046 
1047 
1048  double computeRMSE(const Image<T>& anImage) const;
1049 
1050 
1051  double computeNCC(const Image<T>& anImage) const;
1052 
1053 
1054  gVirtualXRay::FFT<T> getFFT() const;
1055 
1056 
1057  Image<T> transpose() const;
1058 
1059 
1060  Image<T> resize(unsigned int aNewWidth,
1061  unsigned int aNewHeightunsigned,
1062  unsigned int aNewNumberOfSlices) const;
1063 
1064 
1065  Image<T> rotate(float anAngleInDegrees) const;
1066 
1067 
1068  Image<T> setCanvasSize(unsigned int aNewWidth,
1069  unsigned int aNewHeight,
1070  unsigned int aNewNumberOfSlices) const;
1071 
1072 
1073  gVirtualXRay::Sinogram<T> radonTransform(double aFirstAngle,
1074  double anAngleStep,
1075  double aLastAngle) const;
1076 
1077 
1078  //--------------------------------------------------------------------------
1082 
1094  //--------------------------------------------------------------------------
1095  PolygonMesh marchingCubes(const T& aFirstThresholdValue,
1096  const T& aSecondThresholdValue = 0,
1097  bool aTwoThresholdFlag = false,
1098  unsigned char aVerboseLevel = 0) const;
1099 
1100 
1101  //--------------------------------------------------------------------------
1103 
1110  //--------------------------------------------------------------------------
1111  void convertVoxelsToCubes(std::map<T, PolygonMesh>& aPolygonMeshSet,
1112  T aThreshold = -1000,
1113  unsigned char aVerboseLevel = 0) const;
1114 
1115 
1116  Image<T> convertHU2mu(double anEnergy) const;
1117 
1118 
1119  void allocateHostMemory();
1120 
1121 
1122  // Load the image as an OpenGL texture
1123  void transferHostToDevice();
1124 
1125 
1126  void transferDeviceToHost();
1127 
1128 
1129  // Destroy the OpenGL texture of the image if any
1130  void destroyOpenGLTexture();
1131 
1132 
1133  unsigned int getTextureId() const;
1134 
1135 
1136 //******************************************************************************
1137 protected:
1138  VEC3 VertexInterp(const T& aThresholdValue,
1139  const VEC3& p0,
1140  const VEC3& p1,
1141  const T& v0,
1142  const T& v1) const;
1143 
1144 
1146  unsigned int m_width;
1147 
1148 
1150  unsigned int m_height;
1151 
1152 
1154  unsigned int m_number_of_slices;
1155 
1156 
1159 
1160 
1163 
1164 
1166  unsigned int m_texture_id;
1167 
1168 
1169  static unsigned int g_mesh_type;
1170 
1171 
1172  static unsigned int g_vbo_type;
1173 
1174 
1175 //******************************************************************************
1176 private:
1177  void loadMetaHeader(const char* aFileName);
1178 
1179 
1180  void loadMetaHeader(const std::string& aFileName);
1181 
1182 
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/*,
1190  bool aCompressionFlag*/);
1191 
1192 
1193  void saveMetaHeader(const char* aFileName, bool useDeflateCompressionIfPossible) const;
1194 
1195 
1196  void saveMetaHeader(const std::string& aFileName, bool useDeflateCompressionIfPossible) const;
1197 
1198 
1199 #ifdef HAS_GDCM
1200  void addTag(double aValue,
1201  unsigned int anAddress1,
1202  unsigned int anAddress2,
1203  gdcm::File& aFile) const;
1204 
1205 
1206  void addTag(const char* aValue,
1207  unsigned int anAddress1,
1208  unsigned int anAddress2,
1209  gdcm::File& aFile) const;
1210 
1211 
1212  void addTag(const std::string& aValue,
1213  unsigned int anAddress1,
1214  unsigned int anAddress2,
1215  gdcm::File& aFile) const;
1216 #endif
1217 
1218 };
1219 
1220 
1221 } // namespace gVirtualXRay
1222 
1223 
1224 //******************************************************************************
1225 #include "Image.inl"
1226 
1227 
1228 #endif // __Image_h
void destroy()
Release the memory.
Definition: Image.inl:694
void savePGM(const char *aFileName) const
Save the image in a PGM file.
Definition: Image.inl:2597
void loadSeries(const char *aPattern, int aFirstSliceIndex, int aLastSliceIndex, int anIncrementIndex=1)
Definition: Image.inl:2285
T getMaxValue() const
Compute the maximum pixel value in the image.
Definition: Image.inl:850
void saveTIFF(const char *aFileName, bool anInvertLUTFlag=false) const
Save the image in a TIFF file.
Definition: Image.inl:3064
Type declarations.
void saveASCII(const char *aFileName) const
Save the image in an ASCII file.
Definition: Image.inl:2805
double getAverage() const
Definition: Image.inl:3585
Image< T > convolution1D(const std::vector< float > &aKernel) const
Definition: Image.inl:1360
Image< unsigned char > threshold(const T &aLowerThreshold, const T &aUpperThreshold, unsigned char anInValue, unsigned char anOutValue, bool aRunOnGPUFlag=true) const
Definition: Image.inl:1199
T & operator()(unsigned int i, unsigned int j, unsigned int k)
Definition: Image.inl:674
Image< T > operator+(const T &aValue, const Image< T > &anImage)
Definition: Image.inl:5137
PolygonMesh marchingCubes(const T &aFirstThresholdValue, const T &aSecondThresholdValue=0, bool aTwoThresholdFlag=false, unsigned char aVerboseLevel=0) const
Definition: Image.inl:4496
T & getPixel(unsigned int i, unsigned int j, unsigned int k=0)
Accessor on a pixel value.
Definition: Image.inl:582
void loadMHA(const char *aFileName)
Definition: Image.inl:2539
Image< T > log(const Image< T > &anImage)
Definition: Image.inl:5169
Image operator*(const Image< T > &anImage) const
Multiplication operator. Add anImage.
Definition: Image.inl:3875
void load(const char *aFileName)
Definition: Image.inl:2155
bool operator==(const Image< T > &anImage) const
Operator Equal to.
Definition: Image.inl:3528
Image< T > rotate(float anAngleInDegrees) const
Definition: Image.inl:4347
void loadUsingITK(const char *aFileName)
Definition: Image.inl:2222
void loadASCII(const char *aFileName)
Definition: Image.inl:351
gVirtualXRay::FFT< T > getFFT() const
Definition: Image.inl:3721
VEC3 m_spacing
The space between two successive pixels.
Definition: Image.h:1158
Image()
Default constructor.
Definition: Image.inl:184
void transferHostToDevice()
Definition: Image.inl:1028
Image operator-(const Image< T > &anImage) const
Subtraction operator. Add anImage.
Definition: Image.inl:3838
Image operator!() const
Negation operator. Compute the negative of the current image.
Definition: Image.inl:4165
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.
Definition: Image.h:94
Image< T > operator/(const T &aValue, const Image< T > &anImage)
Definition: Image.inl:5113
Image< float > getIsoTropic() const
Definition: Image.inl:1623
double getSum() const
Definition: Image.inl:3569
void destroyOpenGLTexture()
Definition: Image.inl:5046
static unsigned int g_vbo_type
Definition: Image.h:1172
Class to handle a greyscale image.
Image< T > log() const
Definition: Image.inl:2122
Image operator/(const Image< T > &anImage) const
Division operator. Add anImage.
Definition: Image.inl:3912
T * getRawData()
Accessor on the raw data.
Definition: Image.inl:717
double computeSSE(const Image< T > &anImage) const
Definition: Image.inl:3651
void save(const char *aFileName, bool anInvertLUTFlag=false, const char *aComment="", bool useDeflateCompressionIfPossible=false) const
Save the image in a file.
Definition: Image.inl:2432
Image< T > & operator=(const Image< T > &anImage)
Assignment operator (also called copy operator).
Definition: Image.inl:733
T & operator[](unsigned anIndex)
Definition: Image.inl:648
static unsigned int g_mesh_type
Definition: Image.h:1169
const VEC3 & getSpacing() const
Definition: Image.inl:828
void saveDCM(const char *aFileName, bool anInvertLUTFlag=false, const char *aComment="") const
Save the image in a DICOM file.
Definition: Image.inl:2884
void saveRAW(const char *aFileName, bool useDeflateCompressionIfPossible) const
Save the image in a Raw file.
Definition: Image.inl:2780
gVirtualXRay::Sinogram< T > radonTransform(double aFirstAngle, double anAngleStep, double aLastAngle) const
Definition: Image.inl:4422
PolygonMesh is a class to handle polygon (triangles) meshes.
Definition: PolygonMesh.h:114
Image is a class to manage a greyscale image.
Definition: Image.h:92
void saveUsingITK(const char *aFileName, bool useDeflateCompressionIfPossible=false) const
Save the image in a file using ITK.
Definition: Image.inl:3376
Image normalized() const
Normalize the image between 0 and 1.
Definition: Image.inl:2031
void transferDeviceToHost()
Definition: Image.inl:1151
Image< T > & operator-=(const Image< T > &anImage)
Subraction assignment operator. Add anImage.
Definition: Image.inl:3965
unsigned int getHeight() const
Number of pixels along the vertical axis.
Definition: Image.inl:792
void setPixel(unsigned int i, unsigned int j, unsigned int k, T aValue)
Set a pixel.
Definition: Image.inl:563
bool operator!=(const Image< T > &anImage) const
Operator Not equal to.
Definition: Image.inl:3561
Image< T > abs() const
Definition: Image.inl:2103
Image constantPadFilter(const T &aPadValue) const
Definition: Image.inl:1927
unsigned int sizeOf(const char *anElementType) const
Definition: Image.inl:5469
Image< T > resize(unsigned int aNewWidth, unsigned int aNewHeightunsigned, unsigned int aNewNumberOfSlices) const
Definition: Image.inl:4234
Vec3< RATIONAL_NUMBER > VEC3
Type of data used to store 3D vectors.
Definition: Types.h:115
VEC3 getPixelPosition(unsigned int i, unsigned int j, unsigned int k=0) const
Accessor on a pixel position.
Definition: Image.inl:638
Image< T > convolution2D(const Image< float > &aKernel) const
Definition: Image.inl:1396
unsigned int getDepth() const
Number of pixels along the Z axis.
Definition: Image.inl:800
Image< T > & operator+=(const Image< T > &anImage)
Addition assignment operator. Add anImage.
Definition: Image.inl:3953
double computeRMSE(const Image< T > &anImage) const
Definition: Image.inl:3686
unsigned int m_number_of_slices
Number of slices.
Definition: Image.h:1154
Image< float > antiAliasBinaryImageFilter(double aMaximumRMSChange, unsigned int aNumberOfIterations, double aVariance) const
Definition: Image.inl:1857
void loadMHD(const char *aFileName)
Definition: Image.inl:2522
unsigned int m_width
Number of pixel along the horizontal axis.
Definition: Image.h:1146
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).
Definition: Image.inl:509
unsigned int m_texture_id
OpenGL texture ID.
Definition: Image.h:1166
Image< T > setCanvasSize(unsigned int aNewWidth, unsigned int aNewHeight, unsigned int aNewNumberOfSlices) const
Definition: Image.inl:4194
Image< T > transpose() const
Definition: Image.inl:3727
~Image()
Destructor.
Definition: Image.inl:301
Image< T > operator-(const T &aValue, const Image< T > &anImage)
Definition: Image.inl:5146
T getMinValue() const
Compute the minimum pixel value in the image.
Definition: Image.inl:836
double computeMAE(const Image< T > &anImage) const
Definition: Image.inl:3643
Image< T > convertHU2mu(double anEnergy) const
unsigned int getWidth() const
Number of pixels along the horizontal axis.
Definition: Image.inl:784
Image< T > abs(const Image< T > &anImage)
Definition: Image.inl:5177
Image< unsigned char > closing(unsigned int aRadius) const
Definition: Image.inl:1555
Image< T > & operator/=(const Image< T > &anImage)
Division assignment operator. Add anImage.
Definition: Image.inl:3989
void loadRAW(const char *aFileName, unsigned int aWidth, unsigned int aHeight, unsigned int aNumberOfSlices=1, bool aChangeEndianessFlag=false, const char *anElementType=0)
Definition: Image.inl:2548
void setSpacing(const VEC3 &aPixelSize)
Definition: Image.inl:808
Image normalised() const
Normalise the image between 0 and 1.
Definition: Image.inl:2023
Image< T > gauss2D(unsigned int aSize, double aSigmaValue)
Definition: Image.inl:310
Image< T > flipVertically() const
Definition: Image.inl:2039
double getStandardDeviation() const
Definition: Image.inl:3612
double computeMSE(const Image< T > &anImage) const
Definition: Image.inl:3678
unsigned int getTextureId() const
Definition: Image.inl:5058
FFT is a class to compute the FFT of a greyscale image.
Definition: FFT.h:78
Image< T > flipHorizontally() const
Definition: Image.inl:2071
Image< T > & operator*=(const Image< T > &anImage)
Multiplication assignment operator. Add anImage.
Definition: Image.inl:3977
Image< unsigned char > opening(unsigned int aRadius) const
Definition: Image.inl:1487
double getVariance() const
Definition: Image.inl:3593
double computeNCC(const Image< T > &anImage) const
Definition: Image.inl:3694
unsigned int m_height
Number of pixel along the vertical axis.
Definition: Image.h:1150
void makeBlank(const T &aDefaultColour=0)
Replace all the pixels of an image with a default value.
Definition: Image.inl:343
Image shiftScaleFilter(double aShiftValue, double aScaleValue, bool aRunOnGPUFlag=true) const
Definition: Image.inl:892
Image< T > operator*(const T &aValue, const Image< T > &anImage)
Definition: Image.inl:5104
std::string getPixelType(const std::string &aFileName)
Definition: Image.inl:5096
Image operator+(const Image< T > &anImage) const
Addition operator. Add anImage.
Definition: Image.inl:3801
VEC3 VertexInterp(const T &aThresholdValue, const VEC3 &p0, const VEC3 &p1, const T &v0, const T &v1) const
Definition: Image.inl:5185
T * m_p_image
The pixel data.
Definition: Image.h:1162
void saveRaw(const char *aFileName, bool useDeflateCompressionIfPossible) const
Save the image in a Raw file.
Definition: Image.inl:2684
T & getPixelValue(unsigned int i, unsigned int j, unsigned int k=0)
Accessor on a pixel value.
Definition: Image.inl:618
void saveMHD(const char *aFileName, bool useDeflateCompressionIfPossible=false) const
Save the image in a MHD+RAW file.
Definition: Image.inl:2857
void loadDicomSeries(const char *aDirectory)
Definition: Image.inl:2363
double computeSAE(const Image< T > &anImage) const
Definition: Image.inl:3620
void saveMHA(const char *aFileName, bool useDeflateCompressionIfPossible=false) const
Save the image in a MHA+RAW file.
Definition: Image.inl:2871