CustusX  15.3.4-beta
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, 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
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 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
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 
34 #ifndef CXIMAGE_H_
35 #define CXIMAGE_H_
36 
37 #include "cxResourceExport.h"
38 #include "cxPrecompiledHeader.h"
39 
40 #include <map>
41 #include <vector>
42 #include <boost/shared_ptr.hpp>
43 #include "cxBoundingBox3D.h"
44 #include "vtkForwardDeclarations.h"
45 #include "cxForwardDeclarations.h"
46 #include "cxData.h"
47 
48 typedef boost::shared_ptr<std::map<int, int> > HistogramMapPtr;
49 
50 class QDomNode;
51 class QDomDocument;
52 
53 
54 namespace cx
55 {
56 
64 class cxResource_EXPORT Image : public Data
65 {
66 Q_OBJECT
67 
68 public:
70  {
71  bool on;
72  double ambient;
73  double diffuse;
74  double specular;
75  double specularPower;
76 
77  ShadingStruct();
78  void addXml(QDomNode dataNode);
79  void parseXml(QDomNode dataNode);
80 
81  private:
82  double loadAttribute(QDomNode dataNode, QString name, double defVal);
83  };
84 
85  static ImagePtr create(const QString& uid, const QString& name);
86  ImagePtr copy();
87 
88  virtual ~Image();
89  Image(const QString& uid, const vtkImageDataPtr& data, const QString& name = "");
90 
93  virtual void intitializeFromParentImage(ImagePtr parentImage);
94  virtual void setVtkImageData(const vtkImageDataPtr& data, bool resetTransferFunctions = true);
95 
96  virtual vtkImageDataPtr getBaseVtkImageData();
97  virtual vtkImageDataPtr getGrayScaleVtkImageData();
98  virtual vtkImageDataPtr get8bitGrayScaleVtkImageData();
99 // virtual vtkImageDataPtr getRefVtkImageData(); ///< \return the vtkimagedata in the reference coordinate space
100 // LandmarksPtr getLandmarks();
104  virtual ImagePtr getUnsigned(ImagePtr self);
105 
106  virtual QString getModality() const;
107  virtual void setModality(const QString& val);
108  virtual QString getImageType() const;
109  virtual void setImageType(const QString& val);
110 
111  virtual ImageTF3DPtr getTransferFunctions3D();
112  virtual void setTransferFunctions3D(ImageTF3DPtr transferFuntion);
113  virtual ImageLUT2DPtr getLookupTable2D();
114  virtual void setLookupTable2D(ImageLUT2DPtr imageLookupTable2D);
115 
116  virtual void setInitialWindowLevel(double width, double level);
117  double getInitialWindowLevel() const { return mInitialWindowLevel; }
118  double getInitialWindowWidth() const { return mInitialWindowWidth; }
119 
120  virtual DoubleBoundingBox3D boundingBox() const;
121  virtual Eigen::Array3d getSpacing() const;
122  virtual vtkImageAccumulatePtr getHistogram();
123  virtual int getMax();
124  virtual int getMin();
125  virtual int getRange();
126  virtual int getMaxAlphaValue();
127  virtual void setShadingOn(bool on);
128  virtual bool getShadingOn() const;
129  virtual void setShadingAmbient(double ambient);
130  virtual void setShadingDiffuse(double diffuse);
131  virtual void setShadingSpecular(double specular);
132  virtual void setShadingSpecularPower(double specularPower);
133  virtual double getShadingAmbient();
134  virtual double getShadingDiffuse();
135  virtual double getShadingSpecular();
136  virtual double getShadingSpecularPower();
137  virtual Image::ShadingStruct getShading();
138  virtual void setShading(Image::ShadingStruct shading);
139 
140  void addXml(QDomNode& dataNode);
141  virtual void parseXml(QDomNode& dataNode);
142  virtual bool load(QString path);
143  virtual QString getType() const
144  {
145  return getTypeName();
146  }
147  static QString getTypeName()
148  {
149  return "image";
150  }
151 
152  // methods for defining and storing a cropping box. Image does not use these data, this is up to the mapper
153  virtual void setCropping(bool on);
154  virtual bool getCropping() const;
155  virtual void setCroppingBox(const DoubleBoundingBox3D& bb_d);
156  virtual DoubleBoundingBox3D getCroppingBox() const;
157 
158  // methods for defining and storing clip planes. Image does not use these data, this is up to the mapper
159  virtual void addPersistentClipPlane(vtkPlanePtr plane);
160  virtual std::vector<vtkPlanePtr> getAllClipPlanes();
161  virtual void clearPersistentClipPlanes();
162  virtual void setInteractiveClipPlane(vtkPlanePtr plane);
163 
164  void mergevtkSettingsIntosscTransform();
165 
166  void resetTransferFunctions(bool _2D=true, bool _3D=true);
167 
168  void moveThisAndChildrenToThread(QThread* thread);
169 
170  static vtkImageDataPtr createDummyImageData(int axisSize, int maxVoxelValue);
171 
172  void setInterpolationTypeToNearest();
173  void setInterpolationTypeToLinear();
174  void setInterpolationType(int val);
175  int getInterpolationType() const;
176 
177  vtkImageDataPtr resample(long maxVoxels);
178 
179  virtual void save(const QString &basePath);
180 signals:
181  void vtkImageDataChanged();
182  void transferFunctionsChanged();
183  void clipPlanesChanged();
184  void cropBoxChanged();
185 
186 protected slots:
187  virtual void transformChangedSlot();
188 
189 protected:
192 // vtkImageReslicePtr mOrientator; ///< converts imagedata to outputimagedata
193 // vtkMatrix4x4Ptr mOrientatorMatrix;
194 // vtkImageDataPtr mReferenceImageData; ///< imagedata after filtering through the orientatior, given in reference space
197 
198 // LandmarksPtr mLandmarks;
199 
201 
204  std::vector<vtkPlanePtr> mPersistentClipPlanes;
206  QString mModality;
207  QString mImageType;
210 
211 
212 private:
213  Image(const Image& other);
214  Image& operator=(const Image& other);
215  void resetTransferFunction(ImageTF3DPtr imageTransferFunctions3D, ImageLUT2DPtr imageLookupTable2D);
216  void resetTransferFunction(ImageLUT2DPtr imageLookupTable2D);
217  void resetTransferFunction(ImageTF3DPtr imageTransferFunctions3D);
218  DoubleBoundingBox3D getInitialBoundingBox() const;
219  double loadAttribute(QDomNode dataNode, QString name, double defVal);
220 
221  double computeResampleFactor(long maxVoxels);
222 
223  ImageTF3DPtr mImageTransferFunctions3D;
224  ImageLUT2DPtr mImageLookupTable2D;
225 
226  double mInitialWindowWidth;
227  double mInitialWindowLevel;
228 };
229 
230 } // end namespace cx
231 
232 #endif /*CXIMAGE_H_*/
ShadingStruct mShading
Definition: cxImage.h:200
bool mUseCropping
image should be cropped using mCroppingBox
Definition: cxImage.h:202
double getInitialWindowLevel() const
Definition: cxImage.h:117
QString 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:207
vtkSmartPointer< class vtkImageAccumulate > vtkImageAccumulatePtr
virtual QString getType() const
Definition: cxImage.h:143
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:48
double mMaxRGBIntensity
Definition: cxImage.h:208
double getInitialWindowWidth() const
Definition: cxImage.h:118
DoubleBoundingBox3D mCroppingBox_d
box defining the cropping size.
Definition: cxImage.h:203
ImagePtr mUnsigned
version of this containing unsigned data.
Definition: cxImage.h:196
boost::shared_ptr< class ImageLUT2D > ImageLUT2DPtr
vtkPlanePtr mInteractiveClipPlane
Definition: cxImage.h:205
QString mModality
modality of the image, defined as DICOM tag (0008,0060), Section 3, C.7.3.1.1.1
Definition: cxImage.h:206
A volumetric data set.
Definition: cxImage.h:64
boost::shared_ptr< std::map< int, int > > HistogramMapPtr
Definition: cxImage.h:48
static QString getTypeName()
Definition: cxImage.h:147
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
vtkImageAccumulatePtr mHistogramPtr
Histogram.
Definition: cxImage.h:195
Superclass for all data objects.
Definition: cxData.h:69
std::vector< vtkPlanePtr > mPersistentClipPlanes
Definition: cxImage.h:204
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
vtkImageDataPtr mBaseImageData
image data in data space
Definition: cxImage.h:190
int mInterpolationType
mirror the interpolationType in vtkVolumeProperty
Definition: cxImage.h:209
vtkSmartPointer< class vtkPlane > vtkPlanePtr
boost::shared_ptr< class ImageTF3D > ImageTF3DPtr
vtkImageDataPtr mBaseGrayScaleImageData
image data in data space
Definition: cxImage.h:191