CS4442_CS9542_Part 2_Lecture 1_Intro_Filtering
CS4442_CS9542_Part 2_Lecture 1_Intro_Filtering
Part 2: Lecture 1
Yalda Mohsenzadeh
Outline of CS4442/9542 (Part II)
• Instructor of Part II: Dr. Yalda Mohsenzadeh, will take over the
class on Feb 26th
• Email: [email protected]
10
Goldstein and Brockmole, 2016
Low level processing
• Low level operations
• Filtering, edge detection
Mid level processing
• Mid level operations
• Shape formation, 3D shape reconstruction, …
High level processing
• High level operations
• Recognition of objects, people, places, events
Perception versus measurement
Edward Adelson
Perception versus measurement
Image
• 2-D array of numbers (intensity values, gray levels)
• gray level 0 (black) to 255 (white)
• Color images are 3 2-D arrays of numbers
• Red
• Green
• Blue
• Resolution (number of rows and columns)
• 128 x 128
• 256 x 256
• 640 x 480
Images as functions
• We can think of an image as a
function, f, from R2 to R:
• f(x, y) gives the intensity at position
(x,y)
• f(x,y) is proportional to the brightness
at (x,y)
• Realistically, we expect the image only
to be defined over a rectangle, with a
finite range:
• f: [a,b] x[c,d] -> [0, 255]
• Standard range for gray scale images is
(0, 1, 2, …, 255)
• A color image is just three functions
pasted together. We can write this as
vector-valued function
𝑟(𝑥, 𝑦)
𝑓 𝑥, 𝑦 = 𝑔(𝑥, 𝑦)
𝑏(𝑥, 𝑦)
A digital image
• In computer vision we usually operate on digital
(discrete) images:
• Sample the 2D space on a regular grid
• Quantize each sample (round to nearest integer)
• If our samples are Δ apart, we can write this as:
𝑓 𝑖, 𝑗 = 𝑄𝑢𝑎𝑛𝑡𝑖𝑧𝑒{𝑓 𝑖Δ, 𝑗Δ }
• The image can now be represented as a matrix of
integer values
12 15 120 128 128 128 130
240 120 18 120 121 128 128
252 248 22 13 112 133 133
255 243 230 11 20 128 125
24 32 251 255 26 127 123
10 15 252 253 18 120 128
8 14 18 176 154 128 127
129 110 120 127 128 128 130
Image processing
• Image processing operation: defining a new image
g in terms of an existing image f
• We can transform either the domain or the range
of f.
• Range transformation:
• 𝑔 𝑥, 𝑦 = 𝑡 (𝑓 𝑥, 𝑦 )
Image processing
• Digital negative
• 𝑔 𝑥, 𝑦 = 255 − 𝑓(𝑥, 𝑦)
Image processing
• Improving the contrast in the picture
Image processing
• Some operations preserve the range but change
the domain of f:
• 𝑔 𝑥, 𝑦 = 𝑓(𝑡𝑥 𝑥, 𝑦 , 𝑡𝑦 𝑥, 𝑦 )
Common Geometric Transformation
Image Processing
• Still other operations operate on both domain and
the range of f
Image Processing: Filtering
• Modifies pixels based on neighborhood
𝑓 𝑔
r r
z p q z p q
v v
• Useful to:
• Noise reduction, integrate information over constant
regions, scale change, detect changes
Filtering Application: Noise Reduction
• Common types of noise:
• Salt and pepper noise: contains
random occurrences of black
and white pixels
• Impulse noise: contains random
occurrences of white pixels
• Gaussian noise: variations in
intensity drawn from a Gaussian
normal distribution
1 3 2 1
2 9 1 1 1 0 -1 -1 10
* 1 0 -1 =
1 3 2 3 4 12
1 0 -1
5 6 1 2 ℎ 𝑓
g 𝑖, 𝑗 = ℎ ∗ 𝑓 = ∑𝑢,𝑣 ℎ 𝑢, 𝑣 𝑓(𝑖 − 𝑢, 𝑗 − 𝑣)
31
Mean Kernel (also called box filter)
• Kernel for a 3x3 mean filter:
f[𝑥, 𝑦]
ℎ[𝑢, 𝑣]
1
9
Gaussian Filtering
• A Gaussian kernel gives less weights to pixels
further from the center of the window
ℎ[𝑢, 𝑣]
1
16
1 (𝑥 2 + 𝑦 2 )
𝐺𝜎 𝑥,𝑦 = exp −
𝜎 2𝜋 2𝜎 2
• Constant factor at front makes volume sum to 1 (we
should normalize weights to sum to 1 in any case)
• What happens if you increase 𝜎?
Gaussian Filtering
?
Median Filter
• Median of {1, 2, 25, 3, 24, 22, 20, 21, 23}
={1, 2, 3, 20, 21, 22, 23, 24, 25} =21
1 2 25 x x x
3 24 22 x 21 x
20 21 23 x x x