NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
niftkGeneralSegmentorPipeline.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 niftkGeneralSegmentorPipeline_h
16 #define niftkGeneralSegmentorPipeline_h
17 
18 #include "niftkMIDASExports.h"
19 
20 #include <itkCastImageFilter.h>
21 #include <itkContinuousIndex.h>
22 #include <itkExtractImageFilter.h>
23 #include <itkImage.h>
24 #include <itkIndex.h>
25 #include <itkPasteImageFilter.h>
26 
27 #include <mitkContourModelSet.h>
28 #include <mitkPointSet.h>
29 #include <mitkTool.h>
30 
32 
33 namespace niftk
34 {
35 
36 typedef itk::PolyLineParametricPath<3> ParametricPathType;
37 typedef std::vector<ParametricPathType::Pointer> ParametricPathVectorType;
38 typedef ParametricPathType::VertexListType ParametricPathVertexListType;
39 typedef ParametricPathType::VertexType ParametricPathVertexType;
40 
137 
139 void NIFTKMIDAS_EXPORT ConvertMITKSeedsAndAppendToITKSeeds(const mitk::PointSet* seeds, itk::PointSet<float, 3>* points);
140 
141 
181 void NIFTKMIDAS_EXPORT ConvertMITKContoursAndAppendToITKContours(mitk::ContourModelSet* mitkContours, ParametricPathVectorType& itkContours, const mitk::Vector3D& spacing);
182 
183 
188 struct NIFTKMIDAS_EXPORT GeneralSegmentorPipelineParams
189 {
195  const mitk::PointSet* m_Seeds;
196  mitk::ContourModelSet* m_SegmentationContours;
197  mitk::ContourModelSet* m_DrawContours;
198  mitk::ContourModelSet* m_PolyContours;
199 };
200 
205 class NIFTKMIDAS_EXPORT GeneralSegmentorPipelineInterface
206 {
207 public:
208  typedef itk::PointSet<float, 3> PointSetType;
209  typedef PointSetType::Pointer PointSetPointer;
210  typedef PointSetType::PointType PointSetPointType;
211 
212  typedef itk::PolyLineParametricPath<3> ParametricPathType;
213  typedef std::vector<ParametricPathType::Pointer> ParametricPathVectorType;
214  typedef ParametricPathType::VertexListType ParametricPathVertexListType;
215  typedef ParametricPathType::VertexType ParametricPathVertexType;
216 
218 
219 protected:
221 
222 public:
223  virtual void Update(GeneralSegmentorPipelineParams& params) = 0;
224 
225 };
226 
235 template<typename TPixel, unsigned int VImageDimension>
237 {
238 public:
239 
240  typedef itk::Index<VImageDimension> IndexType;
241  typedef itk::ContinuousIndex<double, VImageDimension> ContinuousIndexType;
242  typedef itk::Image<TPixel, VImageDimension> GreyScaleImageType;
243  typedef itk::Image<mitk::Tool::DefaultSegmentationDataType,
244  VImageDimension> SegmentationImageType;
248  typedef typename GreyScaleImageType::PointType PointType;
249  typedef itk::ExtractImageFilter<GreyScaleImageType, GreyScaleImageType> ExtractGreySliceFromGreyImageFilterType;
250  typedef typename ExtractGreySliceFromGreyImageFilterType::Pointer ExtractGreySliceFromGreyImageFilterPointer;
251  typedef itk::ExtractImageFilter<SegmentationImageType,
253  typedef typename ExtractBinarySliceFromBinaryImageFilterType::Pointer ExtractBinarySliceFromBinaryImageFilterPointer;
254 
255  typedef itk::CastImageFilter<GreyScaleImageType, SegmentationImageType> CastGreySliceToSegmentationSliceFilterType;
256  typedef typename CastGreySliceToSegmentationSliceFilterType::Pointer CastGreySliceToSegmentationSliceFilterPointer;
259  itk::PointSet<float, 3> > MIDASRegionGrowingFilterType;
261 
263 
264  virtual ~GeneralSegmentorPipeline();
265 
266  void SetParam(const GreyScaleImageType* referenceImage, SegmentationImageType* segmentationImage, GeneralSegmentorPipelineParams& params);
267 
269 
271  void DisconnectPipeline();
272 
273 private:
274 
286  void SetPaintingRegion(const ContinuousIndexType& voxel, RegionType& paintingRegion);
287 
288 public:
289 
290  // Member variables.
296  ParametricPathVectorType m_SegmentationContours;
297  ParametricPathVectorType m_ManualContours;
298 
299  // Controls whether we write to output. Default = true. If false, we can directly look at m_RegionGrowingFilter->GetOutput().
302 
303  // The main filters.
304  ExtractGreySliceFromGreyImageFilterPointer m_ExtractGreyRegionOfInterestFilter;
305  ExtractBinarySliceFromBinaryImageFilterPointer m_ExtractBinaryRegionOfInterestFilter;
306  CastGreySliceToSegmentationSliceFilterPointer m_CastToSegmentationContourFilter;
307  CastGreySliceToSegmentationSliceFilterPointer m_CastToManualContourFilter;
308  MIDASRegionGrowingFilterPointer m_RegionGrowingFilter;
309  SegmentationImageType* m_OutputImage;
310 };
311 
312 }
313 
314 #include "niftkGeneralSegmentorPipeline.txx"
315 
316 #endif
ParametricPathType::VertexListType ParametricPathVertexListType
Definition: niftkGeneralSegmentorPipeline.h:214
ParametricPathType::VertexType ParametricPathVertexType
Definition: niftkGeneralSegmentorPipeline.h:39
void ConvertMITKContoursAndAppendToITKContours(mitk::ContourModelSet *mitkContours, std::vector< ParametricPathType::Pointer > &itkContours, const mitk::Vector3D &spacingInWorldCoordinateOrder)
Definition: niftkGeneralSegmentorPipeline.cxx:59
ParametricPathType::VertexType ParametricPathVertexType
Definition: niftkGeneralSegmentorPipeline.h:215
bool m_EraseFullSlice
Definition: niftkGeneralSegmentorPipeline.h:190
int m_SliceAxis
Definition: niftkGeneralSegmentorPipeline.h:291
SegmentationImageType * m_OutputImage
Definition: niftkGeneralSegmentorPipeline.h:309
A specific implementation of GeneralSegmentorPipelineInterface, based on ITK, called from MITK...
Definition: niftkGeneralSegmentorPipeline.h:236
PointSetType::Pointer PointSetPointer
Definition: niftkGeneralSegmentorPipeline.h:209
ExtractGreySliceFromGreyImageFilterType::Pointer ExtractGreySliceFromGreyImageFilterPointer
Definition: niftkGeneralSegmentorPipeline.h:250
ImageType::SizeType SizeType
Definition: niftkMakeLapUSProbeBasicModel.cxx:31
SmartPointer< Self > Pointer
Definition: itkMIDASRegionGrowingImageFilter.h:38
CastGreySliceToSegmentationSliceFilterType::Pointer CastGreySliceToSegmentationSliceFilterPointer
Definition: niftkGeneralSegmentorPipeline.h:256
std::vector< ParametricPathType::Pointer > ParametricPathVectorType
Definition: niftkGeneralSegmentorPipeline.h:213
Abstract interface to plug the ITK pipeline into MITK framework.
Definition: niftkGeneralSegmentorPipeline.h:205
const GLfloat * params
Definition: glew.h:1515
itk::Image< mitk::Tool::DefaultSegmentationDataType, VImageDimension > SegmentationImageType
Definition: niftkGeneralSegmentorPipeline.h:244
CastGreySliceToSegmentationSliceFilterPointer m_CastToManualContourFilter
Definition: niftkGeneralSegmentorPipeline.h:307
itk::PolyLineParametricPath< 3 > ParametricPathType
Definition: niftkGeneralSegmentorPipeline.h:212
itk::Index< VImageDimension > IndexType
Definition: niftkGeneralSegmentorPipeline.h:240
mitk::ContourModelSet * m_PolyContours
Definition: niftkGeneralSegmentorPipeline.h:198
double m_LowerThreshold
Definition: niftkGeneralSegmentorPipeline.h:193
ExtractBinarySliceFromBinaryImageFilterPointer m_ExtractBinaryRegionOfInterestFilter
Definition: niftkGeneralSegmentorPipeline.h:305
GreyScaleImageType::RegionType RegionType
Definition: niftkGeneralSegmentorPipeline.h:246
itk::MIDASRegionGrowingImageFilter< GreyScaleImageType, SegmentationImageType, itk::PointSet< float, 3 > > MIDASRegionGrowingFilterType
Definition: niftkGeneralSegmentorPipeline.h:259
bool m_EraseFullSlice
Definition: niftkGeneralSegmentorPipeline.h:301
double m_UpperThreshold
Definition: niftkGeneralSegmentorPipeline.h:194
void SetParam(const GreyScaleImageType *referenceImage, SegmentationImageType *segmentationImage, GeneralSegmentorPipelineParams &params)
TPixel m_UpperThreshold
Definition: niftkGeneralSegmentorPipeline.h:294
bool m_UseOutput
Definition: niftkGeneralSegmentorPipeline.h:300
std::vector< ParametricPathType::Pointer > ParametricPathVectorType
Definition: niftkGeneralSegmentorPipeline.h:37
ParametricPathVectorType m_ManualContours
Definition: niftkGeneralSegmentorPipeline.h:297
MIDASRegionGrowingFilterType::Pointer MIDASRegionGrowingFilterPointer
Definition: niftkGeneralSegmentorPipeline.h:260
void ConvertMITKSeedsAndAppendToITKSeeds(const mitk::PointSet *seeds, itk::PointSet< float, 3 > *points)
This file contains functions that convert between ITK and MITK contour representations.
Definition: niftkGeneralSegmentorPipeline.cxx:33
float PixelType
Definition: niftkBreastDCEandADC.cxx:88
ImageType::RegionType RegionType
Definition: niftkMakeLapUSProbeBasicModel.cxx:30
itk::PointSet< float, 3 > PointSetType
Definition: niftkGeneralSegmentorPipeline.h:208
GLuint GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glew.h:3085
GreyScaleImageType::SizeType SizeType
Definition: niftkGeneralSegmentorPipeline.h:247
itk::ExtractImageFilter< GreyScaleImageType, GreyScaleImageType > ExtractGreySliceFromGreyImageFilterType
Definition: niftkGeneralSegmentorPipeline.h:249
ParametricPathVectorType m_SegmentationContours
Definition: niftkGeneralSegmentorPipeline.h:296
ParametricPathType::VertexListType ParametricPathVertexListType
Definition: niftkGeneralSegmentorPipeline.h:38
A simple parameters object to pass all parameters to the ITK based region growing pipeline...
Definition: niftkGeneralSegmentorPipeline.h:188
int m_SliceIndex
Definition: niftkGeneralSegmentorPipeline.h:292
mitk::ContourModelSet * m_DrawContours
Definition: niftkGeneralSegmentorPipeline.h:197
mitk::ContourModelSet * m_SegmentationContours
Definition: niftkGeneralSegmentorPipeline.h:196
PointSetPointer m_AllSeeds
Definition: niftkGeneralSegmentorPipeline.h:295
MIDASRegionGrowingFilterPointer m_RegionGrowingFilter
Definition: niftkGeneralSegmentorPipeline.h:308
SegmentationImageType::PixelType SegmentationImagePixelType
Definition: niftkGeneralSegmentorPipeline.h:245
itk::CastImageFilter< GreyScaleImageType, SegmentationImageType > CastGreySliceToSegmentationSliceFilterType
Definition: niftkGeneralSegmentorPipeline.h:255
itk::PolyLineParametricPath< 3 > ParametricPathType
Definition: niftkGeneralSegmentorPipeline.h:36
ExtractGreySliceFromGreyImageFilterPointer m_ExtractGreyRegionOfInterestFilter
Definition: niftkGeneralSegmentorPipeline.h:304
itk::ContinuousIndex< double, VImageDimension > ContinuousIndexType
Definition: niftkGeneralSegmentorPipeline.h:241
TPixel m_LowerThreshold
Definition: niftkGeneralSegmentorPipeline.h:293
PointSetType::PointType PointSetPointType
Definition: niftkGeneralSegmentorPipeline.h:210
void Update(GeneralSegmentorPipelineParams &params)
itk::Image< TPixel, VImageDimension > GreyScaleImageType
Definition: niftkGeneralSegmentorPipeline.h:242
GreyScaleImageType::PointType PointType
Definition: niftkGeneralSegmentorPipeline.h:248
int m_SliceAxis
Definition: niftkGeneralSegmentorPipeline.h:191
int m_SliceIndex
Definition: niftkGeneralSegmentorPipeline.h:192
Definition: niftkExceptionObject.h:21
ExtractBinarySliceFromBinaryImageFilterType::Pointer ExtractBinarySliceFromBinaryImageFilterPointer
Definition: niftkGeneralSegmentorPipeline.h:253
const mitk::PointSet * m_Seeds
Definition: niftkGeneralSegmentorPipeline.h:195
CastGreySliceToSegmentationSliceFilterPointer m_CastToSegmentationContourFilter
Definition: niftkGeneralSegmentorPipeline.h:306
itk::ExtractImageFilter< SegmentationImageType, SegmentationImageType > ExtractBinarySliceFromBinaryImageFilterType
Definition: niftkGeneralSegmentorPipeline.h:252
void DisconnectPipeline()
Disconnects the pipeline so that reference counts go to zero for the input image. ...
Implements region growing limited by contours.
Definition: itkMIDASRegionGrowingImageFilter.h:33