chapter 8 geometric operations 8.1 introduction two separate algorithms are required for a geometric...

Post on 04-Jan-2016

241 Views

Category:

Documents

6 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Chapter 8 Geometric Operations 8.1 Introduction

Two separate algorithms are required for a geometric operation. • 1). Spatial transformation which specifies the

“motion” of each pixel as it “moves” from its initial to its final position in the image.

• 2). Gray-level interpolation.

Examples

Lenna and its transformed images

8.1.1 The Spatial Transformation The spatial transformation defines the spatial

relationship between points in the input image and points in the output image.

Where is the input image and is the output image. The functions and

specify the spatial transformation.

)],(),,([)','(),( yxbyxafyxfyxg

),( yxf ),( yxg),( yxa

),( yxb

8.1.2 Gray-Level Interpolation Gray-level interpolation is necessary becau

se the gray-level values are defined only at integral values of x and y, however, spatial transformation may make the output image taking values at fractional positions of and . ),( yxa

),( yxb

),( yxg

Pixel Carry-Over (Forward-Mapping) Interpolation If an input pixel maps to a position betwee

n four output pixels, then its gray level is divided among the four output pixels according to the interpolation rule.

)','( yxf ),( yxg

'x

'y

x

y

Pixel Filling (Backward-Mapping) Interpolation If an output pixel falls between four input p

ixels, its gray level is determined by the four input pixels according to the interpolation rule.

)','( yxf ),( yxg

'x

'y

x

y

Pixel-filling Interpolation 8.2.1 Nearest Interpolation (zero-order)

The gray level of the output pixel is taken to be that of the input pixel nearest the location to which the output pixel maps.

Characteristics of the nearest neighbor interpolation

• Computationally simple• Sometimes produce artifacts

8.2.2 Bilinear Interpolation (first-order)

For a function of two variables, given its values at four vertices of the unit square , , and , we desire to determine the value of at an arbitrary point inside the square. This can be done by a hyperbolic paraboloid defined by the bilinear equation

),( yxf

)0,1(f)1,0(f)0,0(f

)1,1(f

),( yxf

dcxybyaxyxf ),(

The four coefficients a,b,c,d can be determined by solving four linear equations.

)1,1(

)1,0(

)0,1(

)0,0(

fdcba

fdb

fda

fd

Another way to determine coefficients First linearly interpolate between the upper

two points and

Second, interpolate between the two lower points and

)0,0(f )0,1(f

)]0,0()0,1([)0,0()0,( ffxfxf

)1,0(f )1,1(f

)]1,0()1,1([)1,0()1,( ffxfxf

8.2.2 Bilinear Interpolation Finally, linearly interpolate vertically

Substituting the first two equations into the third produces

This agrees with the result of the first

method.

)]0,()1,([)0,(),( xfxfyxfyxf

)0,0()]0,1()1,0()0,0()1,1([

)]0,0()1,0([))0,0()0,1((),(

fxyffff

yffxffyxf

8.2.2 Bilinear Interpolation

)0,0(f

)0,1(f

)1,0(f

)1,1(f

)0,0(

)1,0(

)1,1(

)0,1(

)0,(x

),0( y

)1,(x

),( yx

An example Suppose f(0,0)=2,f(1,0)=3,f(0,1)=1,f(1,1)=

4 Then f(x,y)=x-y+2xy+2

0

1

23

4

5

Z

0.20.4

0.6

1

Y

0.20.4

0.60.8

1

X

Comparison of Nearest and Bilinear Interpolations

Another example An image of tiger

Enalrged image( 纹理复杂,视觉上无明显区别 )

采用最近邻插值放大 1.5 倍 采用双线性插值放大 1.5倍

8.2.3 Higher Order Interpolation The smoothing effect of bilinear interpolation

may degrade fine details in the image and sometimes the slope discontinuities of bilinear interpolation may produce undesirable effects.

When the number of points exceeds that of coefficients, a curve-fitting or error-minimizing procedure can be used.

Examples of higher order interpolation: Bicubic; Cubic splines; Legendre centered functions, function , et.al. .

xx /)sin(

8.3 The Spatial Transformation 8.3.1 Simple Transformations

Translation

Can be expressed in homogeneous coordinates as

00 ),( ),( yyyxbxxyxa

1100

10

01

1

),(

),(

0

0

y

x

y

x

yxb

yxa

8.3 The Spatial Transformation Scaling

Homogeneous form

When : reflection about the y-axis

dyyxbcxyxa /),( /),(

1100

0/10

00/1

1

),(

),(

y

x

d

c

yxb

yxa

1 ,1 dc

yyxbxyxa ),( ),(

8.3 The Spatial Transform Rotation about the origin

)cos()sin(),(

)sin()cos(),(

yxyxb

yxyxa

1100

0)cos()sin(

0)sin()cos(

1

),(

),(

y

x

yxb

yxa

Rotation about the point

1100

10

01

100

0)cos()sin(

0)sin()cos(

100

10

01

1

),(

),(

0

0

0

0

y

x

y

x

y

x

yxb

yxa

),( 00 yx

x, y

a, br

r

cos cos cos sin sin cos sin

sin sin cos cos sin cos sin

sin cos

a r r r x y

b r r r y x

x y

8.3 The Spatial Transform Separable Implementation

Translation and scaling is naturally separable, that can be implemented separately for x-axis and y-axis.

Separable implementation of Rotation Step 1:

Step 2:

yyxb

yxyxa

),(

)sin()cos(),(

)cos(/])sin(),([),(

),(

yyxayxb

xyxa

8.3.2 General Transformation For relatively complex spatial transform

ations, usually no analytic expression exists, in these situations, the pixel position relationship is obtained from measurement of actual images.

Such an example is the geometric calibration of an image taken with a camera having geometric distortion.

Specification by Control Points Specifying the spatial transformation as

a series of displacement values for selected control points in the image.

A polynomial is commonly used as the general form of the transformation expression.

Polynomial of up to the fifth order is practical.

Polynomial Warping• When the number of terms in the polynomial m

atches the number of control points, solve simultaneous linear equations.

• When there are more control points, use a fitting procedure.

• Pseudoinverse matrix; Singular value decomposition;

8.3 The Spatial Transformation Control Points and Polynomial Warping

Break the image into polygonal regions or quadrilaterals and use piecewise bilinear mapping functions or polynomials.

Input Output

8.3 The Spatial Transformation 8.3.5 Control Grid Interpolation

Bilinear spatial transformation

The eight coefficients can be determined by four pairs of vertices of corresponding grids between the input and output images.

A more efficient way to implement bilinear transformation

),()','(),( hgxyfyexdcxybyaxFyxFyxG

8.3 The Spatial Transformation 8.3.5 Control Grid Interpolation

Rewriting the bilinear transformation as

Where and are pixel displacements functions of x and y.

Since and are bilinear, it can be assume that

)],(),,([),( yxdyyyxdxxFyxG ),( yxdx ),( yxdy

),( yxdx ),( yxdy

xyxdxyxdx ),(),1(

yyxdxyxdx ),()1,(

8.3 The Spatial Transformation The bilinear transformation may be solv

ed by computing the displacements at the ends of the output rectangles and linear interpolation.

),( yxdx

),( yxdy),( yx

8.3 The Spatial Transformation Extrapolation of Spatial Transformation

The spatial transformation can be extrapolated outside the rectangles by which the bilinear transformation is defined.

1

1

1

1

2

2

3 3

334

4 4

45

56 6

66

8.4 Applications of Geometric Operations

Geometric Calibration Removal of camera-induced geometric dist

ortion of images, such as those from satellites and radar.

Image Rectification Images taken by imaging systems using no

n-rectangular pixel coordinates must be rectified before processing or display

8.4 Applications of Geometric Operations

Rectification of images digitized by angle-scanning camera involves the projection of a spherical surface onto a tangent plane. (example, Fig.8-8)

A fifth-order polynomial warp, implemented in a polar coordinate system, can rectify images taken by a fish-eye wide-angle camera. (Example, Fig.8-9).

8.4 Applications of Geometric Operations

Image Registration Registering similar images before comparis

on. Image Format Conversion

Image Format Conversion Making images of chromosomes straight by

properly designed geometric transformation with control grid techniques.

8.4 Applications of Geometric Operations

8.4.5 Map Projection Geometric transformations are used to project sph

erical surface to map in a plane. 8.4.6 Morphing (变形)

Morphing is a technique that allows one object to transform gradually into another, which can produce more realistic looking transformation in image fades out and fades in.

8.5 Summary of Important Points

A geometric operation requires a means for specifying its spatial transformation and an algorithm for gray-level interpolation.

A geometric operation can be thought of as mapping each output image pixel into the input image, where the output gray-level value is determined by interpolation.

Bilinear gray-level interpolation is generally superior to nearest neighbor interpolation, and it produces only a modest increase in program complexity ad execution time.

A spatial transformation can be specified by a pair of control grids one defined in the input image and one in the output image.

The input control points map to the corresponding output control points.

Between control points, a spatial transformation is obtained by interpolation.

Bilinear interpolation is useful for non-control-point interpolation.

Geometric operations are useful for digitizer calibration, display rectification, image registration, map projection, image reformatting for display, and visual special effects.

空间变换 2 )多项式卷绕和几何校正

几何校正( calibration ) : 由于镜头的几何变形,使用矩形栅格校准。

多项式卷绕:多项式的项数与控制点数相同,解线性方程组,得系数后矩阵求逆。

测试靶 对应的鱼眼图象

空间变换

变形后的老虎 校正后的老虎

空间变换 多项式卷绕的基本原理 对于一个有 10 个点的测试靶,可以设计一个二维三

阶函数拟合。

20 1 2 3 4

2 2 2 3 35 6 7 8 9

301 1 1 1

32 12 2 2

3910 10 10 10

1

1

1

p x, y c c x c y c xy c x

c y c x y c xy c x c y

cp x , y x y

cp x , y x y

cp x , y x y

空间变换 3 )控制栅格插值和图象卷绕

控制栅格插值:将图象分成小块进行卷绕变换。 常用双线性插值。

又是双线性插值,区别? ( 请思考 )

空间变换

空间变换

空间变换

1:

, ,

4 8

Method

G x y F ax by cxy d ex fy gxy h

双线性空间变换的表达式

解 个点 个方程式可得。

http://www.morpheussoftware.net/

图像变形

鼠标点击观看演示

图像变形

上机实习 1 )用 MATLAB 编写实现图象几何校正的程序。采用控

制栅格的方法。

习题 P117 第 1 题

221.3 221 222 221.3 396.7 396 397 396.7

F 221,397 45.

F x,396 F 221,396 x F 222,396 F 221,396

18 34x

F x,397 F 221,397 x F 222,397 F 221,397

45 9x

F x,y F x,396 y F x,397 F x,396

18 34x y 45 9x 18 3

解: 且

F 221.3,396.7最邻近插值

4x

18 34x 27y 43xy

F 0.3,0.7 38

习题 P118 第 2 题

F 1,0 F 0,0 x F 0,1 F 0,0 y

F 1,1 F 0,0 F 1,0 F 0,1 xy F 0,0

8x 4y 2xy 113

F 1.27,1.44 100.74

F x,y解:

习题 P118 第 3 题

0 0

0 0

, 1 0 cos sin 0 1 0

, 0 1 sin cos 0 0 1

1 0 0 1 0 0 1 0 0 1 1

, 1 0 207 cos 30 sin 30 0

, 0 1 421 sin 30 cos 30 0

1 0 0 1 0

a x y x x x

b x y y y y

a x y

b x y

o

解:

207 421 -33代入( , )和 得

1 0 207

0 1 421

0 1 0 0 1 1

x

y

习题 P118 第 4 题解 :

习题

1 1

1

1

1

1 1

2

2

A 0,0 ,B 5,240 ,A 13, 7 ,B 18,213

step1 : A A

x 1 0 13 x

y 0 1 7 y

1 0 0 1 1

step2 : B A B

240 220arctg arctg

5 5

x cos sin 0 1 0 13

y sin cos 0 0 1 7

1 0 0 1 0 0 1

将 点平移到 点

,将 点旋转到 上

=旋转角度

x

y

1

习题

1 1

2 2

3 2

3 2

step3 :

B x B yc ,d

x y

x c 0 0 x

y 0 d 0 y

1 0 0 1 1

进行缩放变换

top related