|
Medical Imaging Interaction Toolkit
2026.06.00
Medical Imaging Interaction Toolkit
|
Cost function for LiveWire interactive segmentation. More...
#include <itkShortestPathCostFunctionLiveWire.h>


Public Types | |
| enum | Constants { MAPSCALEFACTOR } |
| Constants used internally for cost map scaling. More... | |
| typedef ShortestPathCostFunctionLiveWire | Self |
| typedef ShortestPathCostFunction< TInputImageType > | Superclass |
| typedef SmartPointer< Self > | Pointer |
| typedef SmartPointer< const Self > | ConstPointer |
| typedef itk::ImageRegionConstIterator< TInputImageType > | ConstIteratorType |
| typedef itk::Image< unsigned char, 2 > | UnsignedCharImageType |
| typedef itk::Image< float, 2 > | FloatImageType |
| typedef float | ComponentType |
| typedef itk::CovariantVector< ComponentType, 2 > | OutputPixelType |
| typedef itk::Image< OutputPixelType, 2 > | VectorOutputImageType |
| typedef TInputImageType::IndexType | IndexType |
| typedef TInputImageType | ImageType |
| typedef itk::ImageRegion< 2 > | RegionType |
Public Types inherited from itk::ShortestPathCostFunction< TInputImageType > | |
| typedef ShortestPathCostFunction | Self |
| typedef Object | Superclass |
| typedef SmartPointer< Self > | Pointer |
| typedef SmartPointer< const Self > | ConstPointer |
| typedef ShapedNeighborhoodIterator< TInputImageType > | ShapedNeighborhoodIteratorType |
| typedef TInputImageType | ImageType |
| typedef TInputImageType::Pointer | ImagePointer |
| typedef TInputImageType::ConstPointer | ImageConstPointer |
| typedef TInputImageType::PixelType | PixelType |
| typedef TInputImageType::IndexType | IndexType |
Public Member Functions | |
| Pointer | Clone () const |
| virtual const char * | GetClassName () const |
| double | GetCost (IndexType p1, IndexType p2) override |
| Calculate the weighted cost of transitioning from p1 to p2. More... | |
| double | GetMinCost () override |
| Return the minimal possible cost (needed for the A* heuristic). More... | |
| void | Initialize () override |
| Initialize the cost function by computing derived images. More... | |
| virtual void | AddRepulsivePoint (const IndexType &index) |
| Mark a pixel as repulsive in the cost map. More... | |
| virtual void | RemoveRepulsivePoint (const IndexType &index) |
| Remove a repulsive point from the cost map. More... | |
| virtual void | ClearRepulsivePoints () |
| Clear all repulsive points from the cost function. More... | |
| virtual void | SetRequestedRegion (RegionType _arg) |
| Set the requested image region for processing. More... | |
| virtual RegionType | GetRequestedRegion () |
| Get the requested image region. More... | |
| void | SetImage (const TInputImageType *_arg) override |
| Set the input image and initialize the mask image. More... | |
| void | SetDynamicCostMap (std::map< int, int > &costMap) |
| Set a dynamic (non-linear) cost map for gradient magnitude mapping. More... | |
| void | SetUseCostMap (bool useCostMap) |
| Enable or disable the dynamic cost map. More... | |
| void | SetCostMapMaximum (double max) |
| Set the maximum value of the dynamic cost map. More... | |
| const UnsignedCharImageType * | GetMaskImage () |
| Get the repulsive-point mask image. More... | |
| const FloatImageType * | GetGradientMagnitudeImage () |
| Get the computed gradient magnitude image. More... | |
| const FloatImageType * | GetEdgeImage () |
| Get the computed edge image (Canny edge detection result). More... | |
| const VectorOutputImageType * | GetGradientImage () |
| Get the computed gradient vector image. More... | |
Public Member Functions inherited from itk::ShortestPathCostFunction< TInputImageType > | |
| void | SetStartIndex (const IndexType &index) |
| Set the starting index of the path. More... | |
| void | SetEndIndex (const IndexType &index) |
| Set the ending index of the path. More... | |
Static Public Member Functions | |
| static Pointer | New () |
| static double | Gaussian (double x, double xOfGaussian, double yOfGaussian) |
| Evaluate a Gaussian function at position x. More... | |
Protected Member Functions | |
| ShortestPathCostFunctionLiveWire () | |
| ~ShortestPathCostFunctionLiveWire () override | |
Protected Member Functions inherited from itk::ShortestPathCostFunction< TInputImageType > | |
| ShortestPathCostFunction () | |
| ~ShortestPathCostFunction () override | |
| void | PrintSelf (std::ostream &os, Indent indent) const override |
Protected Attributes | |
| FloatImageType::Pointer | m_GradientMagnitudeImage |
| FloatImageType::Pointer | m_EdgeImage |
| UnsignedCharImageType::Pointer | m_MaskImage |
| VectorOutputImageType::Pointer | m_GradientImage |
| double | m_MinCosts |
| bool | m_UseRepulsivePoints |
| Superclass::PixelType | val |
| Superclass::PixelType | startValue |
| Superclass::PixelType | endValue |
| double | m_GradientMax |
| RegionType | m_RequestedRegion |
| bool | m_Initialized |
| std::map< int, int > | m_CostMap |
| bool | m_UseCostMap |
| double | m_MaxMapCosts |
Protected Attributes inherited from itk::ShortestPathCostFunction< TInputImageType > | |
| ImageConstPointer | m_Image |
| The input image used for cost computation. More... | |
| IndexType | m_StartIndex |
| IndexType | m_EndIndex |
| Start and end indices defining the path endpoints. More... | |
Cost function for LiveWire interactive segmentation.
This cost function computes the cumulative link cost between two neighboring pixels using a weighted combination of three image features:
By default, gradient magnitude is mapped linearly to cost values. A dynamic cost map can be set via SetDynamicCostMap() to use a non-linear mapping based on an inverted histogram of the gradient magnitude image.
The cost is scaled by the Euclidean distance between the two pixels (1.0 for horizontal/vertical neighbors, sqrt(2) for diagonal neighbors).
Repulsive points can be added to force the path away from certain pixels.
| TInputImageType | The ITK image type used as input (typically 2D). |
Definition at line 50 of file itkShortestPathCostFunctionLiveWire.h.
| typedef float itk::ShortestPathCostFunctionLiveWire< TInputImageType >::ComponentType |
Definition at line 70 of file itkShortestPathCostFunctionLiveWire.h.
| typedef itk::ImageRegionConstIterator<TInputImageType> itk::ShortestPathCostFunctionLiveWire< TInputImageType >::ConstIteratorType |
Definition at line 58 of file itkShortestPathCostFunctionLiveWire.h.
| typedef SmartPointer<const Self> itk::ShortestPathCostFunctionLiveWire< TInputImageType >::ConstPointer |
Definition at line 57 of file itkShortestPathCostFunctionLiveWire.h.
| typedef itk::Image<float, 2> itk::ShortestPathCostFunctionLiveWire< TInputImageType >::FloatImageType |
Definition at line 68 of file itkShortestPathCostFunctionLiveWire.h.
| typedef TInputImageType itk::ShortestPathCostFunctionLiveWire< TInputImageType >::ImageType |
Definition at line 75 of file itkShortestPathCostFunctionLiveWire.h.
| typedef TInputImageType::IndexType itk::ShortestPathCostFunctionLiveWire< TInputImageType >::IndexType |
Definition at line 74 of file itkShortestPathCostFunctionLiveWire.h.
| typedef itk::CovariantVector<ComponentType, 2> itk::ShortestPathCostFunctionLiveWire< TInputImageType >::OutputPixelType |
Definition at line 71 of file itkShortestPathCostFunctionLiveWire.h.
| typedef SmartPointer<Self> itk::ShortestPathCostFunctionLiveWire< TInputImageType >::Pointer |
Definition at line 56 of file itkShortestPathCostFunctionLiveWire.h.
| typedef itk::ImageRegion<2> itk::ShortestPathCostFunctionLiveWire< TInputImageType >::RegionType |
Definition at line 76 of file itkShortestPathCostFunctionLiveWire.h.
| typedef ShortestPathCostFunctionLiveWire itk::ShortestPathCostFunctionLiveWire< TInputImageType >::Self |
Standard class typedefs.
Definition at line 54 of file itkShortestPathCostFunctionLiveWire.h.
| typedef ShortestPathCostFunction<TInputImageType> itk::ShortestPathCostFunctionLiveWire< TInputImageType >::Superclass |
Definition at line 55 of file itkShortestPathCostFunctionLiveWire.h.
| typedef itk::Image<unsigned char, 2> itk::ShortestPathCostFunctionLiveWire< TInputImageType >::UnsignedCharImageType |
Definition at line 67 of file itkShortestPathCostFunctionLiveWire.h.
| typedef itk::Image<OutputPixelType, 2> itk::ShortestPathCostFunctionLiveWire< TInputImageType >::VectorOutputImageType |
Definition at line 72 of file itkShortestPathCostFunctionLiveWire.h.
| enum itk::ShortestPathCostFunctionLiveWire::Constants |
Constants used internally for cost map scaling.
| Enumerator | |
|---|---|
| MAPSCALEFACTOR | Scale factor applied to gradient magnitude for cost map lookup. |
Definition at line 197 of file itkShortestPathCostFunctionLiveWire.h.
|
protected |
|
inlineoverrideprotected |
Definition at line 245 of file itkShortestPathCostFunctionLiveWire.h.
|
virtual |
Mark a pixel as repulsive in the cost map.
Pixels marked as repulsive receive a very high cost (1000) to discourage the shortest path from passing through them.
| [in] | index | The pixel index to mark as repulsive. |
|
virtual |
Clear all repulsive points from the cost function.
Resets the mask image to zero and disables repulsive point checking.
| Pointer itk::ShortestPathCostFunctionLiveWire< TInputImageType >::Clone | ( | ) | const |
|
static |
Evaluate a Gaussian function at position x.
Computes the Gaussian approximation:
Used for interpolating between cost map entries.
| [in] | x | The position at which to evaluate. |
| [in] | xOfGaussian | The center (mean) of the Gaussian. |
| [in] | yOfGaussian | The amplitude (peak value) of the Gaussian. |
|
virtual |
Run-time type information (and related methods).
Reimplemented from itk::ShortestPathCostFunction< TInputImageType >.
|
overridevirtual |
Calculate the weighted cost of transitioning from p1 to p2.
The cost is a weighted sum of Laplacian zero-crossing cost, gradient magnitude cost, and gradient direction cost, scaled by the Euclidean distance between the two pixels.
| [in] | p1 | The source pixel index. |
| [in] | p2 | The destination pixel index. |
Implements itk::ShortestPathCostFunction< TInputImageType >.
|
inline |
Get the computed edge image (Canny edge detection result).
Definition at line 235 of file itkShortestPathCostFunctionLiveWire.h.
|
inline |
Get the computed gradient vector image.
Definition at line 241 of file itkShortestPathCostFunctionLiveWire.h.
|
inline |
Get the computed gradient magnitude image.
Definition at line 229 of file itkShortestPathCostFunctionLiveWire.h.
|
inline |
Get the repulsive-point mask image.
Definition at line 223 of file itkShortestPathCostFunctionLiveWire.h.
|
overridevirtual |
Return the minimal possible cost (needed for the A* heuristic).
Implements itk::ShortestPathCostFunction< TInputImageType >.
|
virtual |
Get the requested image region.
|
overridevirtual |
Initialize the cost function by computing derived images.
Computes gradient magnitude, gradient direction, and Canny edge detection images from the input image. Also initializes the mask image for repulsive points. Only performs computation on the first call; subsequent calls only update start/end pixel values.
Implements itk::ShortestPathCostFunction< TInputImageType >.
|
static |
Method for creation through the object factory.
|
virtual |
Remove a repulsive point from the cost map.
| [in] | index | The pixel index to unmark. |
|
inline |
Set the maximum value of the dynamic cost map.
Used for normalization when the dynamic cost map is active. Setting this avoids recomputing the maximum from the map each time.
| [in] | max | The maximum cost map value. |
Definition at line 192 of file itkShortestPathCostFunctionLiveWire.h.
|
inline |
Set a dynamic (non-linear) cost map for gradient magnitude mapping.
The map keys are integer-scaled gradient magnitude values, and the map values represent corresponding histogram-derived weights. When set, a Gaussian interpolation is used instead of linear mapping.
| [in,out] | costMap | The cost map to use. Stored by copy. |
Definition at line 169 of file itkShortestPathCostFunctionLiveWire.h.
|
overridevirtual |
Set the input image and initialize the mask image.
Overrides the base class to additionally allocate and initialize the repulsive-point mask image to match the input image's geometry.
| [in] | _arg | The input image. |
Reimplemented from itk::ShortestPathCostFunction< TInputImageType >.
|
virtual |
Set the requested image region for processing.
|
inline |
Enable or disable the dynamic cost map.
| [in] | useCostMap | If true, use the dynamic cost map; if false, use linear mapping. |
Definition at line 182 of file itkShortestPathCostFunctionLiveWire.h.
|
protected |
Definition at line 259 of file itkShortestPathCostFunctionLiveWire.h.
|
protected |
Definition at line 267 of file itkShortestPathCostFunctionLiveWire.h.
|
protected |
Definition at line 248 of file itkShortestPathCostFunctionLiveWire.h.
|
protected |
Definition at line 250 of file itkShortestPathCostFunctionLiveWire.h.
|
protected |
Definition at line 247 of file itkShortestPathCostFunctionLiveWire.h.
|
protected |
Definition at line 261 of file itkShortestPathCostFunctionLiveWire.h.
|
protected |
Definition at line 265 of file itkShortestPathCostFunctionLiveWire.h.
|
protected |
Definition at line 249 of file itkShortestPathCostFunctionLiveWire.h.
|
protected |
Definition at line 271 of file itkShortestPathCostFunctionLiveWire.h.
|
protected |
Definition at line 252 of file itkShortestPathCostFunctionLiveWire.h.
|
protected |
Definition at line 263 of file itkShortestPathCostFunctionLiveWire.h.
|
protected |
Definition at line 269 of file itkShortestPathCostFunctionLiveWire.h.
|
protected |
Definition at line 254 of file itkShortestPathCostFunctionLiveWire.h.
|
protected |
Definition at line 258 of file itkShortestPathCostFunctionLiveWire.h.
|
protected |
Definition at line 256 of file itkShortestPathCostFunctionLiveWire.h.