Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkImageLiveWireContourModelFilter.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkImageLiveWireContourModelFilter_h
14 #define mitkImageLiveWireContourModelFilter_h
15 
16 #include <mitkCommon.h>
17 #include <mitkContourModel.h>
18 #include <mitkContourModelSource.h>
20 
21 #include <mitkImage.h>
22 #include <mitkImageAccessByItk.h>
23 #include <mitkImageCast.h>
24 
27 
28 namespace mitk
29 {
48  {
49  public:
51  itkFactorylessNewMacro(Self);
52  itkCloneMacro(Self);
53 
55  typedef OutputType::Pointer OutputTypePointer;
57 
58  typedef itk::Image<float, 2> InternalImageType;
61  typedef std::vector<itk::Index<2>> ShortestPathType;
62 
64  itkSetMacro(StartPoint, mitk::Point3D);
65  itkGetMacro(StartPoint, mitk::Point3D);
66 
68  itkSetMacro(EndPoint, mitk::Point3D);
69  itkGetMacro(EndPoint, mitk::Point3D);
70 
75  itkSetMacro(UseDynamicCostMap, bool);
76  itkGetMacro(UseDynamicCostMap, bool);
77 
81 
84  void SetRepulsivePoints(const ShortestPathType &points);
85 
88  void AddRepulsivePoint(const itk::Index<2> &idx);
89 
92  void RemoveRepulsivePoint(const itk::Index<2> &idx);
93 
97  virtual void SetInput(const InputType *input);
98 
99  using Superclass::SetInput;
100 
105  virtual void SetInput(unsigned int idx, const InputType *input);
106 
108  const InputType *GetInput(void);
109 
111  const InputType *GetInput(unsigned int idx);
112 
114  virtual OutputType *GetOutput();
115 
117  virtual void DumpMaskImage();
118 
124 
128  void SetUseCostFunction(bool doUseCostFunction) { m_ShortestPathFilter->SetUseCostFunction(doUseCostFunction); };
129 
130  protected:
132 
134 
135  void GenerateOutputInformation() override{};
136 
137  void GenerateData() override;
138 
140 
143 
146 
149 
152 
155 
158 
161 
162  unsigned int m_TimeStep;
163 
164  template <typename TPixel, unsigned int VImageDimension>
165  void ItkPreProcessImage(const itk::Image<TPixel, VImageDimension> *inputImage);
166 
167  template <typename TPixel, unsigned int VImageDimension>
168  void CreateDynamicCostMapByITK(const itk::Image<TPixel, VImageDimension> *inputImage,
169  mitk::ContourModel *path = nullptr);
170 
171  InternalImageType::Pointer m_InternalImage;
172  };
173 }
174 
175 #endif
#define MITKSEGMENTATION_EXPORT
Cost function for LiveWire interactive segmentation.
ITK image filter that computes the shortest path between pixels using A*.
Base class for all pipeline sources that produce mitk::ContourModel outputs.
A time-resolved contour representation consisting of linked vertices in 3D space.
Calculates a LiveWire contour between two points in an image.
mitk::Point3D m_StartPoint
Start point in world coordinates.
void CreateDynamicCostMapByITK(const itk::Image< TPixel, VImageDimension > *inputImage, mitk::ContourModel *path=nullptr)
virtual void DumpMaskImage()
Debug helper that dumps the internal mask image.
void RemoveRepulsivePoint(const itk::Index< 2 > &idx)
Remove a single repulsive point from the cost function.
CostFunctionType::Pointer m_CostFunction
The cost function to compute costs between two pixels.
const InputType * GetInput(void)
Get the first input image.
mitk::Point3D m_EndPointInIndex
End point in image index coordinates.
mitkClassMacro(ImageLiveWireContourModelFilter, ContourModelSource)
void ItkPreProcessImage(const itk::Image< TPixel, VImageDimension > *inputImage)
const InputType * GetInput(unsigned int idx)
Get the input image at a specific index.
virtual void SetInput(const InputType *input)
Set the input image for the LiveWire computation.
void SetRepulsivePoints(const ShortestPathType &points)
Set a vector with repulsive points to use in the cost function.
mitk::Point3D m_EndPoint
End point in world coordinates.
virtual void SetInput(unsigned int idx, const InputType *input)
Set the input image at a specific index.
ShortestPathImageFilterType::Pointer m_ShortestPathFilter
Shortest path filter according to cost function m_CostFunction.
void ClearRepulsivePoints()
Clear all repulsive points used in the cost function.
void AddRepulsivePoint(const itk::Index< 2 > &idx)
Add a single repulsive point to the cost function.
mitk::Point3D m_StartPointInIndex
Start point in image index coordinates.
bool CreateDynamicCostMap(mitk::ContourModel *path=nullptr)
Create a dynamic cost transfer map using on-the-fly training.
itk::ShortestPathImageFilter< InternalImageType, InternalImageType > ShortestPathImageFilterType
itk::ShortestPathCostFunctionLiveWire< InternalImageType > CostFunctionType
virtual OutputType * GetOutput()
Get the output contour model.
void SetUseCostFunction(bool doUseCostFunction)
Enable or disable the cost function in the shortest path filter.
bool m_UseDynamicCostMap
Flag to use a dynamic cost map or not.
Image class for storing multi-dimensional medical image data.
Definition: mitkImage.h:76
Provides the AccessByItk macro family for type-safe access to mitk::Image data through ITK image type...
Find image slices visible on a given plane.