0% found this document useful (0 votes)
1 views67 pages

Module 3

This document discusses image enhancement techniques in both spatial and frequency domains, including point operations such as clipping, thresholding, and intensity level slicing. It highlights the importance of these techniques in improving image quality for various applications while noting that enhancement does not increase information content but improves visual quality. The document also covers spatial and frequency domain filtering methods, providing examples and applications of image enhancement.
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)
1 views67 pages

Module 3

This document discusses image enhancement techniques in both spatial and frequency domains, including point operations such as clipping, thresholding, and intensity level slicing. It highlights the importance of these techniques in improving image quality for various applications while noting that enhancement does not increase information content but improves visual quality. The document also covers spatial and frequency domain filtering methods, providing examples and applications of image enhancement.
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/ 67

IMAGE PROCESSING TECHNIQUE

MODULE 3
(Image Enhancement in Spatial and Frequency Domain)

Point operations- Clipping and Thresholding, Digital Negative, Intensity


Level Slicing, Bit Extraction, Range Compression.

Spatial Operations- Fundamentals of spatial convolution and


correlation, Spatial averaging and spatial Low pass filtering, Directional
Smoothing, Median Filtering, Unsharp masking and Crispening.

Basics of Filtering in Frequency Domain, Filters, Smoothing


Frequency Domain Filters- Sharpening Frequency Domain Filters

What Is Image Enhancement?


➢Image enhancement techniques improve the quality of image as perceived by
human observer/ machine vision system
➢Image quality can degrade because of poor illumination, improper acquisition
device,coarse quantization noise during acquisition process etc. The recorded
images after acquisition exhibit problems such as.
◦ • Too dark
◦ • Too light
◦ • Not enough contrast
◦ • Noise
➢Thus, enhancement aims to improve visual quality by ‘Cosmetic processing’. A
process of improving the visual quality of any image so that it is more suitable for a
particular application is termed as enhancement
The enhancement process does not increase the information content in the data.
But, it increases the dynamic range of the chosen features so that they can be
detected easily

C. Nikou – Digital Image Processing (E12)

1
Contd..
➢Enhancement is generally one of the preprocessing methods used on an
image so that it is more suitable for further processing.
➢Selection of enhancement technique of an image is depend on the application area to
which that image is used.
➢Another issue related to enhancement is that evaluation of improvement of image
quality by a enhancement process is a very subjective process and is hard to
standardize. An image may be good in one person’s opinion, may not be good in
another person’s opinion

C. Nikou – Digital Image Processing (E12)

Image Enhancement Examples


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

C. Nikou – Digital Image Processing (E12)

2
Image Enhancement Examples (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

C. Nikou – Digital Image Processing (E12)

Image Enhancement Examples (cont…)


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

C. Nikou – Digital Image Processing (E12)

3
Image Enhancement Examples (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

C. Nikou – Digital Image Processing (E12)

Applications of Image Enhancement

1. Deblurring Images: Helps to improve image clarity.


2. Contrast Adjustment: Enhances image detail visibility.
3. Image Brightening: Increases the lightness of an image.
4. Image Smoothing and Sharpening:
• Smoothing filters help reduce and suppress image noise, with common types
including average smoothing, Gaussian smoothing, and adaptive smoothing.
• Sharpening filters enhance edges by eliminating blur.
5. Noise Removal: Noise can be introduced to images during capture, printing, or
transmission. It can be identified in image processing by intensity variance between
neighboring pixels.
6. Grayscale Image Histogram Equalization: Histogram equalization refers to a
transformation where an output image has an approximately uniform distribution of
pixels at each gray level.

C. Nikou – Digital Image Processing (E12)

4
Spatial & Frequency Domains
There are two broad categories of image enhancement
techniques
• Spatial domain Techniques
In spatial (time) domain methods, pixel values are manipulated directly to
get an enhanced image
• Frequency domain techniques
In frequency domain methods, firstly fourier transform of image is taken to
convert image into frequency domain. Then the fourier transform is manipulated and the
modified spectrum is transformed back to spatial domain to view the enhanced image

C. Nikou – Digital Image Processing (E12)

Spatial domain techniques can be subdivided


into:

➢Point Operations (Intensity Transformations):


• In point processing, each pixel in an image is processed independently
of its neighboring pixels.
• The operation performed on each pixel depends only on the intensity
value of that pixel.
• A common example of point processing is image enhancement
techniques like brightness adjustment, contrast stretching, or grayscale
conversion.
• For instance, if you increase the brightness of an image using point
processing, each pixel's intensity value is adjusted uniformly, without
considering the surrounding pixels

C. Nikou – Digital Image Processing (E12)

5
Contd..
➢Neighborhood Processing(Spatial filtering):
• In neighborhood processing, the operation performed on each
pixel depends not only on its own intensity value but also on the
intensity values of its neighboring pixels.
• This means that the processing involves a local area (or
neighborhood) of pixels around each pixel being processed.
• Common operations in neighborhood processing include edge
detection, blurring, and sharpening.

C. Nikou – Digital Image Processing (E12)

Point Operations
➢Point operations are zero memory operations where a given gray level values of
an individual pixel in the input image is mapped into a gray levels of the pixels
in the output image using the transformation T() .
➢In this case T() is referred to as a grey level transformation function or a point
processing operation
➢Point processing operations take the form
s=T(r)
➢where s refers to the processed image pixel value and r refers to the original
image pixel value.

C. Nikou – Digital Image Processing (E12)

6
Point Operations Example:
Negative Images
The negative of an image with intensity levels in the range [0 ,L-1] is
obtained by using the expression
s=L-1-r
Where s is the transformed pixel value
r is the original pixel value
L no of possible gray levels in the image( for a ‘n’ bit
image , the no of possible gray levels L= 2 n , which is in the range
[0,L-1]
➢Reversing the intensity levels of an image in this manner produces
the equivalent of a photographic negative.

C. Nikou – Digital Image Processing (E12)

Negative Images (contd..)

➢Negative images are useful for enhancing white or grey


detail embedded in dark regions of an image especially when
the black areas are dominant in size
➢In spite of the fact that the visual content is the same in both
images, note how much easier it is to analyze the breast tissue in
the negative image in this particular case

Original Negative
Image Image

C. Nikou – Digital Image Processing (E12)

7
Negative Images (contd..)
The negative transformation function can be represented as

C. Nikou – Digital Image Processing (E12)

Negative Images (contd..)

➢ Since maximum pixel value is 255 , we need minimum 8 bit to store one
gray level value. So it can be considered as a 8 bit image

➢ For 8 bit image L=256( no of possible gray levels)

➢ Each pixel value ‘s’ in the transformed image can be calculated using the
equation ( 256-1) -r

C. Nikou – Digital Image Processing (E12)

8
Negative Images (contd..)

C. Nikou – Digital Image Processing (E12)

Tutorial

C. Nikou – Digital Image Processing (E12)

9
Point Operations Example:
Contrast Stretching

C. Nikou – Digital Image Processing (E12)

Example :Contrast stretching

Image after contrast stretching to [0 ,


8-bit image with low contrast. 255] range

C. Nikou – Digital Image Processing (E12)

10
Question
Suppose we have a grayscale image represented by
the following pixel values:

C. Nikou – Digital Image Processing (E12)

Contd..
Calculate the contrast-stretched pixel values using the below formula for
each pixel in the image

When r=20 , s=((255-0)/(240-20)) * (20-20)+0 =0


When r=40 , s=(255/220)*(40-20) +0=24
When r=60, s=
When r=80, s=
When r= 100, s=
When r= 120, s=
When r=140, s=

C. Nikou – Digital Image Processing (E12)

11
Contd..
When r=160, s=
When r=180, s=
When r= 200, s=
When r= 220, s=
When r=240, s=255

C. Nikou – Digital Image Processing (E12)

Point Operations Example:


Clipping
➢A special case of contrast stretching .
➢Here , for contrast stretching , we consider only the values between a
range , say [r1,r2] in the original image.
➢It puts all grey levels below r1 to black(0) and above r2 to white(L-1).
➢ It is used for noise reduction when the input signal is known.
➢The transformation function is

C. Nikou – Digital Image Processing (E12)

12
Question
Suppose we have a grayscale image represented by
the following pixel values:

C. Nikou – Digital Image Processing (E12)

Contd..
Calculate the contrast-stretched pixel values using the below formula for
each pixel in the image

When r=60 , s=((255-0)/(180-60)) * (60-60)+0 =0


When r=80 , s=(255/120)*(80-60) +0=
When r=100, s=
When r=120, s=
When r= 140, s=
When r= 160, s=
When r=180, s=

C. Nikou – Digital Image Processing (E12)

13
Point Operations Example:
Thresholding
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

➢This operation ‘binarizes’ (only two values present) the image.


➢A suitable threshold value ‘t’ is chosen, all the gray levels smaller than
‘t’ are mapped to zero whereas all the grey levels greater than or equal to
‘t’ are mapped to maximum value.
➢It can be considered as a special case of clipping where r1=r2 =t .
➢The transformation function is

C. Nikou – Digital Image Processing (E12)

Point Processing Example:


Thresholding
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

255 r > threshold


s=
0.0 r <= threshold

C. Nikou – Digital Image Processing (E12)

14
Question

C. Nikou – Digital Image Processing (E12)

Point Operations Example:


Intensity Level Slicing
➢Highlighting a specific range of intensities in an image
often is of interest. This process, is called intensity-level
slicing
➢Its applications include enhancing features such as masses
of water in satellite imagery and enhancing flaws in X-ray
images
➢It can be implemented mainly in two ways ;
i. Intensity-level slicing without back ground
ii. Intensity-level slicing with back ground

C. Nikou – Digital Image Processing (E12)

15
Contd..
Intensity-level slicing without back ground :
In this approach we set one value (say, white) for all the values in
the range of interest and another value (say, black) for all other
intensities. This transformation, produces a binary image. The
transformation function is

C. Nikou – Digital Image Processing (E12)

Contd..
Intensity-level slicing with back ground
In this approach, brightens (or darkens) the desired range of intensities
but leaves all other intensity levels in the image unchanged.The
transformation function is

C. Nikou – Digital Image Processing (E12)

16
Contd..

C. Nikou – Digital Image Processing (E12)

Question 1
➢Perform Intensity level slicing with following transformation function

The image is

C. Nikou – Digital Image Processing (E12)

17
Contd..
➢Answer is

C. Nikou – Digital Image Processing (E12)

Question 2
➢Perform Intensity level slicing with following transformation function

The image is

C. Nikou – Digital Image Processing (E12)

18
contd..
➢Answer is

C. Nikou – Digital Image Processing (E12)

University question

C. Nikou – Digital Image Processing (E12)

19
Point Operations Example:
BIT EXTRACTION (BIT PLANE SLICING)
➢Bit-plane slicing is a technique used in image processing to break down
the binary representation of an image pixel intensity values into its
individual bit planes.
➢Each bit plane represents the contribution of a specific bit (either 0 or
1) to the overall pixel intensity

C. Nikou – Digital Image Processing (E12)

Example
➢Consider the image

Since it is 3 bit image, we can slice it in to 3 bit planes

C. Nikou – Digital Image Processing (E12)

20
Contd..
➢Represent each intensity value in binary notation in 3 bits
100 011 101 010
011 110 100 110
010 010 110 101
111 110 100 001

➢Slice it in to three planes


1 0 1 0 0 1 0 1 0 1 1 0
0 1 1 1 1 1 0 1 1 0 0 0
0 0 1 1 1 1 1 0 0 0 0 1
1 1 1 0 1 1 0 0 1 0 0 1

MSB Bit plane Middle bit Plane LSB bit plane


C. Nikou – Digital Image Processing (E12)

Bit-Plane Slicing (Real image


example)

C. Nikou – Digital Image Processing (E12)

21
Significance of bit plane
extraction
➢By analyzing the contribution of each bit plane to the
overall image quality, compression techniques can prioritize
encoding the most significant bit planes while potentially
discarding or compressing the less significant ones. This can
lead to more efficient compression with minimal loss of
image quality
➢We can reconstruct the image from bit plane images using
the equation
N
I (i, j ) =  2n −1 I n (i, j )
n =1

C. Nikou – Digital Image Processing (E12)

University question

C. Nikou – Digital Image Processing (E12)

22
Question
➢Perform bit plane slicing in the following image

➢ANSWER

C. Nikou – Digital Image Processing (E12)

Point Operations Example:


Dynamic Range Compression
➢The equation for dynamic range compression is
s = c * log10(1 + r) :s= is new pixel value
r= original pixel value
c= scaling factor

C. Nikou – Digital Image Processing (E12)

23
Dynamic Range Compression(cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Log functions are particularly useful when the input grey level values may have
an extremely large range of values
In the following example the Fourier transform of an image is put through a log
transform to reveal more detail

s = log(1 + r)

C. Nikou – Digital Image Processing (E12)

Disadvantages of point operations

➢Global Adjustments:
Point operations often apply global adjustments to the entire
image, which may not be suitable for images with diverse content and
lighting conditions.
➢Sensitivity to Outliers:
Some point operations, especially those involving linear
transformations, can be sensitive to outliers or extreme pixel values.
➢Limited Spatial Information:
Point operations do not consider spatial relationships between
pixels, which may limit their effectiveness in certain tasks that require
contextual information.

C. Nikou – Digital Image Processing (E12)

24
Contd..
➢Loss of Information:
Aggressive contrast adjustments or thresholding can lead to a loss
of subtle details or information in the image.

C. Nikou – Digital Image Processing (E12)

Neighbourhood Operations(Spatial filters )


➢In neighborhood processing, the operation performed on each pixel
depends not only on its own intensity value but also on the intensity
values of its neighboring pixels.
➢This means that the processing involves a local area (or
neighborhood) of pixels around each pixel being processed
Origin x
➢ Neighbourhoods are mostly a rectangle
around a central pixel.

(x, y)
Neighbourhood

y Image f (x, y)
C. Nikou – Digital Image Processing (E12)

25
Simple Neighbourhood
Operations
Some simple neighbourhood operations include:
◦ Averge:Set pixel value to the average of Neighbourhood
◦ Min: Set the pixel value to the minimum in the
neighbourhood
◦ Max: Set the pixel value to the maximum in the
neighbourhood
◦ Median: The median value of a set of numbers is the
midpoint value in that set (e.g. from the set [1, 7, 15, 18,
24] 15 is the median). Sometimes the median works
better than the average

C. Nikou – Digital Image Processing (E12)

Neighborhood operations in
spatial domain are mainly
implemented using the concept of
filters

C. Nikou – Digital Image Processing (E12)

26
What is a Spatial Filter?
➢ A spatial filter consists of
(1) a neighborhood, (typically a small rectangle)
(2) a predefined operation that is performed on the image pixels encompassed by the
neighborhood.

➢ Filtering creates a new pixel with coordinates equal to


the coordinates of the center of the neighborhood, and
whose value is the result of the filtering operation.
➢ A processed (filtered) image is generated as the center
of the filter visits each pixel in the input image

C. Nikou – Digital Image Processing (E12)

Contd..
➢ If the operation performed on the image pixels is
linear, then the filter is called a linear spatial filter.
Otherwise, the filter is nonlinear

C. Nikou – Digital Image Processing (E12)

27
Filter Parameters
❖ Many possible filter parameters (size, weights,
function, etc)
• Filter size (size of neighbourhood):

3x3, 5x5, 7x7, …,21x21,..


• Filter shape: not necessarily square. Can be
rectangle, circle, etc
• Filter weights: May apply unequal weighting to
different pixels
• Filters function: can be linear (a weighted
summation) or nonlinear
C. Nikou – Digital Image Processing (E12)

LINEAR SPATIAL FILTERING

C. Nikou – Digital Image Processing (E12)

28
Mechanics of linear spatial filtering

➢In linear spatial filtering, the center of the filtering mask


(also known as the kernel or window) is typically aligned
with each pixel value in the image. This means that the
operation is applied centered on each pixel in the image
➢A linear spatial filter Produces the new pixel values as the
linear combination of filter values and image pixel values.
➢ie, At any point (x, y) in the image, the response,g(x,y) is
the sum of products of the filter coefficients and the image
pixels encompassed by the filter

C. Nikou – Digital Image Processing (E12)

The Linear Spatial Filtering Process


Origin y
a b c r s t
d
g
e
h
f
i
* u
x
v
y
w
z
Original Image Filter
Simple 3*3 Pixels
e 3*3 Filter
Neighbourhood
eprocessed = v*e +
r*a + s*b + t*c +
u*d + w*f +
x Image f (x, y) x*g + y*h + z*i

The above is repeated for every pixel in the


original image C.toNikougenerate the filtered image
– Digital Image Processing (E12)

29
C. Nikou – Digital Image Processing (E12)

Linear Spatial Filtering: Equation


Form
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

For a mask of size m*n we assume that and

.
The equation for linear Spatial filtering can be
written as

Where a=(m-1)/2 and b=(n-1)/2


where x and y are varied so that each pixel in w visits every pixel in f.

C. Nikou – Digital Image Processing (E12)

30
Linear spatial filtering
(contd..)
➢The steps for performing Linear spatial
filtering can be summarized as below;
i. Generate proper filter mask(explained in next slide)
ii. Compute new pixel values corresponding to each image
pixel as the sum of product of filter coefficient and image
pixels values by placing the center of the filter aligned
with the corresponding image pixel
iii. While applying operation on image, the boundary pixels
may have parts of the filter function that do not overlap.
To avoid this , before Applying filter the images should be
properly paddedat the boundaries
C. Nikou – Digital Image Processing (E12)

Contd..
➢Padding can be performed in several ways
(i) Zero padding: In zero padding, extra pixels are
added around the input image, and these pixels are typically
assigned a value of zero.

C. Nikou – Digital Image Processing (E12)

31
Contd..
(ii)Pixel Replication: Replicate padding involves copying the border
pixels of the input image to create the padding.

C. Nikou – Digital Image Processing (E12)

Contd..
iii) Mirror Padding: Mirror padding, also known as reflective padding,
mirrors the pixels of the input image along the edges to create padding

C. Nikou – Digital Image Processing (E12)

32
Generating Spatial Filter Masks
➢Generating an linear spatial filter of size m*n requires that we
specify mn mask coefficients.
➢In turn, these coefficients are selected based on what the filter is
supposed to do, keeping in mind that all we can do with linear
filtering is to implement a sum of products.
➢For example, suppose that we want to replace the pixels in an
image by the average intensity of a neighborhood centered on
those pixels.The average value at any location (x, y) in the image
is the sum of the nine intensity values in the neighborhood
centered on (x, y) divided by 9.Therefore a linear filtering
operation with a mask whose coefficients are 1/ 9 implements the
desired averaging

C. Nikou – Digital Image Processing (E12)

SMOOTHING
SPATIAL FILTERS

C. Nikou – Digital Image Processing (E12)

33
Smoothing Linear Spatial Filters/Low
Pass Filters/Averaging filters
➢Smoothing filters are used for blurring and for noise reduction
➢Smoothing Linear Spatial Filters Simply take the average all of the
pixels in a neighbourhood around a central value.so these filters are
known as averaging filters.
➢By replacing the value of every pixel in an image by the average of the
intensity levels in the neighborhood defined by the filter mask, this
process results in an image with reduced “sharp” transitions in
intensities. Because random noise typically consists of sharp transitions
in intensity levels, so we can say that smoothing reduces noise
➢However, edges (which almost always are desirable features of an
image) also are characterized by sharp intensity transitions, so
averaging filters have the undesirable side effect that they blur edges

C. Nikou – Digital Image Processing (E12)

Contd..
➢Another use of averaging filters is in the reduction of “irrelevant” detail in
an image. By “irrelevant” we mean pixel regions that are small with respect
to the size of the filter mask
The image at the top left
is an original image of
size 500*500 pixels
The subsequent images
show the image after
filtering with an averaging
filter of increasing sizes
◦ 3, 5, 9, 15 and 35

Notice how detail begins


to disappear

C. Nikou – Digital Image Processing (E12)

34
Contd..
Types of averaging Filter masks

(i) Simple averaging Filter/box filter


➢ Here all pixels in the neighborhood have given equal
weightage.
➢ Therefore filtering mask with size 3*3 can be generated as

1/ 1/ 1/
9 9 9
1/ 1/ 1/
9 9 9
1/ 1/ 1/
9 9 9

C. Nikou – Digital Image Processing (E12)

Contd..
➢ To make it computationally efficient, The filtering mask can
be represented as

➢Here instead of being 1/9, the coefficients of the filter can


be all 1’s. At the end of the filtering process the entire
image is divided by 9.
➢A spatial averaging filter in which all coefficients are equal
sometimes is called a box filter

C. Nikou – Digital Image Processing (E12)

35
Contd..
) Weighted averaging Filter
(ii

➢More effective smoothing filters can be generated by allowing


different pixels in the neighbourhood different weights in the
averaging function
➢ Here Pixels closer to the
central pixel are more
important.
➢Here 16 is the sum of coefficients
in the filter mask
Weighted
averaging filter
C. Nikou – Digital Image Processing (E12)

Contd..
(iii) Directional Smoothing
➢To prevent edges from blurring, while smoothing, Directional
smoothing can be used
➢Here spatial averages are computed in several
directions.

➢Take the result from the direction, giving smallest changes


before and after filtering.
➢This restricts smoothing along edge directions
C. Nikou – Digital Image Processing (E12)

36
Example
➢ Consider the following image segment.perform spatial
averaging using a 3*3 mask

C. Nikou – Digital Image Processing (E12)

University Question

C. Nikou – Digital Image Processing (E12)

37
Order-Statistic (Nonlinear)
Smoothing Filters
➢Order-statistic filters are nonlinear spatial filters whose response is
based on ordering (ranking) the pixels contained in the image area
encompassed by the filter, and then replacing the value of the center
pixel with the value determined by the ranking result
➢Examples are
(i) Median filter
(ii)Min filter
(iii) Max filter

C. Nikou – Digital Image Processing (E12)

Median filters
➢It replaces the value of a pixel by the median of the intensity values in
the neighborhood of that pixel (the original value of the pixel is included
in the computation of the median).
➢Median filters are quite popular because, for certain types of random
noise, they provide excellent noise-reduction capabilities, with
considerably less blurring than linear smoothing filters of similar size.
Median filters are particularly effective in the presence of impulse noise,
also called salt-and-pepper noise because of its appearance as white
and black dots superimposed on an image

C. Nikou – Digital Image Processing (E12)

38
Contd..
➢The median, of a set of values is such that half the values in the set are
less than or equal to the median value and half are greater than or equal
to the median value.
➢ In order to perform median filtering at a point in an image, we first sort
the values of the pixel in the neighborhood, determine their median, and
assign that value to the corresponding pixel in the filtered image

C. Nikou – Digital Image Processing (E12)

Contd..
➢ In general, median filtering is much better suited than averaging
for the removal of salt-and-pepper noise.This is illustrated in the figure

C. Nikou – Digital Image Processing (E12)

39
Min and Max Filters
➢MIN filter replaces the value of a pixel by the
minimum of the intensity values in the
neighborhood of that pixel

➢MAX filter replaces the value of a pixel by the


maximum of the intensity values in the
neighborhood of that pixel

C. Nikou – Digital Image Processing (E12)

C. Nikou – Digital Image Processing (E12)

40
Tutorial
➢ Consider the following image. Apply the following smoothing filters of size 3*3
at image position (2,2) and find the resultant pixel value

(i) Averaging
(ii)weighted Averaging
(iii)Median filter
(iv)Min filter
(v)Max filter

C. Nikou – Digital Image Processing (E12)

Correlation and Convolution


➢The Mathematical operation that stands as the basis of
linear spatial filtering is correlation.
➢Correlation is the process of moving a filter mask over the
image and computing the sum of products at each location.
➢ The mechanics of convolution are the same, except that the
filter is first rotated by 180°.
➢It should be clear that, if the filter mask is symmetric,
correlation and convolution yield the same result(A
symmetric matrix is a matrix that is equal to its transpose)

C. Nikou – Digital Image Processing (E12)

41
Contd..
➢ Therefore ,Linear Spatial filtering can be
considered as correlation or convolution operation
of filter mask on every pixel in the image.
➢While applying correlation or convolution
operation on image, the boundary pixels may have
parts of the filter function that do not overlap. To
avoid this , before Applying filter the images should
be properly padded with zeros at the boundaries.

C. Nikou – Digital Image Processing (E12)

Convolution and Correlation of 1D Signal

C. Nikou – Digital Image Processing (E12)

42
Convolution and Correlation of 2D Signal

C. Nikou – Digital Image Processing (E12)

Sharpening Spatial Filters

C. Nikou – Digital Image Processing (E12)

43
Sharpening Spatial Filters
➢The principal objective of sharpening is to highlight
transitions in intensity .
➢we saw that image blurring could be accomplished in the
spatial domain by pixel averaging in a neighborhood. Because
averaging is analogous to integration, it is logical to conclude
that sharpening can be accomplished by spatial differentiation.
➢ie, The characteristic of differentiation operation is used by
Sharpening spatial filters.
➢Main application is highlighting the edges of an image
➢Known as High pass filters

C. Nikou – Digital Image Processing (E12)

Unsharp masking and Crispening

➢A process that has been used for many years by the printing
and publishing industry to sharpen images consists of
subtracting an unsharp (smoothed) version of an image from the
original image.This process, called unsharp masking.
➢This is also known as edge crispening process
➢ It consists of the following steps:
1. Blur the original image.
2. Subtract the blurred image from the original (the resulting
difference is called the mask.)
3. Add the mask to the original.

C. Nikou – Digital Image Processing (E12)

44
Mathematical Expression of unsharp
masking

C. Nikou – Digital Image Processing (E12)

Illustration of mechanics of
unsharp masking

C. Nikou – Digital Image Processing (E12)

45
Example

C. Nikou – Digital Image Processing (E12)

C. Nikou – Digital Image Processing (E12)

46
Image Enhancement in
Frequency domain
Convolution in the spatial domain is equivalent to multiplication in
frequency domain

C. Nikou – Digital Image Processing (E12)

Relationship between spatial


domain and frequency domain
➢We know that to convert a signal from spatial domain to frequency domain ,we are
using Fourier Transform .The equation is

➢We begin by observing in Eq. (4.5-15) that each term of (u, v) contains all values of
(x, y), modified by the values of the exponential terms. Thus, with the exception of
trivial cases, it usually is impossible to make direct associations between specific
components of an image and its transform.

C. Nikou – Digital Image Processing (E12)

47
Contd..
➢However, some general statements can be made about the relationship
between the frequency components of the Fourier transform and spatial
features of an image.
➢ For instance, because frequency is directly related to spatial rates of
change, it is not difficult intuitively to associate frequencies in the
Fourier transform with patterns of intensity variations in an image.
➢The slowest varying frequency component(u=0,v=0) is proportional to
the average intensity of an image.
➢As we move away from the origin of the transform, the low frequencies
correspond to the slowly varying intensity components of an image. In
an image of a room, for example, these might correspond to smooth
intensity variations on the walls and floor.

C. Nikou – Digital Image Processing (E12)

An example for representing image in


spatial domain and frequency domain

C. Nikou – Digital Image Processing (E12)

48
Contd..
➢As we move further away from the origin, the higher frequencies begin
to correspond to faster and faster intensity changes in the image. These
are the edges of objects and other components of an image characterized
by abrupt changes in intensity.

In frequency domain , low frequency component


corresponds to areas of low intensity change(smooth
areas) and high frequency component corresponds to
areas of sharp intensity change(edges)

C. Nikou – Digital Image Processing (E12)

Frequency Domain Filtering


Fundamentals
➢Filtering in the frequency domain consists of modifying the
Fourier transform of an image and then computing the
inverse transform to obtain the processed result

C. Nikou – Digital Image Processing (E12)

49
The basic steps of image enhancement in
frequency domain are
Functions F, H, and
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

1. Compute F(u,v), the DFT of the image f(x,y) g are arrays of


2. Multiply F(u,v) by a filter function H(u,v) size the same as the
input image
3. Compute the inverse DFT of the result

Elementwise
Multiplication

C. Nikou – Digital Image Processing (E12)

The basic steps can be


expanded as
Suppose we have an input image f(x,y) with size M* N and filter
H(u,v) of size M*N
Step 1:.Pad the input image f(x, y) with zeros so that the size of
image becomes P*Q . Typically the value of P & Q are taken as
P=2M and Q=2N. The new padded image is represented as
fp(x,y).
Step 2:Multiply fp(x,y) by ( -1) x + y to center its transform. By
multiplying the image by (-1) (x+y), you effectively shift the
frequency spectrum so that F(0,0) is shifted to( M/2,N/2) position
and the low frequencies are at the center and high frequencies are
at the corners

C. Nikou – Digital Image Processing (E12)

50
Contd..
Step 3 : Compute the DFT of the image fp(x,y) .Suppose the
DFT is represented as F(u,v)
Step4:Generate a real, symmetric filter function, H(u, v), of
size P* Q with center at coordinates (P /2,Q /2).
Step 5:Form the product G(u,v) by multiplying F (u,v) with
H(u,v) using array multiplication(The basic theory is that the
product of two functions in the frequency domain implies
convolution in the spatial domain).

C. Nikou – Digital Image Processing (E12)

Contd..
Step 6:Find the inverse transform of the real part of G(u,v)
and Multiply the result by (-1)x+y , so that we can obtain the
processed image in spatial domain.

Step 7: Obtain the final processed result by extracting M*N


region from the image

C. Nikou – Digital Image Processing (E12)

51
Correspondence Between Filtering in the
Spatial and Frequency Domains

➢Given a spatial filter, we obtain its frequency domain


representation by taking the forward Fourier transform of the
spatial filter.
➢Ie, if we now a spatial filter value h(x,y), corresponding
frequency domain filter H(u,v) is obtained by taking the fourier
transform of h(x,y)
➢Here the issue is that spatial filters always smaller than image
is given and we have to obtain its full-size frequency domain
representation.

C. Nikou – Digital Image Processing (E12)

Image Enhancement in the


frequency domain
◦Image smoothing in frequency domain
◦Image sharpening in frequency domain

C. Nikou – Digital Image Processing (E12)

52
Image Smoothing Using Frequency
Domain Filters

C. Nikou – Digital Image Processing (E12)

Image Smoothing in frequency domain


➢ In frequency domain representation of an image , low frequency
component corresponds to areas of low intensity change(smooth
areas) and high frequency component corresponds to areas of
sharp intensity change(edges ).

➢Therefore smoothing an image in frequency domain requires to


filter low frequency component from the image while dropping the
high frequency component.
So smoothing filters are generally known as low pass
filters

C. Nikou – Digital Image Processing (E12)

53
Smoothing Frequency Domain Filters
➢Here filters are constructed in such a way that
while multiplying the filter with frequency domain
images, we should get the desired result
➢We consider three types of lowpass filters in
frequency domain:
(i)Ideal lowpass filter
(ii) Butterworth lowpass filters
(iii)Gaussian lowpass filters

C. Nikou – Digital Image Processing (E12)

Ideal Low Pass Filter


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

A 2-D lowpass filter that passes without attenuation all frequencies within a
circle of radius D0 from the origin and “cuts off” all frequencies outside this
circle is called an ideal lowpass filter (ILPF). D0 is the cut off frequency

1 if D(u, v)  D0
H (u, v) = 
0 if D(u, v)  D0

D(u, v) = [(u − M / 2) 2 + (v − N / 2) 2 ]1/ 2


➢Since image is centred at M/2,N/2 , the filter should also centered at
M/2,N/2(ie, distance is calculated with respect to M/2,N/2 )

C. Nikou – Digital Image Processing (E12)

54
Ideal Low Pass Filter (cont…)
The visual representation for the ideal low pass filter can be given as:

C. Nikou – Digital Image Processing (E12)

Ideal Low Pass Filter (cont…)


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Above we show an image, it’s Fourier spectrum and a series of ideal low pass
filters of radius 5, 15, 30, 80 and 230 superimposed on top of it

C. Nikou – Digital Image Processing (E12)

55
Ideal Low Pass Filter (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Result of filtering
Original with ideal low pass
image filter of radius 5

Result of filtering Result of filtering


with ideal low pass with ideal low pass
filter of radius 15 filter of radius 30

Result of filtering
Result of filtering
with ideal low pass
with ideal low pass
filter of radius 230
filter of radius 80

C. Nikou – Digital Image Processing (E12)

Butterworth Lowpass Filters


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

The transfer function of a Butterworth lowpass filter of order n with cutoff


frequency at distance D0 from the origin is defined as:

1
H (u, v) =
1 + [ D(u, v) / D0 ]2 n

C. Nikou – Digital Image Processing (E12)

56
Butterworth Lowpass Filter
(cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Result of filtering
Original with Butterworth
image filter of order 2 and
cutoff radius 5

Result of filtering with Result of filtering


Butterworth filter of with Butterworth
order 2 and cutoff filter of order 2 and
radius 15 cutoff radius 30

Result of filtering
Result of filtering with
with Butterworth
Butterworth filter of
filter of order 2 and
order 2 and cutoff
cutoff radius 230
radius 80

C. Nikou – Digital Image Processing (E12)

Gaussian Lowpass Filters


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

The transfer function of a Gaussian lowpass filter is defined as:

− D 2 ( u ,v ) / 2 D0 2
H (u, v) = e

C. Nikou – Digital Image Processing (E12)

57
Gaussian Lowpass Filters
(cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Result of filtering
Original with Gaussian filter
image with cutoff radius 5

Result of filtering Result of filtering


with Gaussian with Gaussian filter
filter with cutoff with cutoff radius 30
radius 15

Result of filtering Result of filtering


with Gaussian with Gaussian filter
filter with cutoff with cutoff radius
radius 85 230

C. Nikou – Digital Image Processing (E12)

Lowpass Filters Compared


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Result of filtering
Result of filtering
with Butterworth
with ideal low pass
filter of order 2
filter of radius 15
and cutoff radius
15

Result of filtering
with Gaussian
filter with cutoff
radius 15

C. Nikou – Digital Image Processing (E12)

58
Lowpass Filtering Examples
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

A low pass Gaussian filter is used to connect broken


text

C. Nikou – Digital Image Processing (E12)

Lowpass Filtering Examples


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

C. Nikou – Digital Image Processing (E12)

59
Lowpass Filtering Examples
(cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Different lowpass Gaussian filters used to remove blemishes in a


photograph

C. Nikou – Digital Image Processing (E12)

Lowpass Filtering Examples


(cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

C. Nikou – Digital Image Processing (E12)

60
COMPARISON BETWEEN LOW PASS FILTERS

C. Nikou – Digital Image Processing (E12)

Image Sharpening Using


Frequency Domain Filters

C. Nikou – Digital Image Processing (E12)

61
Sharpening in the Frequency Domain
➢In frequency domain representation of an image , low
frequency component corresponds to areas of low intensity
change(smooth areas) and high frequency component
corresponds to areas of sharp intensity change(edges ).

➢Therefore sharpening an image in frequency domain


requires to filter high frequency component from the image
while dropping the low frequency component.
So smoothing filters are generally known as high
pass filters

C. Nikou – Digital Image Processing (E12)

Contd..
➢High pass frequencies are precisely the reverse of
low pass filters, so:
Hhp(u, v) = 1 – Hlp(u, v)

C. Nikou – Digital Image Processing (E12)

62
Sharpening Frequency Domain
Filters
➢Here filters are constructed in such a way that
while multiplying the filter with frequency domain
images, we should get the desired result
➢We consider three types of highpass filters in
frequency domain:
(i)Ideal highpass filter
(ii) Butterworth highpass filters
(iii)Gaussian highpass filters

C. Nikou – Digital Image Processing (E12)

Ideal High Pass Filters


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

The ideal high pass filter is given as:


0 if D(u, v)  D0
H (u, v) = 
1 if D(u, v)  D0
where D0 is the cut off distance as before

C. Nikou – Digital Image Processing (E12)

63
Ideal High Pass Filters (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Results of ideal Results of ideal Results of ideal


high pass filtering high pass filtering high pass filtering
with D0 = 15 with D0 = 30 with D0 = 80
C. Nikou – Digital Image Processing (E12)

Butterworth High Pass Filters


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

The Butterworth high pass filter is given as:


1
H (u, v) =
1 + [ D0 / D(u, v)]2 n
where n is the order and D0 is the cut off distance as before

C. Nikou – Digital Image Processing (E12)

64
Butterworth High Pass Filters (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Results of Results of
Butterworth Butterworth
high pass high pass
filtering of filtering of
order 2 with order 2 with
D0 = 15 D0 = 80

Results of Butterworth high pass


filtering of order 2 with D0 = 30

C. Nikou – Digital Image Processing (E12)

Gaussian High Pass Filters


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

The Gaussian high pass filter is given as:


− D 2 ( u ,v ) / 2 D0 2
H (u, v) = 1 − e
where D0 is the cut off distance as before

C. Nikou – Digital Image Processing (E12)

65
Gaussian High Pass Filters
(cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Results of Results of
Gaussian Gaussian
high pass high pass
filtering with filtering with
D0 = 15 D0 = 80

Results of Gaussian high pass


filtering with D0 = 30

C. Nikou – Digital Image Processing (E12)

Highpass Filter Comparison


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Results of ideal Results of Butterworth Results of Gaussian


high pass filtering high pass filtering of order high pass filtering with
with D0 = 15 2 with D0 = 15 D0 = 15
C. Nikou – Digital Image Processing (E12)

66
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

High frequency
emphasis result Original image

C. Nikou – Digital Image Processing (E12)


Highpass Filtering Example

equalisation Highpass filtering result


After histogram

67

You might also like