CSSE463: Image Recognition Day 5 Lab 2 due Wednesday, 1:30. Lab 2 due Wednesday, 1:30. Tip: by Tues...
-
Upload
phoebe-primrose-mcbride -
Category
Documents
-
view
216 -
download
2
Transcript of CSSE463: Image Recognition Day 5 Lab 2 due Wednesday, 1:30. Lab 2 due Wednesday, 1:30. Tip: by Tues...
CSSE463: Image Recognition CSSE463: Image Recognition Day 5Day 5
Lab 2 due Wednesday, 1:30.Lab 2 due Wednesday, 1:30. Tip: by Tues 1:30 Tip: by Tues 1:30 + 1 late day to use on: + 1 late day to use on:
Fruit Finder Fruit Finder due Friday, 11:59 pm.due Friday, 11:59 pm. Ask questions as they arise, about technique or about MATLABAsk questions as they arise, about technique or about MATLAB
Today: Global vs local operations, filtering Today: Global vs local operations, filtering
Questions?Questions?
Global vs. local operatorsGlobal vs. local operators
Given a pixel, p, it can be transformed to Given a pixel, p, it can be transformed to p’ using:p’ using:Global operatorsGlobal operators
Use information from the entire imageUse information from the entire imagep’ = f(p, p p’ = f(p, p img) img)
Local operatorsLocal operatorsTransform each pixel based on its value or its Transform each pixel based on its value or its
neighborhoods’ values only (pneighborhoods’ values only (pNN includes p) includes p)
p’ = f(p, p p’ = f(p, p p pNN))
Q1
Enhancement: gray-level mappingEnhancement: gray-level mapping Maps each pixel value to Maps each pixel value to
another valueanother value Could use a lookup table, Could use a lookup table,
e.g., [(0,0), (1, 3), (2, 5), …]e.g., [(0,0), (1, 3), (2, 5), …] Could use a functionCould use a function
Identity mapping, y=x is Identity mapping, y=x is straight linestraight line
Function values above y=x Function values above y=x are boosted, those below are boosted, those below are suppressed.are suppressed.
Gamma function, y = Gamma function, y = x^(1/g) (assuming x in x^(1/g) (assuming x in range [0,1]) is a common range [0,1]) is a common a control in monitors/TVs.a control in monitors/TVs.
g=2 shown to leftg=2 shown to left Effect?Effect?
Q2
Gamma mappings, y = x^(1/g)Gamma mappings, y = x^(1/g)Original Dark (g = 0.5)
Light (g = 2) Very light (g = 4)
Histogram EqualizationHistogram Equalization
Creates a mapping that flattens the histogram.Creates a mapping that flattens the histogram. Uses full range [0, 255] Uses full range [0, 255]
Good: “automatically” enhances contrast where needed.Good: “automatically” enhances contrast where needed. Approx same level of pixels of each gray level Approx same level of pixels of each gray level
Unpredictable results.Unpredictable results. Maintains the histogram’s shape, but changes the Maintains the histogram’s shape, but changes the
density of the histogramdensity of the histogram
Good example of a Good example of a global global operationoperation Next: pros and consNext: pros and cons
But where’s the color?But where’s the color?
Can we use gray-level mapping on color Can we use gray-level mapping on color images?images?
Discuss howDiscuss how
Q3
Local operatorsLocal operators
The most common local operators are The most common local operators are filtersfilters..Today: for smoothingToday: for smoothingTomorrow: for edge detectionTomorrow: for edge detection
Image smoothingImage smoothing Gaussian distributions are often used to model Gaussian distributions are often used to model
noise in the imagenoise in the image g = gg = grr + N(0, + N(0, ))
g = sensed gray valueg = sensed gray value ggrr = real grayvalue = real grayvalue N(0, N(0, ) is a Gaussian (aka, ) is a Gaussian (aka, NNormal, or bell curve) with ormal, or bell curve) with
mean = 0, std. dev = mean = 0, std. dev = .. Lots of Gaussian distributions in this course…Lots of Gaussian distributions in this course…
Answer: average it out! 3 methodsAnswer: average it out! 3 methods Box filterBox filter Gaussian filterGaussian filter Median filterMedian filter
Box filtersBox filters
2
2
2
2
),(25
1),(
i j
jcirIcrJ
Simplest.Simplest. Improves homogeneous Improves homogeneous
regions. regions. Unweighted average of Unweighted average of
the pixels in a small the pixels in a small neighborhood. neighborhood.
For 5x5 neighborhood,For 5x5 neighborhood,
See why this is a “local operation?”I = orig image, J=filtered image
Gaussian filtersGaussian filters
Then use weight in box Then use weight in box filter formulafilter formula
In practice, we use a In practice, we use a discrete approximation to discrete approximation to W(i,j)W(i,j)
Nicest theoretical Nicest theoretical properties. properties.
Average weighted by Average weighted by distance from center distance from center pixel. Weight of pixel (i,j):pixel. Weight of pixel (i,j):
2
2
2
2
1),(
d
ejiW
Median filtersMedian filters Step edge demoStep edge demo
smoothGaussDemosmoothGaussDemo Salt demoSalt demo
smoothSaltDemosmoothSaltDemo
Averaging filters have two Averaging filters have two problems.problems. They blur edges.They blur edges. They don’t do well with “salt-They don’t do well with “salt-
and-pepper” noise:and-pepper” noise: Faulty CCD elementsFaulty CCD elements Dust on lensDust on lens
Median filter: Replace each Median filter: Replace each pixel with the median of the pixel with the median of the pixels in its neighborhoodpixels in its neighborhood More expensiveMore expensive Harder to do with hardwareHarder to do with hardware
But can be made somewhat But can be made somewhat efficientefficient (Sonka, p 129)(Sonka, p 129)
Hybrid: sigma filteringHybrid: sigma filtering
Q4,5
Discrete filtersDiscrete filters Discrete 3x3 box filter:Discrete 3x3 box filter: To get the output at a To get the output at a
single point, take cross-single point, take cross-correlation (basically a correlation (basically a dot-product) of filter and dot-product) of filter and image at that pointimage at that point
To filter the whole image, To filter the whole image, shift the filter over each shift the filter over each pixel in the original imagepixel in the original image
9/19/19/1
9/19/19/1
9/19/19/1