0% found this document useful (0 votes)
29 views76 pages

Lecture - 11 - 16 ImageEnhancement - Till - March1 - 2023

Spatial domain image enhancement techniques operate directly on pixel values. They include point operations that modify each pixel independently and local operations based on neighboring pixel values. Common techniques are brightness adjustments through thresholds, contrasts stretching, and histogram equalization. Spatial filtering uses small filters or kernels that are convolved with an image to modify pixels based on their neighbors. This smoothing or sharpening helps extract important features while removing noise.

Uploaded by

rovap45602
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views76 pages

Lecture - 11 - 16 ImageEnhancement - Till - March1 - 2023

Spatial domain image enhancement techniques operate directly on pixel values. They include point operations that modify each pixel independently and local operations based on neighboring pixel values. Common techniques are brightness adjustments through thresholds, contrasts stretching, and histogram equalization. Spatial filtering uses small filters or kernels that are convolved with an image to modify pixels based on their neighbors. This smoothing or sharpening helps extract important features while removing noise.

Uploaded by

rovap45602
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 76

Image enhancement- Spatial

domain
BITS Pilani Rajitha
Hyderabad Campus
K
Image enhancement

• To improve the perception or


interpretability of information in the
image for humans
• Helps to see hidden features
• Filter the important features in image
• Remove the noise in the image
• Discard unimportant features in image

BITS Pilani, Hyderabad Campus


Image enhancement

• Improve the visual interpretability of an image by increasing


the apparent distinction between the features in the scene.
Categorized as:
• Point operation: Modifies brightness value of each pixel
independently
• Local operation: Based on neighboring brightness

BITS Pilani, Hyderabad Campus


Spatial
domain
Spatial domain: It refers to the image
plane and Operates directly on pixels

f(x , g(x ,
Operatio
y) n y)
T(f( x ,
y))
Spatial
domain
• The operator T in spatial domain can
be defined over
1)The set of pixels (x, y) of the
image
2)The set of ‘neighbour’ N(x, y) of each
pixel
3)A set of images f1,f2,f3
( ) =T(
) Any Enhancement
technique
Enhanced Image(x,y)= T ( original Image
(x,y)
g(x,y)= T[f(x,y)]
Spatial domain approach
is performed in a
“neighborhood”
Image f(x,y)
x

(x,y)

y
Kern
al X

Y
bv1 bv2 bv C1 C2 C3 (Bv1 x c1 ) + (bv2 x
3 +(Bv3
c2) x c3 ) + (bv4 x
X C4 C5 C6 c4)
= +(Bv5 x c5 ) + (bv6 x
bv4 bv5 bv =
c6)
6 C7 C8 C9 +(Bv7 x c7 ) + (bv8 x
bv7 bv8 bv c8) (Bv9 x c9 )

9
Point Processing
WhenKernelsizebecomes 1x1thetechniqueisreferredtoaspointprocessing
OrGrayleveltransformations

bv1 bv bv3
2 X
= C5 = bv5 x
bv4 bv bv6 c5
5
bv7 bv bv9
8
Negative
Transformation
Replacing
the original
image gray
level value r
with 255-r

25
Output gray level

25

Output gray level


5 s=255- 5
r
(s)

0 255
(s)
0 255
Input gray level Input gray level
Log
Transformation

25
5
Output gray level

Corresponding area in the output


image
(s)

255
Input gray level (r)
Dark area of input image
Fourier spectrum and log
transformation
Power- law
This is also called as GAMMA
TransformationsCORRECTION
General Equation is…..
s = crγ

25
5

For Every Gamma value we


Output gray level

get an output image.


output Images can be compared
and
selected for different uses
(s)

25
5
Gamma
correction

When the Gamma value increases the image become


Darker
HISTOGRA
MS
.

Pixels
No. of

0 25
0 Grey
levels 5
Histograms of a color
Histograms of a Black and white
image
image
Understanding
Histograms .

0 25 0
5 25
5
Histogram statistics and contrast
Contrast stretching

ORIGINAL IMAGE
X
0 255

STRETCHED IMAGE
X’
0 255
X-Xmin
X’= X 255
Xmax- Xmin
Contrast stretching
STRETCHABLE AREA
Gray level Thresholding
Grey level thresholding is used to segment
an input image into two classes
It display a continuous image(0-255) to a
bi-level map(0-1)

0
Gray level Thresholding

Brightness values Brightness values


more than 200 is more than 30 is
assigned as 1 and assigned as 0 and
less than 200 is less than 30 is
assigned 0 assigned 1
Histogram
If image have intensity values [0,L-1]
Histogram of digital image is a discrete function
h(𝑟𝑘 ) = 𝑛𝑘
𝑟𝑘 = discrete intensity value
𝑛𝑘 = No of pixels having the particular intensity
values
Normalized histogram: P(𝑟𝑘 )= 𝑛𝑘 /n
n= No of pixels in the image
Pr(r) gives the of occurrence pixel r in the image
Histogram of the two images are
same; Contents are different
Histogram Equalization
Redistribute the original histogram ,so that each brightness level has
Approximately equal number of pixels

20
frequency

frequency
10
5

50 60 70 154 0 255
Before Equalisation After Equalization
Histogram Equalization

Image before Equalization Image After Equalization


Example:
Consider an 3 bit 64 x 64 image with gray values (0, 1,
…,7).
• We get
• S0 =1.33 = 1
• S1=3.08 =3
• S2 =4.55=5
• S3= 5.67=6
• S4= 6.23=6
• S5=6.65=7
• S6 =6.86=7
• S7= 7=7
r0=0 r1= 1 r2=2 r3=3 r4=4 r5=5 r6=6 r7=7
S0=1 S1=3 S2=5 S3=6 S4=6 S5=7 S6=7 S7=7
Histogram Matching
Bit plane slicing

• Each pixel is a digital number represented by 8 bits for 8 bit image

• 8 bit image contains 8 1bit planes


Spatial Filtering
• Spatial filtering term is the filtering operations that are
performed directly on the pixels of an image
• Filter in spatial domain is a sub image
• It is also called mask , kernel, template, window etc.
• The values in the filtered image are called coefficients
Spatial filtering
 Smoothing filter
Linear filter (Average, weighted average)
Non linear ( order statistics filters- Max,
min, median)
 Sharpening filter
Linear filter (Laplacian filter, First degree
derivative filter)
Mechanics of spatial filtering

• The process consists simply of moving the filter


mask from point to point in an image.
• At each point (x,y) the response of the filter at that
point is calculated using a predefined relationship
• A new pixel is created with coordinates equal to
coordinates of center of neighborhood and value is
the result of filtering operation
Kernal
X

Y
bv1 bv2 bv3 C1 C2 C3 (Bv1 x c1 ) + (bv2 x c2)
X +(Bv3 x c3 ) + (bv4 x c4)
= bv4 bv5 bv6 C4 C5 C6 = +(Bv5 x c5 ) + (bv6 x c6)
+(Bv7 x c7 ) + (bv8 x c8)
bv7 bv8 bv9 C7 C8 C9 (Bv9 x c9 )
Linear filtering techniques
• Correlation
a b
g ( x, y )  w( x, y ) * f ( x, y )    w(s, t ) f ( x  s, y  t )
s   at   b

• Convolution

a b
g ( x, y )  w( x, y )  f ( x, y )    w(s, t ) f ( x  s, y  t )
s   at   b
Generating spatial filter masks
• Selection of coefficients for linear filtering masks depends
upon the type of application

Linear filters are implemented using convolution masks and


general observations are

• If sum of the coefficients is one average brightness of the


image is retained

• If sum of the coefficients is zero, then brightness is lost

• If coefficients are alternative positive and negative, the mask


will create a sharp image

• If coefficients are positive , blurred image will be produced


Smoothing filtering/low pass filtering
• Aim is to reduce the effect of camera noise, spurious pixels,
missing pixels etc
Average filter is a low pass filter
• Spatial filter with all values are equal to one are called box
filter.
• Blurring is a common problem for average/box filter
• To reduce the blurring effect , weighted average is used with
maximum weightage to centre pixel and values of other mask
coefficients are based on the distance from centre pixel
Box filter

1 1 1
1 1 1

1 1 1

Weighted average filter

1 2 1
2 4 2
1 2 1
Gaussian Filter
Order statistics (non-linear filters)

• Response of the filter is based on the


ranking of pixels contained in the
image area encompassed by the filter
and then by replacing the value of the
pixel by the ranking result.
Example: Median filter , min, max filter
etc
Sharpening spatial filters

- To highlight transitions in intensity


- Achieved by image spatial differentiation
- Differentiation enhances edges and noise
areas
Sharpening filters

The principal objective of sharpening is to


highlight fine detail in an image or to
enhance detail that has been blurred,
either in error or as an natural effect of a
particular method of image acquisition.
Definition for a first derivative

 Must be zero in flat segments


 Must be nonzero at the onset of a gray-level
step or ramp; and
 Must be nonzero along ramps.
Definition for a second derivative
• Must be zero in flat areas;
• Must be nonzero at the onset and end
of a gray-level step or ramp;
• Must be zero along ramps of constant
slope
Definition of the 1st-order derivative

A basic definition of the first-order derivative of a


one-dimensional function f(x) is

f
 f ( x  1)  f ( x)
x
Gray-level profile

0 0 0 1 2 3 2 0 0 2 2 6 3 3 2 2 3 3 0 0 0 0 0 0 7 7 6 5 5 3
7
6
5
4
3
2
1
0
1st make thick edge and 2nd make thin edge

• The 1st-order derivative is nonzero along the


entire ramp, while the 2nd-order derivative is
nonzero only at the onset and end of the ramp.

• The response at and around the point is much


stronger for the 2nd- than for the 1st-order
derivative
Second order derivative
2 f
 f ( x  1)  f ( x  1)  2 f ( x).
x 2

• Easy to implement using Laplacian operator

 2
f  2
f
 f  2  2
2

x y
Discrete form of derivative

f(x-1,y) f(x,y) f(x+1,y) 2 f


 f ( x  1, y)  f ( x  1, y)  2 f ( x, y)
x 2

f(x,y-1)

2 f
f(x,y)  f ( x, y  1)  f ( x, y  1)  2 f ( x, y)
y 2

f(x,y+1)
2-Dimentional Laplacian
The digital implementation of the 2-Dimensional
Laplacian is obtained by summing 2 components
2 f 2 f
 f  2  2
2

x y
 2 f  f ( x  1, y)  f ( x  1, y)  f ( x, y  1)  f ( x, y  1)  4 f ( x, y)

1 -4 1

1
Laplacian

0 1 0 1 1 1

1 -4 1 1 -8 1

0 1 0 1 1 1

1 0 1

0 -4 0

1 0 1
Implementation
* By applying laplacian to image it highlight the edges
but deemphasizes slow varying intensity areas. In to
recover the background details we add original
image to laplacian output.

 f ( x, y )   2 f ( x, y ) If the center coefficient is negative


g ( x, y )  
 f ( x , y )   2
f ( x, y ) If the center coefficient is positive

Where f(x,y) is the original image


 2 f ( x, y ) is Laplacian filtered image
g(x,y) is the sharpen image
Unsharp masking

• A process to sharpen images consists of


subtracting a blurred version of an image from
the image itself. This process, called unsharp
masking.

• Where fs ( x, y) denotes the mask obtained by


f s ( x, y) and
unsharp masking, y) ,y)f ( is
f ( x,f(x x, ay)blurred
version of original image.
• g(x,y) = f(x , y)+𝑓𝑠 (x, y)
High boost filtering

• If we add a weighted portion of the


mask back to original image
• g(x, y)=f(x , y)+k*fs (x,y)
• When k =1 we will have unsharp
masking
• When k>1 the process is referred as
high boost filtering
Non Linear Spatial filters

• Nonlinear spatial filters also operate on


neighborhoods, and the mechanics of
sliding a mask past an image are the same
as was just outlined.

• The filtering operation is based


conditionally on the values of the pixels in
the neighborhood under consideration
First order derivatives for image
sharpening

• First Derivatives in image


processing are implemented using
the magnitude of the gradient.
 f  of function f(x,y) is
• The gradient
Gx   x 
f      f 
G y   
 y 

mag(f )  Gx2  Gy2  Gx  Gy


Robert’s Method
• The simplest approximations to a first-order
derivative that satisfy the conditions stated
in that section are
z1 z2 z3 Gx = (z9-z5) and Gy = (z8-z6)

z4 z51 z6 f  ( z9  z5 ) 2  ( z8  z6 ) 2

z7 z8 z9
f  z9  z5  z8  z6
Robert’s Method
-1 0 0 -1

0 1 1 0

• These mask are referred to as the


Roberts cross-gradient operators.
Sobel’s Method

• Mask of even size are awkward to apply.


• The smallest filter mask should be 3x3.
• The difference between the third and first
rows of the 3x3 mage region approximate
derivative in x-direction, and the difference
between the third and first column
approximate derivative in y-direction.
Sobel’s Method
• Using this equation
f  ( z7  2 z8  z9 )  ( z1  2 z2  z3 )  ( z3  2 z6  z9 )  ( z1  2 z4  z7 )

-1 -2 -1 -1 0 1

0 0 0 -2 0 2

1 2 1 -1 0 1
• Gradients enhances small discontinuities
in flat gray fields
Original image Laplacian image
Sharpened image Sobel image
(original+ Laplacian)
Mask image obtained
Smoothened sobel
by multipying sobel
image)
smoothened and
laplacian sharp
Sharpened image Power law
(original image +mask transformation

You might also like