Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "CSci 6971: Image Registration Lecture 8: Image Resampling February 3, 2004 Prof. Chuck Stewart, RPI Dr. Luis Ibanez, Kitware Prof. Chuck Stewart, RPI Dr."— Presentation transcript:

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

2 Image RegistrationLecture 7 2 Why Resampling ? Resampling is the Essence of Intensity Based Image Registration

3 Image RegistrationLecture 7 3 What is an Image ? An Image is a sampling of a continuous field using a discrete grid

4 Image RegistrationLecture 7 4 Image Origin & Spacing Origin (Ox,Oy) Spacing (Sy) Spacing (Sx) x y

5 Image RegistrationLecture 7 5 Image Sampling Grid Origin (Ox,Oy) Spacing (Sy) Spacing (Sx)

6 Image RegistrationLecture 7 6 Image Pixel Origin (Ox,Oy) Spacing (Sy) Spacing (Sx) Pixel Value Pixel Region

7 Image RegistrationLecture 7 7 Image 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

8 Image RegistrationLecture 7 8 Index 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 )

9 Image RegistrationLecture 7 9 Image Region Origin (Ox,Oy) Spacing (Sy) Spacing (Sx) Pixel Value Pixel Region Image Region

10 Image RegistrationLecture 7 10 Image Region Origin (Ox,Oy) Spacing (Sy) Spacing (Sx) Image Region Starting Index Region Size [2,3] [3,5]

11 Image RegistrationLecture 7 11 Basic Resampling Resampling Trivial Cases

12 Image RegistrationLecture 7 12 Sub-Sampling by Half Origin (Ox,Oy) Spacing (Sy) Spacing (Sx) Image Region Spacing ( 2 x Sy ) Spacing ( 2 x Sx )

13 Image RegistrationLecture 7 13 Sub-Sampling by Half Origin (Ox,Oy) New Origin (O’x,O’y) New Spacing S’y New Spacing S’x

14 Image RegistrationLecture 7 14 Super-Sampling by Double Origin (Ox,Oy) Spacing (Sy) Spacing (Sx) Image Region Spacing ( Sy/2 ) Spacing ( Sx/2 )

15 Image RegistrationLecture 7 15 Super-Sampling by Double Origin (Ox,Oy) New Spacing S’x New Spacing S’y New Origin (O’x,O’y)

16 Image RegistrationLecture 7 16 Resampling in ITK itk::ResampleImageFilter

17 Image RegistrationLecture 7 17 Resampling in ITK Transform Interpolator Origin Spacing Region Start Region Size Resample Filter Input Image Output Image

18 Image RegistrationLecture 7 18 Resample Image Filter #include "itkImage.h" #include "itkResampleImageFilter.h" #include "itkIdentityTransform.h“ #include "itkLinearInterpolateImageFunction.h" typedef itk::Image ImageType; ImageType::Pointer inputImage = GetImageSomeHow(); typedef itk::ResampleImageFilter FilterType; FilterType::Pointer resampler = FilterType::New(); ImageType::SizeType size; size[0] = 200; size[1] = 300; ImageType::IndexType start; start[0] = 0; start[1] = 0;

19 Image RegistrationLecture 7 19 Resample Image Filter ImageType::PointType origin; origin[0] = 10.0; // millimeters origin[1] = 25.5; // millimeters ImageType::SpacingType spacing; spacing[0] = 2.0; // millimeters spacing[1] = 1.5; // millimeters resampler->SetOutputSpacing( spacing ); resampler->SetOutputOrigin( origin ); resampler->SetSize( size ); resampler->SetOutputStartIndex( start ); resampler->SetDefaultPixelValue( 100 ); resampler->SetInput( inputImage );

20 Image RegistrationLecture 7 20 Resample Image Filter typedef itk::LinearInterpolateImageFunction InterpolatorType; InterpolatorType::Pointer interpolator = InterpolatorType::New(); typedef itk::TranslationTransform TransformType; TransformType::Pointer transform = TransformType::New(); transform->SetIdentity(); resampler->SetInterpolator( interpolator ); resampler->SetTransform( transform ); resampler->Update(); const ImageType * outputImage = resampler->GetOutput();

21 Image RegistrationLecture 7 21 Basic Registration Registration Basics

22 Image RegistrationLecture 7 22 Coordinate System Conversions Image Grid j i y x Physical Coordinates y’ x’ Physical Coordinates Image Grid j i Space Transform x y

23 Image RegistrationLecture 7 23 Things I will not do… I will not register images in pixel space I will not register images in pix

24 Image RegistrationLecture 7 24 Fixed Image & Moving Image Fixed Image Grid j i y x Fixed Image Physical Coordinates y’ x’ Moving Image Physical Coordinates Moving Image Grid j i Space Transform

25 Image RegistrationLecture 7 25 Selecting 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

26 Image RegistrationLecture 7 26 Quiz #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 ?

27 Image RegistrationLecture 7 27 Quiz #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

28 Image RegistrationLecture 7 28 Things I will not do… I will not register images in pixel space I will not register images in pix

29 Image RegistrationLecture 7 29 Security "Do not accept packages or baggage from unknown individuals." "Do not accept images or volumes without pixel spacing." Airport Security Image Security

30 Image RegistrationLecture 7 30 Exercise #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 )

31 Image RegistrationLecture 7 31 Exercise #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

32 Image RegistrationLecture 7 32 Resample Image Filter #include "itkImage.h" #include "itkResampleImageFilter.h" #include "itkIdentityTransform.h" #include "itkNearestNeighborInterpolateImageFunction.h" typedef itk::Image ImageType; ImageType::ConstPointer inputImage = reader->GetOutput(); typedef itk::ResampleImageFilter FilterType; FilterType::Pointer resampler = FilterType::New(); ImageType::RegionType region = inputImage->GetBufferedRegion(); resampler->SetSize( region->GetSize() ); resampler->SetOutputStartIndex( region->GetIndex() ); resampler->SetOutputSpacing( inputImage->GetSpacing() );

33 Image RegistrationLecture 7 33 Resample Image Filter ImageType::PointType origin; origin[0] = 35.0; // millimeters origin[1] = 50.0; // millimeters resampler->SetOutputOrigin( origin ); typedef itk::IdentityTransform TransformType; TransformType::Pointer transform = TransformType::New(); resampler->SetTransform( transform ); resampler->SetDefaultPixelValue( 100 ); resampler->SetInput( inputImage ); writer->SetInput( resampler->GetOutput() ); writer->Update();

34 Image RegistrationLecture 7 34 Exercise #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

35 Image RegistrationLecture 7 35 Quiz #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 ?

36 Image RegistrationLecture 7 36 Things I will not do… I will not register images in pixel space I will not register images in pix

37 Image RegistrationLecture 7 37 Quiz #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 ?

38 Image RegistrationLecture 7 38 Return 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 )

39 Image RegistrationLecture 7 39 More Resampling Resampling Less Trivial Cases

40 Image RegistrationLecture 7 40 Rotation y Fixed Transform 10 o x y Moving x

41 Image RegistrationLecture 7 41 Rotation y Fixed Transform 10 o x y Moving x

42 Image RegistrationLecture 7 42 Rotation y Fixed Transform 10 o x y Moving x

43 Image RegistrationLecture 7 43 Rotation around the Origin Origin (Ox,Oy) Spacing (Sy) Spacing (Sx) Rotation Center

44 Image RegistrationLecture 7 44 Rotation around the Origin Origin (Ox,Oy) Spacing (Sy) Spacing (Sx)

45 Image RegistrationLecture 7 45 Rotation around the Origin Origin (Ox,Oy) Default Pixel Value

46 Image RegistrationLecture 7 46 Rotation around the Center y Fixed Transform 10 o x y Moving x

47 Image RegistrationLecture 7 47 Rotation around the Center y Fixed Transform 10 o x y Moving x

48 Image RegistrationLecture 7 48 Rotation around the Center y Fixed Transform 10 o x y Moving x

49 Image RegistrationLecture 7 49 Rotation around the Center y Fixed Transform 10 o x y Moving x

50 Image RegistrationLecture 7 50 Rotation around the Center Origin (Ox,Oy) Spacing (Sy) Spacing (Sx) Rotation Center

51 Image RegistrationLecture 7 51 Rotation around the Center Origin (Ox,Oy) Spacing (Sy) Spacing (Sx)

52 Image RegistrationLecture 7 52 Rotation around the Center Origin (Ox,Oy) Default Pixel Value

53 Image RegistrationLecture 7 53 Resample Image Filter #include "itkImage.h" #include "itkResampleImageFilter.h" #include "itkCenteredRigid2DTransform.h“ #include "itkNearestNeighborInterpolateImageFunction.h" typedef itk::Image ImageType; ImageType::Pointer inputImage = GetImageSomeHow(); typedef itk::ResampleImageFilter FilterType; FilterType::Pointer resampler = FilterType::New(); ImageType::SizeType size; size[0] = 200; size[1] = 300; ImageType::IndexType start; start[0] = 0; start[1] = 0;

54 Image RegistrationLecture 7 54 Resample Image Filter ImageType::PointType origin; origin[0] = 10.0; // millimeters origin[1] = 25.5; // millimeters ImageType::SpacingType spacing; spacing[0] = 2.0; // millimeters spacing[1] = 1.5; // millimeters resampler->SetOutputSpacing( spacing ); resampler->SetOutputOrigin( origin ); resampler->SetSize( size ); resampler->SetOutputStartIndex( start ); resampler->SetDefaultPixelValue( 100 ); resampler->SetInput( inputImage );

55 Image RegistrationLecture 7 55 Resample Image Filter typedef itk::NearestNeighborInterpolateImageFunction InterpolatorType; InterpolatorType::Pointer interpolator = InterpolatorType::New(); resampler->SetInterpolator( interpolator ); typedef itk::CenteredRigid2DTransform 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;

56 Image RegistrationLecture 7 56 Resample Image Filter transform->SetCenter( center ); angle = 10.0 * 3.1514 / 180.0; transform->SetRotation( angle ); transform->ComputeOffset(); resampler->Update(); const ImageType * outputImage = resampler->GetOutput();

57 Image RegistrationLecture 7 57 Scaling y Fixed Transform 10% x y Moving x

58 Image RegistrationLecture 7 58 Scaling y Fixed x y Moving x Transform 10%

59 Image RegistrationLecture 7 59 Scaling y Fixed x y Moving x Transform 10%

60 Image RegistrationLecture 7 60 Scaling y Fixed x y Moving x Transform 10%

61 Image RegistrationLecture 7 61 Resample Image Filter #include "itkImage.h" #include "itkResampleImageFilter.h" #include "itkScaleTransform.h" #include "itkNearestNeighborInterpolateImageFunction.h" typedef itk::Image ImageType; ImageType::ConstPointer inputImage = reader->GetOutput(); typedef itk::ResampleImageFilter FilterType; FilterType::Pointer resampler = FilterType::New(); ImageType::RegionType region = inputImage->GetBufferedRegion(); resampler->SetSize( region->GetSize() ); resampler->SetOutputStartIndex( region->GetIndex() );

62 Image RegistrationLecture 7 62 Resample Image Filter resampler->SetOutputSpacing( inputImage->GetSpacing() ); resampler->SetOutputOrigin( inputImage->GetOrigin() ); typedef itk::ScaleTransform 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();

63 Image RegistrationLecture 7 63 Quiz #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

64 Image RegistrationLecture 7 64 Quiz #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

65 Image RegistrationLecture 7 65 End Enjoy ITK !


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

Similar presentations


Ads by Google