csci 6971: image registration lecture 8: registration components february 6, 2004 prof. chuck...

76
CSci 6971: Image Registration Lecture 8: Registration Components February 6, 2004 Prof. Chuck Stewart, RPI Dr. Luis Ibanez, Kitware

Post on 20-Dec-2015

218 views

Category:

Documents


0 download

TRANSCRIPT

CSci 6971: Image Registration Lecture 8: Registration Components

February 6, 2004

CSci 6971: Image Registration Lecture 8: Registration Components

February 6, 2004

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

Image Registration Lecture 8 2

Image MetricsImage Metrics

How similar is

image A to image B ?

Image Registration Lecture 8 3

Image MetricsImage Metrics

Does Image B

matches Image A better

than Image C ?

Image Registration Lecture 8 4

Image MetricsImage Metrics

Image A Image CImage B

Match( A , B ) Match( A , C )><

Image Registration Lecture 8 5

Image MetricsImage Metrics

Match( A , B )

Simplest Metric

Mean Squared Differences

Image Registration Lecture 8 6

Mean Squared DifferencesMean Squared Differences

Image A Image B

For each pixel in A

Difference( index ) = A( index ) – B( index )

Sum += Difference( index ) 2

Match( A , B ) = Sum / numberOfPixels

Image Registration Lecture 8 7

For each pixel in the Fixed ImageFor each pixel in the Fixed Image

Fixed Image Grid

j

i

y

x

Fixed ImagePhysical Coordinates

y’

x’

Moving ImagePhysical Coordinates

Moving Image Grid

j

i

Space Transform

Image Registration Lecture 8 8

Image MetricsImage Metrics

FixedImage

MovingImage

Metric

Transform

Interpolator

Value

Parameters

Image Registration Lecture 8 9

Mean Squared DifferencesMean Squared Differences

#include "itkImage.h"#include "itkMeanSquaresImageToImageMetric.h"#include "itkLinearInterpolateImageFunction.h"#include "itkTranslationTransform.h"

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

ImageType::ConstPointer fixedImage = GetFixedImage(); ImageType::ConstPointer movingImage = GetMovingImage();

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

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

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

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

Image Registration Lecture 8 10

Mean Squared DifferencesMean Squared Differences

typedef itk::MeanSquaresImageToImageMetric< ImageType, ImageType > MetricType;

MetricType::Pointer metric = MetricType::New();

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

metric->SetFixedImage( fixedImage );metric->SetMovingImage( movingImage );

MetricType::TransformParametersType translation( Dimension );

translation[0] = 12;translation[1] = 27;

double value = metric->GetValue( translation );

Image Registration Lecture 8 11

Mean Squared DifferencesMean Squared Differences

MetricType::TransformParametersType translation( Dimension );

double value[21][21];

for( int dx = 0; dx <= 20; dx++) {

for( int dy = 0; dy <= 20; dy++) {

translation[0] = dx;translation[1] = dy;

value[dx][dy] = metric->GetValue( translation );

}}

Image Registration Lecture 8 12

Evaluating many matchesEvaluating many matches

y

Fixed Image

Transform

x

y

Moving Image

x

Image Registration Lecture 8 13

Plotting the MetricPlotting the Metric

Mean Squared Differences

Transform Parametric Space

Image Registration Lecture 8 14

Plotting the MetricPlotting the Metric

Mean Squared Differences

Transform Parametric Space

Image Registration Lecture 8 15

Evaluating many matchesEvaluating many matches

y

Fixed Image

Transform

x

y

Moving Image

x

(-15,-25) mm

Image Registration Lecture 8 16

Plotting the MetricPlotting the Metric

Mean Squared Differences

Transform Parametric Space

Image Registration Lecture 8 17

Plotting the MetricPlotting the Metric

Mean Squared Differences

Transform Parametric Space

Image Registration Lecture 8 18

The Best Transform ParametersThe Best Transform Parameters

Evaluation of the full parameter space

is equivalent to performoptimization by

exhaustive search

Image Registration Lecture 8 19

The Best Transform ParametersThe Best Transform Parameters

Very Safe

but

Very Slow

Image Registration Lecture 8 20

The Best Transform ParametersThe Best Transform Parameters

Better Optimization Methods

for example

Gradient Descent

Image Registration Lecture 8 21

Image Registration FrameworkImage Registration Framework

FixedImage

MovingImage

Metric

Transform

Interpolator Optimizer

Parameters

Image Registration Lecture 8 22

Gradient Descent OptimizerGradient Descent Optimizer

f( x , y )

S = L ∙ G( x , y )f( x , y )

G( x , y ) =

S = Step

L = LearningRate

Image Registration Lecture 8 23

Gradient Descent OptimizerGradient Descent Optimizer

f( x , y )

S = L ∙ G( x , y )f( x , y )

G( x , y ) =

Image Registration Lecture 8 24

Gradient Descent OptimizerGradient Descent Optimizer

f( x , y )

S = L ∙ G( x , y )f( x , y )

G( x , y ) =

L too large

Image Registration Lecture 8 25

Gradient Descent OptimizerGradient Descent Optimizer

f( x , y )

S = L ∙ G( x , y )f( x , y )

G( x , y ) =

L too small

Image Registration Lecture 8 26

Gradient Descent OptimizerGradient Descent Optimizer

What’s wrong with this algorithm ?

Image Registration Lecture 8 27

Gradient Descent OptimizerGradient Descent Optimizer

S Units ? = millimeters

f(x,y) Units ? = intensity

G(x,y) Units ? = intensity / millimeters

L Units ? = millimeters2 / intensity

S = L ∙ G( x , y )

Image Registration Lecture 8 28

Gradient Descent OptimizerGradient Descent Optimizer

f( x )S = L ∙ G( x )

1

1

Image Registration Lecture 8 29

Gradient Descent OptimizerGradient Descent Optimizer

f( x )

1 1

S = L ∙ G( x )

S = Large in high gradients

S = Small in low gradients

Image Registration Lecture 8 30

Gradient Descent OptimizerGradient Descent Optimizer

f( x )S = L ∙ G( x )

Works great with this function

Works badly with this function

Image Registration Lecture 8 31

Gradient Descent VariantGradient Descent Variant

Driving Safe !

Image Registration Lecture 8 32

Regular Step Gradient DescentRegular Step Gradient Descent

f( x )

S = D ∙ G( x )^

Di = Di-1 / 2.0

D1

If G changes direction

D1

D1

D2

Image Registration Lecture 8 33

Regular Step Gradient DescentRegular Step Gradient Descent

f( x )

S = D ∙ G( x )^

D1

User Selects D1

D1

D1

D2

User Selects Dstop

User Selects Gstop

Image Registration Lecture 8 34

Optimizers are like a carOptimizers are like a car

Watch while you are driving !

Image Registration Lecture 8 35

Watch over your optimizerWatch over your optimizer

Example:

Optimizer registering an image with itself starting at (-15mm, -25mm)

Image Registration Lecture 8 36

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Mean Squared Differences

Step Length = 1.0 mm

Image Registration Lecture 8 37

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Mean Squared Differences

Step Length = 2.0 mm

Image Registration Lecture 8 38

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Mean Squared Differences

Step Length = 5.0 mm

Image Registration Lecture 8 39

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Mean Squared Differences

Step Length = 10.0 mm

Image Registration Lecture 8 40

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Mean Squared Differences

Step Length = 20.0 mm

Image Registration Lecture 8 41

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Mean Squared Differences

Step Length = 40.0 mm

Image Registration Lecture 8 42

Watch over your optimizerWatch over your optimizer

Example:

Optimizer registering an image shifted by (-15mm, -25mm)

The optimizer starts at (0mm,0mm)

Image Registration Lecture 8 43

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Mean Squared Differences

Step Length = 1.0 mm

Image Registration Lecture 8 44

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Mean Squared Differences

Step Length = 2.0 mm

Image Registration Lecture 8 45

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Mean Squared Differences

Step Length = 5.0 mm

Image Registration Lecture 8 46

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Mean Squared Differences

Step Length = 10.0 mm

Image Registration Lecture 8 47

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Mean Squared Differences

Step Length = 20.0 mm

Image Registration Lecture 8 48

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Mean Squared Differences

Step Length = 40.0 mm

Image Registration Lecture 8 49

Other Image MetricsOther Image Metrics

Normalized Correlation

Image Registration Lecture 8 50

Normalized CorrelationNormalized Correlation

Image A Image B

For each pixel in A

SumAB += A( index ) ∙ B( index )

Match( A , B ) = SumAB / √ ( SumAA ∙ SumBB )

SumAA += A( index ) ∙ A( index )SumBB += B( index ) ∙ B( index )

Image Registration Lecture 8 51

Evaluating many matchesEvaluating many matches

y

Fixed Image

Transform

x

y

Moving Image

x

Image Registration Lecture 8 52

Plotting the MetricPlotting the Metric

Normalized Correlation Metric

Transform Parametric Space

Image Registration Lecture 8 53

Plotting the MetricPlotting the Metric

Normalized Correlation Metric

Transform Parametric Space

Image Registration Lecture 8 54

Normalized Correlation MetricNormalized Correlation Metric

#include "itkImage.h"#include "itkNormalizedCorrelationImageToImageMetric.h"#include "itkLinearInterpolateImageFunction.h"#include "itkTranslationTransform.h"

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

ImageType::ConstPointer fixedImage = GetFixedImage(); ImageType::ConstPointer movingImage = GetMovingImage();

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

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

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

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

Image Registration Lecture 8 55

Normalized Correlation MetricNormalized Correlation Metric

typedef itk::NormalizedCorrelationImageToImageMetric< ImageType, ImageType > MetricType;

MetricType::Pointer metric = MetricType::New();

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

metric->SetFixedImage( fixedImage );metric->SetMovingImage( movingImage );

MetricType::TransformParametersType translation( Dimension );

translation[0] = 12;translation[1] = 27;

double value = metric->GetValue( translation );

Image Registration Lecture 8 56

Watch over your optimizerWatch over your optimizer

Example:

Optimizer registering an image with itself starting at (-15mm, -25mm)

Image Registration Lecture 8 57

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Normalized Correlation Metric

Step Length = 1.0 mm

Image Registration Lecture 8 58

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Normalized Correlation Metric

Step Length = 2.0 mm

Image Registration Lecture 8 59

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Normalized Correlation Metric

Step Length = 5.0 mm

Image Registration Lecture 8 60

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Normalized Correlation Metric

Step Length = 10.0 mm

Image Registration Lecture 8 61

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Normalized Correlation Metric

Step Length = 20.0 mm

Image Registration Lecture 8 62

Plotting the Optimizer’s PathPlotting the Optimizer’s Path

Normalized Correlation Metric

Step Length = 40.0 mm

Image Registration Lecture 8 63

Evaluating many matchesEvaluating many matches

y

Fixed Image

Transform

x

y

Moving Image

x

(-15,-25) mm

Image Registration Lecture 8 64

Plotting the MetricPlotting the Metric

Normalized Correlation Metric

Transform Parametric Space

Image Registration Lecture 8 65

Plotting the MetricPlotting the Metric

Normalized Correlation Metric

Transform Parametric Space

Image Registration Lecture 8 66

Watch over your optimizerWatch over your optimizer

Example:

Optimizer registering an image shifted by (-15mm, -25mm)

The optimizer starts at (0mm,0mm)

Image Registration Lecture 8 67

Plotting the Optimizer PathPlotting the Optimizer Path

Normalized Correlation Metric

Step Length = 1.0 mm

Image Registration Lecture 8 68

Plotting the Optimizer PathPlotting the Optimizer Path

Normalized Correlation Metric

Step Length = 2.0 mm

Image Registration Lecture 8 69

Plotting the Optimizer PathPlotting the Optimizer Path

Normalized Correlation Metric

Step Length = 5.0 mm

Image Registration Lecture 8 70

Plotting the Optimizer PathPlotting the Optimizer Path

Normalized Correlation Metric

Step Length = 10.0 mm

Image Registration Lecture 8 71

Plotting the Optimizer PathPlotting the Optimizer Path

Normalized Correlation Metric

Step Length = 20.0 mm

Image Registration Lecture 8 72

Plotting the Optimizer PathPlotting the Optimizer Path

Normalized Correlation Metric

Step Length = 40.0 mm

Image Registration Lecture 8 73

Watch over your optimizerWatch over your optimizer

How much can you blindly

trust your optimizer…

Image Registration Lecture 8 74

I left my Optimizer working…I left my Optimizer working…

Image Registration Lecture 8 75

I think it’s going to finish soon…I think it’s going to finish soon…

Image Registration Lecture 8 76

EndEnd

Enjoy ITK !