Académique Documents
Professionnel Documents
Culture Documents
► Spatial domain
image plane itself, directly process the intensity values of
the image plane
► Transform domain
process the transform coefficients, not directly process the
intensity values of the image plane
9/21/19 2
Spatial Domain Process
g ( x, y ) = T [ f ( x, y )])
f ( x, y ) : input image
g ( x, y ) : output image
T : an operator on f defined over
a neighborhood of point ( x, y)
9/21/19 3
Spatial Domain Process
9/21/19 4
Spatial Domain Process
Intensity transformation function
s = T (r )
9/21/19 5
Some Basic Intensity Transformation
Functions
9/21/19 6
Image Negatives
Image negatives
s = L -1- r
9/21/19 7
Log Transformations
Log Transformations
s = c log(1 + r )
9/21/19 8
Example: Log Transformations
9/21/19 9
Power-Law (Gamma) Transformations
g
s = cr
9/21/19 10
Example: Gamma Transformations
9/21/19 11
Example: Gamma Transformations
Cathode ray tube
(CRT) devices have an
intensity-to-voltage
response that is a
power function, with
exponents varying
from approximately
1.8 to 2.5
s=r 1/2.5
9/21/19 12
Example: Gamma Transformations
9/21/19 13
Example: Gamma Transformations
9/21/19 14
Piecewise-Linear Transformations
► Contrast Stretching
— Expands the range of intensity levels in an image so that it spans
the full intensity range of the recording medium or display device.
► Intensity-level Slicing
— Highlighting a specific range of intensities in an image often is of
interest.
9/21/19 15
Highlight the major
lood vessels and
tudy the shape of the
low of the contrast
medium (to detect
lockages, etc.)
9/21/19 17
Bit-plane Slicing
9/21/19 18
Bit-plane Slicing
9/21/19 19
Histogram Processing
► Histogram Equalization
► Histogram Matching
9/21/19 20
Histogram Processing
Histogram h(rk ) = nk
rk is the k th intensity value
nk is the number of pixels in the image with intensity rk
nk
Normalized histogram p( rk ) =
MN
nk : the number of pixels in the image of
size M �N with intensity rk
9/21/19 21
9/21/19 22
Histogram Equalization
The intensity levels in an image may be viewed as
random variables in the interval [0, L-1].
Let pr (r ) and ps ( s) denote the probability density
function (PDF) of random variables r and s.
9/21/19 23
Histogram Equalization
s = T (r ) 0 �r �L - 1
9/21/19 24
Histogram Equalization
s = T (r ) 0 �r �L - 1
ps ( s)ds = pr (r )dr
9/21/19 25
Histogram Equalization
r
s = T (r ) = ( L - 1) �pr ( w)dw
0
ds dT (r ) d �r �
dr
=
dr
= ( L - 1)
dr �
�0
pr ( w) dw
�
= ( L - 1) pr (r )
pr (r )dr pr (r ) pr (r ) 1
ps ( s ) = = = =
ds �ds � ( ( L - 1) pr (r ) ) L - 1
� �
�dr �
9/21/19 26
Example
Suppose that the (continuous) intensity values
in an image have the PDF
� 2r
� , for 0 �r �L-1
pr (r ) = �( L - 1) 2
� 0, otherwise
�
9/21/19 27
Example
r
s = T (r ) = ( L - 1) �pr ( w)dw
0
r 2w
= ( L - 1) � dw
0 ( L - 1) 2
2
r
=
L -1
9/21/19 28
Histogram Equalization
Continuous case:
r
s = T (r ) = ( L - 1) �pr ( w)dw
0
Discrete values:
k
sk = T (rk ) = ( L - 1)�pr (rj )
j =0
k nj L -1 k
= ( L - 1)� = � nj k=0,1,..., L-1
j = 0 MN MN j =0
9/21/19 29
Example: Histogram Equalization
Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096)
has the intensity distribution shown in following table.
Get the histogram equalization transformation function and give the
ps(sk) for each sk.
9/21/19 30
Example: Histogram Equalization
9/21/19 31
Example: Histogram Equalization
9/21/19 32
9/21/19 33
9/21/19 34
Question
Is histogram equalization always good?
No
9/21/19 35
Histogram Matching
Histogram matching (histogram specification)
— generate a processed image that has a specified histogram
Let pr ( r ) and pz ( z ) denote the continous probability
density functions of the variables r and z. pz ( z ) is the
specified probability density function.
Let s be the random variable with the probability
r
s = T ( r ) = ( L - 1) �pr ( w) dw
0
-1
z = G ( s) = G -1
[ T (r ) ]
9/21/19 37
Histogram Matching: Procedure
► Obtain pr(r) from the input image and then obtain the values of s
r
s = ( L - 1) �pr ( w)dw
0
► Use the specified PDF and obtain the transformation function G(z)
z
G ( z ) = ( L - 1) �pz (t )dt = s
0
► Mapping from s to z
z = G -1 ( s )
9/21/19 38
Histogram Matching: Example
� 0, otherwise
�
Find the transformation function that will produce an image
whose intensity PDF is
� 3z 2
� , for 0 �z �( L -1)
pz ( z ) = �( L - 1) 3
� 0, otherwise
�
9/21/19 39
Histogram Matching: Example
z z 3t 2 z3
G ( z ) = ( L - 1) �pz (t )dt = ( L - 1) � dt = =s
0 0 ( L - 1)3 ( L - 1) 2
► Obtain pr(rj) from the input image and then obtain the values of
sk, round the value to the integer range [0, L-1].
k
( L - 1) k
sk = T (rk ) = ( L - 1)�pr (rj ) = � nj
j =0 MN j =0
► Use the specified PDF and obtain the transformation function
G(zq), round the value to the integer range [0, L-1].
q
G ( zq ) = ( L - 1)�pz ( zi ) = sk
i =0
► Mapping from sk to zq
zq = G -1 ( sk )
9/21/19 41
Example: Histogram Matching
Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096)
has the intensity distribution shown in the following table (on the
left). Get the histogram transformation function and make the output
image with the specified histogram, listed in the table on the right.
9/21/19 42
Example: Histogram Matching
Obtain the scaled histogram-equalized values,
9/21/19 43
Example: Histogram Matching
9/21/19 44
Example: Histogram Matching
9/21/19 45
Example: Histogram Matching
9/21/19 46
Example: Histogram Matching
9/21/19 47
Example: Histogram Matching
9/21/19 48
Example: Histogram Matching
9/21/19 49
Local Histogram Processing
9/21/19 50
Local Histogram Processing: Example
9/21/19 51
Using Histogram Statistics for Image
Enhancement
Average Intensity L -1 M -1 N -1
1
m = �ri p (ri ) =
MN
��f ( x, y)
x =0 y =0
i =0
L -1
un (r ) = �(ri - m) n p( ri )
i =0
Variance L -1 M -1 N -1
1
s = u2 (r ) = �(ri - m) ��[ f ( x, y) - m]
2 2 2
p(ri ) =
i =0
MN x =0 y =0
9/21/19 52
Using Histogram Statistics for Image
Enhancement
Local variance
L -1
s s2xy = �(ri - msxy ) 2 psxy (ri )
i =0
9/21/19 53
Spatial Filtering
a b
g ( x, y ) = ��w(s, t ) f ( x + s, y + t )
s =- a t =- b
9/21/19 54
Spatial Filtering
9/21/19 55
https://towardsdatascience.com/intuitively-understanding-convolutions-for-deep-learning-1f6f42faee1
9/21/19 56
9/21/19 57
Spatial Correlation
a b
w( x, y ) f ( x, y ) = ��w( s, t ) f ( x + s, y + t )
s =- a t =- b
9/21/19 58
Spatial Convolution
a b
w( x, y ) f ( x, y ) = ��w(s, t ) f ( x - s, y - t )
s =- a t =- b
9/21/19 59
9/21/19 60
Smoothing Spatial Filters
9/21/19 61
Spatial Smoothing Linear Filters
��w(s, t ) f ( x + s, y + t )
g ( x, y ) = s =- a t =- b
a b
��w(s, t )
s =- a t =- b
where m = 2a + 1, n = 2b + 1.
9/21/19 62
Two Smoothing Averaging Filter Masks
9/21/19 63
9/21/19 64
Example: Gross Representation of Objects
9/21/19 65
Order-statistic (Nonlinear) Filters
— Nonlinear
9/21/19 66
Example: Use of Median Filtering for Noise Reduction
9/21/19 67
Sharpening Spatial Filters
► Foundation
► Laplacian Operator
9/21/19 68
Sharpening Spatial Filters: Foundation
�
f
= f ( x + 1) - f ( x)
�
x
�2 f
2
= f ( x + 1) + f ( x - 1) - 2 f ( x)
�x
9/21/19 69
9/21/19 70
Sharpening Spatial Filters: Laplace Operator
�x �y
�2 f
2
= f ( x + 1, y ) + f ( x - 1, y ) - 2 f ( x, y )
�x
�2 f
2
= f ( x, y + 1) + f ( x, y - 1) - 2 f ( x, y )
�y
�2 f = f ( x + 1, y ) + f ( x - 1, y ) + f ( x, y + 1) + f ( x, y - 1)
- 4 f ( x, y )
9/21/19 71
Sharpening Spatial Filters: Laplace Operator
9/21/19 72
Sharpening Spatial Filters: Laplace Operator
g ( x, y ) = f ( x, y ) + c �
� f ( x, y ) �
� 2
�
where,
f ( x, y ) is input image,
g ( x, y ) is sharpenend images,
c = -1 if �2 f ( x, y ) corresponding to Fig. 3.37(a) or (b)
and c = 1 if either of the other two filters is used.
9/21/19 73
9/21/19 74
Q. Prove that the Laplacian operator isotropic(
independent of rotation).
Hint:-
x=x1cos-y1sin
y=x1sin+y1cos
9/21/19 75
= + = +
= cos + sin A
= - sin + cos B
9/21/19 76
=
9/21/19 77
Unsharp Masking and Highboost Filtering
► Unsharp masking
Sharpen images consists of subtracting an unsharp (smoothed)
version of an image from the original image
e.g., printing and publishing industry
► Steps
1. Blur the original image
2. Subtract the blurred image from the original
3. Add the mask to the original
9/21/19 78
Unsharp Masking and Highboost Filtering
9/21/19 79
Unsharp Masking: Demo
9/21/19 80
Unsharp Masking and Highboost Filtering: Example
9/21/19 81
Q.1 Prove that subtracting the Laplacian from
an image is highboost filtering.
Hint:
9/21/19 82
Image Sharpening based on First-Order Derivatives
9/21/19 83
Image Sharpening based on First-Order Derivatives
| gx | + | g y |
M ( x, y ) �
z1 z2 z3
M ( x, y ) =| z8 - z5 | + | z6 - z5 |
z4 z5 z6
z7 z8 z9
9/21/19 84
Image Sharpening based on First-Order Derivatives
Sobel Operators
| ( z7 + 2 z8 + z9 ) - ( z1 + 2 z2 + z3 ) |
M ( x, y ) �
z1 z2 z3 + | ( z3 + 2 z6 + z9 ) - ( z1 + 2 z4 + z7 ) |
z4 z5 z6
z7 z8 z9
9/21/19 85
Image Sharpening based on First-Order Derivatives
9/21/19 86
Example
9/21/19 87
Example:
Combining
Spatial
Enhancement
Methods
Goal:
Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail
9/21/19 88
Example:
Combining
Spatial
Enhancement
Methods
Goal:
Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail
9/21/19 89