MeVisLab Toolbox Reference
mlMedicalImageProperties.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_MEDICAL_IMAGE_PROPERTIES_H
14 #define ML_MEDICAL_IMAGE_PROPERTIES_H
15 
19 
20 // ML-includes
21 #include "mlDateTime.h"
22 #include "mlImageProperties.h"
23 #include "mlLinearAlgebra.h"
25 
26 #ifdef _MSC_VER
27 // Save warning state.
28 #pragma warning( push )
29 
30 // Warning disabled: 'warning C4275': non DLL-interface
31 // Reason: Exporting is done manually or as inline functions for the
32 // template class ImageProperties.
33 #pragma warning(disable : 4275 )
34 #endif
35 
36 ML_START_NAMESPACE
37 
38 // Use incomplete type to reduce header file dependencies.
39 class RuntimeType;
40 
41 //-------------------------------------------------------------------------
67 //-------------------------------------------------------------------------
69 {
70 
71 public:
72 
73  //-------------------------------------------------------------------
76  //-------------------------------------------------------------------
81 
84 
87  MedicalImageProperties(const MedicalImageProperties& medicalImageProperties);
88 
91  MedicalImageProperties &operator=(const MedicalImageProperties& medicalImageProperties);
92 
96  void setImageProperties(const MedicalImageProperties& medicalImageProperties);
98 
99  //-------------------------------------------------------------------
102  //-------------------------------------------------------------------
104  bool operator==(const MedicalImageProperties& medicalImageProperties) const;
105 
107  bool operator!=(const MedicalImageProperties& medicalImageProperties) const;
109 
110  //-------------------------------------------------------------------
113  //-------------------------------------------------------------------
116 
118  void setVoxelSize(const Vector3& voxelSize);
119 
122 
126 
130 
132 
133  //-------------------------------------------------------------------
136  //-------------------------------------------------------------------
148 
151  void setVoxelToWorldMatrixValid(bool valid);
152 
155 
157  void setVoxelToWorldMatrix(const Matrix4& matrix);
158 
161 
163  Vector3 mapVoxelToWorld(const Vector3& voxelPosition) const;
164 
166  Vector3 mapWorldToVoxel(const Vector3& worldPosition) const;
167 
170  void scaleVoxelToWorldMatrix(const Vector3& scaleFactors);
171 
173  void translateVoxelToWorldMatrix(const Vector3& offsetVector);
174 
176 
177  //--------------------------------------------------------------------------------
180  //--------------------------------------------------------------------------------
199  std::vector<std::string>& getCDimensionInfos() { return _cDimInfos; };
200  std::vector<DateTime>& getTDimensionInfos() { return _tDimInfos; };
201  std::vector<std::string>& getUDimensionInfos() { return _uDimInfos; };
202 
203  const std::vector<std::string>& getCDimensionInfos() const { return _cDimInfos; };
204  const std::vector<DateTime>& getTDimensionInfos() const { return _tDimInfos; };
205  const std::vector<std::string>& getUDimensionInfos() const { return _uDimInfos; };
206 
208 
209  //--------------------------------------------------------------------------------
212  //--------------------------------------------------------------------------------
214  ImagePropertyExtensionContainer& getImagePropertyContainer() { return _imagePropertyExtensions; }
215  const ImagePropertyExtensionContainer& getConstImagePropertyContainer() const { return _imagePropertyExtensions; }
217 
218 
219 private:
220 
221  //-------------------------------------------------------------------
224  //-------------------------------------------------------------------
227  void updateVoxelSizeFromToWorldMatrix();
228 
234  void updateToWorldMatrixFromVoxelSize();
235 
239  void correctToWorldMatrix();
241 
242 
248  void _assignMembers(const MedicalImageProperties& medicalImageProperties);
249 
250  //-------------------------------------------------------------------
253  //-------------------------------------------------------------------
255  MLdouble _x_VoxelSize;
256 
258  MLdouble _y_VoxelSize;
259 
261  MLdouble _z_VoxelSize;
262 
264  Matrix4 _toWorldMatrix;
265 
268  Matrix4 _toVoxelMatrix;
269 
272  bool _isToWorldMatrixValid;
274 
275  //-------------------------------------------------------------------
278  //-------------------------------------------------------------------
281  std::vector<std::string> _cDimInfos;
282  std::vector<DateTime> _tDimInfos;
283  std::vector<std::string> _uDimInfos;
285 
286 
287  //-------------------------------------------------------------------
291  //-------------------------------------------------------------------
292  ImagePropertyExtensionContainer _imagePropertyExtensions;
294 
295 #if ML_DEPRECATED_SINCE(3,5,0)
296 
299 
300 public:
301 
304  inline ML_DEPRECATED void setImgProps(const MedicalImageProperties &medImgProps) { setImageProperties(medImgProps); }
307  inline ML_DEPRECATED bool isToWorldMatrixValid() const { return isVoxelToWorldMatrixValid(); }
310  inline ML_DEPRECATED void setToWorldMatrixValid(bool valid) { setVoxelToWorldMatrixValid(valid); }
313  ML_DEPRECATED void getVoxelSize(MLfloat *dx, MLfloat *dy, MLfloat *dz) const;
316  ML_DEPRECATED void getToWorldMatrix(MLfloat *mat) const;
319  ML_DEPRECATED void setToWorldMatrix(MLfloat *mat);
322  ML_DEPRECATED const Matrix4* getToWorldMatrix() const;
325  ML_DEPRECATED void setToWorldMatrix(const Matrix4 *mat);
328  ML_DEPRECATED void setToWorldMatrixIdentity();
331  ML_DEPRECATED void getToVoxelMatrix(MLfloat *mat) const;
334  ML_DEPRECATED const Matrix4* getToVoxelMatrix() const;
337  ML_DEPRECATED void transformToWorldCoord (MLfloat *x, MLfloat *y, MLfloat *z) const;
340  ML_DEPRECATED void transformToWorldCoord (MLdouble *x, MLdouble *y, MLdouble *z) const;
343  ML_DEPRECATED void transformToWorldCoord (const Vector3& voxel, Vector3& world) const;
346  ML_DEPRECATED void transformToVoxelCoord (MLfloat *x, MLfloat *y, MLfloat *z) const;
349  ML_DEPRECATED void transformToVoxelCoord (MLdouble *x, MLdouble *y, MLdouble *z) const;
352  ML_DEPRECATED void transformToVoxelCoord (const Vector3& world, Vector3& voxel) const;
355  inline ML_DEPRECATED void scaleImage(MLfloat x, MLfloat y, MLfloat z) { scaleVoxelToWorldMatrix(Vector3(x,y,z)); }
358  inline ML_DEPRECATED void translateImage(MLfloat x, MLfloat y, MLfloat z) { translateVoxelToWorldMatrix(Vector3(x,y,z)); }
361  inline ML_DEPRECATED std::vector<std::string>& getCDimInfos() { return getCDimensionInfos(); };
364  inline ML_DEPRECATED std::vector<DateTime>& getTDimInfos() { return getTDimensionInfos(); };
367  inline ML_DEPRECATED std::vector<std::string>& getUDimInfos() { return getUDimensionInfos(); };
370  inline ML_DEPRECATED const std::vector<std::string> &getConstCDimInfos() const { return getCDimensionInfos(); };
373  inline ML_DEPRECATED const std::vector<DateTime> &getConstTDimInfos() const { return getTDimensionInfos(); };
376  inline ML_DEPRECATED const std::vector<std::string> &getConstUDimInfos() const { return getUDimensionInfos(); };
377 
379 
380 #endif
381 
382 };
383 
384 
385 #ifdef _MSC_VER
387 #pragma warning( pop )
388 #endif
389 
390 
391 ML_END_NAMESPACE
392 
393 
394 
395 
396 
397 #endif //of __mlMedicalImageProperties_H
398 
399 
400 
#define ML_DEPRECATED
Definition: CSOGroup.h:371
This class represents basic image properties:
MLEXPORT void setImageProperties(const ImageProperties &imageProperties)
Copy property parameters from another image property instance imageProperties.
This class is a container for extended image properties derived from ImagePropertyExtension.
This class encapsulates basic medical image properties:
void setVoxelSize(const Vector3 &voxelSize)
Sets the voxel size to voxelSize. The transformation matrix is adapted adequately.
std::vector< std::string > & getUDimensionInfos()
Vector3 getVoxelSize() const
Returns the voxel size.
MedicalImageProperties()
Constructor.
const Matrix4 & getVoxelToWorldMatrix() const
Returns the voxelToWorld matrix.
bool isVoxelToWorldMatrixValid() const
Shows the validity state of the VoxelToWorldMatrix (default=true=valid).
void setVoxelToWorldMatrix(const Matrix4 &matrix)
Sets the matrix which transforms voxel to world coordinates to matrix.
void setImageProperties(const MedicalImageProperties &medicalImageProperties)
Sets a copy of the passed image properties medicalImageProperties.
std::vector< DateTime > & getTDimensionInfos()
Vector3 mapWorldToVoxel(const Vector3 &worldPosition) const
Maps the worldPosition vector to voxel coordinates and returns it.
const Matrix4 & getWorldToVoxelMatrix() const
Returns the worlToVoxel matrix.
bool operator!=(const MedicalImageProperties &medicalImageProperties) const
Returns true if *this and medicalImageProperties differ, otherwise false.
const ImagePropertyExtensionContainer & getConstImagePropertyContainer() const
const std::vector< DateTime > & getTDimensionInfos() const
bool operator==(const MedicalImageProperties &medicalImageProperties) const
Returns true if *this and medicalImageProperties are identical, otherwise false.
void setVoxelToWorldMatrixValid(bool valid)
Validates/Invalidates the VoxelToWorld matrix by passing true/false as valid.
~MedicalImageProperties() override
Destructor. Cleans up dynamically allocated memory.
void setVoxelSize(MLdouble dx, MLdouble dy, MLdouble dz)
Sets the voxel size to dx, dy and dz. This changes the voxelToWorld matrix.
double getVoxelVolumeInMilliliters() const
Returns the volume of a single voxel in milliliters (ml).
std::vector< std::string > & getCDimensionInfos()
Permits access to the additional information for subimages on the c-, t- and u-dimensions.
Vector3 mapVoxelToWorld(const Vector3 &voxelPosition) const
Maps the voxelPosition vector to world coordinates and returns it.
const std::vector< std::string > & getCDimensionInfos() const
ImagePropertyExtensionContainer & getImagePropertyContainer()
Permits access to the container for user image properties.
const std::vector< std::string > & getUDimensionInfos() const
MedicalImageProperties(const MedicalImageProperties &medicalImageProperties)
Copy constructor from an existing medicalImageProperties object to get a copy.
void translateVoxelToWorldMatrix(const Vector3 &offsetVector)
Translates the voxelToWorld matrix by the offsetVector.
void scaleVoxelToWorldMatrix(const Vector3 &scaleFactors)
Scales the voxelToWorld matrix by the vector scaleFactors and updates the image's voxel size.
MedicalImageProperties & operator=(const MedicalImageProperties &medicalImageProperties)
Assignment operator from an existing edicalImageProperties object to get a copy.
double getVoxelVolumeInCubicMillimeters() const
Returns the volume of a single voxel in cubic millimeters (mm3).
#define MLEXPORT
To export symbols from a dll/shared object, we need to mark them with the MLEXPORT symbol.
double MLdouble
Definition: mlTypeDefs.h:223
float MLfloat
Definition: mlTypeDefs.h:207
MLDICOM_TO_ML_TOOLS_EXPORT size_t getVoxelSize(DCMTree::Const_TreePtr treePtr, double &voxSizeX, double &voxSizeY, double &voxSizeZ, bool replaceOnlyIfFound, bool *isPrecise, std::vector< DCMTree::RawTagId > *usedTags, DicomMessageCollector &dcmMsgCollector)
Determine the voxel size from the DICOM tags and returns the number of found extents.
Tmat4< MLdouble > Matrix4
The standard 4x4 matrix of type double.
Definition: mlMatrix4.h:726
Tvec3< MLdouble > Vector3
A vector with 3 components of type double.
Definition: mlVector3.h:300