lecture 21 itk ’ s path framework

28
The content of these slides by John Galeotti, © 2012 Carnegie Mellon University (CMU), was made possible in part by NIH NLM contract# HHSN276201000580P, and is licensed under a Creative Commons Attribution 3.0 Unported License . To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 171 2nd Street, Suite 300, San Francisco, California, 94105, USA. Permissions beyond the scope of this license may be available either from CMU or by emailing [email protected]. Lecture 21 ITK’s Path Framework Methods in Medical Image Analysis - Spring 2012 BioE 2630 (Pitt) : 16-725 (CMU RI) 18-791 (CMU ECE) : 42-735 (CMU BME) Dr. John Galeotti

Upload: sandro

Post on 22-Feb-2016

34 views

Category:

Documents


0 download

DESCRIPTION

Lecture 21 ITK ’ s Path Framework. Methods in Medical Image Analysis - Spring 2012 BioE 2630 (Pitt) : 16-725 (CMU RI) 18-791 (CMU ECE) : 42-735 (CMU BME) Dr. John Galeotti. Preface. This is based on the slides I presented at MICCAI 05 ’ s ITK workshop. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Lecture  21 ITK ’ s  Path Framework

The content of these slides by John Galeotti, © 2012 Carnegie Mellon University (CMU), was made possible in part by NIH NLM contract# HHSN276201000580P, and is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 171 2nd Street, Suite 300, San Francisco, California, 94105, USA. Permissions beyond the scope of this license may be available either from CMU or by emailing [email protected] most recent version of these slides may be accessed online via http://itk.galeotti.net/

Lecture 21ITK’s Path Framework

Methods in Medical Image Analysis - Spring 2012BioE 2630 (Pitt) : 16-725 (CMU RI)

18-791 (CMU ECE) : 42-735 (CMU BME)Dr. John Galeotti

Page 2: Lecture  21 ITK ’ s  Path Framework

2

Preface

This is based on the slides I presented at MICCAI 05’s ITK workshop.

They discuss the motivation and usage for the unified path framework I added to ITK.

You can see the related Insight Journal article at http://hdl.handle.net/1926/40 (Note: It used to be one of the top-rated journal

articles until I.J. was redone, and all the old reviews were scrapped.)

Page 3: Lecture  21 ITK ’ s  Path Framework

3

Introduction

The need for paths in ITKBasic concepts and path typesImplementation detailsExample usage

Page 4: Lecture  21 ITK ’ s  Path Framework

4

The Need for Paths in ITK

A path is a curve that maps a scalar value to a point in n-dimensional space

Page 5: Lecture  21 ITK ’ s  Path Framework

5

The Need for Paths in ITK

Paths are useful for: Segmentation algorithms Active contours, snakes, LiveWire

Ridge trackingPath planningUser interaction

Implementation of the above in ITK can be simplified by having a common, existing path framework.

Page 6: Lecture  21 ITK ’ s  Path Framework

6

The Need for Paths in ITK

Unfortunately, the ITK pipeline was originally designed to operate on image and mesh data typesNeither images nor meshes are well suited for path

representation

Page 7: Lecture  21 ITK ’ s  Path Framework

7

Basic Concepts and Path Types

Two common types of paths:Chain codes are a type of discrete curve

Parametric curves are continuous

Other types of paths are also possible

Page 8: Lecture  21 ITK ’ s  Path Framework

8

Chain Codes

Represent a path as as sequence of offsets between adjoining voxels

Provide efficient incremental access and comparatively poor random index access

Page 9: Lecture  21 ITK ’ s  Path Framework

9

2D Chain Code Example:Freeman Code

7

21

3

8

6 45

0

= “18765432”

7

2

1

3

86

4

5

Page 10: Lecture  21 ITK ’ s  Path Framework

10

Parametric Curves

Represent a path as an algebraically defined curve parameterized over a scalar input

Provide efficient random access and comparatively poor incremental index access Difficult to know how much to increment the parameterized

input to reach the next voxel

0

1

P 0 1

P

Page 11: Lecture  21 ITK ’ s  Path Framework

11

Implementation Details

Necessary FunctionalityPath class hierarchyPath iteratorsPath filter hierarchy

Page 12: Lecture  21 ITK ’ s  Path Framework

12

Necessary Functionality

EfficiencyHandle open, closed, & self-crossing pathsIterate along a path through an imageExamine image data in an arbitrarily defined

neighborhood surrounding any given point along a path

Page 13: Lecture  21 ITK ’ s  Path Framework

13

Necessary Functionality

Create and modify arbitrary chain codesSmooth paths in continuous index spaceFind exact normals to smooth pathsDistort paths by orthogonal offsets at regular

spacingSupport user interaction

Page 14: Lecture  21 ITK ’ s  Path Framework

14

Path Class HierarchyFunctionBase<TInput,TOutput> (API)DataObject

Path<TInput,TOutput,VDimension>

Path<int,Offset<VDimension>,VDimension>

ChainCodePath<VDimension>

ChainCodePath2D

Path<double,ContinuousIndex<VDimension>,VDimension>

ParametricPath<VDimension>

FourierSeriesPath<VDimension>

PolyLineParametricPath<VDimension>

OrthogonallyCorrected2DParametricPath

Key

Instantiatable Class

Abstract Base Class

Page 15: Lecture  21 ITK ’ s  Path Framework

15

PolyLineParametricPath

Represents a path as a series of vertices connected by line segments

Provides a simple means of creating a path that can then be converted to other path types

Page 16: Lecture  21 ITK ’ s  Path Framework

16

Represents a closed path by its Fourier coefficients in each dimension

Has continuous well-defined derivatives with respect to its input At all points along the

curve, the normal direction is well-defined and easy to compute.

FourierSeriesPath

t y(t)

x(t)

Page 17: Lecture  21 ITK ’ s  Path Framework

17

Orthogonally Corrected Path

Page 18: Lecture  21 ITK ’ s  Path Framework

18

Path Iterators

Iterators traverse paths through imagesAllows const pathsNecessary for path inputs in pipeline

Implemented a universal path iterator

PathConstIterator <TImage,TPath>

PathIterator <Timage,Tpath>

Page 19: Lecture  21 ITK ’ s  Path Framework

19

Path Iterators: Implementation

Iterators traverse paths through imagesPaths do not store a current position; iterators doAllows const paths with many concurrent positionsThe path iterator is able to traverse any type of path

Path iterators are supported by the Path:: IncrementInput(InputType & Input) functionAll paths must know how much to increment a given

path input to increment the path output to the next neighboring voxel along the path

For efficiency, IncrementInput() returns the offset resulting from its modification of Input

Page 20: Lecture  21 ITK ’ s  Path Framework

20

Current Base Class API

Path<TInput,TOutput,VDimension> virtual InputType StartOfInput() const virtual InputType EndOfInput() const virtual OutputType Evaluate(InputType) const =0 virtual IndexType EvaluateToIndex(InputType) const =0 virtual OffsetType IncrementInput(InputType) const =0

PathConstIterator<TImage,TPath> GoToBegin() bool IsAtEnd() operator++() IndexType GetIndex() PathInputType GetPathPosition()

Page 21: Lecture  21 ITK ’ s  Path Framework

21

Subclass API Extensions

ChainCodePath<VDimension> SetStart(IndexType) IndexType GetStart() const unsigned NumberOfSteps() const InsertStep(InputType position, OffsetType step) ChangeStep(InputType position, OffsetType step) Clear()

ParametricPath<VDimension> VectorType EvaluateDerivative(InputType) const

FourierSeriesPath<VDimension> AddHarmonic(VectorType CosCoef, VectorType SinCoef) Clear()

Page 22: Lecture  21 ITK ’ s  Path Framework

22

Path Filter HierarchyProcessObject

ImageSource<TOutputImage>

ImageToImageFilter<TInputImage,TOutputImage>

PathSource<TOutputPath>

PathToPathFilter<TInputPath,TOutputPath>

ImageAndPathToImageFilter<TInputImage,TInputPath,

TOutputImage>

PathAndImageToPathFilter<TInputPath,TInputImage,

TOutputPath>

OrthogonalSwath2DPathFilter<TFourierSeriesPath,TSwathMeritImage>

ExtractOrthogonalSwath2DImageFilter<Timage>

PathToImageFilter<TInputPath,TOutputImage>

PathToChainCodePathFilter

<TInputPath,TOutputChainCodePath>

ChainCodeToFourierSeriesPathFilter

<TInputChainCodePath,TOutputFourierSeriesPath>

Page 23: Lecture  21 ITK ’ s  Path Framework

23

Conversion Filters

ChainCodeToFourierSeriesPathFilter

FourierSeriesPath

PathToChainCodePathFilter

ChainCode

Path

ChainCode

AllowDiagonalSteps(bool=true)

SetNumHarmonics(int=8)

Page 24: Lecture  21 ITK ’ s  Path Framework

24

Philosophical Comparison with Spatial Objects

Spatial Objects represent geometric shapes (and therefore their associated boundaries)A Spatial Object’s interior is well defined

Paths represent sequences of connected indicesA path may not be closed (no interior defined)A closed path’s interior is difficult to compute

Page 25: Lecture  21 ITK ’ s  Path Framework

25

Empirical Comparison with Spatial Objects

Spatial Objects are well suited to rendering, analysis, and data interchange

Paths are well suited to computation, optimization, and iterator direction control

ITK could be extended to enable simple conversion by:Making a Spatial Object that uses one or more paths

as an internal representationMaking a Path that uses one or more intersecting

spatial objects as an internal representation

Page 26: Lecture  21 ITK ’ s  Path Framework

26

Example Usage

Implementation of a published 2D active contour algorithm Finds optimal orthogonal offsets at evenly spaced

points along an initial pathRequires that neighboring offsets differ in value by at

most oneAdded to ITK, including demonstration test

code Modules/Filtering/Path/test/itkOrthogonalSwath2DPathFilterTest.cxx

Page 27: Lecture  21 ITK ’ s  Path Framework

27

OrthogonalSwath2DPathFilterPolyLineParametricPath (closed)

Image

PathToChainCodePathFilter

ChainCodeToFourierSeriesPathFilter

ExtractOrthogonalSwath2DImageFilter

DerivativeImageFilter (vertical)

OrthogonalCorrected2DParametricPath

OrthogonalSwath2DPathFilter

Page 28: Lecture  21 ITK ’ s  Path Framework

28

Conclusion

Added user-extensible path support to ITKData type hierarchy Iterators Filter hierarchyExample implementation in test code

New core data types can be added to ITK!