03 - JKD - Image Enhancement Spatial Domain
03 - JKD - Image Enhancement Spatial Domain
Stretch, compress
Example: log transform
lena
FFT(lena)
brighten
darken
Power –Law (Gamma) transformation
Power –Law (Gamma) transformation
gamma correction
-17-
Contrast stretching (Piece-wise linear transformation)
Contrast stretching is a process that expands the range of intensity levels in a image
so that it spans the full intensity range of the recording medium or display device.
Contrast-stretching transformations increase the contrast between the darks and the lights
Threshoding
Thresholding function
Intensity-level slicing
Highlighting a specific range of gray levels in an image
Image bit-planes
-21-
Bitplanes slicing
-24-
kernel operator / filter masks
TN (.) w(.)
Spatial g
f Filtering
kernel
a b
g(x, y) w(i, j) f (x i,y j)
ia j b
1 1
g(x, y) w(i, j) f (x i,y j) For a 3x3 mask
i1 j 1
-25-
Spatial Filtering/Mask operation
• Smoothing Filters
– Linear spatial filtering
• Averaging
• Weighted averaging
– Non-linear spatial filtering
• Median filtering
• Min filtering
• Max filtering
• Sharpening Filters
– Second order derivative (Laplacian)
– Unsharp Masking and High boost filtering
– First order derivative
Linear smoothing operator
Smoothing: Image Averaging
Weighted averaging
Averaging
(Gaussian)
a b
1
g(x,y) a b w(i, j) f (x i,y j)
w(i, j)
ia j b
ia j b
smoothing
operator
• averaging
v(m,n) = (1/Nw) x(m-k, n-l) + (1/Nw) N(m-k, n-l)
• Nw: number of pixels in the averaging window
– Noise variance reduced by a factor of Nw
– SNR improved by a factor of Nw
– Window size is limited to avoid excessive blurring
UMCP ENEE408G
-28-
smoothing operator of different sizes
original 3x3
5x5 9x9
15x15 35x35
-29-
directional smoothing
G Slides (created by M.Wu & R.Liu © 2002)
• Directional smoothing
– Compute spatial average along several directions
UMCP ENEE408G
– Take the result from the direction giving the smallest changes before &
after filtering
• Other solutions
– Use more explicit edge detection and adapt filtering accordingly
-30-
Non-linear smoothing operator
• Median filtering
– Based on order statistics (response depends upon ordering
of intensity value)
– Reduces blurring effect
– Algorithm
• Take a mask of any size (3X3, 5X5, 7X7)
• Order the intensity values of all pixel in the window in some order
• Take the median value as the filter response
• For even-sized windows take the average of two middle values as
output
– Nonlinear
• median{ x(m) + y(m) } median{x(m)} + median{y(m)}
•-31- Other order statistics: min, max etc.
Median filter example
• Median filtering
– Resilient to statistical outliers
– Incurs less blurring
– Simple to implement
-32-
Order statistics filters
g ( x, y ) median{ f ( s, t )}
( s ,t )W( x , y )
g ( x, y ) max { f ( s, t )}
( s ,t )W( x , y )
original
g ( x, y ) min { f ( s, t )}
( s ,t )W( x , y )
-33-
Sharpening (Image derivative)
• First order
• Second order
-34-
Second derivative in 2D
Image Laplacian:
-35-
Result of Laplacian
http://flickr.com/photos/starfish235/388557119/
-36-
Unsharp masking
• Unsharp masking is an image manipulation technique for increasing the
apparent sharpness of photographic images.
• The "unsharp" of the name derives from the fact that the technique uses a
blurred, or "unsharp", positive to create a "mask" of the original image.
The unsharped mask is then combined with the negative, creating a
resulting image sharper than the original.
Steps
Blur the image
Subtract the blurred
version from the original
(this is called the mask)
Add the “mask” to the
original
-37-
High-boost filtering
Avg.
-
+
+ f hb ( x, y ) Af ( x, y ) f lp ( x, y )
Unsharp mask:
high-boost with A=1
-38-
Unsharp mask example
-39-
Edge detection operators
Image gradient:
f
Gx x
f f
G y
y
f G x G y
Robert’s
operator
Sobel’s
operator
-40-
Edge detection example
Roberts
Sobel
-41- http://flickr.com/photos/reneemarie11/97326485/
Gray-level image histogram
• Represents the relative frequency of occurrence of the
various gray levels in the image
– For each gray level, count the number of pixels having that level
– Can group nearby levels to form a big bin & count #pixels in it
-42-
Histogram and its processing
The histogram of a digital image with
gray levels in the range [0, L-1] is a discrete
function h(rk)=nk , where rk is the kth gray
level and nk is the number of pixels in the
image having gray level rk.
L 1 k
MN j 0
n j , k 0,1,2,..., L 1
Histogram Equalization - Example
• Let f be an image with size 64x64 pixels and L=8 and let f has the intensity
distribution as shown in the table
0
rk nk p r(rk )=nk/MN s0 T (r0 ) 7 pr (r j ) 7 pr (r0 ) 1.33
0 790 0.19 j 0
1
r
s T (r ) ( L 1) pr ( w)dw
0
z
G ( z ) ( L 1) p z (t )dt s
0
z G 1 ( s ) G 1[T (r )]
k k nj
sk T (rk ) ( L 1) pr (rj ) ( L 1) , k 0,1,2,..., L 1
j 0 j 0 n
k
vk G ( z k ) ( L 1) p z ( zi ) sk , k 0,1,2,..., L 1
i 0
• Histogram matching
– Obtain the histogram of the given image, T(r)
– Precompute a mapped level sk for each level rk
– Obtain the transformation function G from
the given p z (z )
– Precompute z k for each value of sk
– Map rk to its corresponding level sk ; then
map level sk into the final level z k
Summary
• Spatial transformation and filtering are popular
methods for image enhancement
• Intensity Transformation
– Intensity transformation functions (negative, log, gamma),
intensity and bit-place slicing, contrast stretching
– Histograms: equalization, matching, local processing
• Spatial Filtering
– smoothing filters
– Median filters
– Order statistic filters
– Sharpening filters
• Second order derivative: Laplacian, unsharp masking, high boost
filtering
• First order derivative: Robert’s cross gradiant operator, Sobel
-61-
operator