csci 6971: image registration lecture 8: image resampling february 3, 2004

65
CSci 6971: Image Registration Lecture 8: Image Resampling February 3, 2004 Prof. Chuck Stewart, RPI Dr. Luis Ibanez, Kitware

Upload: eden-estes

Post on 31-Dec-2015

35 views

Category:

Documents


0 download

DESCRIPTION

CSci 6971: Image Registration Lecture 8: Image Resampling February 3, 2004. Prof. Chuck Stewart, RPI Dr. Luis Ibanez, Kitware. Why Resampling ?. Resampling is the Essence of Intensity Based Image Registration. What is an Image ?. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

CSci 6971: Image Registration Lecture 8: Image Resampling

February 3, 2004

CSci 6971: Image Registration Lecture 8: Image Resampling

February 3, 2004

Prof. Chuck Stewart, RPIDr. Luis Ibanez, KitwareProf. Chuck Stewart, RPIDr. Luis Ibanez, Kitware

Page 2: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 2

Why Resampling ?Why Resampling ?

Resampling

is the Essence

of Intensity Based

Image Registration

Page 3: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 3

What is an Image ?What is an Image ?

An Image is a sampling of a continuous field

using a discrete grid

Page 4: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 4

Image Origin & SpacingImage Origin & Spacing

Origin (Ox,Oy)

Spacing (Sy)

Spacing (Sx)

x

y

Page 5: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 5

Image Sampling GridImage Sampling Grid

Origin (Ox,Oy)

Spacing (Sy)

Spacing (Sx)

Page 6: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 6

Image PixelImage Pixel

Origin (Ox,Oy)

Spacing (Sy)

Spacing (Sx)

Pixel Value

Pixel Region

Page 7: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 7

Image IndicesImage Indices

Origin (Ox,Oy)

Spacing (Sy)

Spacing (Sx)

[0,0] [1,0] [2,0] [3,0] [4,0] [5,0]

[0,1]

[0,2]

[0,3]

[0,4]

[0,5]

[4,7]

[0,6]

[0,7] Pixel Index

Page 8: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 8

Index to Physical CoordinatesIndex to Physical Coordinates

Origin (Ox,Oy)

Spacing (Sy)

Spacing (Sx)

[0,0] [1,0] [2,0] [3,0] [4,0] [5,0]

[0,1]

[0,2]

[0,3]

[0,4]

[0,5]

[4,7]

[0,6]

[0,7] Pixel Index

P[0] = Index[0] x Spacing[0] + Origin[0]P[1] = Index[1] x Spacing[1] + Origin[1]

Index[0] = floor( ( P[0] - Origin[0] ) / Spacing[0] + 0.5 )Index[1] = floor( ( P[1] - Origin[1] ) / Spacing[1] + 0.5 )

Page 9: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 9

Image RegionImage Region

Origin (Ox,Oy)

Spacing (Sy)

Spacing (Sx)

Pixel Value

Pixel Region

Image Region

Page 10: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 10

Image RegionImage Region

Origin (Ox,Oy)

Spacing (Sy)

Spacing (Sx)

Image Region

Starting Index

Region Size

[2,3]

[3,5]

Page 11: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 11

Basic ResamplingBasic Resampling

Resampling

Trivial Cases

Page 12: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 12

Sub-Sampling by HalfSub-Sampling by Half

Origin (Ox,Oy)

Spacing (Sy)

Spacing (Sx)

Image Region Spacing( 2 x Sy )

Spacing ( 2 x Sx )

Page 13: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 13

Sub-Sampling by HalfSub-Sampling by Half

Origin (Ox,Oy)

New Origin(O’x,O’y)

New SpacingS’y

New SpacingS’x

Page 14: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 14

Super-Sampling by DoubleSuper-Sampling by Double

Origin (Ox,Oy)

Spacing (Sy)

Spacing (Sx)

Image RegionSpacing ( Sy/2 )

Spacing ( Sx/2 )

Page 15: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 15

Super-Sampling by DoubleSuper-Sampling by Double

Origin (Ox,Oy)

New SpacingS’x

New SpacingS’y

New Origin(O’x,O’y)

Page 16: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 16

Resampling in ITKResampling in ITK

itk::ResampleImageFilter

Page 17: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 17

Resampling in ITKResampling in ITK

Transform

Interpolator

Origin

Spacing

Region Start

Region Size

Resample Filter

Input Image Output Image

Page 18: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 18

Resample Image FilterResample Image Filter

#include "itkImage.h"#include "itkResampleImageFilter.h"#include "itkIdentityTransform.h“#include "itkLinearInterpolateImageFunction.h"

typedef itk::Image< char, 2 > ImageType;

ImageType::Pointer inputImage = GetImageSomeHow();

typedef itk::ResampleImageFilter< ImageType > FilterType;

FilterType::Pointer resampler = FilterType::New();

ImageType::SizeType size;size[0] = 200;size[1] = 300;

ImageType::IndexType start; start[0] = 0;start[1] = 0;

Page 19: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 19

Resample Image FilterResample Image Filter

ImageType::PointType origin;origin[0] = 10.0; // millimetersorigin[1] = 25.5; // millimeters

ImageType::SpacingType spacing; spacing[0] = 2.0; // millimetersspacing[1] = 1.5; // millimeters

resampler->SetOutputSpacing( spacing );resampler->SetOutputOrigin( origin );

resampler->SetSize( size );resampler->SetOutputStartIndex( start );

resampler->SetDefaultPixelValue( 100 );

resampler->SetInput( inputImage );

Page 20: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 20

Resample Image FilterResample Image Filter

typedef itk::LinearInterpolateImageFunction< ImageType, double > InterpolatorType;

InterpolatorType::Pointer interpolator = InterpolatorType::New();

typedef itk::TranslationTransform< double, 2 > TransformType;

TransformType::Pointer transform = TransformType::New();

transform->SetIdentity();

resampler->SetInterpolator( interpolator );resampler->SetTransform( transform );

resampler->Update();

const ImageType * outputImage = resampler->GetOutput();

Page 21: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 21

Basic RegistrationBasic Registration

Registration

Basics

Page 22: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 22

Coordinate System ConversionsCoordinate System Conversions

Image Grid

j

i

y

x

Physical Coordinates

y’

x’

Physical Coordinates

Image Grid

j

i

Space Transform

x

y

Page 23: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 23

Things I will not do…Things I will not do…

I will not register images in pixel space

I will not register images in pixel space

I will not register images in pixel space

I will not register images in pixel space

I will not register images in pixel space

I will not register images in pix

Page 24: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 24

Fixed Image & Moving ImageFixed Image & Moving Image

Fixed Image Grid

j

i

y

x

Fixed ImagePhysical Coordinates

y’

x’

Moving ImagePhysical Coordinates

Moving Image Grid

j

i

Space Transform

Page 25: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 25

Selecting Moving & Fixed ImagesSelecting 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

Page 26: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 26

Quiz #1Quiz #1

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.

Images from the same patient

256 x 256 pixels

MRI-T2

128 x 128 pixels

PET

Moving Image ?

Fixed Image ?

Page 27: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 27

Quiz #2Quiz #2

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.

Images from the same patient

256 x 256 pixels

MRI-T2

128 x 128 pixels

PET

Scaling Transform

What scale factor ?

a) 2.0

b) 1.0

c) 0.5

Page 28: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 28

Things I will not do…Things I will not do…

I will not register images in pixel space

I will not register images in pixel space

I will not register images in pixel space

I will not register images in pixel space

I will not register images in pixel space

I will not register images in pix

Page 29: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 29

SecuritySecurity

"Do not accept packages or baggage from unknown individuals."

"Do not accept images or volumes without pixel spacing."

Airport Security

Image Security

Page 30: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 30

Exercise #1Exercise #1

Input Image

Size: 181x217 pixels

Spacing: 0.8 x 0.9 mm

Origin: (0,0)Coordinates ?( 144.8mm , 0.0mm )

Coordinates ?( 0.0mm , 195.3mm )

Coordinates ?( 144.8mm , 195.3mm )

Output Image

Size: 181x217 pixels

Spacing: 0.8 x 0.9 mm

Output Origin( 35.0mm , 50.0mm )

Page 31: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 31

Exercise #1Exercise #1

Input Image

Size: 181x217 pixels

Spacing: 0.8 x 0.9 mm

Origin: (0,0)

Output Image

Size: 181x217 pixels

Spacing: 0.8 x 0.9 mm

Page 32: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 32

Resample Image FilterResample Image Filter

#include "itkImage.h"#include "itkResampleImageFilter.h"#include "itkIdentityTransform.h"#include "itkNearestNeighborInterpolateImageFunction.h"

typedef itk::Image< char, 2 > ImageType;

ImageType::ConstPointer inputImage = reader->GetOutput();

typedef itk::ResampleImageFilter< ImageType > FilterType;

FilterType::Pointer resampler = FilterType::New();

ImageType::RegionType region = inputImage->GetBufferedRegion();

resampler->SetSize( region->GetSize() );resampler->SetOutputStartIndex( region->GetIndex() );

resampler->SetOutputSpacing( inputImage->GetSpacing() );

Page 33: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 33

Resample Image FilterResample Image Filter

ImageType::PointType origin;origin[0] = 35.0; // millimetersorigin[1] = 50.0; // millimeters

resampler->SetOutputOrigin( origin );

typedef itk::IdentityTransform< double, 2 > TransformType;

TransformType::Pointer transform = TransformType::New();

resampler->SetTransform( transform );

resampler->SetDefaultPixelValue( 100 );

resampler->SetInput( inputImage );

writer->SetInput( resampler->GetOutput() );

writer->Update();

Page 34: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 34

Exercise #1Exercise #1

Input Image

Size: 181x217 pixels

Spacing: 0.8 x 0.9 mm

Origin: (0,0)

Output Image

Size: 181x217 pixels

Spacing: 0.8 x 0.9 mm

Page 35: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 35

Quiz #3Quiz #3

Fixed Image

Size: 181x217 pixels

Spacing: 0.8 x 0.9 mm

Origin: (0,0)

Moving Image

Size: 181x217 pixels

Spacing: 0.8 x 0.9 mm

Origin: (35,50)

Transform ?

Page 36: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 36

Things I will not do…Things I will not do…

I will not register images in pixel space

I will not register images in pixel space

I will not register images in pixel space

I will not register images in pixel space

I will not register images in pixel space

I will not register images in pix

Page 37: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 37

Quiz #4Quiz #4

Fixed Image

Size: 181x217 pixels

Spacing: 0.8 x 0.9 mm

Origin: (0,0)

Moving Image

Size: 181x217 pixels

Spacing: 0.8 x 0.9 mm

Origin: (0,0)

Transform ?

Page 38: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 38

Return to the SourceReturn to the Source

Input Image

Size: 181x217 pixels

Spacing: 0.8 x 0.9 mm

Origin: (0,0)

Output Image

Size: 181x217 pixels

Spacing: 0.8 x 0.9 mm

Origin: (0,0)

(35,50)

Translation

( -35 , -50 )

Page 39: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 39

More ResamplingMore Resampling

Resampling

Less Trivial Cases

Page 40: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 40

Rotation Rotation

y

Fixed

Transform

10o

x

y

Moving

x

Page 41: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 41

RotationRotation

y

Fixed

Transform

10o

x

y

Moving

x

Page 42: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 42

RotationRotation

y

Fixed

Transform

10o

x

y

Moving

x

Page 43: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 43

Rotation around the OriginRotation around the Origin

Origin (Ox,Oy)

Spacing (Sy)

Spacing (Sx)

Rotation Center

Page 44: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 44

Rotation around the OriginRotation around the Origin

Origin (Ox,Oy)

Spacing (Sy)

Spacing (Sx)

Page 45: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 45

Rotation around the OriginRotation around the Origin

Origin (Ox,Oy)

DefaultPixelValue

Page 46: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 46

Rotation around the Center Rotation around the Center

y

Fixed

Transform

10o

x

y

Moving

x

Page 47: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 47

Rotation around the Center Rotation around the Center

y

Fixed

Transform

10o

x

y

Moving

x

Page 48: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 48

Rotation around the CenterRotation around the Center

y

Fixed

Transform

10o

x

y

Moving

x

Page 49: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 49

Rotation around the CenterRotation around the Center

y

Fixed

Transform

10o

x

y

Moving

x

Page 50: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 50

Rotation around the CenterRotation around the Center

Origin (Ox,Oy)

Spacing (Sy)

Spacing (Sx)

RotationCenter

Page 51: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 51

Rotation around the CenterRotation around the Center

Origin (Ox,Oy)

Spacing (Sy)

Spacing (Sx)

Page 52: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 52

Rotation around the CenterRotation around the Center

Origin (Ox,Oy)

DefaultPixelValue

Page 53: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 53

Resample Image FilterResample Image Filter

#include "itkImage.h"#include "itkResampleImageFilter.h"#include "itkCenteredRigid2DTransform.h“#include "itkNearestNeighborInterpolateImageFunction.h"

typedef itk::Image< char, 2 > ImageType;

ImageType::Pointer inputImage = GetImageSomeHow();

typedef itk::ResampleImageFilter< ImageType > FilterType;

FilterType::Pointer resampler = FilterType::New();

ImageType::SizeType size;size[0] = 200;size[1] = 300;

ImageType::IndexType start; start[0] = 0;start[1] = 0;

Page 54: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 54

Resample Image FilterResample Image Filter

ImageType::PointType origin;origin[0] = 10.0; // millimetersorigin[1] = 25.5; // millimeters

ImageType::SpacingType spacing; spacing[0] = 2.0; // millimetersspacing[1] = 1.5; // millimeters

resampler->SetOutputSpacing( spacing );resampler->SetOutputOrigin( origin );

resampler->SetSize( size );resampler->SetOutputStartIndex( start );

resampler->SetDefaultPixelValue( 100 );

resampler->SetInput( inputImage );

Page 55: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 55

Resample Image FilterResample Image Filter

typedef itk::NearestNeighborInterpolateImageFunction< ImageType, double > InterpolatorType;

InterpolatorType::Pointer interpolator = InterpolatorType::New();

resampler->SetInterpolator( interpolator );

typedef itk::CenteredRigid2DTransform< double, 2 > TransformType;

TransformType::Pointer transform = TransformType::New();

resampler->SetTransform( transform );

TransformType::InputPointType center;

center[0] = origin[0] + spacing[0] * size[0] / 2;center[1] = origin[1] + spacing[1] * size[1] / 2;

Page 56: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 56

Resample Image FilterResample Image Filter

transform->SetCenter( center );

angle = 10.0 * 3.1514 / 180.0;

transform->SetRotation( angle );

transform->ComputeOffset();

resampler->Update();

const ImageType * outputImage = resampler->GetOutput();

Page 57: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 57

ScalingScaling

y

Fixed

Transform

10%

x

y

Moving

x

Page 58: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 58

ScalingScaling

y

Fixedx

y

Moving

x

Transform

10%

Page 59: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 59

ScalingScaling

y

Fixedx

y

Moving

x

Transform

10%

Page 60: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 60

ScalingScaling

y

Fixedx

y

Moving

x

Transform

10%

Page 61: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 61

Resample Image FilterResample Image Filter

#include "itkImage.h"#include "itkResampleImageFilter.h"#include "itkScaleTransform.h"#include "itkNearestNeighborInterpolateImageFunction.h"

typedef itk::Image< char, 2 > ImageType;

ImageType::ConstPointer inputImage = reader->GetOutput();

typedef itk::ResampleImageFilter< ImageType > FilterType;

FilterType::Pointer resampler = FilterType::New();

ImageType::RegionType region = inputImage->GetBufferedRegion();

resampler->SetSize( region->GetSize() );

resampler->SetOutputStartIndex( region->GetIndex() );

Page 62: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 62

Resample Image FilterResample Image Filter

resampler->SetOutputSpacing( inputImage->GetSpacing() );resampler->SetOutputOrigin( inputImage->GetOrigin() );

typedef itk::ScaleTransform< double, 2 > TransformType;

TransformType::Pointer transform = TransformType::New();

TransformType::ScaleType scale;scale[0] = 1.1;scale[1] = 1.1;transform->SetScale( scale );

resampler->SetTransform( transform );

resampler->SetDefaultPixelValue( 100 );

resampler->SetInput( inputImage );

writer->SetInput( resampler->GetOutput() );writer->Update();

Page 63: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 63

Quiz #5Quiz #5

Fixed Image

Size: 181x217 pixels

Spacing: 0.8 x 0.9 mm

Origin: (0,0)

Moving Image

Size: 181x217 pixels

Spacing: 0.8 x 0.9 mm

Origin: (0,0)

Transform ?

a) 1.50

b) 0.75

1. Scale X

2. Scale Y

Page 64: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 64

Quiz #6Quiz #6

Fixed Image

Size: 181x217 pixels

Spacing: 0.8 x 0.9 mm

Origin: (0,0)

Moving Image

Size: 181x217 pixels

Spacing: 0.8 x 0.9 mm

Origin: (0,0)

Transform ?

a) 1.50

b) 0.75

1. Scale X

2. Scale Y

Page 65: CSci 6971: Image Registration  Lecture 8:  Image Resampling February 3, 2004

Image Registration Lecture 7 65

EndEnd

Enjoy ITK !