Image Intensity Transformation and Image Enhancement
AJIT RAJWADE
CS 663
Intensity transformations
2
Image Enhancement
3
Popular image transformations
4
Image Negatives
5
6
Logarithmic transformation
7
8
Logarithmic transformations
9
10
When we do Fourier transforms later in class, we will make heavy use of log(r+1) type transformations.
Note: the 1 in log(r+1) is used for stabilization since log 0 is undefined. In some applications, if there are intensity values which are very tiny which need to be preserved, the 1 should be replaced by some ε value which is several times smaller than the smallest non-zero value.
Power-Law (Gamma) Transformation
11
12
Note: The curves have been scaled to the range [0,L-1] after applying the gamma transformation. This has the effect of enhancing brighter intensities when gamma is more than 1.
Power-Law (Gamma) Transformation
13
14
Power-Law (Gamma) Transformation
15
16
17
Contrast Stretching
18
19
Ignore the yellowed out images
Bit-plane slicing
20
21
Bit slicing
22
k-th bit-plane image
23
Parameter selection in image enhancement
24
Parameter selection in image enchancement
25
Histogram equalization
26
Low contrast image: histogram is narrow
High contrast image: histogram is more spread out!
Image has higher dynamic range – details more clearly visible
http://en.wikipedia.org/wiki/Histogram_equalization
Histogram equalization
27
28
Histogram equalization
29
Segway: Probability refresher
30
Histogram equalization
31
Histogram equalization
32
Cumulative distribution function (cdf) of R. It satisfies the monotonicity as well as range-based criteria mentioned earlier.
Called “transformation of random variables” (eg: https://www.math.arizona.edu/~jwatkins/f-transform.pdf )
This formula requires T(r) to be one-one and hence monotonically increasing (or decreasing)
Histogram equalization
33
34
Histogram equalization
35
36
Histogram equalization
37
38
Histogram equalization
39
Histogram specification (also called matching)
41
Histogram specification
42
Histogram specification
43
Proof
44
Chain rule
Recall that G-1(T(r)) = z from the previous slide. Also G’(z) = (L-1)pZ(z)
Histogram specification
45
46
Equalization
Histogram specification versus equalization
47
Histogram specification versus equalization
48
Example
50
Discrete Representation
51
The inverse of G is computed via a lookup table. In practice, one evaluates G at all integer values from 0 to L-1. We use the stored values of G to find the integer zq such that G(zq) is closest to sk for each sk value.
52
Trial and error
53
Local Histogram Equalization
54
Local (also called Adaptive) Histogram Equalization
55
56
Adaptive means same as local
https://towardsdatascience.com/histogram-equalization-5d1013626e64
57
Original Image
Global histogram-equalized image (see next slide for the results with local HE)
58
Local histogram-equalized image (size 100 x 100)
Local histogram-equalized image (size 50 x 50)
Ignore the fact that these are color images because color image HE is slightly different and we will study it later. Concentrate on the advantages of local over global.
Spatial Filters
Local Spatial Filters
60
Input image
Output image
Weights
Local Spatial Filters
61
Local Spatial Filters
62
Image
Filter mask
63
Correlation and convolution
64
Correlation and convolution
65
66
For a filter of size m (in 1D), pad with m-1 zeros on either side
Correlation and convolution
67
68
Correlation and convolution
69
Correlation (denoted by an empty asterisk in the book)
Convolution (denoted by a solid black asterisk in the book)
Notes:
Correlation and convolution
70
After zero-padding w and f so that they have infinite extent. Note this doesn’t change the summation value.
Correlation and convolution
71
Genesis of convolution
72
Genesis of convolution
73
Genesis of convolution
74
Genesis of convolution: Proof
75
Note: This specific example talks about 1D systems, but the same theory is applicable for 2D signals (where the shifts will be in 2D) or any higher dimension.
Genesis of correlation
76
77
Search for the template (Messi’s face) inside the larger image in the middle.
First row: On the left you have the cross-correlation map
Second row: On the left you have the normalized cross-correlation map
Why is the latter superior to the former? Notice the false match in the top row and the correct match in the second one.
Types of image noise
78
Symbol for Gaussian distribution with mean 0, standard deviation σ
Formula for Gaussian distribution with mean μ, standard deviation σ
Types of image noise
79
Low σ, Gaussian
High σ, Gaussian
Impulse
Mean filter
80
Mean filter
81
82
Filtered image
Original image
Noisy image
-Amount of smoothing is directly proportional to the width of the filter window.
-Repeated application of a mean filter will lead to a constant intensity image in the limit of infinite iterations
83
Weighted mean filter
84
Decay parameter
Gaussian weights
Called the 2D Gaussian function
Weighted mean filter
85
Weighted mean filter
86
Median Filter
87
Median versus mean: try out
88
Median Filter
89
Original
With salt and pepper noise
5 x 5 Mean filter
5 x 5 Median filter
Much better feature preservation with median filter
Comparing mean and median filter
90
High σ, Gaussian
3 x 3 Median
3 x 3 Mean
http://homepages.inf.ed.ac.uk/rbf/HIPR2/median.htm
91
Works quite well even with strong impulses, provided most neighborhoods have no more than 50 percent of the pixels corrupted.
92
Median filter outputs – given filters of size 3 x 3 and 5 x 5
Original and noisy (impulse corrupted) images
Linear and non-linear filters
93
Sharpening filter
94
95
sharpening
Sharpening filters
96
Digital Derivative Operators (1D)
97
1st derivative: Zero in constant areas, non-zero at the onset of an intensity ramp or intensity step, non-zero along a ramp
2nd derivative: Zero in constant areas, zero along intensity ramps of constant slope, non-zero at the onset and end of an intensity ramp or step
Assume 1-D image for now, i.e. our image is f(x) instead of f(x,y)
98
From book by Gonzalez and Woods
Intensity discontinuity, also called step edge
From book by Gonzalez and Woods
Digital derivatives: first versus second
100
Laplacian of an image
101
Laplacian of an image
102
Laplacian of an image
103
Laplacian operators: second operator is obtained by adding second derivatives along both the diagonals, to the first operator
Rotationally symmetric operator (in the continuous domain)
Laplacian of an image
104
Laplacian for image sharpening
105
Laplacian for image sharpening
106
107
From book by Gonzalez and Woods
Intensity discontinuity, also called step edge
sharpened edge: 6-(-1) = 7 at the beginning and 1-1=0 at the end.
Laplacian for image sharpening
108
109
From Book by Gonzalez and woods
Sharpening filter: convolution mask
110
111
Unsharp masking
112
113
From Book by Gonzalez and woods
114
Derivative filters: dealing with noise
115
116
117
Grayscale image
Gradient map (after applying Sobel filter)
X-Sobel filter output
Y-Sobel filter output
Sobel filters: outer products
118
Other examples of separable filters
119
Laplacian of Gaussians
120
Laplacian of Gaussians
121
122
Discrete approximation with σ=1
123
https://homepages.inf.ed.ac.uk/rbf/HIPR2/log.htm
LoG filter of size 7 x 7 with σ=1
Bilateral Filters
Bilateral filter versus mean/median filter
125
126
Gaussian blur
The median filter will assign the median of the values in the red neighborhood to the corner pixel – and will convert the otherwise black pixel to a yellow one (as most of the pixels in the neighborhood are yellow). Thus the median filter does not always preserve edges well!
Bilateral Filter
127
Intensity-based weights
Space-based weights
Effect of parameter σs:
Effect of parameter σr:
130
Bilateral filter implementation
131
Cross-bilateral filter
132
133
134
Staircase effect of the bilateral filter
135
Staircase effect of the bilateral filter
136
Staircase effect of the bilateral filter
138
Bokeh Filters
Bokeh filters
140
142
Bokeh
143
144
Shallow depth of field
Bokeh
145
146
From left to right: an original photo with no bokeh or blur; the same photo with synthetic bokeh effect applied to its background; the same photo with Gaussian blur applied to its background
147