You are on page 1of 117

SET-II

MAN 325
Autumn Semester 2020-21
Mathematical Imaging
Techniques

Sources:
Gonzalez, R. C. and Woods, R. E., "Digital Image Processing", Prentice Hall,
CS 589-04 Digital Image Processing@ nmt
Image Enhancement

Image Enhancement is the process of manipulating


an image so that the result is more suitable than
the original for a specific application.
Image enhancement can be done in :
Spatial Domain
Frequency Domain

 Spatial Domain Transformation are :


Point operations
Mask Operations
DIGITAL IMAGE PROCESSING 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)

02/04/2023 3
Point Operation
 Operation deals with pixel intensity values individually.
 The intensity values are altered using particular
transformation techniques as per the requirement.
 The transformed output pixel value does not depend on
any of the neighbouring pixel value of the input image.

Examples:
 Image Negative.
 Contrast Stretching.
 Thresholding.
 Brightness Enhancement.
 Log Transformation.
 Power Law Transformation.

DIGITAL IMAGE PROCESSING 4


Mask Operation

 Mask is a small matrix useful for blurring,


sharpening, edge-detection and more.

New image is generated by multiplying the input


image with the mask matrix.

The output pixel values thus depend on the


neighbouring input pixel values.

The mask may be of any dimension 3X3 4X4 ….


DIGITAL IMAGE PROCESSING 5
Mask Operation

DIGITAL IMAGE PROCESSING 6


Transfer function for different Intensity
Transformations

Transfer function of
a) Negative
b) Log
c) Nth root
d) Identity
e) Nth power
DIGITAL IMAGE PROCESSING
f) Inverse log 7
Image Negative

 Negative images are useful for enhancing white or


grey detail embedded in dark regions of an image.

 The negative of an image with gray levels in the


range [0,L-1] is obtained by using the expression
s = L -1 - r
L-1 = Maximum pixel value .
r = Pixel value of an image.

DIGITAL IMAGE PROCESSING 8


Example: Image Negatives

Small
lesion

02/04/2023 9
Image Negative

Original Image Image negative

DIGITAL IMAGE PROCESSING 10


Image Negative

Matlab code : % program for image enhancement using image


negative
clear all
clc
close all
a=imread('clown.png');
[m,n]=size(a);
for i=1:1:m
for j=1:1:n
b(i,j)=255-a(i,j);
end
end
subplot(1,2,1),subimage((a)),title('Original Image');
subplot(1,2,2),subimage((b)),title('Image after
image negative transformation')

DIGITAL IMAGE PROCESSING 11


Image Negative

Output screen:

DIGITAL IMAGE PROCESSING 12


Contrast Stretching
 Contrast basically the difference between the
intensity values of darker and brighter pixels .
 Contrast stretching expands the range of intensity
levels in an image.
 Contrast stretching is done in three ways:
 Multiplying each input pixel intensity value with a constant
scalar.
Example: s=2*r
 Using Histogram Equivalent
 Applying a transform which makes dark portion darker by
assigning slope of < 1 and bright portion brighter by
assigning slope of > 1.
DIGITAL IMAGE PROCESSING 13
Contrast Stretching (Using Transfer Function)

Formulation is given below:


s = l*r ; for 0 <= r <= a
= m(r-a) + v ; for a < r <= b
= n(r-b) + w ; for b < r
DIGITAL IMAGE PROCESSING 14
Contrast Stretching

Original Contrast Enhanced


Image Image
DIGITAL IMAGE PROCESSING 15
Contrast Stretching
Contrast Stretching By Multiplication of each pixel with a
scalar. % program to increase the contrast of an image
x=input('Enter the factor which contrast should be
Matlab code: increased');
a=imread('clown.png');
[m,n]=size(a);
for i=1:1:m
for j=1:1:n
b(i,j)=a(i,j)*x;
end
end
subplot(1,2,1),subimage(a),title('Original Image');
subplot(1,2,2),subimage(b),title('contrast
Image'),xlabel(sprintf('Contrast increased by a
factor of %g',x));

DIGITAL IMAGE PROCESSING 16


Contrast Stretching

Output screen:

DIGITAL IMAGE PROCESSING 17


Contrast Stretching
Contrast Stretching by using threshold function.
Matlab code: % program to increase the contrast of an image
x=input('Enter the factor which contrast should be
increased');
a=imread('clown.png');
[m,n]=size(a);
for i=1:1:m
for j=1:1:n
if(a(i,j)<50)
b(i,j)=a(i,j);%slope of transfer function
between i/p and o/p is 1
elseif (a(i,j)>200)
b(i,j)=a(i,j);
else
b(i,j)=a(i,j)*x;%slope of transfer function
between i/p and o/p is x.Hence contrast of some
particular pixel value range increased
DIGITAL IMAGE PROCESSING 18
Contrast Stretching

Matlab code:
end
end
end
subplot(1,2,1),subimage(a),title('Original Image');
subplot(1,2,2),subimage(b),title('contrast
Image'),xlabel(sprintf('Contrast increased by a factor
of %g in the range 50 to 200',x));

DIGITAL IMAGE PROCESSING 19


Contrast Stretching

Output screen:

DIGITAL IMAGE PROCESSING 20


Contrast Stretching
Contrast Stretching By Histogram Equalisation.
Matlab code : % program to increase the contrast of an image by histogram
equivalent

a=imread('clown.png');
b=histeq(a);
subplot(2,2,1),subimage(a),title('Original Image');
subplot(2,2,2),subimage(b),title('contrast
Image'),xlabel(sprintf('Contrast increased by Histogram
equivalent'));
subplot(2,2,3),imhist(a),title('Histogram of Original Image');
subplot(2,2,4),imhist(b),title('Histogram of Contrast Image');

DIGITAL IMAGE PROCESSING 21


Contrast Stretching

Output screen :

DIGITAL IMAGE PROCESSING 22


Thresholding

 Extreme Contrast Stretching yields Thresholding.

 Thresholded image has maximum contrast as it


has only BLACK & WHITE gray values.

 In Contrast Stretching figure, if l & n slope are


made ZERO & if m slope is increased then we get
Thresholding Transformation

 If r1 = r2, s1 = 0 & s2 = L-1 ,then we get


Thresholding function.
DIGITAL IMAGE PROCESSING 23
Thresholding Function

Expression goes as under:


s = 0; if r = a
s = L – 1 ; if r >a
where, L is
number of gray levels.

DIGITAL IMAGE PROCESSING 24


Thresholding

Original Transformed Image


Image
DIGITAL IMAGE PROCESSING 25
Thresholding

Matlab code:% program for image thresholding


a=imread('pout.tif');
[m,n]=size(a);
for i=1:1:m
for j=1:1:n
if(a(i,j)<125)
b(i,j)=0;%pixel values below 125 are mapped to zero
else
b(i,j)=255;%pixel values equal or above 125 are mapped to 25
end
end
end
subplot(1,2,1),subimage(a),title('Original Image');
subplot(1,2,2),subimage(b),title('threshold Image');

DIGITAL IMAGE PROCESSING 26


Thresholding

Output screen:

DIGITAL IMAGE PROCESSING 27


Brightness Enhancement

Brightness Enhancement is shifting of intensity


values to a higher level.
The darker and the lighter pixels both get their
values shifted by some constant value.
 Example : In x-ray images brightness can be
enhanced to find the darker spots.

DIGITAL IMAGE PROCESSING 28


Brightness Enhancement

Matlab code : % program to increase the brightness of an image


x=input('Enter the factor which brightness should be
increased');
a=imread('clown.png');
[m,n]=size(a);
for i=1:1:m
for j=1:1:n
b(i,j)=a(i,j)+x;
end
end
subplot(1,2,1),subimage(a),title('Original Image');
subplot(1,2,2),subimage(b),title('Brighter
Image'),xlabel(sprintf('Brightness increased by a factor of
%g',x));

DIGITAL IMAGE PROCESSING 29


Brightness Enhancement

Output screen:

DIGITAL IMAGE PROCESSING 30


Log Transformation

 The log transformation is given by the expression


s = c log(1 + r)
where c is a constant and it is assumed that r≥0.
 This transformation maps a narrow range of low-
level grey scale intensities into a wider range of
output values.
 Similarly maps the wide range of high-level grey
scale intensities into a narrow range of high level
output values.
 This transform is used to expand values of dark
pixels and compress values of bright pixels.
DIGITAL IMAGE PROCESSING 31
Logarithmic Transformation Contd…

Original Image Transformed Image

DIGITAL IMAGE PROCESSING 32


Log Transformation

Matlab code: % program for image enhancement using logarithmic


transformation
A=input('Enter the value of constant A');
a=imread('clown.jpg');
a=rgb2gray(a);
[m,n]=size(a);
a=double(a);
for i=1:1:m
for j=1:1:n
b(i,j)=A*log(1+a(i,j));
end
end
figure,subplot(1,2,1),subimage(uint8(a)),title('Original
Image');
subplot(1,2,2),subimage(uint8(b)),title('Image after
logarithmic transformation'),xlabel(sprintf('Constant is
%g',A));
DIGITAL IMAGE PROCESSING 33
Log Transformation

Output screen:

DIGITAL IMAGE PROCESSING 34


Power Law Transformation
Expression for power law transformation is given
by: s = c *(r γ )
s is the output pixels value.
r is the input pixel value.
c and γ are real numbers.
For various values of γ different levels of
enhancements can be obtained.
 This technique is quite commonly called as
Gamma Correction , used in monitor displays.

DIGITAL IMAGE PROCESSING 35


Power Law Transformation
 Different display monitors display images at different
intensities and clarity because every monitor has built-in
gamma correction in it with certain gamma ranges .
 A good monitor automatically corrects all the images
displayed on it for the best contrast to give user the best
experience.
 The difference between the log-transformation function and
the power-law functions is that using the power-law
function a family of possible transformation curves can be
obtained just by varying the γ .

DIGITAL IMAGE PROCESSING 36


Power Law Transformation
A B
A : original
image
For c=1
B : γ =3.0
C : γ =4.0
C D D : γ =5.0

37
Power Law Transformation

Matlab code:
% program for image enhancement using power law
A=input('Enter the value of constant A');
x=input('Enter the value of power x');
a=imread('clown.png');
[m,n]=size(a);
for i=1:1:m
for j=1:1:n
b(i,j)=A*(a(i,j)^x);
end
end
subplot(1,2,1),subimage(a),title('Original Image');
subplot(1,2,2),subimage(b),title('Image after power law
transformation'),xlabel(sprintf('Constant is %g\nPower
is %g',A,x));

DIGITAL IMAGE PROCESSING 38


Power Law Transformation

Output screen:

DIGITAL IMAGE PROCESSING 39


Bit Plane Slicing
► Instead of highlighting intensity ranges,
highlighting the contribution made to the
total image appearance by specific bit might
be desired.
► Imagine that the image is composed of
eight 1-bit planes, ranging from plane 0 for
least significant bit to plane 7 for the most
significant bit.
► Bit-plane slicing reveals that only the five
highest order bits contain visually significant
data. Also, note that plane 7, corresponds
exactly with an image threshold at gray-
level 128.
Bit-plane Slicing

02/04/2023 42
Bit-plane Slicing

02/04/2023 43
Bit-plane Slicing

02/04/2023 44
Histogram Processing

► Histogram Equalization

► Histogram Matching

► Local Histogram Processing

► Using Histogram Statistics for Image Enhancement

02/04/2023 45
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

02/04/2023 46
02/04/2023 47
Histogram Equalization
► Histogram equalization is a method in image
processing of contrast adjustment using
the image's histogram.
► This method usually increases the global contrast of many
images, especially when the usable data of the image is
represented by close contrast values.
► Through this adjustment, the intensities can be better
distributed on the histogram.
► This allows for areas of lower local contrast to gain a higher
contrast.
► Histogram equalization accomplishes this by effectively
spreading out the most frequent intensity values.
Weeks 1 & 2 48
Histogram Equalization

Weeks 1 & 2 49
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.

02/04/2023 50
Histogram Equalization

s  T (r ) 0  r  L 1

a. T(r) is a strictly monotonically increasing function


in the interval 0  r  L -1;
b. 0  T (r )  L -1 for 0  r  L -1.

02/04/2023 51
Histogram Equalization

s  T (r ) 0  r  L 1

a. T(r) is a strictly monotonically increasing function


in the interval 0  r  L -1;
b. 0  T (r )  L -1 for 0  r  L -1.

T (r ) is continuous and differentiable.

ps ( s )ds  pr (r )dr
02/04/2023 52
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 
02/04/2023 53
Example
Suppose that the (continuous) intensity values
in an image have the PDF

 2r
 2
, for 0  r  L-1
pr (r )   ( L  1)
 0, otherwise

Find the transformation function for equalizing


the image histogram.

02/04/2023 54
Example
r
s  T (r )  ( L  1)  pr ( w)dw
0

r 2w
 ( L  1)  2
dw
0 ( L  1)
2
r

L 1

02/04/2023 55
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
02/04/2023 56
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.

02/04/2023 57
Example: Histogram Equalization

0
s0  T (r0 )  7 pr (rj )  7  0.19  1.33 1
j 0
1
s1  T (r1 )  7 pr (rj )  7  (0.19  0.25)  3.08 3
j 0
s2  4.55  5 s3  5.67  6
s4  6.23  6 s5  6.65  7
s6  6.86  7 s7  7.00  7
02/04/2023 58
Example: Histogram Equalization

02/04/2023 59
02/04/2023 60
02/04/2023 61
Question
Is histogram equalization always good?

No

02/04/2023 62
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. p z ( 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

Define a random variable z with the probability


z
G ( z )  ( L  1)  pz (t ) dt  s
0
02/04/2023 63
Histogram Matching
r
s  T ( r )  ( L  1)  pr ( w)dw
0
z
G ( z )  ( L  1)  pz (t )dt  s
0

1
z  G (s)  G 1
T (r )

02/04/2023 64
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 )

02/04/2023 65
Histogram Matching: Example

Assuming continuous intensity values, suppose that an image has


the intensity PDF
 2r
 2
, for 0  r  L -1
pr (r )   ( L  1)
 0, otherwise

Find the transformation function that will produce an image
whose intensity PDF is
 3z 2
 3
, for 0  z  ( L -1)
pz ( z )   ( L  1)
 0, otherwise

02/04/2023 66
Histogram Matching: Example

Find the histogram equalization transformation for the input image


2
r 2w r r
s  T (r )  ( L  1)  pr ( w)dw  ( L  1)  dw 
0 0 ( L  1) 2
L 1

Find the histogram equalization transformation for the specified histogram

z z 3t 2 z3
G ( z )  ( L  1)  pz (t )dt  ( L  1)  3
dt  2
s
0 0 ( L  1) ( L  1)
The transformation function
2 1/3
2 1/3  2 r  2 1/3
z  ( L  1) s   ( L  1)    ( L  1)r 
 L  1 
02/04/2023 67
Histogram Matching: Discrete Cases

► 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 )
02/04/2023 68
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.

02/04/2023 69
Example: Histogram Matching

Obtain the scaled histogram-equalized values,

s0  1, s1  3, s2  5, s3  6, s4  7,
s5  7, s6  7, s7  7.
Compute all the values of the transformation function G,
0
G ( z0 )  7 pz ( z j )  0.00  0
j 0

G ( z1 )  0.00 0 G( z2 )  0.00  0
G ( z3 )  1.05 1 G( z4 )  2.45  2
G ( z5 )  4.55  5 G ( z6 )  5.95  6
G ( z7 )  7.00  7

02/04/2023 70
Example: Histogram Matching

02/04/2023 71
Example: Histogram Matching

Obtain the scaled histogram-equalized values,

s0  1, s1  3, s2  5, s3  6, s4  7,
s5  7, s6  7, s7  7.
Compute all the values of the transformation function G,
0
G ( z0 )  7 pz ( z j )  0.00  0
j 0

G ( z1 )  0.00 0 G( z2 )  0.00  0
G ( z3 )  1.05 1 s0 G( z4 )  2.45  2 s1
G ( z5 )  4.55  5 s2 G ( z6 )  5.95  6 s3
G ( z7 )  7.00  7 s4 s5 s 6 s 7

02/04/2023 72
Example: Histogram Matching

s0  1, s1  3, s2  5, s3  6, s4  7,
s5  7, s6  7, s7  7.

rk
0
1
2
3
4
5
02/04/2023 6 73

7
Example: Histogram Matching
rk  zq
03
1 4
25
36
47
57
67
77
02/04/2023 74
Example: Histogram Matching

02/04/2023 75
Example: Histogram Matching

02/04/2023 76
Example: Histogram Matching

02/04/2023 77
Local Histogram Processing

Define a neighborhood and move its center from pixel to


pixel

At each location, the histogram of the points in the


neighborhood is computed. Either histogram equalization or
histogram specification transformation function is obtained

Map the intensity of the pixel centered in the neighborhood

Move to the next location and repeat the procedure

02/04/2023 78
Local Histogram Processing: Example

02/04/2023 79
Using Histogram Statistics for Image
Enhancement
Average Intensity L 1
1 M 1 N 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
1 M 1 N 1
  u2 (r )   (ri  m)    f ( x, y )  m 
2 2 2
p(ri ) 
i 0
MN x 0 y 0

02/04/2023 80
Using Histogram Statistics for Image
Enhancement

Local average intensity


L 1
msxy   ri psxy (ri )
i 0

sxy denotes a neighborhood

Local variance
L 1
 s2xy   (ri  msxy ) 2 psxy (ri )
i 0

02/04/2023 81
Using Histogram Statistics for Image
Enhancement: Example

 E  f ( x, y ), if msxy  k 0 mG and k1 G   sxy  k 2 G


g ( x, y )  
 f ( x, y ), otherwise

mG : global mean;  G : global standard deviation


k0  0.4; k1  0.02; k2  0.4; E  4

02/04/2023 82
Spatial Filtering

A spatial filter consists of (a) a neighborhood, and (b) a


predefined operation

Linear spatial filtering of an image of size MxN with a filter


of size mxn is given by the expression

a b
g ( x, y )    w(s, t ) f ( x  s, y  t )
s  a t  b

02/04/2023 83
Spatial Filtering

02/04/2023 84
Spatial Correlation

The correlation of a filter w( x, y) of size m  n


with an image f ( x, y ), denoted as w( x, y) f ( x, y)

a b
w( x, y ) f ( x, y )    w( s, t ) f ( x  s, y  t )
s  a t  b

02/04/2023 85
Spatial Convolution

The convolution of a filter w( x, y) of size m  n


with an image f ( x, y ), denoted as w( x, y) f ( x, y)

a b
w( x, y ) f ( x, y )    w(s, t ) f ( x  s, y  t )
s  a t  b

02/04/2023 86
02/04/2023 87
Smoothing Spatial Filters

Smoothing filters are used for blurring and for noise


reduction

Blurring is used in removal of small details and bridging of


small gaps in lines or curves

Smoothing spatial filters include linear filters and nonlinear


filters.

02/04/2023 88
Spatial Smoothing Linear Filters

The general implementation for filtering an M  N image


with a weighted averaging filter of size m  n is given
a b

  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.

02/04/2023 89
Two Smoothing Averaging Filter Masks

02/04/2023 90
Two Smoothing Averaging Filter Masks

A=
3 3 2 3
2 2 7 2
2 3 2 3
2 2 3 3

h = ones(3,3)/9;
0.1111 0.1111 0.1111
0.1111 0.1111 0.1111
0.1111 0.1111 0.1111
02/04/2023 91
I2 = imfilter (A, h);

A=
3 3 2 3
2 2 7 2
2 3 2 3 1 2 2 2
2 3 3 2
2 2 3 3
1 3 3 2
1 2 2 1
0.1111 0.1111 0.1111
0.1111 0.1111 0.1111
0.1111 0.1111 0.1111

02/04/2023 92
02/04/2023 93
Smoothing Filters: Averaging
(cont’d)
► Mask size determines the degree of smoothing (loss of
detail).
original 3x3 5x5 7x7

15x15 25x25
Smoothing Filters: Averaging
(cont’d)
Example: extract largest, brightest objects

15 x 15 averaging image thresholding


Example: Gross Representation of Objects

02/04/2023 96
Order-statistic (Nonlinear) Filters

— Nonlinear

— Based on ordering (ranking) the pixels contained in the


filter mask

— Replacing the value of the center pixel with the value


determined by the ranking result

E.g., median filter, max filter, min filter

02/04/2023 97
Smoothing Filters: Median Filtering (cont’d)
► Replace each pixel by the median in a
neighborhood around the pixel.
Example: Use of Median Filtering for Noise Reduction

02/04/2023 99
Sharpening Spatial Filters

► Foundation

► Laplacian Operator

► Unsharp Masking and Highboost Filtering

► Using First-Order Derivatives for Nonlinear Image


Sharpening — The Gradient

02/04/2023 100
Sharpening Spatial Filters: Foundation

► The first-order derivative of a one-dimensional function f(x)


is the difference

f
 f ( x  1)  f ( x)
x

► The second-order derivative of f(x) as the difference

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

02/04/2023 101
02/04/2023 102
Sharpening Spatial Filters: Laplace Operator

The second-order isotropic derivative operator is the


Laplacian for a function (image) f(x,y)
2 2
2  f  f
 f  2  2
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 )
02/04/2023 103
Sharpening Spatial Filters: Laplace Operator

02/04/2023 104
Sharpening Spatial Filters: Laplace Operator

Image sharpening in the way of using the Laplacian:

g ( x, y )  f ( x, y )  c  2 f ( x, y ) 
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.

02/04/2023 105
02/04/2023 106
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

02/04/2023 107
Unsharp Masking and Highboost Filtering

Let f ( x, y ) denote the blurred image, unsharp masking is


g mask ( x, y)  f ( x, y )  f ( x, y )
Then add a weighted portion of the mask back to the original
g ( x, y )  f ( x, y )  k * g mask ( x, y ) k 0

when k  1, the process is referred to as highboost filtering.

02/04/2023 108
Unsharp Masking: Demo

02/04/2023 109
Unsharp Masking and Highboost Filtering: Example

02/04/2023 110
Image Sharpening based on First-Order Derivatives

For function f ( x, y ), the gradient of f at coordinates ( x, y )


is defined as
 f 
 g x   x 
f  grad( f )      
 g y   f 
 y 

The magnitude of vector f , denoted as M ( x, y )


2 2
Gradient Image M ( x, y)  mag(f )  g x  g y
02/04/2023 111
Image Sharpening based on First-Order Derivatives

The magnitude of vector f , denoted as M ( x, y )


2 2
M ( x, y)  mag(f )  g x  g y

M ( x, y ) | g x |  | g y |

z1 z2 z3
M ( x, y ) | z8  z5 |  | z6  z5 |
z4 z5 z6
z7 z8 z9
02/04/2023 112
Image Sharpening based on First-Order Derivatives

Roberts Cross-gradient Operators


M ( x, y ) | z9  z5 |  | z8  z6 |

Sobel Operators
M ( x, y ) | ( z7  2 z8  z9 )  ( z1  2 z2  z3 ) |
z1 z2 z3  | ( z3  2 z6  z9 )  ( z1  2 z4  z7 ) |
z4 z5 z6
z7 z8 z9
02/04/2023 113
Image Sharpening based on First-Order Derivatives

02/04/2023 114
Example

02/04/2023 115
Example:

Combining
Spatial
Enhancement
Methods

Goal:

Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail

02/04/2023 116
Example:

Combining
Spatial
Enhancement
Methods

Goal:

Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail

02/04/2023 117

You might also like