Imen 3
Imen 3
PDA/Camera hybrids
Mobile hybrids
Image Enhancement
To process an image so that the result is
more suitable than the original image for a
specific application.
Improvement of image quality
* Image quality depends on context &
application
*Improvement depends on quality
measure
Image Enhancement
Involves image denoising & image deblurring
f(x,y) g(x,y)
T[N{f(x,y)}]
Mask processing or
Spatial filter
Different approaches
Spatial domain
Point processing
Mask processing
(neighborhood processing) (spatial
filters)
Frequency domain
Frequency domain filters
9
Spatial Domain Enhancement
Procedures that operate directly on the
aggregate of pixels composing an image
g ( x, y ) T [ f ( x, y )]
A neighborhood about (x,y) is defined by using
a square (or rectangular) subimage area
centered at (x,y).
Spatial Domain Methods
13
Point Operations
Output
grey level
Stretch
Unchanged
A point operation will never
alter the spatial relationships
within an image.
Compress Input
grey level
Gray level transformation
Image Enhancement in
the
Spatial Domain
Contrast Thresholding
Stretching
Some transformations
s = T(r) = L 1 r
s T r c log1 r
s = cr
s T r mr b
255 if A r B
s T r
0 otherwise
21
Examples of Point Operations
Transformation function
Low contrast image
s T r mr b
25
Window-Center adjustment
(monitors dynamic range)
Output gray level
256
0
0 input gray level 60000
(high dynamic range image)
Image Thresholding
Thresholding means choosing threshold level between the
maximum and minimum intensity of the initial image.
Thresholding is a way to get rid of the effect of noise and to
improve the signal-noise ratio.
30% threshold
lena.gif 10% threshold
Histogram of raw TM values shows a narrow distribution peak at low
pixel values. We might predict from this that we have a dark, flat image.
This is indeed the case:
Most of the DN values, however, lie between 9 and 65
perform a simple linear stretch: 9 goes to 5 and 65 goes to 255
Most of scene features are discriminable. But the image still is rather dark.
choose new limits in which we take pixels between 5 and 45 and expand
these to 0 to 255. This stretch results in the following histogram and image
Algebraic operations
A point form of operation (with >1 input image)
Grey level of each output pixel depends only on
grey levels of corresponding pixels in input images
Four major operations:
Addition: Multiplication:
C A B C A B
Subtraction Division:
C A B C A B
Other operations can be defined that involve more than 2
input images, or using (for example) boolean or logic
operators.
Applications of algebraic operations
Addition
Ensemble averaging to reduce noise
Superimposing one image upon another
Subtraction
Removal of unwanted additive interference
(background suppression)
Motion detection
Applications (continued)
Multiplication
Removal of unwanted multiplicative interference
(background suppression)
Masking prior to combination by addition
Windowing prior to Fourier transformation
Division
Background suppression (as multiplication)
Special imaging signals (multi-spectral work)
Image Negatives
s = T(r) = L 1 r
Log Transformations
s = c log(1+r)
c: constant
s T r c log1 r
38
Image Enhancement in Spatial Domain
Power-Law Transformations
s cr
C, : positive constants
Gamma correction
Basic Point Processing Power- law transformations
s = cr
42
Gray-Level Slicing
To highlight a specific range of gray levels in
an image (e.g. to enhance certain features).
One way is to
display a high value
for all gray levels in
the range of interest
and a low value for
all other gray levels
(binary image).
Gray-Level Slicing
Second approach is to brighten the
desired range of gray levels but preserve
the background and gray-level tonalities in
the input image
Bit-Plane Slicing
To highlight the contribution made to the total
image appearance by specific bits.
2D
z1 z2 z3 f1 f2 f3
z4 z5 z6 f4 f5 f6
g1 z5 f1 z6 f 2 z8 f 4 z9 f 5
z7 z8 z9 f7 f8 f9 9
g 5 zi f i
i 1
mask image
Spatial filters
Purpose: Purpose
Blur or noise reduction Highlight fine detail or
Lowpass/Smoothing spatial enhance detail blurred
filtering Highpass/Sharpening spatial
Sum of the mask filter
coefficients is 1 Sum of the mask
Visual effect: reduced noise coefficients is 0
but blurred edge as well Visual effect: enhanced
Smoothing linear filters edges on a dark background
Averaging filter High-boost filtering and
Weighted average (e.g., unsharp masking
Gaussian) Derivative filters
Smoothing nonlinear filters 1st
Order statistics filters (e.g., 2nd
median filter)
58
Smoothing filters 1 1 1
1/9 x 1 1 1
Purpose:
Blur or noise reduction 1 1 1
Smoothing linear filtering (lowpass spatial filter)
Neighborhood (weighted) averaging 1 2 1
Can use different size of masks 1/16 2 4 2
Sum of the mask coefficients is 1
Drawback: 1 2 1
Order-statistic nonlinear filters
Response is determined by ordering the pixels contained in the image
area covered by the mask
Median filtering
The gray level of each pixel is replaced by the median of its neighbor.
Good at denoising (salt-and-pepper noise/impulse noise)
Max filter
Min filter
Averaging
filter
Median
filter
Image Enhancement in Spatial Domain
2D filtering
It is written:
Mean Filter
Gaussian Filter
Image Enhancement in the
Spatial Domain
Example1: Averaging
1
g ( x, y ) f ( x 1, y 1) f ( x 1, y) f ( x 1, y 1) ... f ( x 1, y 1)
9
Two 3x3 smoothing filter masks
mean filter product, which Sobel edge enhancement filter
tends to generalize image highlights abrupt discontinuities,
such as rock joints and faults, field
boundaries, and street patterns:
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 100 130 110 120 110 0 0
0 0 0 110 90 100 90 100 0 0
0 0 0 130 100 90 130 110 0 0
0 0 0 120 100 130 110 120 0 0
0 0 0 90 110 80 120 100 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Mean filtering
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10
0 0 0 90 90 90 90 90 0 0 0 20 40 60 60 60 40 20
0 0 0 90 90 90 90 90 0 0 0 30 60 90 90 90 60 30
0 0 0 90 90 90 90 90 0 0 0 30 50 80 80 90 60 30
0 0 0 90 0 90 90 90 0 0 0 30 50 80 80 90 60 30
0 0 0 90 90 90 90 90 0 0 0 20 30 50 50 60 40 20
0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 30 20 10
0 0 90 0 0 0 0 0 0 0 10 10 10 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Effect of
mean filters
Finite differences responding to noise
Increasingnoise>
(thisiszeromeanadditivegaussiannoise)
Low pass spatial filter (Linear):
Used for smoothing (removal of small details prior to
large object extraction, bridging small gaps in lines)
and noise reduction.
Bandpass Images
Image Averaging
A noisy image:
g ( x, y ) f ( x, y ) n ( x, y )
E g x, y f x, y
1 2
2
g x, y x, y
M
How to generate Gaussian noise?
//This function creates a gaussian random number between -3
and 3//
double gaussrand() {
static double V1, V2, S;
static int phase = 0;
double X;
if (phase == 0) {
do {
double U1 = (double)rand() / RAND_MAX;
double U2 = (double)rand() / RAND_MAX;
V1 = 2 * U1 - 1;
V2 = 2 * U2 - 1;
S = V1 * V1 + V2 * V2;
} while(S >= 1 || S == 0);
X = V1 * sqrt(-2 * log(S) / S);
}
else
X = V2 * sqrt(-2 * log(S) / S);
phase = 1 - phase;
return X;
}
a)Image of galaxy pair NGC 3314
b)Corrupted by zero mean AWGN
with std dev of 64 gray levels
c-f) Averagin with
K=8,16,64,128 noisy images
Image Smoothing
Given image f( x, y) and smoothing filter h( i, j), image,
smoothing is defined by:
The intensity of pixel (x, y) in the output is obtained
from weighted sum of intensities of pixels at and
surrounding (x, y) in the input.
I J
w(i, j ) f (m i, n j )
i I j J
g ( m, n ) I J
w(i, j )
i I j J
Normalization of coefficient to
ensure 0 g(m,n) L-1
Median filter (non-linear):
Replace the current
pixel value by the
median pixel value in
a given
neighborhood.
Achieves effective
noise supression.
Preserves the
sharpness of real
boundaries.
Median Filtering
Output pixel value at (x, y) is obtained from the median of
values at and surrounding (x, y) in input.
It is rotationally invariant, if median of circular rather than
rectangular windows is used.
Median filtering is effective when impulse noise is present in
input image.
Gaussian Filtering
If the weights are chosen as Gaussian coefficients in image smoothing, it is
known as Gaussian filtering.
Gaussian and mean filtering are effective when image noise has a mean of
zero.
Gaussian filtering is rotationally invariant.
A 2- D Gaussian can be decomposed into two 1- D Gaussians, and filtering
can be carried in 1- D rather than in 2- D:
G( x, y) = G( x) * G( y)
basic effects of (2D) Gaussian filter: smoothing the image and wiping off the
noise
A Gaussian kernel gives less weight to pixels further from the center of the
window
1 2 1
2 4 2
1 2 1
This kernel is an approximation of a
Gaussian function:
GAUSSIAN MASKS
Gaussian mask is a circularly symmetrical (or isotropic) mask, such that
any cross-section through its centre yields a weight profile in the form of
a Gaussian or normal curve.
r (y-axis) --- the distance (in pixels) from the centre of the mask
(x-axis) --- the "width" of the mask
Noise Canceling
Histogram
pk nk / N
93
The Grey-level Histogram
Number of
pixels
95
Example
97
Histogram Equalization
Enhances visibility of gradients
When image histogram has a few peaks separated
by wide valleys, the variation of brightness values
of pixels that correspond to the peaks may not be
visible on the display
Equalization spreads the peaks out and makes the
differences between those pixels more evident.
Neighborhood equalization provides for local
contrast enhancement by modifying the brightness
of each pixel according to brightnesses of
neighboring pixels.
Histogram Equalization
HISTOGRAM METHODS
Grey Level Histogram Equalisation
In GLH equalisation, a non-linear grey scale
transformation redistributes the grey levels,
producing an image with a flattened histogram.
This can result in a striking contrast
improvement.
102
HE Example 2
Original Dendrite image. Equalized Dendrite image.
nj
pr r j
k k
sk T rk
j 0 n j 0
r
s T r pr w dw
0
pr r pr r
ps s 1
ds pr r
dr
Histogram equalization
Transformation function
s T r pr w dw
r
0 r 1
0
j 0 n j 0
r hist(r) r s s
0 10 0 10 10 10
hist(s)
1 70 1 80 80 70
2 15 2 95 95 15
3 5 3 100 100 5
*Histogram specification
120
HS - Example
r hist(r) r s
0 10 0 10
1 70 1 80 r z
2 15 2 95 0 10
3 5 3 100 1 30
2 60
z hist(z) z G(z) 3 65
Specified 10 10 10 10
histogram 15 20 15 30
30 50 30 80
60 15 60 95
Comparison (HE vs. HM/HS)
125
Image Subtraction
Mask mode radiography
h(x,y) is the mask
g ( x, y ) f ( x, y ) h ( x, y )
Image Gradients
An image gradient consists of the horizontal
and vertical partial derivatives
I
Derivative Estimators x
Gx
I
-1
Gy I
Horz: -1 1 Vert: 1
y
Problems:
Derivatives enhance noise
We desire some filtering
We prefer odd sized filters, not even
Note relation to high-pass filtering
Image gradient
The gradient of an image:
Prewitt operator
-1 -1 -1
-1 0 1
Horz: 0 0 0
-1 0 1 Vert:
1 1 1
-1 0 1
Sobel operator
-1 0 1 -1 -2 -1
Horz: -2 0 2 Vert: 0 0 0
-1 0 1 1 2 1
Derivative Masks
Determining edge locations
Purpose
Highlight fine detail or enhance detail that has been blurred
Basic highpass spatial filter
Sum of the mask coefficients is 0
Visual effect: enhanced edges on a dark background
Unsharp masking and High-boost filtering
Derivatives
1st derivative
2nd derivative
135
Example 2 - Sharpening filter
1 0 0 1
h1 h2
0 1 1 0
Sobel Operator
y
1
Edge Magnitude = Edge Direction = tan
x2 y2 x
Prewitt Operator
Gaussian
Unsharp masking
To generate the mask: Subtract a blurred version of the image
from itself
Add the mask to the original
144
Example 1 - Unsharp Mask
Perfect image
Corrupted image
147
Unsharp Masking
100
200
300 =
400
500
+ =
Image gradient
The gradient of an image:
Laplacian of Gaussian
operator
0 1 0 1 1 1
1 -4 1 1 -8 1
To recover the image:
0 1 0 1 1 1 g x , y f x, y 2 f x , y
0 -1 0 -1 -1 -1
-1 4 -1 -1 8 1 g x , y f x, y 2 f x, y
0 -1 0 -1 -1 -1
155
Laplacian Operators
(Cont.)
Masks for 4 and 8 neighborhoods
0 1 0 1 1 1
1 4 1 1 8 1
0 1 0 1 1 1
Proposed by Marr/Hildreth
Gaussian Filter for noise elimination
Problem of finding maximum
Normalized magnitude peaks may be flat
Finds zero crossings of Laplacian of image
Does not require thresholding
Motivated by human vision system
Sharpening Linear Filters
High Boost Filter Laplacian operator:
2
f ( x , y ) 2
f ( x, y )
2 f ( x, y )
x 2 y 2
f ( x 1, y) f ( x 1, y) f ( x, y 1) f ( x, y 1) 4 f ( x, y )
A1
- Derivative filter:
- Use derivatives to
approximate high pass
filters.
- Usually 2nd derivatives are
preferred.
- The most common one is
the Laplacian operator.
High-Boost Filtering
Generalization of unsharp masking
f hb x, y Af x, y f x, y
Here A is called boost coefficient, and
We rewrite the equation as
A 1
f hb x, y A 1 f x, y f x, y f x, y
A 1 f x, y f s x, y
Applicable to any sharpening operation
can be
The filter for fhb becomes
fs f f
2
0 1 0
h 1 A 4 1
0 1 0
0 1 0
h 1 A 4 1
0 1 0
High-Boost Filtering: Demo
By varying A, better overall brightness can be improved.
original A=0
A=1.7, much
A=1 brighter
Laplacian Filter for Image Enhancement
f ( x, y ) 2 f ( x, y ) center of mask 0;
g ( x, y )
f ( x, y ) f ( x, y ) center of mask 0.
2
Sobel operator
Original Saturn
Kirsch.
image. Sobel magnitude.
Sobel direction.
Nonlinear Filters
Will discuss some of them in more detail later for
the purpose of image restoration.
Maximum filter: the output the maximum value
under the mask
Minimum filter: the output the minimum value
under the mask
Rank-order filter:
Elements under the mask are ordered, and a particular value is
returned.
Both maximum and minimum filter are instances of rank-order
Another popular instance is median filter
Edge detection and editing
2D edge detection filters
Laplacian of Gaussian
Laplacian of Gaussian
operator
Laplacian of Gaussian
Original Muscle image. Top hat (inner rad.=1) Top hat (inner rad.=3)
Boundary sharpening
Boundaries between regions are the visually most
important part of an image
Boundary types: steps in brightness, dark (or light)
lines that separate regions, subtle changes in color
(either hue or saturation), texture or orientation.
median does not shift boundaries, although it can
round corners
iterated median filter sharpens the local contrast at
blurred edges but does not alter the contrast, while
removing noise from the image.
Original Au_Resn image
Iterated median filtered image
Boundary Detection
Image Enhancement
in Frequency Domain
Image Processing in Frequency Space
Frequency space has attractive advantages for image processing.
It makes large linear filtering operations (large neighborhood
kernels) much faster
collects information in many to separate signal from noise or
allow measurements that would be very difficult in the spatial
domain.
The common denominator in all of these operations is the FFT or
fast Fourier transform.
Forward FT to perform the conversion from the spatial domain to
the frequency domain. This will replace the original image with
the power spectrum
power spectrum image can be processed like any other grey scale
image
Fourier Transform
Original Mullite image and its FT Power Spectrum.
Understanding and implementing
Fourier transform
Extension to 2D
According to translation
y
(0,0) y (0,0)
0 -255 v
-0 255 (0,0)
x x
u
f(x,y) f(x,y)(-1)x+y |F(u-M/2,v-N/2)|
Filtering in Frequency Domain: Basic Steps
Basic Steps
1. Multiply pixel f(x,y) of
the input image by
(-1)x+y.
1. Compute F(u,v),
the DFT
3. G(u,v)=F(u,v)H(u,v)
4. g1(x,y)=F-1{G(u,v)}
5. g(x,y) = g1(x,y)*(-1)x+y
Low-pass & High-pass Filtering
Man-made Scene
Can change spectrum, then
reconstruct
Low and High Pass filtering
The Convolution Theorem
The greatest thing since sliced (banana) bread!
h(x,y) |H(sx,sy)|
g(x,y) |G(sx,sy)|
Fourier Transform pairs
Lowpass filtering
Ideal filter 1 if D u , v D0
H u , v
D(u, v): distance from point (u, v) to the origin
0 if D u , v D0
cutoff frequency (D0)
nonphysical
radially symmetric about the origin
Butterworth filter
H u, v e D 2 u ,v / 2 D0 2
Power ratio
99.9699.6599.0497.84
100
P u, v / PT u, v
u v
Highpass filter
Ideal filter
0 if D u , v D0
H u, v
1 if D u , v D0
Butterworth filter
1
H u, v
1 D0 / D u , v
2n
H u, v 1 e D 2 u ,v / 2 D0 2
Example
Low-pass, Band-pass, High-
pass
low-pass:
filters
High-pass / band-pass:
Edges in images
Notch Filter
0 uv0
F (u , v)
1 otherwise.
f x, y i x, y r x, y
z x, y ln f x, y ln i x, y ln r x, y
F z x, y F ln i x, y F ln r x, y
Z (u , v) Fi (u , v) Fr (u , v)
S u , v H u , v Fi u , v H u , v Fr u , v
s x, y i x, y r x, y
H 1 c ( D 2 ( u ,v ) / D02 )
H (u , v) ( H L )[1 e ] L
L 1
Homomorphic filter - example
Point processing Mask processing Frequency domain
(spatial filters) filters