Professional Documents
Culture Documents
SKM4213
CHAPTER 3
PRE-PROCESSING
2
Content:
• Region-of-Interest (Image Geometry)
• Crop, zoom, translation, rotation, shrinking
• Image Algebra
• Addition, subtraction, multiplication, division, Image masking,
AND, OR, NOT
• Image Quantization
• Gray level reduction
• Spatial quantization
3
CV SYSTEM MODEL
Image Analysis
4
INTRODUCTION
• Pre-processing:
• To make data reduction and image analysis
task easier.
REGION-OF-INTEREST
(ROI)
GEOMETRIC TRANSFORM (CROP, ZOOM, SHRINK,
TRANSLATE, ROTATE)
6
REGION-OF-INTEREST (ROI)
• To investigate more closely a specific area within an
image.
Crop
• Selecting a small portion of the image (a sub image),
and cutting it away from the rest of the image.
8
Zooming
• This photo is too small:
Zooming (cont.)
• Zooming requires 2 steps:
1. The creation of new pixel locations.
3. Bilinear Interpolation
4. Bicubic Interpolation
5. Polynomial Interpolation
10
Interpolation
• I(r,c) gives us the intensity values of an image at integer
locations.
Original Image Image with columns expanded Image with rows and columns
expanded
12
13
14
• Class Exercise:
4 8
8 2
16
Linear Interpolation
• Perform linear interpolation between adjacent pixels.
8 4 8 8 6 4 6 8 8 6 4 6 8
6 6 6 6 6
4 8 4 4 6 8 6 4
4 6 8 6 4
8 2 8 8 5 2 5 8 6 5.5 5 5.5 6
8 5 2 5 8
• Class Exercise:
Based on First-order Hold, generate the zoomed image for the following
image:
6 3 6
3 5 5
6 4 6
19
20
Convolution
• Previous interpolation methods could also be done
using convolution (filtering) with a convolution mask.
• Steps:
o Adding rows and columns of zeros between
existing rows and columns.
Convolution (cont.)
Note: Convolution masks for computer imaging applications are typically symmetric,
meaning if it is flipped about its center it will remain the same.
23
Convolution (cont.)
• Convolution process:
• Overlay the mask on the image, multiply the coincident values, and sum all
these results (equivalent to finding the vector inner product of the mask with
underlying sub image).
• The result is used to substitute the pixel value that coincide with the center of
the mask. Note that the output image must be put in a separate image array
called a buffer, so that the existing values are not overwritten during the
convolution process.
• Once the end of the row is reached, the convolution mask is moved down one
row and the process is repeated row by row for the entire image.
24
Convolution (cont.)
25
Convolution (cont.)
26
Convolution (cont.)
• Example: Convolution for first-order hold
• For example, if we put the mask over the upper-left corner of the image, we
obtain (from left to right, and top to bottom):
1/4(0) + 1/2(0) + 1/4(0) + 1/2(0) + 1(3) + 1/2(0) + 1/4(0) + 1/2(0) + 1/4(0) = 3
• The next step is to slide the mask over by on pixel and repeat the process, as
follows:
1/4(0) + 1/2(0) + 1/4(0) + 1/2(3) + 1(0) + 1/2(5) + 1/4(0) + 1/2(0) + 1/4(0) = 4
27
Convolution (cont.)
K-times Zooming
• Linear Interpolation only allows image enlargement by a
factor of (2N-1).
• Add the result to the smaller value, and keep adding the result from the
second step in a running total until all (K-1) intermediate pixel locations
are filled.
• Do for every pair of adjacent pixels, first along the rows and then along
the columns.
30
15 30 15
30 15 30
Original Image
15 20 25 30 25 20 15
20 21.67 23.34 25 23.34 21.67 20
25 23.34 21.67 20 21.67 23.34 25
30 25 20 15 20 25 30
Enlarged Image
31
[ ]
3 15 9
12 3 15
9 3 1 8
33
Translation
• Process of moving a ROI from one position to another.
Rotation
• Process of rotating a ROI for a number of degrees.
• θ is the angle of rotation of the image, defined in a clockwise direction from the
horizontal axis at the image origin in the upper left corner.
37
Translation + Rotation
Translation difficulty
• Created a leftover space. What to do with it?
Rotation difficulty
• Some part might be rotated off the screen (image plane).
40
Exercise
• Translate Image 1 by 10 columns to the right and 5 rows
up with the initial point (0,0) is on the left top corner.
What are the new coordinates for the point (r,c) =(10,10)?
IMAGE ALGEBRA
ARITHMETIC (+, -, *, /) & LOGIC (AND, OR, NOT)
44
IMAGE ALGEBRA
• There are two categories of algebraic operations that can
be applied to images.
• Arithmetic operations:
• Addition, subtraction, division and multiplication.
• Logic operations:
• AND, OR, NOT
Addition
• To combine information in two images.
+ =
46
Example : Addition (cont.)
+ =
47
48
Subtraction
• to detect motion. Background subtraction.
49
Multiplication
• Brighten the image.
Division
• Darken the image.
‘AND’, ‘OR’
• To perform a masking operation.
• Application:
• Special effects.
52
53
‘NOT’
• creates a negative of the original image.
• Inverting each bit within each pixel value.
Added by 128
Subtracted by 128
56
Multiplied by 2
Divided by 2
57
Example: Complement
60
QUANTIZATION
61
Image Quantization
• Process of reducing image data by removing some of the
detail information by mapping groups of data to a single
point.
2. Spatial reduction:
• Reduce number of pixels.
• Map a group of pixels into one pixels.
62
Gray-level reduction
1. The simplest method of gray-level reduction is
thresholding.
• Any pixel above the threshold is set to 1, and the rest to 0.
• This turns a gray-level image into binary image.
• 256 28, 32 25
0 255
0 7 15 23 31 …255
256 - 32 AND (low end) OR (high end) New pixel value
0-7 0 7 0
8 – 15 8 15 1
16 – 23 16 23 2
24 - 31 24 31 3
: : : :
248 - 255 248 255 31
Gray-level reduction (cont.)
Example (cont.)
• Let say, we want to quantize an 8-bit value (250) to 5-bit value (what is the
value of 250 in 5-bit?):
1. Change the decimal value to binary:
• 25010 111110102
8 16 24 32……
0 7 15 23 31 …255
69
71
72
Spatial reduction
• Quantization in spatial coordinates results in reducing the size
of the image.
Decimation
78
EXERCISE
2 4 6 8 5 8
4 5 7 3 7 9
3 4 5 6 7 8
4 2 1 7 3 5
6 7 2 5 4 3
7 5 3 7 6 6
Perform spatial reduction techniques of averaging and median to the following 6x6
image using 3x3 mask. From your observation, in term of image contrast, which one
give the best or both giving the same output?
80
Conclusion
• Region-of-Interest (Image Geometry)
• Crop, zoom, translation, rotation, shrinking
• Image Algebra
• Addition, subtraction, multiplication, division, Image masking, AND,
OR, NOT
• Image Quantization
• Gray level reduction
• Thresholding
• Reducing the number of bits per pixel
• Uniform quantization bins
• Variable quantization bins
• Spatial quantization
• Averaging
• Median
• Decimation