Title: CSci 6971: Image Registration Lecture 8: Image Resampling February 3, 2004
1CSci 6971 Image Registration Lecture 8 Image
ResamplingFebruary 3, 2004
Prof. Chuck Stewart, RPI Dr. Luis Ibanez, Kitware
2Why Resampling ?
Resamplingis the Essence of Intensity
BasedImage Registration
3What is an Image ?
An Image is a sampling of a continuous field
using a discrete grid
4Image Origin Spacing
Spacing (Sx)
Spacing (Sy)
Origin (Ox,Oy)
5Image Sampling Grid
Spacing (Sx)
Spacing (Sy)
Origin (Ox,Oy)
6Image Pixel
Spacing (Sx)
Pixel Value
Pixel Region
Spacing (Sy)
Origin (Ox,Oy)
7Image Indices
Spacing (Sx)
Pixel Index
0,7
4,7
0,6
0,5
0,4
0,3
0,2
Spacing (Sy)
0,1
0,0
1,0
2,0
3,0
4,0
5,0
Origin (Ox,Oy)
8Index to Physical Coordinates
Spacing (Sx)
Pixel Index
0,7
4,7
0,6
0,5
P0 Index0 x Spacing0 Origin0
P1 Index1 x Spacing1 Origin1
0,4
Index0 floor( ( P0 - Origin0 ) /
Spacing0 0.5 )
0,3
Index1 floor( ( P1 - Origin1 ) /
Spacing1 0.5 )
0,2
Spacing (Sy)
0,1
0,0
1,0
2,0
3,0
4,0
5,0
Origin (Ox,Oy)
9Image Region
Spacing (Sx)
Pixel Value
Image Region
Pixel Region
Spacing (Sy)
Origin (Ox,Oy)
10Image Region
Spacing (Sx)
Region Size
Image Region
3,5
Starting Index
2,3
Spacing (Sy)
Origin (Ox,Oy)
11Basic Resampling
ResamplingTrivial Cases
12Sub-Sampling by Half
Spacing (Sx)
Image Region
Spacing (Sy)
Origin (Ox,Oy)
13Sub-Sampling by Half
New Spacing Sx
New Spacing Sy
New Origin (Ox,Oy)
Origin (Ox,Oy)
14Super-Sampling by Double
Spacing ( Sx/2 )
Spacing (Sx)
Spacing ( Sy/2 )
Image Region
Spacing (Sy)
Origin (Ox,Oy)
15Super-Sampling by Double
New Spacing Sx
New Origin (Ox,Oy)
Origin (Ox,Oy)
16Resampling in ITK
itkResampleImageFilter
17Resampling in ITK
Origin
Spacing
Region Size
Resample Filter
Region Start
Transform
Interpolator
18Resample Image Filter
include "itkImage.h" include "itkResampleImageFi
lter.h" include "itkIdentityTransform.h include
"itkLinearInterpolateImageFunction.h" typedef
itkImagelt char, 2 gt ImageType ImageTypePoin
ter inputImage GetImageSomeHow() typedef
itkResampleImageFilterlt ImageType gt
FilterType FilterTypePointer resampler
FilterTypeNew() ImageTypeSizeType
size size0 200 size1 300 ImageTypeIn
dexType start start0 0 start1 0
19Resample Image Filter
ImageTypePointType origin origin0 10.0
// millimeters origin1 25.5 //
millimeters ImageTypeSpacingType spacing
spacing0 2.0 // millimeters spacing1
1.5 // millimeters resampler-gtSetOutputSpacing(
spacing ) resampler-gtSetOutputOrigin( origin
) resampler-gtSetSize( size ) resampler-gtSetOutp
utStartIndex( start ) resampler-gtSetDefaultPixel
Value( 100 ) resampler-gtSetInput( inputImage )
20Resample Image Filter
typedef itkLinearInterpolateImageFunctionlt
ImageType,
double gt
InterpolatorType InterpolatorTypePointer
interpolator InterpolatorTypeNew() typedef
itkTranslationTransformlt double, 2 gt
TransformType TransformTypePointer transform
TransformTypeNew() transform-gtSetIdentity()
resampler-gtSetInterpolator( interpolator
) resampler-gtSetTransform( transform
) resampler-gtUpdate() const ImageType
outputImage resampler-gtGetOutput()
21Basic Registration
RegistrationBasics
22Coordinate System Conversions
23Things I will not do
24Fixed Image Moving Image
25Selecting Moving Fixed Images
In principle the denomination of Fixed Image
Moving Image is arbitrary
In practice the moving image is the one that will
be resampled into the fixed image coordinate
system
26Quiz 1
Images from the same patient
Moving Image ? Fixed Image ?
Images provided as part of the project
Retrospective Image Registration Evaluation,
NIH, Project No. 8R01EB002124-03, Principal
Investigator, J. Michael Fitzpatrick, Vanderbilt
University, Nashville, TN.
27Quiz 2
Images from the same patient
What scale factor ?
Images provided as part of the project
Retrospective Image Registration Evaluation,
NIH, Project No. 8R01EB002124-03, Principal
Investigator, J. Michael Fitzpatrick, Vanderbilt
University, Nashville, TN.
28Things I will not do
29Security
Airport Security
"Do not accept packages or baggage from unknown
individuals."
Image Security
"Do not accept images or volumes without pixel
spacing."
30Exercise 1
Output Image Size 181x217 pixels Spacing 0.8 x
0.9 mm
Input Image Size 181x217 pixels Spacing 0.8 x
0.9 mm
Coordinates ?
Coordinates ?
( 0.0mm , 195.3mm )
( 144.8mm , 195.3mm )
Output Origin
( 35.0mm , 50.0mm )
Coordinates ?
Origin (0,0)
( 144.8mm , 0.0mm )
31Exercise 1
Output Image Size 181x217 pixels Spacing 0.8 x
0.9 mm
Input Image Size 181x217 pixels Spacing 0.8 x
0.9 mm
Origin (0,0)
32Resample Image Filter
include "itkImage.h" include "itkResampleImageFi
lter.h" include "itkIdentityTransform.h" include
"itkNearestNeighborInterpolateImageFunction.h" t
ypedef itkImagelt char, 2 gt ImageType ImageTyp
eConstPointer inputImage reader-gtGetOutput()
typedef itkResampleImageFilterlt ImageType gt
FilterType FilterTypePointer resampler
FilterTypeNew() ImageTypeRegionType region
inputImage-gtGetBufferedRegion() resampler-gtSet
Size( region-gtGetSize() ) resampler-gtSetOutputSta
rtIndex( region-gtGetIndex() ) resampler-gtSetOutp
utSpacing( inputImage-gtGetSpacing() )
33Resample Image Filter
ImageTypePointType origin origin0 35.0
// millimeters origin1 50.0 //
millimeters resampler-gtSetOutputOrigin( origin
) typedef itkIdentityTransformlt double, 2 gt
TransformType TransformTypePointer transform
TransformTypeNew() resampler-gtSetTransform(
transform ) resampler-gtSetDefaultPixelValue(
100 ) resampler-gtSetInput( inputImage
) writer-gtSetInput( resampler-gtGetOutput()
) writer-gtUpdate()
34Exercise 1
Output Image Size 181x217 pixels Spacing 0.8 x
0.9 mm
Input Image Size 181x217 pixels Spacing 0.8 x
0.9 mm
Origin (0,0)
35Quiz 3
Moving Image Size 181x217 pixels Spacing 0.8 x
0.9 mm
Fixed Image Size 181x217 pixels Spacing 0.8 x
0.9 mm
Origin (0,0)
Origin (35,50)
36Things I will not do
37Quiz 4
Moving Image Size 181x217 pixels Spacing 0.8 x
0.9 mm
Fixed Image Size 181x217 pixels Spacing 0.8 x
0.9 mm
Origin (0,0)
Origin (0,0)
38Return to the Source
Output Image Size 181x217 pixels Spacing 0.8 x
0.9 mm
Input Image Size 181x217 pixels Spacing 0.8 x
0.9 mm
(35,50)
Origin (0,0)
Origin (0,0)
39More Resampling
ResamplingLess Trivial Cases
40Rotation
y
y
Transform
10o
x
x
Fixed
Moving
41Rotation
y
y
Transform
10o
x
x
Fixed
Moving
42Rotation
y
y
Transform
10o
x
x
Fixed
Moving
43Rotation around the Origin
Spacing (Sx)
Spacing (Sy)
Rotation Center
Origin (Ox,Oy)
44Rotation around the Origin
Spacing (Sx)
Spacing (Sy)
Origin (Ox,Oy)
45Rotation around the Origin
DefaultPixelValue
Origin (Ox,Oy)
46Rotation around the Center
y
y
Transform
10o
x
x
Fixed
Moving
47Rotation around the Center
y
y
Transform
10o
x
x
Fixed
Moving
48Rotation around the Center
y
y
Transform
10o
x
x
Fixed
Moving
49Rotation around the Center
y
y
Transform
10o
x
x
Fixed
Moving
50Rotation around the Center
Spacing (Sx)
RotationCenter
Spacing (Sy)
Origin (Ox,Oy)
51Rotation around the Center
Spacing (Sx)
Spacing (Sy)
Origin (Ox,Oy)
52Rotation around the Center
DefaultPixelValue
Origin (Ox,Oy)
53Resample Image Filter
include "itkImage.h" include "itkResampleImageFi
lter.h" include "itkCenteredRigid2DTransform.h
include "itkNearestNeighborInterpolateImageFunctio
n.h" typedef itkImagelt char, 2 gt
ImageType ImageTypePointer inputImage
GetImageSomeHow() typedef itkResampleImageFil
terlt ImageType gt FilterType FilterTypePointer
resampler FilterTypeNew() ImageTypeSizeTy
pe size size0 200 size1
300 ImageTypeIndexType start start0
0 start1 0
54Resample Image Filter
ImageTypePointType origin origin0 10.0
// millimeters origin1 25.5 //
millimeters ImageTypeSpacingType spacing
spacing0 2.0 // millimeters spacing1
1.5 // millimeters resampler-gtSetOutputSpacing(
spacing ) resampler-gtSetOutputOrigin( origin
) resampler-gtSetSize( size ) resampler-gtSetOutp
utStartIndex( start ) resampler-gtSetDefaultPixel
Value( 100 ) resampler-gtSetInput( inputImage )
55Resample Image Filter
typedef itkNearestNeighborInterpolateImageFuncti
onlt ImageType,
double gt
InterpolatorType InterpolatorTypePointer
interpolator InterpolatorTypeNew() resampler
-gtSetInterpolator( interpolator ) typedef
itkCenteredRigid2DTransformlt double, 2 gt
TransformType TransformTypePointer transform
TransformTypeNew() resampler-gtSetTransform(
transform ) TransformTypeInputPointType
center center0 origin0 spacing0
size0 / 2 center1 origin1 spacing1
size1 / 2
56Resample Image Filter
transform-gtSetCenter( center ) angle 10.0
3.1514 / 180.0 transform-gtSetRotation( angle
) transform-gtComputeOffset() resampler-gtUpdate
() const ImageType outputImage
resampler-gtGetOutput()
57Scaling
y
y
Transform
10
x
x
Fixed
Moving
58Scaling
y
y
Transform
10
x
x
Fixed
Moving
59Scaling
y
y
Transform
10
x
x
Fixed
Moving
60Scaling
y
y
Transform
10
x
x
Fixed
Moving
61Resample Image Filter
include "itkImage.h" include "itkResampleImageFi
lter.h" include "itkScaleTransform.h" include
"itkNearestNeighborInterpolateImageFunction.h" ty
pedef itkImagelt char, 2 gt ImageType ImageType
ConstPointer inputImage reader-gtGetOutput()
typedef itkResampleImageFilterlt ImageType gt
FilterType FilterTypePointer resampler
FilterTypeNew() ImageTypeRegionType region
inputImage-gtGetBufferedRegion() resampler-gtSet
Size( region-gtGetSize() ) resampler-gtSetOutputSt
artIndex( region-gtGetIndex() )
62Resample Image Filter
resampler-gtSetOutputSpacing( inputImage-gtGetSpacin
g() ) resampler-gtSetOutputOrigin(
inputImage-gtGetOrigin() ) typedef
itkScaleTransformlt double, 2 gt
TransformType TransformTypePointer transform
TransformTypeNew() TransformTypeScaleType
scale scale0 1.1 scale1
1.1 transform-gtSetScale( scale
) resampler-gtSetTransform( transform
) resampler-gtSetDefaultPixelValue( 100
) resampler-gtSetInput( inputImage
) writer-gtSetInput( resampler-gtGetOutput()
) writer-gtUpdate()
63Quiz 5
Moving Image Size 181x217 pixels Spacing 0.8 x
0.9 mm
Fixed Image Size 181x217 pixels Spacing 0.8 x
0.9 mm
Origin (0,0)
Origin (0,0)
64Quiz 6
Moving Image Size 181x217 pixels Spacing 0.8 x
0.9 mm
Fixed Image Size 181x217 pixels Spacing 0.8 x
0.9 mm
Origin (0,0)
Origin (0,0)
65End
Enjoy ITK !