22
Geometric Image Transformations and Related Topics 9 th Lesson on Image Processing Martina Mudrová 2004

Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

GeometricImage Transformations

and Related Topics9th Lesson on Image Processing

Martina Mudrová 2004

Page 2: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Topics

What will be the topic of the following lesson?

• Geometric image transformations• Interpolation in the image• Spatial image transformations• Warping and morphing• Image registration

2M. Mudrová, 2004

Page 3: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Geometric Transformations

• translation• scaling• rotation around the origin• shearing•…

X

P x

y

ee

e 'e '

x'y'

P '

12

1

2

more complicated transformation are composed from these basic operations

Carthesian coordinate system Affine coordinate system

),,,( 321 eeeP rrr),,,( 321 eeeP rrr

321 ,, eee rrr… linear non-dependent… perpendicular one to each other

321 ,, eee rrr…linear non-dependent

3M. Mudrová, 2004

Page 4: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Translation of an Image

• the simplest geometric transformation• [x,y]…pixel position

x

y

[x0,y0]

y'

[x0',y0'] x'

[x,y]

[x',y']

'0''0'

yyyxxx

+=+=

4M. Mudrová, 2004

Page 5: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Scaling of an Image (Zooming) (1)

[x0,y0]

y[x,y]

xx'

y'

[x',y']

1.5

0.5sx… scale coefficient in the direction of x axissy… scale coefficient in the direction of y axis

y

x

syysxx.'.'

==

0<|s|<1 … contraction|s|>1 … dilatations<0 … opposite direction

- scaling process changes image size !!= image resizing

5M. Mudrová, 2004

Page 6: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Scaling of an Image (Zooming) (2)

What happens, if the coefficients sx,y are not integer?

[x0,y0]

y

xx'

y'

- Appropriate interpolation method is required

6M. Mudrová, 2004

Page 7: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Rotation of an Image around the Origin

[x0,y0]

y

x

x'y'

)cos(.)sin(.')sin(.)cos(.'

αααα

yxyyxx

+=−=

Rotation around the point [X,Y] :-composition of translation and rotation around the origin

)cos().()sin().(')sin().()cos().('

αααα

YyXxYyYyXxXx

−+−+=−−−+=

Pixels do not map exactly onto another pixel – interpolation is required!!7

M. Mudrová, 2004

Page 8: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Rotation of an Image

As a new image must be rectangular, how should I solve a surrounding area?

1. to cut the resulting image according to the original size (in pixels)

2. to enlarge the size of resulting image so as new image can fit into new area, some value must be selected for the undefined pixels

8M. Mudrová, 2004

Page 9: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Matlab Commands for Basic Geometric Image Transformations

imresize

imrotate

9M. Mudrová, 2004

Page 10: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Image Interpolation Methods

Interpolation methods are used to compute the value in the unmeasured position

Input: points A, B, C,… A(a0,a1), B(b0,b1),…,known values of an image function h(A), h(B),…coordinates [i,j] of point Q in which we would like to know value of function h

Output: h(Q)

h… grayscale function in the case of intensity image3 functions of RGB components, the same method must be used for each of them

The most common interpolation methods:

• nearest neighbor method• bilinear method• bicubic method• spline interpolation

10M. Mudrová, 2004

Page 11: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Nearest Neighbor Method

-the pixel value is replaced by the same value as the nearest known point

= interpolation of the 0-th order

- very rough method but:- acceptable for all image types- the only method for the indexed images and BW images

11M. Mudrová, 2004

Page 12: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Bilinear Interpolation Method

What is a difference between bi-linear and linear interpolation?

Bi-linear means application the same – linear principle twice

12

x

h(x)

h(B)

h(Q)=?

h(A)

A Q B

A

B

C

D

i

j P QR

Bilinear interpolation

ABAQAhBhAhQh

−−

−+= )).()(()()(

Linear interpolation

= interpolation of the 1-st orderM. Mudrová, 2004

Page 13: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Interpolation of Higher Orders

-bicubic, spline interpolation:

- use polynomials of the 2-nd or 3-rd order instead of the linear function- need large number of surrounding points- higher computation requirements

13M. Mudrová, 2004

Page 14: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

2D Interpolation Method Use

What can happens in the case of improper interpolation method use?

Examples:1. Rotation of BW image with bicubic int. method use –> loosing sharpness2. Resizing of indexed images (with palette) –> colour nonsense3. Which method is the best for true-colour images?

Interpolation methods provides basic tools in the case of picture damage

What are other methods of reconstruction in this case?

- methods of signal modelling and prediction in 2D – AR models, NN, …

14M. Mudrová, 2004

Page 15: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Matlab Commands for 2D Interpolation

griddata

meshgrid

(interp2)

15M. Mudrová, 2004

Page 16: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Spatial Transformations

= advanced methods of geometric transformations

-are used to remove various types of image distortions caused by- using the various optical systems (lense)- taking the photos from the various points of view- projection of the spatial 3D objects into the 2D space only(aerial photos of the surface of the Earth,...)- ...

Examples of image distortion:

original Pincushiondistortion

BarreldistortionM. Mudrová, 2004

16

Page 17: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Image Registration Principle

-due to reasons described in the previous slide the pixels are shifted from their correct position:

-the goal of image registration: Geometric restoration= find such a transformation and its parameters which leads from

one coordinate system to other:

x

y

x'

y'

),('),('

yxTyyxTx

y

x

==

8765

4321

''

cxycycxcycxycycxcx+++=+++=for example:

M. Mudrová, 200417

Page 18: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Mapping Methods Principle

Forward mapping:

- we are going through the pixels of the input image A and finding their position in the output image B according to the selected transformation

- the appropriate interpolation method must be used to fill the empty areas

Backward mapping:

- we are going through the pixels of the output image B and finding the corresponding points in the input image

18M. Mudrová, 2004

Page 19: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

The Most Common Spatial Transformations

What are the most common spatial transformations? What are their properties?

19

• Linear conformal(translation, rotation, scaling) - streight lines remain straight, parallel remain parallel, angles are saved

• Affine(shearing)– streight lines remain straight, parallel remain parallel, but angles are changed

• Projective– streight lines remain straight, parallel lines converges toward vanishing points

• Polynomial- new system is described using curves (polynomial ot order 2,3 or higher)

• ...M. Mudrová, 2004

Page 20: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Estimation of Transformation Parameters

How can be estimated the parameters of the selected transformation?

-the parameters c1, c2, ... can be determined from the transformationof known points – control point pairsusing appropriate criteria (LSM)

For example:

based image ... image which we suppose to be correctinput image ...image which should be corrected

20M. Mudrová, 2004

Page 21: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Corresponding Terms

Image warping„ image is printed on a sheet of rubber“

-image is drawn on a 3D net projected into 2D, the same method of the net distortion is used for ech part of texture- by changing the net the resulting image is changed

- try to use Matlab command warp

Image morphing-involves two steps of warping with a smooth (spline) interpolationbetween initial and the resulting image- it is „animated warping“

21M. Mudrová, 2004

Page 22: Geometric Image Transformations and Related Topicsuprt.vscht.cz/mudrova/ip/lectures/09-TRANSFORMATIONS/Transformations.pdf · Spatial Transformations = advanced methods of geometric

Algorithm of Image Registration in Matlab

Goal: Registration of an input image according to the base image

Algorithm and Matlab commands:

1. Read the input and base images (imread)

2. Select the control point pairs (cpselect) and save them intothe Matlab environment

3. Correct the control points pairs using correlation analysis(cpcorr)

4. Perform the selected spatial transform, estimate its parameters(cp2tform, imtransform)

22M. Mudrová, 2004