NorMIT-nav  22.09
An IGT application
cxImage.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 
13 #ifndef CXIMAGE_H_
14 #define CXIMAGE_H_
15 
16 #include "cxResourceExport.h"
17 #include "cxPrecompiledHeader.h"
18 
19 #include <map>
20 #include <vector>
21 #include <boost/shared_ptr.hpp>
22 #include "cxBoundingBox3D.h"
23 #include "vtkForwardDeclarations.h"
24 #include "cxForwardDeclarations.h"
25 #include "cxData.h"
26 
27 typedef boost::shared_ptr<std::map<int, int> > HistogramMapPtr;
28 
29 class QDomNode;
30 class QDomDocument;
31 
32 
33 namespace cx
34 {
35 typedef std::map<int, int> IntIntMap;
36 typedef std::map<int, QColor> ColorMap;
37 
45 class cxResource_EXPORT Image : public Data
46 {
47 Q_OBJECT
48 
49 public:
51  {
52  bool on;
53  double ambient;
54  double diffuse;
55  double specular;
56  double specularPower;
57 
58  ShadingStruct();
59  void addXml(QDomNode dataNode);
60  void parseXml(QDomNode dataNode);
61 
62  private:
63  double loadAttribute(QDomNode dataNode, QString name, double defVal);
64  };
65 
66  static ImagePtr create(const QString& uid, const QString& name);
67  ImagePtr copy();
68 
69  virtual ~Image();
70  Image(const QString& uid, const vtkImageDataPtr& data, const QString& name = "");
71 
74  virtual void intitializeFromParentImage(ImagePtr parentImage);
75  virtual void setVtkImageData(const vtkImageDataPtr& data, bool resetTransferFunctions = true);
76 
77  virtual vtkImageDataPtr getBaseVtkImageData();
78  virtual vtkImageDataPtr getGrayScaleVtkImageData();
79  virtual vtkImageDataPtr get8bitGrayScaleVtkImageData();
80 
83  virtual ImagePtr getUnsigned(ImagePtr self);
84 
85  virtual IMAGE_MODALITY getModality() const;
86  virtual void setModality(const IMAGE_MODALITY &val);
87  virtual IMAGE_SUBTYPE getImageType() const;
88  virtual void setImageType(const IMAGE_SUBTYPE &val);
89 
90  virtual ImageTF3DPtr getTransferFunctions3D();
91  virtual void setTransferFunctions3D(ImageTF3DPtr transferFuntion);
92  virtual ImageLUT2DPtr getLookupTable2D();
93  virtual void setLookupTable2D(ImageLUT2DPtr imageLookupTable2D);
94 
95  virtual void setInitialWindowLevel(double width, double level);
96  double getInitialWindowLevel() const { return mInitialWindowLevel; }
97  double getInitialWindowWidth() const { return mInitialWindowWidth; }
98 
99  virtual DoubleBoundingBox3D boundingBox() const;
100  virtual Eigen::Array3d getSpacing() const;
101  virtual vtkImageAccumulatePtr getHistogram();
102  virtual int getMax();
103  virtual int getMin();
104  virtual int getRange();
105  virtual int getMaxAlphaValue();
106  virtual void setShadingOn(bool on);
107  virtual bool getShadingOn() const;
108  virtual void setShadingAmbient(double ambient);
109  virtual void setShadingDiffuse(double diffuse);
110  virtual void setShadingSpecular(double specular);
111  virtual void setShadingSpecularPower(double specularPower);
112  virtual double getShadingAmbient();
113  virtual double getShadingDiffuse();
114  virtual double getShadingSpecular();
115  virtual double getShadingSpecularPower();
116  virtual Image::ShadingStruct getShading();
117  virtual void setShading(Image::ShadingStruct shading);
118 
119  void addXml(QDomNode& dataNode);
120  virtual void parseXml(QDomNode& dataNode);
121  virtual bool load(QString path, FileManagerServicePtr filemanager);
122  virtual QString getType() const
123  {
124  return getTypeName();
125  }
126  static QString getTypeName()
127  {
128  return "image";
129  }
130  virtual QIcon getIcon() {return QIcon(":/icons/volume.png");}
131 
132  // methods for defining and storing a cropping box. Image does not use these data, this is up to the mapper
133  virtual void setCropping(bool on);
134  virtual bool getCropping() const;
135  virtual void setCroppingBox(const DoubleBoundingBox3D& bb_d);
136  virtual DoubleBoundingBox3D getCroppingBox() const;
137 
138  void mergevtkSettingsIntosscTransform();
139 
140  void resetTransferFunctions(bool _2D=true, bool _3D=true);
141 
142  void moveThisAndChildrenToThread(QThread* thread);
143 
144  static vtkImageDataPtr createDummyImageData(int axisSize, int maxVoxelValue);
145 
146 // void setInterpolationTypeToNearest();
147 // void setInterpolationTypeToLinear();
148  void setInterpolationType(int val);
149  int getInterpolationType() const;
150 
151  vtkImageDataPtr resample(long maxVoxels);
152 
153  virtual void save(const QString &basePath, FileManagerServicePtr filemanager);
154 
155  void startThresholdPreview(const Eigen::Vector2d& threshold);
156  void stopThresholdPreview();
157  double getVTKMinValue();
158  double getVTKMaxValue();
159  bool is2D();
160 
161 signals:
162  void vtkImageDataChanged(QString uid = QString());
163  void transferFunctionsChanged();
164  void cropBoxChanged();
165 
166 protected slots:
167  virtual void transformChangedSlot();
168 
169 protected:
172 // vtkImageReslicePtr mOrientator; ///< converts imagedata to outputimagedata
173 // vtkMatrix4x4Ptr mOrientatorMatrix;
174 // vtkImageDataPtr mReferenceImageData; ///< imagedata after filtering through the orientatior, given in reference space
177 
178 // LandmarksPtr mLandmarks;
179 
181 
184 
185  IMAGE_MODALITY mModality;
186  IMAGE_SUBTYPE mImageType;
189 
190 
191 private:
192  Image(const Image& other);
193  Image& operator=(const Image& other);
194  void resetTransferFunction(ImageTF3DPtr imageTransferFunctions3D, ImageLUT2DPtr imageLookupTable2D);
195  void resetTransferFunction(ImageLUT2DPtr imageLookupTable2D);
196  void resetTransferFunction(ImageTF3DPtr imageTransferFunctions3D);
197  DoubleBoundingBox3D getInitialBoundingBox() const;
198  double loadAttribute(QDomNode dataNode, QString name, double defVal);
199 
200  double computeResampleFactor(long maxVoxels);
201 
202  ColorMap createPreviewColorMap(const Eigen::Vector2d &threshold);
203  IntIntMap createPreviewOpacityMap(const Eigen::Vector2d &threshold);
204  void createThresholdPreviewTransferFunctions3D(const Eigen::Vector2d &threshold);
205  void createThresholdPreviewLookupTable2D(const Eigen::Vector2d &threshold);
206 
207  ImageTF3DPtr getUnmodifiedTransferFunctions3D();
208  ImageLUT2DPtr getUnmodifiedLookupTable2D();
209 
210  ImageTF3DPtr mImageTransferFunctions3D;
211  ImageLUT2DPtr mImageLookupTable2D;
212 
213  double mInitialWindowWidth;
214  double mInitialWindowLevel;
215 
216  bool mThresholdPreview;
217  ImageTF3DPtr mTresholdPreviewTransferfunctions3D;
218  ImageLUT2DPtr mTresholdPreviewLookupTable2D;
219 };
220 
221 } // end namespace cx
222 
223 #endif /*CXIMAGE_H_*/
cx::Image::mBaseImageData
vtkImageDataPtr mBaseImageData
image data in data space
Definition: cxImage.h:170
cx::Image::getType
virtual QString getType() const
Definition: cxImage.h:122
cx::Image::ShadingStruct::specular
double specular
Definition: cxImage.h:55
cx::DoubleBoundingBox3D
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,...
Definition: cxBoundingBox3D.h:63
cx::Image::mUnsigned
ImagePtr mUnsigned
version of this containing unsigned data.
Definition: cxImage.h:176
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cxPrecompiledHeader.h
cxForwardDeclarations.h
cx::Image::getInitialWindowLevel
double getInitialWindowLevel() const
Definition: cxImage.h:96
cx::Image::ShadingStruct::on
bool on
Definition: cxImage.h:52
vtkImageDataPtr
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
Definition: cxVideoConnectionWidget.h:30
cxBoundingBox3D.h
cx::ImageTF3DPtr
boost::shared_ptr< class ImageTF3D > ImageTF3DPtr
Definition: cxForwardDeclarations.h:50
cx::FileManagerServicePtr
boost::shared_ptr< class FileManagerService > FileManagerServicePtr
Definition: cxLogicManager.h:31
cx::Image::mInterpolationType
int mInterpolationType
mirror the interpolationType in vtkVolumeProperty
Definition: cxImage.h:188
cx::ColorMap
std::map< int, QColor > ColorMap
Definition: cxImage.h:36
cxData.h
cx::Image::ShadingStruct
Definition: cxImage.h:50
cx::Image::mBaseGrayScaleImageData
vtkImageDataPtr mBaseGrayScaleImageData
image data in data space
Definition: cxImage.h:171
cx::Image::mHistogramPtr
vtkImageAccumulatePtr mHistogramPtr
Histogram.
Definition: cxImage.h:175
cx::Image::getIcon
virtual QIcon getIcon()
Definition: cxImage.h:130
cx::Image::getTypeName
static QString getTypeName()
Definition: cxImage.h:126
vtkImageAccumulatePtr
vtkSmartPointer< class vtkImageAccumulate > vtkImageAccumulatePtr
Definition: vtkForwardDeclarations.h:63
vtkForwardDeclarations.h
cx::Image::mImageType
IMAGE_SUBTYPE mImageType
type of the image, defined as DICOM tag (0008,0008) (mainly value 3, but might be a merge of value 4)...
Definition: cxImage.h:186
cx::ImagePtr
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
cx::IntIntMap
std::map< int, int > IntIntMap
Definition: cxImage.h:35
cx::Image::mShading
ShadingStruct mShading
Definition: cxImage.h:180
cx::Image::mMaxRGBIntensity
double mMaxRGBIntensity
Definition: cxImage.h:187
cx::Image::getInitialWindowWidth
double getInitialWindowWidth() const
Definition: cxImage.h:97
HistogramMapPtr
boost::shared_ptr< std::map< int, int > > HistogramMapPtr
Definition: cxImage.h:27
cx::Image::mModality
IMAGE_MODALITY mModality
modality of the image, defined as DICOM tag (0008,0060), Section 3, C.7.3.1.1.1
Definition: cxImage.h:185
cx::Image
A volumetric data set.
Definition: cxImage.h:45
cx::Data
Superclass for all data objects.
Definition: cxData.h:89
cx::Image::ShadingStruct::specularPower
double specularPower
Definition: cxImage.h:56
cx::Image::ShadingStruct::ambient
double ambient
Definition: cxImage.h:53
cx::Image::ShadingStruct::diffuse
double diffuse
Definition: cxImage.h:54
cx::ImageLUT2DPtr
boost::shared_ptr< class ImageLUT2D > ImageLUT2DPtr
Definition: cxForwardDeclarations.h:51
cx::Image::mCroppingBox_d
DoubleBoundingBox3D mCroppingBox_d
box defining the cropping size.
Definition: cxImage.h:183
cx::Image::mUseCropping
bool mUseCropping
image should be cropped using mCroppingBox
Definition: cxImage.h:182