Medical Imaging Interaction Toolkit  2025.12.02
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 {
49  {
50  public:
52  itkFactorylessNewMacro(Self);
53  itkCloneMacro(Self);
54 
56  typedef OutputType::Pointer OutputTypePointer;
58 
59  typedef itk::Image<float, 2> InternalImageType;
62  typedef std::vector<itk::Index<2>> ShortestPathType;
63 
65  itkSetMacro(StartPoint, mitk::Point3D);
66  itkGetMacro(StartPoint, mitk::Point3D);
67 
69  itkSetMacro(EndPoint, mitk::Point3D);
70  itkGetMacro(EndPoint, mitk::Point3D);
71 
76  itkSetMacro(UseDynamicCostMap, bool);
77  itkGetMacro(UseDynamicCostMap, bool);
78 
82 
85  void SetRepulsivePoints(const ShortestPathType &points);
86 
89  void AddRepulsivePoint(const itk::Index<2> &idx);
90 
93  void RemoveRepulsivePoint(const itk::Index<2> &idx);
94 
95  virtual void SetInput(const InputType *input);
96 
97  using Superclass::SetInput;
98  virtual void SetInput(unsigned int idx, const InputType *input);
99 
100  const InputType *GetInput(void);
101 
102  const InputType *GetInput(unsigned int idx);
103 
104  virtual OutputType *GetOutput();
105 
106  virtual void DumpMaskImage();
107 
110 
111  void SetUseCostFunction(bool doUseCostFunction) { m_ShortestPathFilter->SetUseCostFunction(doUseCostFunction); };
112 
113  protected:
115 
117 
118  void GenerateOutputInformation() override{};
119 
120  void GenerateData() override;
121 
123 
126 
129 
132 
135 
138 
141 
144 
145  unsigned int m_TimeStep;
146 
147  template <typename TPixel, unsigned int VImageDimension>
148  void ItkPreProcessImage(const itk::Image<TPixel, VImageDimension> *inputImage);
149 
150  template <typename TPixel, unsigned int VImageDimension>
151  void CreateDynamicCostMapByITK(const itk::Image<TPixel, VImageDimension> *inputImage,
152  mitk::ContourModel *path = nullptr);
153 
154  InternalImageType::Pointer m_InternalImage;
155  };
156 }
157 
158 #endif
#define MITKSEGMENTATION_EXPORT
Cost function for LiveWire purposes. Specific features are considered to calculate cumulative costs o...
Superclass of all classes generating ContourModels.
ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
Calculates a LiveWire contour between two points in an image.
mitk::Point3D m_StartPoint
start point in worldcoordinates
void CreateDynamicCostMapByITK(const itk::Image< TPixel, VImageDimension > *inputImage, mitk::ContourModel *path=nullptr)
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)
mitkClassMacro(ImageLiveWireContourModelFilter, ContourModelSource)
void ItkPreProcessImage(const itk::Image< TPixel, VImageDimension > *inputImage)
const InputType * GetInput(unsigned int idx)
virtual void SetInput(const InputType *input)
void SetRepulsivePoints(const ShortestPathType &points)
Set a vector with repulsive points to use in the cost function.
mitk::Point3D m_EndPoint
end point in woorldcoordinates
virtual void SetInput(unsigned int idx, const InputType *input)
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 index.
bool CreateDynamicCostMap(mitk::ContourModel *path=nullptr)
Create dynamic cost transfer map - on the fly training.
itk::ShortestPathImageFilter< InternalImageType, InternalImageType > ShortestPathImageFilterType
itk::ShortestPathCostFunctionLiveWire< InternalImageType > CostFunctionType
virtual OutputType * GetOutput()
bool m_UseDynamicCostMap
Flag to use a dynamic cost map or not.
Image class for storing images.
Definition: mitkImage.h:70
Find image slices visible on a given plane.