NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
niftkImageToSurfaceFilter.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef niftkImageToSurfaceFilter_h
16 #define niftkImageToSurfaceFilter_h
17 
18 #include "niftkCoreExports.h"
19 
20 #include <mitkCommon.h>
21 #include <mitkSurfaceSource.h>
22 #include <mitkSurface.h>
23 #include <mitkImage.h>
24 
25 #include <vtkPolyData.h>
26 #include <vtkImageData.h>
27 #include <vtkSmoothPolyDataFilter.h>
28 #include <vtkMarchingCubes.h>
29 #include <vtkSmartPointer.h>
30 
31 #include "niftkBasicVertex.h"
32 #include "niftkBasicTriangle.h"
33 #include "niftkCMC33.h"
34 #include "mitkBasicImageProcessor.h"
35 
36 namespace niftk
37 {
38 
58 
59 class NIFTKCORE_EXPORT ImageToSurfaceFilter : public mitk::SurfaceSource
60 {
61 public:
62 
63  enum SurfaceExtractionMethod {StandardExtractor, EnhancedCPUExtractor, GPUExtractor};
64  enum SurfaceDecimationMethod {NoDecimation, DecimatePro, QuadricVTK, Quadric, QuadricTri, Melax, ShortestEdge};
65  enum SurfaceSmoothingMethod {NoSurfaceSmoothing, TaubinSmoothing, CurvatureNormalSmooth, InverseEdgeLengthSmooth, WindowedSincSmoothing, StandardVTKSmoothing};
66  enum InputSmoothingMethod {NoInputSmoothing, GaussianSmoothing, MedianSmoothing};
67 
68  mitkClassMacro(ImageToSurfaceFilter, SurfaceSource)
69  itkNewMacro(Self)
70 
72  virtual void GenerateData() override;
73 
75  virtual void GenerateOutputInformation() override;
76 
78  const mitk::Image *GetInput(void);
79 
81  using itk::ProcessObject::SetInput;
82  virtual void SetInput(const mitk::Image *image);
83 
84 
89  itkSetMacro(Threshold, mitk::ScalarType);
90 
92  itkGetConstMacro(Threshold, mitk::ScalarType);
93 
95  itkGetConstMacro(SurfaceExtractionType, SurfaceExtractionMethod);
96 
98  itkSetMacro(SurfaceExtractionType, SurfaceExtractionMethod);
99 
100 
101 
103  itkGetConstMacro(InputSmoothingType, InputSmoothingMethod);
104 
106  itkSetMacro(InputSmoothingType, InputSmoothingMethod);
107 
109  itkSetMacro(PerformInputSmoothing,bool);
110 
112  itkBooleanMacro(PerformInputSmoothing);
113 
115  itkGetConstMacro(PerformInputSmoothing,bool);
116 
118  itkSetMacro(InputSmoothingRadius, float);
119 
121  itkGetConstMacro(InputSmoothingRadius, float);
122 
124  itkSetMacro(InputSmoothingIterations, int);
125 
127  itkGetConstMacro(InputSmoothingIterations, int);
128 
129 
130 
132  itkGetConstMacro(SurfaceSmoothingType, SurfaceSmoothingMethod);
133 
135  itkSetMacro(SurfaceSmoothingType, SurfaceSmoothingMethod);
136 
138  itkSetMacro(PerformSurfaceSmoothing,bool);
139 
141  itkBooleanMacro(PerformSurfaceSmoothing);
142 
144  itkGetConstMacro(PerformSurfaceSmoothing,bool);
145 
147  itkSetMacro(SurfaceSmoothingRadius, float);
148 
150  itkGetConstMacro(SurfaceSmoothingRadius, float);
151 
153  itkSetMacro(SurfaceSmoothingIterations, int);
154 
156  itkGetConstMacro(SurfaceSmoothingIterations, int);
157 
158 
159 
161  itkGetConstMacro(SurfaceDecimationType, SurfaceDecimationMethod);
162 
164  itkSetMacro(SurfaceDecimationType, SurfaceDecimationMethod);
165 
167  itkSetMacro(PerformSurfaceDecimation,bool);
168 
170  itkBooleanMacro(PerformSurfaceDecimation);
171 
173  itkGetConstMacro(PerformSurfaceDecimation,bool);
174 
176  itkSetMacro(TargetReduction, float);
177 
179  itkGetConstMacro(TargetReduction, float);
180 
182  itkSetMacro(SamplingRatio, double);
183 
185  itkGetConstMacro(SamplingRatio, double);
186 
187 
189  itkSetMacro(PerformSurfaceCleaning,bool);
191  itkGetConstMacro(PerformSurfaceCleaning,bool);
192 
194  itkSetMacro(SurfaceCleaningThreshold, int);
195 
197  itkGetConstMacro(SurfaceCleaningThreshold, int);
198 
199 
201  template <class T1, class T2, class T3>
202  inline void mitkVtkLinearTransformPoint(T1 matrix[4][4], T2 in[3], T3 out[3])
203  {
204  T3 x = matrix[0][0]*in[0]+matrix[0][1]*in[1]+matrix[0][2]*in[2]+matrix[0][3];
205  T3 y = matrix[1][0]*in[0]+matrix[1][1]*in[1]+matrix[1][2]*in[2]+matrix[1][3];
206  T3 z = matrix[2][0]*in[0]+matrix[2][1]*in[1]+matrix[2][2]*in[2]+matrix[2][3];
207  out[0] = x;
208  out[1] = y;
209  out[2] = z;
210  }
211 
212 protected:
213 
216 
218  virtual ~ImageToSurfaceFilter();
219 
229  void CreateSurface(mitk::Image *image, mitk::Surface *surface);
230 
232  void VTKSurfaceExtraction(mitk::Image *image, vtkSmartPointer<vtkPolyData> vtkSurface);
234  void CMC33SurfaceExtraction(mitk::Image *inputImage, MeshData * meshData);
235 
237  void MeshSmoothing(MeshData * meshData);
238 
240  void SurfaceSmoothingVTK(vtkSmartPointer<vtkPolyData> vtkSurface);
242  void ComputeSmoothNormals(MeshData * meshData);
243 
245  void EditSurface(MeshData * meshData, bool recomputeNormals, bool flipNormals, bool reorientFaces, bool fixCracks);
246 
248  vtkSmartPointer<vtkPolyData> BuildVTKPolyData(MeshData * meshData);
249 
252  mitk::ScalarType m_Threshold;
253 
255 
260 
265 
269 
272 
275 
277 
278 };
279 
280 }
281 
282 #endif
GLdouble GLdouble z
Definition: glew.h:1543
float m_SurfaceSmoothingRadius
Definition: niftkImageToSurfaceFilter.h:264
InputSmoothingMethod
Definition: niftkImageToSurfaceFilter.h:66
SurfaceDecimationMethod m_SurfaceDecimationType
Definition: niftkImageToSurfaceFilter.h:266
SurfaceSmoothingMethod
Definition: niftkImageToSurfaceFilter.h:65
SurfaceExtractionMethod m_SurfaceExtractionType
Definition: niftkImageToSurfaceFilter.h:254
Converts pixel data to surface data by using a threshold The mitkNifTKImageToSurfaceFilter is used to...
Definition: niftkImageToSurfaceFilter.h:59
int m_InputSmoothingIterations
Definition: niftkImageToSurfaceFilter.h:258
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: glew.h:4052
Definition: ReceptorMemberCommandTest.cxx:25
bool m_VTKNormalCompute
Definition: niftkImageToSurfaceFilter.h:273
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1236
Definition: niftkITKAffineResampleImage.cxx:74
GLuint in
Definition: glew.h:10220
int m_SurfaceCleaningThreshold
Definition: niftkImageToSurfaceFilter.h:271
Definition: niftkImageToSurfaceFilter.h:65
bool m_PerformSurfaceSmoothing
Definition: niftkImageToSurfaceFilter.h:262
SurfaceDecimationMethod
Definition: niftkImageToSurfaceFilter.h:64
float m_InputSmoothingRadius
Definition: niftkImageToSurfaceFilter.h:259
SurfaceExtractionMethod
Definition: niftkImageToSurfaceFilter.h:63
Definition: niftkImageToSurfaceFilter.h:66
double m_SamplingRatio
Definition: niftkImageToSurfaceFilter.h:276
mitk::ScalarType m_Threshold
Definition: niftkImageToSurfaceFilter.h:252
bool m_FlipNormals
Definition: niftkImageToSurfaceFilter.h:274
int m_SurfaceSmoothingIterations
Definition: niftkImageToSurfaceFilter.h:263
GLuint GLenum matrix
Definition: glew.h:12775
bool m_PerformSurfaceDecimation
Definition: niftkImageToSurfaceFilter.h:267
bool m_PerformInputSmoothing
Definition: niftkImageToSurfaceFilter.h:257
GLint GLint GLint GLint GLint x
Definition: glew.h:1236
Simultaneous itk::Image and itk::Array (and hence vnl_vector) class.
InputSmoothingMethod m_InputSmoothingType
Definition: niftkImageToSurfaceFilter.h:256
double m_TargetReduction
Definition: niftkImageToSurfaceFilter.h:268
Container class for passing around data structures containing a mesh.
Definition: niftkCMC33.h:61
Definition: niftkExceptionObject.h:21
bool m_PerformSurfaceCleaning
Definition: niftkImageToSurfaceFilter.h:270
SurfaceSmoothingMethod m_SurfaceSmoothingType
Definition: niftkImageToSurfaceFilter.h:261