Geometry
Geometry
Image Geometry
• Change the shape, size , or orientation of
an image, for printing/viewing purposes.
• Affine transformation
– Lines are transformed to lines
•
Data Interpolation
• Suppose we have a collection of four values that
we wish to enlarge to eight.
• Spatial transformation
x 1 2 3 4
x' 1 2 3 4 5 6 7 8
• Interpolation:
Interpolation estimate f(x') from f(x)
Data Interpolation
• In digital (discrete), none of the new points coincide
exactly with an original point except for the first and
last.
F f ( x1 ) f ( x2 ) f ( x1 )
1
F f ( x2 ) (1 ) f ( x1 )
Data Interpolation - Example
f ( x1 ) 2, f ( x2 ) 3, f ( x3 )1.5, f ( x4 ) 2.5
f ( x4 ' ) 2
7 f ( x3 ) 75 f ( x2 ) 2.5714
f ( x7 ' ) 4
7 f ( x4 ) 73 f ( x3 ) 2.0714
Image Interpolation
Open circle=original
Bilinear Interpolation
f ( x, y ' ) f ( x, y 1) (1 ) f ( x, y )
f ( x 1, y ' ) f ( x 1, y 1) (1 ) f ( x 1, y )
image = color.rgb2gray(data.camera())
head=image[140:190,255:325]
head4n=rescale(head,2,order=0)
headbilinear=rescale(head,2,order=1)
io.imshow(head4n)
NN
bilinear
General Interpolation
f ( x' ) R ( ) f ( x1 ) R (1 ) f ( x2 )
General Interpolation
Nearest neighbor Interpolation :
0 , if u 0.5
R0 1 , if 0.5 u 0.5
0 , if u 0.5
Linear Interpolation :
1 u , if u0
R1
1 u , if u0
Cubic Interpolation
1.5 | u |3 2.5 | u |2 1, if | u | 1
R3 (u )
0.5 | u |3 2.5 | u |2 4 | u | 2, if 1 | u | 2
f ( x' ) R3 (1 ) f ( x1 ) R3 ( ) f ( x2 ) R3 (1 ) f ( x3 ) R4 (2 ) f ( x4 )
Cubic Interpolation
Cubic Interpolation
headbicubic=rescale(head,4,order=3)
Scaling Smaller
• Scaling smaller is called image minimization.
minimization
• Subsampling : making image smaller by deleting
pixels (nearest neighbor approach)
• Subsampling does not give good result
• To solve the problem
– Apply a lowpass filter (averaging) before subsampling
– Apply data interpolation (e.g. bicubic)
smallerimage=rescale(image,0.25,order=0)
Rotation
x ' cos sin x
y ' sin cos y
x cos sin x '
y sin cos y '
Image Rotation
• Filled circles indicate the original position, and the open
circles point their positions after rotation.
• Must ensure that even after rotation, the points remain in a
grid.
Rotation
• The gray value at (x", y") can be found by interpolation,
using surrounding gray values.
• This value is then the gray value for the pixel at (x', y') in the
rotated image.
rotate Function
• Example:
from skimage import data, color, io
from skimage.transform import rescale ,rotate
image = color.rgb2gray(data.camera())
head4n=rotate(image,60,order=0)
io.imshow(head4n)
Rotation Examples
Ch6-p.139