NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
niftkGeneralSegmentorUtils.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 niftkGeneralSegmentorUtils_h
16 #define niftkGeneralSegmentorUtils_h
17 
18 #include "niftkMIDASExports.h"
19 
20 #include <itkImage.h>
21 #include <itkPolyLineParametricPath.h>
22 
23 #include <mitkContourModelSet.h>
24 #include <mitkDataNode.h>
25 #include <mitkImage.h>
26 #include <mitkPointSet.h>
27 
28 
29 namespace niftk
30 {
31 
32 class OpPropagate;
33 class OpWipe;
34 
35 
39 void NIFTKMIDAS_EXPORT GenerateOutlineFromBinaryImage(mitk::Image::Pointer image,
40  int sliceAxis,
41  int sliceIndex,
42  int projectedSliceNumber,
43  mitk::ContourModelSet* outputContourSet
44  );
45 
46 
48 template<typename TPixel, unsigned int VImageDimension>
49 void ITKFillRegion(
50  itk::Image<TPixel, VImageDimension>* itkImage,
52  TPixel fillValue
53  );
54 
55 
57 template<typename TPixel, unsigned int VImageDimension>
58 void ITKClearImage(
59  itk::Image<TPixel, VImageDimension>* itkImage
60  );
61 
62 
64 template<typename TPixel, unsigned int VImageDimension>
65 void ITKCopyImage(
66  const itk::Image<TPixel, VImageDimension>* input,
67  itk::Image<TPixel, VImageDimension>* output
68  );
69 
70 
72 template<typename TPixel, unsigned int VImageDimension>
73 void ITKCopyRegion(
74  const itk::Image<TPixel, VImageDimension>* input,
75  int sliceAxis,
76  int sliceIndex,
77  itk::Image<TPixel, VImageDimension>* output
78  );
79 
81 template<typename TPixel, unsigned int VImageDimension>
83  const itk::Image<TPixel, VImageDimension>* itkImage,
84  int sliceAxis,
85  int sliceIndex,
87  );
88 
90 template<typename TPixel, unsigned int VImageDimension>
92  const itk::Image<TPixel, VImageDimension>* itkImage,
93  int sliceAxis,
94  int sliceIndex,
95  std::vector<int>& outputRegion
96  );
97 
98 
100 template<typename TPixel, unsigned int VImageDimension>
101 void ITKClearSlice(itk::Image<TPixel, VImageDimension>* itkImage,
102  int sliceAxis,
103  int sliceIndex
104  );
105 
108 template<typename TPixel, unsigned int VImageDimension>
110  const itk::Image<TPixel, VImageDimension>* itkImage,
111  const mitk::PointSet* inputSeeds,
112  int sliceAxis,
113  int sliceIndex,
114  mitk::PointSet* outputSeeds
115  );
116 
120 template<typename TPixel, unsigned int VImageDimension>
122  const itk::Image<TPixel, VImageDimension>* itkImage,
123  const mitk::PointSet* inputSeeds,
124  int sliceAxis,
125  int sliceIndex,
126  double& min,
127  double& max
128  );
129 
133 template<typename TPixel, unsigned int VImageDimension>
135  const itk::Image<TPixel, VImageDimension>* itkImage,
136  const typename itk::Image<TPixel, VImageDimension>::RegionType& regionOfInterest,
137  const mitk::PointSet* inputSeeds,
138  mitk::PointSet* outputCopyOfInputSeeds,
139  mitk::PointSet* outputNewSeedsNotInRegionOfInterest
140  );
141 
143 template<typename TPixel, unsigned int VImageDimension>
145  const itk::Image<TPixel, VImageDimension>* itkImage,
146  const mitk::PointSet* seeds,
147  int sliceAxis,
148  int sliceIndex
149  );
150 
153 template<typename TPixel, unsigned int VImageDimension>
154 bool ITKSliceIsEmpty(
155  const itk::Image<TPixel, VImageDimension>* itkImage,
156  int sliceAxis,
157  int sliceIndex,
158  bool& outputSliceIsEmpty
159  );
160 
166 template<typename TPixel, unsigned int VImageDimension>
168  const itk::Image<TPixel, VImageDimension>* itkImage,
169  bool skipUpdate,
170  const mitk::Image* workingImage,
171  const mitk::PointSet* seeds,
172  mitk::ContourModelSet* segmentationContours,
173  mitk::ContourModelSet* drawContours,
174  mitk::ContourModelSet* polyContours,
175  int sliceAxis,
176  int sliceIndex,
177  double lowerThreshold,
178  double upperThreshold,
179  mitk::Image* outputRegionGrowingImage
180  );
181 
184 template<typename TPixel, unsigned int VImageDimension>
186  const itk::Image<TPixel, VImageDimension>* itkImage,
187  const mitk::PointSet* inputSeeds,
188  int sliceAxis,
189  int sliceIndex,
190  int direction,
191  double lowerThreshold,
192  double upperThreshold,
193  mitk::PointSet* outputCopyOfInputSeeds,
194  mitk::PointSet* outputNewSeeds,
195  std::vector<int>& outputRegion,
196  mitk::Image* outputRegionGrowingImage
197  );
198 
204 template<typename TPixel, unsigned int VImageDimension>
206  const itk::Image<TPixel, VImageDimension>* itkImage,
207  const mitk::PointSet* seeds,
208  int sliceAxis,
209  int sliceIndex,
210  int direction,
211  double lowerThreshold,
212  double upperThreshold,
213  mitk::Image* outputRegionGrowingImage
214  );
215 
218 template <typename TGreyScalePixel, unsigned int VImageDimension>
220  const itk::Image<TGreyScalePixel, VImageDimension>* itkImage,
221  mitk::Image* segmentedImage,
222  mitk::Image* regionGrowingImage,
223  OpPropagate* op);
224 
227 template<typename TPixel, unsigned int VImageDimension>
229  const itk::Image<TPixel, VImageDimension>* itkImage,
230  int sliceAxis,
231  int sliceIndex,
232  int projectedSliceIndex,
233  mitk::ContourModelSet* contourSet
234  );
235 
240 template<typename TPixel, unsigned int VImageDimension>
242  const itk::Image<TPixel, VImageDimension>* itkImage,
243  TPixel foregroundPixelValue,
244  typename itk::Image<TPixel, VImageDimension>::IndexType& outputSeedIndex,
245  int& outputDistance
246  );
247 
250 template<typename TPixel, unsigned int VImageDimension>
252  const itk::Image<TPixel, VImageDimension>* itkImage,
253  const typename itk::Image<TPixel, VImageDimension>::RegionType& regionOfInterest,
254  int sliceAxis,
255  mitk::PointSet* outputNewSeeds
256  );
257 
269 template<typename TPixel, unsigned int VImageDimension>
271  const itk::Image<TPixel, VImageDimension>* itkImage,
272  const mitk::PointSet* inputSeeds,
273  int oldSliceAxis,
274  int oldSliceIndex,
275  int newSliceAxis,
276  int newSliceIndex,
277  bool optimiseSeedPosition,
278  bool newSliceIsEmpty,
279  mitk::PointSet* outputCopyOfInputSeeds,
280  mitk::PointSet* outputNewSeeds,
281  std::vector<int>& outputRegion
282  );
283 
286 template<typename TPixel, unsigned int VImageDimension>
288  const itk::Image<TPixel, VImageDimension>* itkImage,
289  const mitk::PointSet* inputSeeds,
290  int sliceAxis,
291  int sliceIndex,
292  int direction,
293  mitk::PointSet* outputCopyOfInputSeeds,
294  mitk::PointSet* outputNewSeeds,
295  std::vector<int>& outputRegion
296  );
297 
304 template<typename TPixel, unsigned int VImageDimension>
305 void ITKDoWipe(
306  itk::Image<TPixel, VImageDimension>* itkImage,
307  mitk::PointSet* currentSeeds,
308  OpWipe* op
309  );
310 
312 template<typename TPixel, unsigned int VImageDimension>
314  const itk::Image<TPixel, VImageDimension>* itkImage
315  );
316 
327 template<typename TPixel, unsigned int VImageDimension>
329  const itk::Image<TPixel, VImageDimension>* itkImage,
330  const mitk::PointSet* seeds,
331  mitk::ContourModelSet* segmentationContours,
332  mitk::ContourModelSet* polyToolContours,
333  mitk::ContourModelSet* drawToolContours,
334  const mitk::Image* workingImage,
335  double lowerThreshold,
336  double upperThreshold,
337  bool useThresholds,
338  int sliceAxis,
339  int sliceIndex,
340  bool& sliceDoesHaveUnenclosedSeeds
341  );
342 
354 template<typename TPixel, unsigned int VImageDimension>
355 void ITKFilterContours(
356  const itk::Image<TPixel, VImageDimension>* itkImage,
357  const mitk::Image* workingImage,
358  const mitk::PointSet* seeds,
359  mitk::ContourModelSet* segmentationContours,
360  mitk::ContourModelSet* drawContours,
361  mitk::ContourModelSet* polyContours,
362  int sliceAxis,
363  int sliceIndex,
364  double lowerThreshold,
365  double upperThreshold,
366  bool isThresholding,
367  mitk::ContourModelSet* outputCopyOfInputContours,
368  mitk::ContourModelSet* outputContours
369 );
370 
376 template<typename TPixel, unsigned int VImageDimension>
378  const itk::Image<TPixel, VImageDimension>* itkImage,
379  const mitk::PointSet* currentSeeds,
380  mitk::PointSet* newSeeds,
381  int sliceAxis,
382  int oldSliceIndex,
383  int newSliceIndex
384  );
385 
389 template<typename TPixel, unsigned int VImageDimension>
390 void ITKDestroyPipeline(
391  const itk::Image<TPixel, VImageDimension>* itkImage
392  );
393 
394 
401 template<typename TPixel, unsigned int VImageDimension>
403  const itk::Image<TPixel, VImageDimension>* itkImage,
404  mitk::PointSet* seeds,
405  int sliceAxis,
406  int sliceIndex
407  );
408 
409 }
410 
411 #include "niftkGeneralSegmentorUtils.txx"
412 
413 #endif
void ITKClearImage(itk::Image< TPixel, VImageDimension > *itkImage)
Clears an image by setting all voxels to zero using ITKFillRegion.
void ITKPreprocessingOfSeedsForChangingSlice(const itk::Image< TPixel, VImageDimension > *itkImage, const mitk::PointSet *inputSeeds, int oldSliceAxis, int oldSliceIndex, int newSliceAxis, int newSliceIndex, bool optimiseSeedPosition, bool newSliceIsEmpty, mitk::PointSet *outputCopyOfInputSeeds, mitk::PointSet *outputNewSeeds, std::vector< int > &outputRegion)
Does any pre-processing of seeds necessary to facilitate Undo/Redo for Threshold Apply, and also changing slice.
void ITKFilterSeedsToCurrentSlice(const itk::Image< TPixel, VImageDimension > *itkImage, const mitk::PointSet *inputSeeds, int sliceAxis, int sliceIndex, mitk::PointSet *outputSeeds)
Takes the inputSeeds and filters them so that outputSeeds contains just those seeds contained within ...
void ITKSliceDoesHaveUnenclosedSeeds(const itk::Image< TPixel, VImageDimension > *itkImage, const mitk::PointSet *seeds, mitk::ContourModelSet *segmentationContours, mitk::ContourModelSet *polyToolContours, mitk::ContourModelSet *drawToolContours, const mitk::Image *workingImage, double lowerThreshold, double upperThreshold, bool useThresholds, int sliceAxis, int sliceIndex, bool &sliceDoesHaveUnenclosedSeeds)
Will return true if slice has unenclosed seeds, and false otherwise.
bool ITKSliceIsEmpty(const itk::Image< TPixel, VImageDimension > *itkImage, int sliceAxis, int sliceIndex, bool &outputSliceIsEmpty)
Creates a region of interest within itkImage corresponding to the given slice, and checks if it is em...
void ITKGetLargestMinimumDistanceSeedLocation(const itk::Image< TPixel, VImageDimension > *itkImage, TPixel foregroundPixelValue, typename itk::Image< TPixel, VImageDimension >::IndexType &outputSeedIndex, int &outputDistance)
Works out the largest minimum distance to the edge of the image data, filtered on a given foregroundP...
void ITKCalculateSliceRegionAsVector(const itk::Image< TPixel, VImageDimension > *itkImage, int sliceAxis, int sliceIndex, std::vector< int > &outputRegion)
Calculates the region corresponding to a single slice.
GLenum GLenum GLenum input
Definition: glew.h:12016
void ITKPropagateToRegionGrowingImage(const itk::Image< TPixel, VImageDimension > *itkImage, const mitk::PointSet *inputSeeds, int sliceAxis, int sliceIndex, int direction, double lowerThreshold, double upperThreshold, mitk::PointSet *outputCopyOfInputSeeds, mitk::PointSet *outputNewSeeds, std::vector< int > &outputRegion, mitk::Image *outputRegionGrowingImage)
Method takes all the input, and calculates the 3D propagated region (up or down or 3D)...
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: glew.h:4052
void ITKRecalculateMinAndMaxOfSeedValues(const itk::Image< TPixel, VImageDimension > *itkImage, const mitk::PointSet *inputSeeds, int sliceAxis, int sliceIndex, double &min, double &max)
Called from RecalculateMinAndMaxOfSeedValues(), the actual method in ITK that recalculates the min an...
ImageType::IndexType IndexType
Definition: niftkMakeLapUSProbeBasicModel.cxx:32
void GenerateOutlineFromBinaryImage(mitk::Image::Pointer image, int sliceAxis, int sliceIndex, int projectedSliceIndex, mitk::ContourModelSet *outputContourSet)
Used to generate a contour outline round a binary segmentation image, and refreshes the outputSurface...
Definition: niftkGeneralSegmentorUtils.cxx:23
void ITKCopyRegion(const itk::Image< TPixel, VImageDimension > *input, int sliceAxis, int sliceIndex, itk::Image< TPixel, VImageDimension > *output)
Copies the region from input to output, assuming both images are the same size, and contain the regio...
void ITKPreprocessingForWipe(const itk::Image< TPixel, VImageDimension > *itkImage, const mitk::PointSet *inputSeeds, int sliceAxis, int sliceIndex, int direction, mitk::PointSet *outputCopyOfInputSeeds, mitk::PointSet *outputNewSeeds, std::vector< int > &outputRegion)
Does any pre-processing necessary to facilitate Undo/Redo for Wipe commands, which in this case means...
void ITKFilterInputPointSetToExcludeRegionOfInterest(const itk::Image< TPixel, VImageDimension > *itkImage, const typename itk::Image< TPixel, VImageDimension >::RegionType &regionOfInterest, const mitk::PointSet *inputSeeds, mitk::PointSet *outputCopyOfInputSeeds, mitk::PointSet *outputNewSeedsNotInRegionOfInterest)
Takes the inputSeeds and copies them to outputCopyOfInputSeeds, and also copies seeds to outputNewSee...
void ITKAddNewSeedsToPointSet(const itk::Image< TPixel, VImageDimension > *itkImage, const typename itk::Image< TPixel, VImageDimension >::RegionType &regionOfInterest, int sliceAxis, mitk::PointSet *outputNewSeeds)
For the given input itkImage (assumed to always be binary), and regionOfInterest, will iterate on a s...
void ITKGenerateOutlineFromBinaryImage(const itk::Image< TPixel, VImageDimension > *itkImage, int sliceAxis, int sliceIndex, int projectedSliceIndex, mitk::ContourModelSet *contourSet)
Called to extract a contour set from a binary image, as might be used for "See Prior", "See Next", or the outlining a binary segmentation.
bool ITKSliceDoesHaveSeeds(const itk::Image< TPixel, VImageDimension > *itkImage, const mitk::PointSet *seeds, int sliceAxis, int sliceIndex)
Will return true if the given slice has seeds within that slice.
void ITKFilterContours(const itk::Image< TPixel, VImageDimension > *itkImage, const mitk::Image *workingImage, const mitk::PointSet *seeds, mitk::ContourModelSet *segmentationContours, mitk::ContourModelSet *drawContours, mitk::ContourModelSet *polyContours, int sliceAxis, int sliceIndex, double lowerThreshold, double upperThreshold, bool isThresholding, mitk::ContourModelSet *outputCopyOfInputContours, mitk::ContourModelSet *outputContours)
Extracts a new contour set, for doing "Clean" operation.
void ITKFillRegion(itk::Image< TPixel, VImageDimension > *itkImage, const typename itk::Image< TPixel, VImageDimension >::RegionType &region, TPixel fillValue)
Fills the itkImage region with the fillValue.
ImageType::RegionType RegionType
Definition: niftkMakeLapUSProbeBasicModel.cxx:30
bool ITKImageHasNonZeroEdgePixels(const itk::Image< TPixel, VImageDimension > *itkImage)
Returns true if the image has non-zero edge pixels, and false otherwise.
void ITKPropagateToSegmentationImage(const itk::Image< TGreyScalePixel, VImageDimension > *itkImage, mitk::Image *segmentedImage, mitk::Image *regionGrowingImage, OpPropagate *op)
Called from the ExecuteOperate (i.e. undo/redo framework) to actually apply the calculated propagated...
void ITKDestroyPipeline(const itk::Image< TPixel, VImageDimension > *itkImage)
Completely removes the current 2D region growing pipeline that is stored in the map m_TypeToPipelineM...
void ITKClearSlice(itk::Image< TPixel, VImageDimension > *itkImage, int sliceAxis, int sliceIndex)
Clears a slice by setting all voxels to zero for a given slice and axis.
void ITKInitialiseSeedsForSlice(const itk::Image< TPixel, VImageDimension > *itkImage, mitk::PointSet *seeds, int sliceAxis, int sliceIndex)
Creates seeds for each distinct 4-connected region for a given slice.
void ITKCalculateSliceRegion(const itk::Image< TPixel, VImageDimension > *itkImage, int sliceAxis, int sliceIndex, typename itk::Image< TPixel, VImageDimension >::RegionType &outputRegion)
Calculates the region corresponding to a single slice.
void ITKPropagateUpOrDown(const itk::Image< TPixel, VImageDimension > *itkImage, const mitk::PointSet *seeds, int sliceAxis, int sliceIndex, int direction, double lowerThreshold, double upperThreshold, mitk::Image *outputRegionGrowingImage)
Called from ITKPropagateToRegionGrowingImage to propagate up or down.
void ITKPropagateSeedsToNewSlice(const itk::Image< TPixel, VImageDimension > *itkImage, const mitk::PointSet *currentSeeds, mitk::PointSet *newSeeds, int sliceAxis, int oldSliceIndex, int newSliceIndex)
Given an image, and a set of seeds, will append new seeds in the new slice if necessary.
Definition: niftkExceptionObject.h:21
void ITKDoWipe(itk::Image< TPixel, VImageDimension > *itkImage, mitk::PointSet *currentSeeds, OpWipe *op)
Does the wipe command for Wipe, Wipe+, Wipe-.
void ITKCopyImage(const itk::Image< TPixel, VImageDimension > *input, itk::Image< TPixel, VImageDimension > *output)
Copies an image from input to output, assuming input and output already allocated and of the same siz...
void ITKUpdateRegionGrowing(const itk::Image< TPixel, VImageDimension > *itkImage, bool skipUpdate, const mitk::Image *workingImage, const mitk::PointSet *seeds, mitk::ContourModelSet *segmentationContours, mitk::ContourModelSet *drawContours, mitk::ContourModelSet *polyContours, int sliceAxis, int sliceIndex, double lowerThreshold, double upperThreshold, mitk::Image *outputRegionGrowingImage)
Called from UpdateRegionGrowing(), updates the interactive ITK single 2D slice region growing pipelin...