3. 3.1 Review
Geometric transformation vs Intensity transformation
Spatial domain
The value at the
corresponding position
of the image does not
change, but the pixel
position changes
The pixel position in
the image does not
change, but the value
changes
5. 3.2 The key points and difficulties of this class
๏ Be familiar with the principal techniques used for intensity transformations
๏ Learn basic log transformations and power-law transformations
๏ Understand the realization process of the two transformations
15. Discussion
What are the advantages and disadvantages
of these transformations?
Trial and error
A certain basis
intensity distribution
peaks and valleys
Discuss the pros and cons of these methods:
๏ผ Reasonable or not
๏ผ Automatic degree
๏ผ Robustness
16. 3.3 Intensity Transformation
Trial and error
A certain basis
intensity distribution
๏ตDiscussion
๏ You may ask, to achieve this result, I can directly use PS, what is the meaning of
learning these transformations?
๏ผ We know how to use PS to achieve effects more
quickly and accurately without a lot of trying
๏ผ We can perform different transformations in
different regions
๏ผ We can perform different transformations on
different grayscale ranges
20. 3.2 Histogram Processing
๏ตImage gray histogram
๏ผ No spatial information involved
๏ผ The same histogram distribution may
correspond to different images
๏ผ Information additivity
๏ผ Related to the amount of information
21. ๏ตDescribe image with gray histogram
The grayscale of the image is concentrated
in the brighter area, and a considerable part
of them are concentrated in the part close to
1, resulting in overexposure of the image
The pixel distribution in the image
is โpolarizedโ, resulting in the loss
of image details
The distribution of image histogram is related to the quality of image to some extent
3.4 Histogram equalization
22. A โclearโ image
The histogram reflects the clarity of the image, when it is evenly distributed, the image is โclearerโ
Histogram
equalization
each gray level should have a
certain number of gray values
Different objects should have
distinguishable grayscale variations
3.4 Histogram equalization
24. original image target image
For a random
distribution transform
to uniform distribution
original histogram
target histogram
L r s
S=T(r)
๐๐(๐๐๐๐) โ ๐๐(๐๐๐๐) ๐๐(๐ ๐ ๐๐) = ๐๐(๐ ๐ ๐๐)
๐๐ ๐๐ ๐๐๐๐ < ๐ ๐ < ๐๐ ๐๐๐๐ =
โซ๐๐๐๐
๐๐๐๐
๐๐ ๐๐ ๐๐๐๐ =
1
๐ฟ๐ฟโ1
ร (๐๐ ๐๐๐๐ โ ๐๐ ๐๐๐๐ )
๐๐๐๐ ๐๐๐๐ > ๐๐๐๐, ๐ ๐ ๐๐> ๐ ๐ ๐๐
a b
๐๐(๐๐ โค ๐ ๐ โค ๐๐)
๐ ๐ = ๐๐ ๐๐ = (๐ฟ๐ฟ โ 1) ๏ฟฝ
0
๐๐
๐๐(๐๐) ๐๐๐๐
3.4 Histogram equalization
25. k refers to the different gray values in the original image
P(k) corresponds to the frequency of the value in all pixels of the original image
Histogram
๏ผ normalized ๏ผ
Unique Pixel of
๐๐(๐๐,๐๐)
๐๐๐๐ ๐๐๐๐ โฆ ๐๐๐๐ โฆ ๐๐๐๐
frequency of
๐๐(๐๐,๐๐)
๐๐๐๐ ๐๐๐๐ โฆ ๐๐๐๐ โฆ ๐๐๐๐
Pixel of
๐๐(๐๐, ๐๐)/(๐ณ๐ณ โ ๐๐)
๐๐๐๐ ๐๐๐๐+๐๐๐๐ โฆ +โฆ+๐๐๐๐ โฆ +โฆ+๐๐๐๐
Discrete situation: Gray value quantification The quantization value closest to its
value is taken as the final gray value
๐ ๐ = ๐๐ ๐๐ = (๐ฟ๐ฟ โ 1) ๏ฟฝ
0
๐๐
๐๐(๐๐) ๐๐๐๐
3.4 Histogram equalization
36. 1. After histogram equalization, how does the gray level of
the new imagechange?
2. What are the advantages and disadvantages of gray
histogram equalization? (Human intervention required;
reversible; Is it valid in all cases?)
๏ผ Purpose of Histogram Equalization
๏ผ Principle of Histogram Equalization
๏ผ Specific operation of histogram equalization
3.4 Histogram equalization
Summary and Discussion
39. 3.5 Histogram Processing
Linear stretch Histogram equalization
Transformation
function
Comparisonof
image
enhancement
๏ Simple transformation
๏ Can be transformed
back to the original
image
๏ Need to manually set
parameters
๏ Poor generality
๏ Less information loss
๏ Automated, no
parameters required
๏ Unable to restore
๏ Poor generality
42. Some improvement methods
3.5 Histogram Processing
LOCAL HISTOGRAM PROCESSING
Some differences and consistency in the
local area need to be preserved, but they
are often destroyed because the global
calculated value is obviously different from
the local calculated value.
p.150-153
44. ๏ตHistogram matching (specification)
3.5 Histogram Processing
When doing change
detection on two
geometrically
aligned images
|๐ฐ๐ฐ๐๐ โ ๐ฐ๐ฐ๐๐|
45. Histogram equalization where we take any histogram, any pixel distribution, and
we match it to something which is as uniform as possible.
3.5 Histogram Processing
๐๐(๐๐,๐๐)
Input
image
๐๐(๐๐, ๐๐)
Target
image
๐ ๐ = ๐๐ ๐๐ = ๏ฟฝ
0
๐๐
๐๐๐๐(๐ข๐ข) ๐๐๐๐
๐ ๐ = ๐๐ z = ๏ฟฝ
0
๐๐
๐๐๐ง๐ง(๐ฃ๐ฃ) ๐๐๐๐
Histogram matching (specification)
46. 3.5 Histogram Processing
๏ตHistogram matching (specification)
Just by doing the histogram equalizations, we can match any two desired distributions
Step1: Compute the histogram of the input image r, and do histogram equalization to
get the histogram-equalized image s1.
Step2: Compute the histogram of the target image z, and do histogram equalization
to get the histogram-equalized image s2.
Step3: For every value of s1, use the stored values of s2 from Step 2 to find the
corresponding value closest to s1 . Store these mappings from s1 to z
Step4: For every value of the image r, let the {๐๐๐๐} to be {๐ง๐ง๐๐
โฒ
} ,by using the mappings
found in Step 3 to get the histogram-specified image.
47. The expressions of spatial domain processing
neighborhoodis of size 1 ร 1
The function T can be linear or non-linear,
new gray value can be obtained by transforming
the original pixel value, or it can be obtained by
transforming the neighborhoodpixels.
48. 3.6 Fundamentals of Spatial Filtering
If a pixel value in an
image is lost (or affected
by noise), can we use the
information in other
place to estimate its
value?
It can be approximately equal to the
average of all values of the entire image
It can be approximately given by the
average of several nearby pixel values
The value of each pixel changes by
globally
or
locally Related to its location
49. Spatial filtering modifies an image by
replacing the value of each pixel by a
function of the values of the pixel and its
neighbors.
linear spatial filter
nonlinear spatial filter
๐๐ = ๐๐๐๐ + ๐๐
3.6 Fundamentals of Spatial Filtering
50. ๏ตThe mechanics of linear spatial
filtering
A linear spatial filter performs a sum-of-
products operation between an image f
and a filter kernel w
kernel :
an array ;
size defines the neighborhood of operation;
coefficients determine the nature of the filter;
also can be called mask, template, window
ไธ็ง็นๅพๆๅๅจ
3.6 Fundamentals of Spatial Filtering
51. ๏ตThe mechanics of linear spatial filtering
The size of the kernel is odd, because we
must ensure that the current point we are
dealing with is in the exact center
m=2a+1; n=2b+1
3.6 Fundamentals of Spatial Filtering
52. 3.6 Fundamentals of Spatial Filtering
๏ตThe mechanics of linear spatial filtering
with box kernels
of sizes 3 ร 3,
11 ร 11,
and 21 ร 21
the larger the neighborhood, the
more pixels we are averaging
53. 3.6 Fundamentals of Spatial Filtering
๏ตSpatial correlation and convolution
Correlationconsists of moving the
center of a kernel over an image, and
computing the sum of products at each
location.
VS
spatial convolution are the same,
except that the correlation kernel is
rotated by 180ยฐ
when the values of a kernel are symmetricaboutits center, correlationand convolutionyield sameresult
54. 3.6 Fundamentals of Spatial Filtering
We can define correlation and convolution
so that every element of w(instead of just
its center) visits every pixel in f. This
requires that the starting configuration be
such that the right, lower corner of the kernel
coincides with the origin of the image.
the size of the resulting full correlation or
convolution array will be of size๏ผby padding๏ผ
Sv รS h ๏ผ
55. 3.6 Fundamentals of Spatial Filtering
๏ตSpatial correlation and convolution
โconvolving a kernel with an imageโ often is used to denote the sliding, sum-of-products process
Sometimes an image is filtered (i.e., convolved) sequentially, multistage filtering can be done in a
single filtering operation,
These convolution kernels can be combined and of course can be separated
57. 3.7 Smoothing (Lowpass) Spatial Filters
๏ตAverage kernel
Becauserandomnoisetypicallyconsistsof sharp transitionsin intensity, an obviousapplicationof
smoothingis noisereduction.
The differencebetween each pixeland its surroundingpixels will be smaller than theoriginalones,
so smoothingfiltercan be used to smooththe imageand remove somefalsecontours.
BOX FILTER KERNELS
Smoothing is used to reduce irrelevantdetailin an image
The kernel should be normalized
with box kernels
of sizes 3 ร 3,
11 ร 11,
and 21 ร 21
59. 3.7 Smoothing (Lowpass) Spatial Filters
๏ตAverage kernel
LOWPASS GAUSSIAN FILTER KERNELS
circularlysymmetric(also
called isotropic)kernel
Distances from
the center for
various sizes of
square kernels.
ๅๅฝขๅฏน็งฐ๏ผไน็งฐไธบๅๅๅๆง๏ผๆ ธ
60. 3.7 Smoothing (Lowpass) Spatial Filters
๏ตAverage kernel
LOWPASS GAUSSIAN FILTER KERNELS
K = 1
๐๐ = 1
ๅฆๆๆๆๅ ๆ ธ้ฝๆฏ้ซๆฏ๏ผๆไปฌๅฏไปฅ
ๅจ่กจไธญไฝฟ็จ็ปๆๆฅ่ฎก็ฎๅคๅๅ ๆ ธ็
ๆ ๅๅๅทฎ๏ผๅนถๅฎไนๅฎ๏ผ๏ผ่ๆ ้ๅฎ
้ ๆง่กๆๆๅ ๆ ธ็ๅท็งฏใ
If all kernels are Gaussian, we can use the
composite kernel (and define it), without actually
performing the convolution of all kernels.
61. 3.7 Smoothing (Lowpass) Spatial Filters
๏ตAverage kernel
kernel of size 21 ร 21,
standard deviations 3.5
kernel of size 43 ร 43,
standard deviations 3.5
box kernels
of sizes 11 ร 11,
21 ร 21
Comparison
62. 3.7 Smoothing (Lowpass) Spatial Filters
๏ตAverage kernel Comparison
with a box kernel of size 71 ร 71
Gaussian kernel of size 151
ร 151, with K = 1 and ๐๐= 25
โข box filter producedlinearsmoothing, with the transitionfrom blackto whitehavingthe shapeof a ramp
โข the Gaussianfilter yieldedsignificantlysmoother results aroundthe edge transitions
63. 3.7 Smoothing (Lowpass) Spatial Filters
Applications
Using lowpass filtering and thresholding for region extraction
2566 ร 2758 Hubble Telescope
image
Result of lowpass filtering
with a Gaussian kernel
size 151 ร 151, ๐๐ = 25
Result of thresholding the filtered
image
๏ตAverage kernel
64. 3.7 Smoothing (Lowpass) Spatial Filters
Applications
Shading correction using lowpass filtering
Lowpass filtering is a rugged, simple
method for estimating shading patterns
512 ร 512 Gaussian kernel (four
times the size of squares), K = 1, and
๐๐= 128 (equal to the size of squares)
๏ตAverage kernel
65. 3.7 Smoothing (Lowpass) Spatial Filters
๏ตOrder-statistic (nonlinear) filters
๏ฌ response is based on ordering (ranking) the pixels contained in the region
encompassed by the filter
๏ฌ Smoothing is achieved by replacing the value of the center pixel with the value
determined by the ranking result.
๏ฌ median filter: replaces the value of the center pixel by the median of the intensity
values in the neighborhood of that pixel
FORCE POINTS TO BE MORE LIKE THEIR NEIGHBORS
median filter
66. 3.7 Smoothing (Lowpass) Spatial Filters
๏ตOrder-statistic (nonlinear) filters median filter
image corrupted by salt-
and-pepper noise
result using 19 ร 19
Gaussian lowpass filter
kernel with ๐๐= 3
result using 7 ร 7
median filter
67. 3.8 Sharpening (Highpass) Spatial Filters
๏ตDistribution of grayscale changes in the image
Scan line
The gray distribution of the image
in the direction of the scan line
First derivative
Second derivative
69. 3.8 Sharpening (Highpass) Spatial Filters
The gradientof an image f at coordinates(x, y) is defined as the two dimensional column vector
๏ตImage gradient
The magnitude (length) of vector f , denotedas M(x, y)
First derivative
70. 3.8 Sharpening (Highpass) Spatial Filters
๏ตImage gradient๏ผ derivative operation --> differential operation
For discrete images, differentiation can be approximated by difference
||๐ป๐ป๐๐|| = (๐๐ ๐ฅ๐ฅ,๐ฆ๐ฆ โ ๐๐ ๐ฅ๐ฅ + 1, ๐ฆ๐ฆ )2+(๐๐ ๐ฅ๐ฅ, ๐ฆ๐ฆ โ ๐๐ ๐ฅ๐ฅ, ๐ฆ๐ฆ + 1 )2
computationally to approximate the squares and square root operations by absolute values
๐ป๐ป๐๐ โ ๐๐ ๐ฅ๐ฅ, ๐ฆ๐ฆ โ ๐๐ ๐ฅ๐ฅ + 1,๐ฆ๐ฆ + |๐๐ ๐ฅ๐ฅ, ๐ฆ๐ฆ โ ๐๐ ๐ฅ๐ฅ, ๐ฆ๐ฆ + 1 |
The magnitude of the gradient is approximated as the (absolute) sum
of the adjacent pixel differencesalong the horizontal and vertical axes
71. 3.8 Sharpening (Highpass) Spatial Filters
โ The pixel value of the new image is directly replaced by the gradient of the original image
โก The output image is according to the gradient threshold
๏ตImage Sharpening ๅพๅ้ๅ
72. 3.8 Sharpening (Highpass) Spatial Filters
๏ตImage Sharpening using gradient
The edges of the image are enhanced, and some noise is also amplified
73. Robert Operator
3.8 Sharpening (Highpass) Spatial Filters
The differential sum of the two
directions after rotating ยฑ45ยฐ
The area involved in the calculation is too
small, and the obtained edge is weak
๏ตImage Sharpening using gradient
74. 3.8 Sharpening (Highpass) Spatial Filters
๏ตImage Sharpening using gradient 3*3 kernel
image
x
y
Maintaining directional consistency in the calculation, 3*3 can be viewed as a
superposition of multiple 2*2 regions with respect to the current pixel position.
82. 3.8 Sharpening (Highpass) Spatial Filters
๏ตsecond-order derivative of f (x)
Flexible extensions of the Laplace operator
1 -2 1
-2 4 -2
1 -2 1
Background features can be โrecoveredโ while still preserving the sharpening effect of the
Laplacian by adding the Laplacian image to the original.
Let c = โ1
91. 3.8 Combining Spatial Enhancement Methods
a nuclear
whole body
bone scan
image
Objective: show more of the skeletal detail
method: enhance the edges
Laplacian of image Sharpened image
92. 3.8 Combining Spatial Enhancement Methods
Objective: show more of the skeletal detail
method: enhance the edges and suppress noise
Sobel gradient of image Sobel image smoothed with a 5 ร 5 box filter
Mask image formed by
the product of (b) and (e).
93. 3.8 Combining Spatial Enhancement Methods
Objective: show more of the skeletal detail method: enhance the edges and suppress noise
Sharpened image obtained
by the adding images (a) and (f).
95. Homework Deadline๏ผ before 9 April
1. Consider that the maximum value of an image ๐ฐ๐ฐ๐๐is M and its minimum is m
(mโ M). An intensity transform that maps the image ๐ฐ๐ฐ๐๐ onto ๐ฐ๐ฐ๐๐ such that the
maximal value of ๐ฐ๐ฐ๐๐ is L and the minimal value is๏ผ
2. Why global discrete histogram equalization does not, in general, yield a flat
(uniform) histogram?
A Because images are in color.
B Becausethe histogramequalizationmathematicalderivationdoesnโtexist for discretesignals.
C In global histogramequalization, all pixels with the same value are mapped to same value.
D Actually, global discretehistogramequalizationalways yields flat histograms by definition.
96. Homework
3. Discrete histogram equalization is an invertible operation, meaning we can
recover the original image from the equalized one by inverting the operation,
since?
A Actually, histogram equalization is in general non-invertible.
B There is a unique histogram equalization formula per image.
C Pixels with different values are mapped to pixels with different values.
D Images have unique histograms.
4. Given an image with only 3 pixels and 4 possible values for each one. Determine
the number of possible different images and the number of possible different
histograms. How many images and histograms?
97. Homework
5. This image is a 6*6 grayscale image I(x, y) , with 4 gray levels
(x = 0, 1, 2, ... 5; y = 0, 1, 2, ..., 5) , the value of each point in the
figure represents the gray value of the image pixels.
1) Calculate the histogram of the image
2) Using histogram equalization to process this image (write the
process details )
3) Write the new histogram after histogram equalization.
98. Homework
6. Which integer number minimizes
7. Which integer number minimizes
8. Applying a 3ร3 averaging filter to an image a large (infinity) number of times is:
A Equivalent to replacing all the pixel values by 0..
B Equivalent to replacing all the pixel values by the average of the values in the
original image.
C The same as applying it a single time.
D The same as applying a median filter.
99. 9. In the original image used to generate the three blurred images shown, the vertical
bars are 5 pixels wide, 100 pixels high, and their separation is 20 pixels. The image was
blurred using square box kernels of sizes 23, 25, and 45 elements on the side,
respectively. The vertical bars on the left, lower part of (a) and (c) are blurred, but a
clear separation exists between them. However, the bars have merged in image (b),
despite the fact that the kernel used to generate this image is much smaller than the
kernel that produced image (c). Explain the reason for this.
Homework