|
Medical Imaging Interaction Toolkit
2026.06.00
Medical Imaging Interaction Toolkit
|
ITK image filter that computes the shortest path between pixels using A*. More...
#include <itkShortestPathImageFilter.h>


Classes | |
| struct | CompareNodeStar |
| Comparator for the A* priority queue. More... | |
Public Types | |
| typedef ShortestPathImageFilter | Self |
| typedef ImageToImageFilter< TInputImageType, TOutputImageType > | Superclass |
| typedef SmartPointer< Self > | Pointer |
| typedef SmartPointer< const Self > | ConstPointer |
| typedef ShortestPathCostFunction< TInputImageType > | CostFunctionType |
| typedef CostFunctionType::Pointer | CostFunctionTypePointer |
| typedef TInputImageType | InputImageType |
| typedef TInputImageType::Pointer | InputImagePointer |
| typedef TInputImageType::PixelType | InputImagePixelType |
| typedef TInputImageType::SizeType | InputImageSizeType |
| typedef TInputImageType::IndexType | IndexType |
| typedef itk::ImageRegionIteratorWithIndex< InputImageType > | InputImageIteratorType |
| typedef TOutputImageType | OutputImageType |
| typedef TOutputImageType::Pointer | OutputImagePointer |
| typedef TOutputImageType::PixelType | OutputImagePixelType |
| typedef TOutputImageType::IndexType | OutputImageIndexType |
| typedef ImageRegionIteratorWithIndex< OutputImageType > | OutputImageIteratorType |
| typedef itk::ShapedNeighborhoodIterator< TInputImageType > | itkShapedNeighborhoodIteratorType |
Public Member Functions | |
| Pointer | Clone () const |
| virtual const char * | GetClassName () const |
| void | PrintSelf (std::ostream &os, Indent indent) const override |
| Print object information to an output stream. More... | |
| void | SetStartIndex (const IndexType &StartIndex) |
| Set the start pixel index for the shortest path computation. More... | |
| void | AddEndIndex (const IndexType &index) |
| Add an additional endpoint for multi-target shortest path search. More... | |
| void | SetEndIndex (const IndexType &EndIndex) |
| Set the (single) endpoint for the shortest path computation. More... | |
| virtual void | SetFullNeighborsMode (bool _arg) |
| Set the neighborhood connectivity mode. More... | |
| virtual bool | GetFullNeighborsMode () |
| Get the current neighborhood connectivity mode. More... | |
| virtual void | SetGraph_fullNeighbors (bool _arg) |
| Set graph-level full neighbors mode. More... | |
| virtual void | SetMakeOutputImage (bool _arg) |
| Set whether to produce a binary output image of the path. More... | |
| virtual bool | GetMakeOutputImage () |
| Get whether output image generation is enabled. More... | |
| virtual void | SetStoreVectorOrder (bool _arg) |
| Set whether to record the pixel visit order. More... | |
| virtual bool | GetStoreVectorOrder () |
| Get whether visit order recording is enabled. More... | |
| virtual void | SetCalcAllDistances (bool _arg) |
| Set whether to compute distances to all pixels. More... | |
| virtual bool | GetCalcAllDistances () |
| Get whether all-distances mode is enabled. More... | |
| virtual void | SetActivateTimeOut (bool _arg) |
| Set whether to enable a 30-second timeout. More... | |
| virtual bool | GetActivateTimeOut () |
| Get whether the timeout is enabled. More... | |
| std::vector< IndexType > | GetVectorPath () |
| Get the computed shortest path as a vector of pixel indices. More... | |
| std::vector< std::vector< IndexType > > | GetMultipleVectorPaths () |
| Get multiple shortest paths for multi-endpoint searches. More... | |
| OutputImagePointer | GetVectorOrderImage () |
| Get an image showing the pixel visit order. More... | |
| OutputImagePointer | GetDistanceImage () |
| Get the distance image showing shortest distances from the start. More... | |
| void | MakeShortestPathVector () |
| Trace back from end to start and fill m_VectorPath. More... | |
| void | CleanUp () |
| Clean up allocated resources. More... | |
| virtual void | SetCostFunction (CostFunctionType *_arg) |
| Set the cost function used for computing transition costs. More... | |
| virtual CostFunctionType * | GetCostFunction () |
| Get the cost function used for computing transition costs. More... | |
| void | SetUseCostFunction (bool doUseCostFunction) |
| Enable or disable the custom cost function. More... | |
| bool | GetUseCostFunction () |
| Query whether the custom cost function is enabled. More... | |
Static Public Member Functions | |
| static Pointer | New () |
Protected Member Functions | |
| ShortestPathImageFilter (Self &) | |
| void | operator= (const Self &) |
| ShortestPathImageFilter () | |
| ~ShortestPathImageFilter () override | |
| void | MakeOutputs () |
| void | GenerateData () override |
| double | getEstimatedCostsToTarget (const IndexType &a) |
| TInputImageType::IndexType | NodeToCoord (NodeNumType) |
| unsigned int | CoordToNode (IndexType) |
| std::vector< ShortestPathNode * > | GetNeighbors (NodeNumType nodeNum, bool FullNeighbors) |
| bool | CoordIsInBounds (IndexType) |
| void | InitGraph () |
| void | StartShortestPathSearch () |
Protected Attributes | |
| std::vector< IndexType > | m_endPoints |
| std::vector< IndexType > | m_endPointsClosed |
| ShortestPathNode * | m_Nodes |
| NodeNumType | m_Graph_NumberOfNodes |
| NodeNumType | m_Graph_StartNode |
| NodeNumType | m_Graph_EndNode |
| bool | m_Graph_fullNeighbors |
| bool | m_useCostFunction |
| std::vector< ShortestPathNode * > | m_Graph_DiscoveredNodeList |
| bool | m_FullNeighborsMode |
| bool | m_MakeOutputImage |
| bool | m_StoreVectorOrder |
| bool | m_CalcAllDistances |
| bool | multipleEndPoints |
| bool | m_ActivateTimeOut |
| bool | m_Initialized |
| CostFunctionTypePointer | m_CostFunction |
| IndexType | m_StartIndex |
| IndexType | m_EndIndex |
| std::vector< IndexType > | m_VectorPath |
| std::vector< std::vector< IndexType > > | m_MultipleVectorPaths |
| std::vector< NodeNumType > | m_VectorOrder |
| InputImageType::Pointer | m_magnitudeImage |
Static Protected Attributes | |
| static const int | BACKGROUND |
| static const int | FOREGROUND |
ITK image filter that computes the shortest path between pixels using A*.
This filter finds the optimal (minimum cost) path between a start pixel and one or more end pixels in an image, using the A* graph search algorithm with a pluggable cost function. The cost function (ShortestPathCostFunction) determines the transition cost between neighboring pixels.
Required inputs:
Optional settings:
Output retrieval:
| TInputImageType | The input image type (2D or 3D). |
| TOutputImageType | The output image type (typically same dimensionality). |
Definition at line 59 of file itkShortestPathImageFilter.h.
| typedef SmartPointer<const Self> itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::ConstPointer |
Definition at line 66 of file itkShortestPathImageFilter.h.
| typedef ShortestPathCostFunction<TInputImageType> itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::CostFunctionType |
Definition at line 69 of file itkShortestPathImageFilter.h.
| typedef CostFunctionType::Pointer itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::CostFunctionTypePointer |
Definition at line 70 of file itkShortestPathImageFilter.h.
| typedef TInputImageType::IndexType itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::IndexType |
Definition at line 77 of file itkShortestPathImageFilter.h.
| typedef itk::ImageRegionIteratorWithIndex<InputImageType> itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::InputImageIteratorType |
Definition at line 78 of file itkShortestPathImageFilter.h.
| typedef TInputImageType::PixelType itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::InputImagePixelType |
Definition at line 75 of file itkShortestPathImageFilter.h.
| typedef TInputImageType::Pointer itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::InputImagePointer |
Definition at line 74 of file itkShortestPathImageFilter.h.
| typedef TInputImageType::SizeType itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::InputImageSizeType |
Definition at line 76 of file itkShortestPathImageFilter.h.
| typedef TInputImageType itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::InputImageType |
Definition at line 73 of file itkShortestPathImageFilter.h.
| typedef itk::ShapedNeighborhoodIterator<TInputImageType> itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::itkShapedNeighborhoodIteratorType |
Definition at line 85 of file itkShortestPathImageFilter.h.
| typedef TOutputImageType::IndexType itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::OutputImageIndexType |
Definition at line 83 of file itkShortestPathImageFilter.h.
| typedef ImageRegionIteratorWithIndex<OutputImageType> itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::OutputImageIteratorType |
Definition at line 84 of file itkShortestPathImageFilter.h.
| typedef TOutputImageType::PixelType itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::OutputImagePixelType |
Definition at line 82 of file itkShortestPathImageFilter.h.
| typedef TOutputImageType::Pointer itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::OutputImagePointer |
Definition at line 81 of file itkShortestPathImageFilter.h.
| typedef TOutputImageType itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::OutputImageType |
Definition at line 80 of file itkShortestPathImageFilter.h.
| typedef SmartPointer<Self> itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::Pointer |
Definition at line 65 of file itkShortestPathImageFilter.h.
| typedef ShortestPathImageFilter itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::Self |
Definition at line 63 of file itkShortestPathImageFilter.h.
| typedef ImageToImageFilter<TInputImageType, TOutputImageType> itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::Superclass |
Definition at line 64 of file itkShortestPathImageFilter.h.
|
protected |
|
protected |
|
overrideprotected |
| void itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::AddEndIndex | ( | const IndexType & | index | ) |
Add an additional endpoint for multi-target shortest path search.
When multiple endpoints are added, the algorithm finds the shortest path from the start to each endpoint. Results can be retrieved via GetMultipleVectorPaths().
| [in] | index | The image index of the additional endpoint. |
| void itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::CleanUp | ( | ) |
Clean up allocated resources.
Deletes the node array and resets internal state. Called automatically at the end of GenerateData().
| Pointer itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::Clone | ( | ) | const |
|
protected |
|
protected |
|
overrideprotected |
|
virtual |
Get whether the timeout is enabled.
|
virtual |
Get whether all-distances mode is enabled.
|
virtual |
|
virtual |
Get the cost function used for computing transition costs.
| OutputImagePointer itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::GetDistanceImage | ( | ) |
Get the distance image showing shortest distances from the start.
Each pixel value represents the minimum cumulative cost from the start pixel to that pixel.
|
protected |
|
virtual |
Get the current neighborhood connectivity mode.
|
virtual |
Get whether output image generation is enabled.
| std::vector<std::vector<IndexType> > itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::GetMultipleVectorPaths | ( | ) |
Get multiple shortest paths for multi-endpoint searches.
Returns one path per endpoint added via AddEndIndex().
|
protected |
|
virtual |
Get whether visit order recording is enabled.
|
inline |
Query whether the custom cost function is enabled.
Definition at line 279 of file itkShortestPathImageFilter.h.
References itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::m_useCostFunction.
| OutputImagePointer itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::GetVectorOrderImage | ( | ) |
Get an image showing the pixel visit order.
Each pixel value represents the order in which it was visited during the search. Useful for debugging and visualization.
| std::vector<IndexType> itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::GetVectorPath | ( | ) |
Get the computed shortest path as a vector of pixel indices.
|
protected |
|
protected |
| void itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::MakeShortestPathVector | ( | ) |
Trace back from end to start and fill m_VectorPath.
Follows the prevNode links from the end node back to the start node to construct the shortest path vector.
|
static |
|
protected |
|
protected |
|
override |
Print object information to an output stream.
| [in,out] | os | The output stream. |
| [in] | indent | The indentation level. |
|
virtual |
Set whether to enable a 30-second timeout.
Default is false. When true, the algorithm terminates after 30 seconds. Useful for debugging; inspect GetVectorOrderImage() to see how far the search progressed.
|
virtual |
Set whether to compute distances to all pixels.
Default is false. When true, the algorithm does not stop at the endpoint but continues until all reachable pixels are visited. Results can be retrieved via GetDistanceImage().
|
virtual |
Set the cost function used for computing transition costs.
| void itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::SetEndIndex | ( | const IndexType & | EndIndex | ) |
Set the (single) endpoint for the shortest path computation.
| [in] | EndIndex | The image index where the path ends. |
|
virtual |
Set the neighborhood connectivity mode.
When false (default), uses N4 (2D) or N6 (3D) neighborhood (no diagonal neighbors). When true, uses N8 (2D) or N26 (3D).
|
virtual |
Set graph-level full neighbors mode.
Internal setting controlling whether the graph uses diagonal neighbors. Typically set to match FullNeighborsMode.
|
virtual |
Set whether to produce a binary output image of the path.
Default is true. When true, the output image shows FOREGROUND (255) on path pixels and BACKGROUND (0) elsewhere. The path can also be retrieved as a vector via GetVectorPath().
| void itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::SetStartIndex | ( | const IndexType & | StartIndex | ) |
Set the start pixel index for the shortest path computation.
| [in] | StartIndex | The image index where the path begins. |
|
virtual |
Set whether to record the pixel visit order.
Default is false. When true, the visit order is stored and can be retrieved via GetVectorOrderImage(). Useful for debugging.
|
inline |
Enable or disable the custom cost function.
When disabled, a default unit cost is used for all transitions.
| [in] | doUseCostFunction | true to use the set cost function, false for unit cost. |
Definition at line 273 of file itkShortestPathImageFilter.h.
References itk::ShortestPathImageFilter< TInputImageType, TOutputImageType >::m_useCostFunction.
|
protected |
|
staticprotected |
Definition at line 295 of file itkShortestPathImageFilter.h.
|
staticprotected |
Definition at line 296 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 306 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 301 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 310 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 311 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 283 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 284 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 297 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 292 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 289 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 290 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 287 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 288 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 308 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 330 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 299 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 313 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 286 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 311 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 300 of file itkShortestPathImageFilter.h.
|
protected |
|
protected |
Definition at line 315 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 312 of file itkShortestPathImageFilter.h.
|
protected |
Definition at line 304 of file itkShortestPathImageFilter.h.