Download as pdf or txt
Download as pdf or txt
You are on page 1of 33

MODULE-2 Digital Image Processing Quick Reference [17EC72]

SYLLABUS:

Spatial Domain: Some Basic Intensity Transformation Functions, Histogram Processing,


Fundamentals of Spatial Filtering, Smoothing Spatial Filters, Sharpening Spatial Filters
[Text: Chapter 3: Sections 3.2 to 3.6]

Frequency Domain: Preliminary Concepts, The Discrete Fourier Transform (DFT) of


Two Variables, Properties of the 2-D DFT, Filtering in the Frequency Domain, Image
Smoothing and Image Sharpening Using Frequency Domain Filters, Selective Filtering.
[Text: Chapter 4: Sections 4.2, 4.5 to 4.10]

RBT: L1, L2, L3

TEXT, REFERENCE & ADDITIONAL REFERENCE BOOKS:

BOOK TITLE/AUTHORS/PUBLICATION /Web links/Channel

Digital Image Processing- Rafel C Gonzalez and Richard E. Woods,


T-1.
PHI 3rd Edition 2010.

Digital Image Processing- S.Jayaraman, S. Esakkirajan,


AR-1
T.Veerakumar, Tata McGraw Hill 2014.

Fundamentals of Digital Image Processing-A. K. Jain, Pearson


AR-2
2004.

WR-1 https://nptel.ac.in/courses/117/105/117105135/

WR-2 https://www.youtube.com/watch?v=DSGHkvQBMbs

Channel https://www.youtube.com/channel/UCD0mXLuJqtvPxBqRI1r66cg/videos

Dr. Ganesh V Bhat Dept. of ECE CEC Page 1


MODULE-2 Digital Image Processing Quick Reference [17EC72]

MODULE -2
IMAGE ENHANCEMENT IN SPATIAL DOMAIN

2.1 What is meant by Spatial domain methods in IP?

Spatial domain refers to the image plane itself, and approaches in this category are
based on direct manipulation of pixels in an image. Frequency domain processing
techniques are based on modifying the Fourier transform of the image.
Suppose we have a digital image which can be represented by a two dimensional
random field f(x,y) . Spatial domain processes will be denoted by the expression

g ( x, y) = T  f ( x, y) or s = T (r )

The value of pixels, before and after processing, will be denoted by r and s, respectively.
Where f(x, y) is the input to the image, g(x, y) is the processed image and T is an
operator on f.

The operator T applied on f(x,y) may be defined over:


(i) A single pixel (x.y). In this case T is a grey level transformation (or mapping)
function.
(ii) Some neighbourhood of (x,y).
(iii) T may operate to a set of input images instead of a single image.

2.2 What is a Histogram, how is it obtained? What is the difference


between a histogram and a bar chart?
A histogram is an approximate representation of the distribution of numerical data. To
construct a histogram, the first step is to "bin" (or "bucket") the range of values—that
is, divide the entire range of values into a series of intervals—and then count how many
values fall into each interval. The bins are usually specified as consecutive, non-
overlapping intervals of a variable. The bins (intervals) must be adjacent, and are often
(but not required to be) of equal size.
Suppose we have a digital image of size N  N with grey levels in the range [0, L − 1] . The
n
histogram of the image is defined as the following discrete function: p(rk ) = k , Where,
n
rk is the kth grey level, k = 0,1,, L −1, n k is the number of pixels in the image with grey
level rk and n is the total number of pixels in the image.The histogram represents the
frequency of occurrence of the various grey levels in the image.

Dr. Ganesh V Bhat Dept. of ECE CEC Page 2


MODULE-2 Digital Image Processing Quick Reference [17EC72]

Histograms give a rough sense of the density of the underlying distribution of the data,
and often for density estimation: estimating the probability density function of the
underlying variable. The total area of a histogram used for probability density is always
normalized. Histograms are sometimes confused with bar charts. A histogram is used
for continuous data, where the bins represent ranges of data, while a bar chart is a plot
of categorical variables. Some authors recommend that bar charts have gaps between
the rectangles to clarify the distinction
2.3 What is the importance of image enhancement in image processing?
List out any three Image Enhancement
Techniques?
➢ Contrast Stretching: The result of the
transformation shown in the figure below is to
produce an image of higher contrast than the
original, by darkening the levels below m and
brightening the levels above m in the original
image. This technique is known as contrast
stretching.

➢ Thresholding: If g(x, y) is a thresholded version of f(x,


y) at some global threshold T,
then the following can be applied:
Why do we need a binary image?
A few reasons are, for example, that we may be interested
in separating an image into foreground and background;
that the image is to be printed with a black and white
printer
➢ Filtering or masking: One of the principal approaches
is based on the use of so-called masks (also referred to as
filters). So, a mask/filter: is a small (say 3X3) 2-D array,
such as the one shown in the figure, in which the values of
the mask coefficients determine the nature of the process, such as image sharpening.
Enhancement techniques based on this type of approach often are referred to as mask
processing or filtering.

Dr. Ganesh V Bhat Dept. of ECE CEC Page 3


MODULE-2 Digital Image Processing Quick Reference [17EC72]

2.4 Give some commonly used Grey Level Transformations and their
applications?
Grey level transforms are image enhancement methods that are based only on the
intensity of single pixels. Given below are the three basic types of functions used
frequently for image enhancement. The three
basic types of functions used frequently for image
enhancement:
1. Linear Functions:
• Negative Transformation
• Identity Transformation
2. Logarithmic Functions:
• Log Transformation
• Inverse-log Transformation
3. Power-Law Functions:
• nth power transformation
• nth root transformation

Discussion and Uses:

➢ Identity Function
• Output intensities are identical to input intensities
• This function doesn’t have an effect on an image, it was included in the graph
only for completeness
• Its expression: s=r
➢ Negative Transformation
• The negative of a digital image is obtained by the transformation function
s = T (r ) = L − 1 − r shown in the following figure, where L is the number of grey
levels. The idea is that the intensity of the output image decreases as the
intensity of the input increases. This is useful in numerous applications such as
displaying medical images.
➢ Log Transformation
The general form of the log transformation: s = c log(1 + r ) Where c is a constant,
and r ≥ 0
• Log curve maps a narrow range of low grey-level values in the input image
into a wider range of the output levels.
• Used to expand the values of dark pixels in an image while compressing the
higher-level values.
• It compresses the dynamic range of images with large variations in pixel
values.
➢ Inverse Logarithm Transformation
• Do opposite to the log transformations
• Used to expand the values of high pixels in an image while compressing the
darker-level values.
Dr. Ganesh V Bhat Dept. of ECE CEC Page 4
MODULE-2 Digital Image Processing Quick Reference [17EC72]

➢ Power-law transformations
• Power-law transformations have the
basic form of: s = c.rᵞ Where c and γ
are positive constants Different
transformation curves are obtained by
varying γ (gamma)
Variety of devices used for image capture,
printing and display respond according to
a power law. The process used to correct
these power-law response phenomena is
called gamma correction.
For example, cathode ray tube (CRT)
devices have an intensity-to-voltage
response that is a power function, with
exponents varying from approximately 1.8
to 2.5. With reference to the curve for
γ=2.5, display systems would tend to
produce images that are darker than intended. In addition
to gamma correction, power-law transformations are
useful for general-purpose contrast manipulation.

2.5 Explain some of the Piecewise-Linear Transformation Functions


used in image processing
• Principle Advantage: Some important transformations can be formulated only as a
piecewise function.
• Principle Disadvantage: Their specification requires more user input that previous
transformations
• Types of Piecewise transformations are:
• Contrast Stretching
• Grey-level Slicing
• Bit-plane slicing
Contrast Stretching
Low contrast images occur often due to poor or
non-uniform lighting conditions, or due to
nonlinearity or due to small dynamic range of the
imaging sensor. Contrast-stretching
transformation, which is used to enhance the low
contrast images. Figure shows the contrast
stretching, obtained by setting (r1, s1) = (rmin, 0)
and (r2, s2) = (rmax,L-1) where rmin and rmax denote
the minimum and maximum grey levels in the
image, respectively. Thus, the transformation
function stretched the levels linearly from their
original range to the full range [0, L-1].

Dr. Ganesh V Bhat Dept. of ECE CEC Page 5


MODULE-2 Digital Image Processing Quick Reference [17EC72]

• If r1 = s1 and r2 = s2, the transformation is a linear function that


produces no changes in gray levels.
• If r1 = r2, s1 = 0 and s2 = L-1, the transformation becomes a
thresholding function that creates a binary image
• Intermediate values of (r1, s1) and (r2, s2) produce various
degrees of spread in the gray levels of the output image, thus
affecting its contrast. In general, r1 ≤ r2 and s1 ≤ s2 is assumed,
so the function is always increasing

➢ Gray-level Slicing
This technique is used to highlight a specific range of grey levels in a given image. It
can be implemented in several ways, but the two basic themes are:
• One approach is to display a high value for all grey levels in the range of interest
and a low value for all other
gray levels. The transformation,
shown to the left in the below
produces a binary image.
• The second approach, based on
the transformation shown to
the right in the given Fig,
brightens the desired range of
gray levels but preserves gray
levels unchanged.

➢ Bit-plane Slicing
Pixels are digital numbers, each one composed of 8 bits. Plane 0 contains the least
significant bit and plane 7 contains the most significant bit. Instead of highlighting
gray-level range, we could highlight the contribution made by each bit
This method is useful and used in image compression as Most significant bits contain
the majority of visually significant data

Dr. Ganesh V Bhat Dept. of ECE CEC Page 6


MODULE-2 Digital Image Processing Quick Reference [17EC72]

2.6 List out some of the Histogram based image enhancement


techniques used in digital image processing.
By processing (modifying) the histogram of an image we can create a new image with
specific desired properties.
• Images whose pixels occupy the entire range of intensity levels and tend to be
distributed uniformly will have an appearance of high contrast
• It is possible to develop a transformation function that can automatically achieve
this effect, based on the histogram of the input image.

Types of processing:

• Histogram equalization
• Histogram matching (specification)
• Local enhancement
➢ Histogram equalisation (Automatic)
Consider transform of the form s = T (r ) 0≤ r ≤ 1 ; We
assume that T(r) satisfies the following conditions
• T(r) monotonically increasing in range 0≤ r ≤ 1
• 0≤ T( r) ≤ 1 for 0≤ r ≤ 1
Fig: A grey level transformation function that is both
single valued and monotonically increasing.
• The requirement in the first condition T(r) to be
single valued is needed to guarantee that the
inverse transformation will exist, and the
monotonicity condition preserves the increasing order from black to white in the
output image
• Second condition guarantees that the output gray levels will be in the same range
as the input levels.
The inverse transformation from s back to r is denoted r = T −1 (s) 0 ≤ S ≤ 1
• pr (r ) denote the probability density function (pdf) of the variable r
• ps (s) denote the probability density function (pdf) of the variable s
• If pr (r ) and T(r) is known then ps (s) can be obtained from 𝑃𝑠 (𝑠) = 𝑃𝑟 (𝑟)|𝑑𝑟
𝑑𝑠
| … (a)

A transformation function of particular importance in image processing has the form


r
s = T (r ) =  pr ( w)dw , 0  r  1 , by observing the this transformation we immediately see
0

that it possesses the following properties:


(i) 0  s  1.
(ii) r2  r1  T (r2 )  T (r1 ) , i.e., the function T (r ) is increasing with r .
0 1
(iii) s = T (0) =  pr ( w)dw = 0 and s = T (1) =  pr ( w)dw = 1 .
0 0

Dr. Ganesh V Bhat Dept. of ECE CEC Page 7


MODULE-2 Digital Image Processing Quick Reference [17EC72]

Moreover, if the original image has intensities only within a certain range [rmin , rmax ]
rmin rmax

then s = T (rmin ) =  pr (w)dw = 0 and s = T (rmax ) =


0
 p (w)dw = 1 since
0
r pr (r ) = 0, r  rmin and r  rmax .

Therefore, the new intensity s takes always all values within the available range [0 1].
Suppose that Pr (r ) , Ps (s ) are the probability distribution functions (PDF’s) of the
variables r and s respectively.

ds dT (r ) d  
r
= =   Pr ( w)dw = Pr (r ) (b)
dr dr dr  0 
1
From equation (a) 𝑃𝑠 (𝑠) = 𝑃𝑟 (𝑟)|𝑑𝑟
𝑑𝑠
| =𝑃𝑟 (𝑟) |𝑃 |=1 0≤ s ≤1, For discrete values we deal
𝑟(𝑟)
with probabilities and summations instead of probability density functions and
integrals. The probability of occurrence of gray level rk in an image is approximated by
n
p(rk ) = k2 k=0,1,2,….L-1, N is the total number of pixels in the image, nk is the
N
number of pixels that have gray level rk and L is the total number of possible gray level
in the image. Unfortunately, in a real life scenario we must deal with digital images. The
discrete form of histogram equalization is given by the relation
k k n
s = T (r ) =  Pr (rj ) =  j
j =0 j =0 n

Above equation is called histogram equalization or histogram linearization. The inverse


transform from s back to r is denoted by
Histogram equalization may not always produce desirable results, particularly if the
given histogram is very narrow. It can produce false edges and regions. It can also
increase image “graininess” and “patchiness.”

➢ Histogram Matching/Histogram Specification


In image processing, histogram matching or histogram-specification is the
transformation of an image so that its histogram matches a specified histogram. The
well-known histogram equalization method is a special case in which the specified
histogram is uniformly distributed.
It is possible to use histogram matching to
balance detector responses as a relative detector
calibration technique. It can be used to normalize
two images, when the images were acquired at the
same local illumination (such as shadows) over
the same location, but by different sensors,
atmospheric conditions or global illumination.
Suppose we want to specify a particular
histogram shape (not necessarily uniform) which
is capable of highlighting certain grey levels in the
image.

Dr. Ganesh V Bhat Dept. of ECE CEC Page 8


MODULE-2 Digital Image Processing Quick Reference [17EC72]

Let us suppose that Pr (r) and Pz (z) represent the PDFs of r and z where r is the input
pixel intensity level and z is the output pixel intensity Suppose that histogram
equalization is first applied on the original image r
k k nj
sk = T (rk ) =  Pr (rj ) =  𝑣𝑘 = 𝐺(𝑧𝑘 ) = ∑𝑘𝑖=0 𝑃𝑧 (𝑧𝑖 ) = 𝑠𝑘 𝑊ℎ𝑒𝑟𝑒 𝑘=0,1,2,…..𝐿−1
j =0 j =0 n
Where n is the total number of pixels in the image, nk is the number of pixels that have
gray level rk and L is the total number of possible gray level in the image and z is the
available image. Finally 𝑧𝑘 = 𝐺 −1 [𝑇(𝑟𝑘) ] 𝑘 = 0,1,2 … . 𝐿 − 1
Or −1
𝑧𝑘 = 𝐺 (𝑠𝑘 ) 𝑘 = 0,1,2 … . 𝐿 − 1

➢ Local histogram equalization/Adaptive Histogram Equalization

Global histogram equalisation is suitable for overall enhancement. It is often necessary


to enhance details over small areas. The procedure is to define a square or rectangular
neighbourhood and move the centre of this area from pixel to pixel. At each location the
histogram of the points in the neighbourhood is computed and a histogram
equalisation transformation function is obtained. This function is finally used to map
the grey level of the pixel centred in the neighbourhood. The centre of the
neighbourhood region is then moved to an adjacent pixel location and the procedure is
repeated. Since only one new row or column of the neighbourhood changes during a
pixel-to-pixel translation of the region, updating the histogram obtained in the previous
location with the new data introduced at each motion step is possible quite easily. This
approach has obvious advantages over repeatedly computing the histogram over all
pixels in the neighbourhood region each time the region is moved one pixel location.

If the image is simply divided in blocks, each histogram equalization, the intermediate
block and the block will be apparent brightness discontinuity. In order to eliminate this
phenomenon, we use linear interpolation approach, namely in the following figure, part
shade of blue pixels using bilinear interpolation; green shaded by linear interpolation;
pink shaded using pixel after the normal histogram equalization value.
I.e., for a point in FIG. 00, the region (assuming that the length and width of the region
W; f (00), f (01), f (10), f (11) are four points where the
transformation function block), the transformed pixel
values of the points:

Linear interpolation of the green shaded so long as the


following conditions are met for:

Dr. Ganesh V Bhat Dept. of ECE CEC Page 9


MODULE-2 Digital Image Processing Quick Reference [17EC72]

Another approach often used to reduce computation is to utilise non overlapping


regions, but this methods usually produces an undesirable checkerboard effect.

➢ Contrast Limited Adaptive Histogram Equalization (just for reference, not for exams)
Contrast Limited AHE (CLAHE) differs from adaptive histogram equalization in its
contrast limiting. In the case of CLAHE, the contrast limiting procedure is applied to
each neighbourhood from which a transformation function is derived. CLAHE was
developed to prevent the over amplification of noise that adaptive histogram
equalization can give rise to.

2.7 list out some of the Histogram Statistics used for characterization of
digital images.
The purpose of a histogram is to graphically summarize the distribution of a
univariate data set. The histogram graphically shows the following:

1. center (i.e., the location) of the data;


2. spread (i.e., the scale) of the data;
3. skewness of the data;
4. presence of outliers; and
5. presence of multiple modes in the data.

These features provide strong indications of the proper distributional model for the
data. The probability plot or a goodness-of-fit test can be used to verify the
distributional model.

Dr. Ganesh V Bhat Dept. of ECE CEC Page 10


MODULE-2 Digital Image Processing Quick Reference [17EC72]

The histogram can be used to answer the following questions:

1. What kind of population distribution do the data come from?


2. Where are the data located?
3. How spread out are the data?
4. Are the data symmetric or skewed?
5. Are there outliers in the data?

Some statistical parameters that we use are given below

2.8 List some of the Arithmetic/Logic Operations used for image


enhancement
• Masking
is referred to as ROI (region of interest) processing
Isolate an area for processing
• Arithmetic operations
Addition:
Subtraction:
Multiplication: used to implement gray-level rather than binary
Division:
• Logic operations
And: used for masking (Fig. 3.27)
Or: used for masking
Not operation: negative transformation
Also: are used in conjunction with morphological operations

Dr. Ganesh V Bhat Dept. of ECE CEC Page 11


MODULE-2 Digital Image Processing Quick Reference [17EC72]

Arithmetic/logic operations involving images are performed on a pixel-by-pixel basis


between two or more images (this excludes the logic operation NOT, which is performed
on a single image).The four arithmetic operations, subtraction and addition (in that
order) arethe most useful for image enhancement.
Image Addition: In a RGB image, the addition of two images can be done using the ‘+’
operator. C=A+B; Here, the minimum value of A+B and 255 is taken. (i.e)
C(i,j,1)=min(A(i,j,1)+B(i,j,1),255) where (i,j) represents the pixel position. Image addition
can be used to add the components from one image into other image.

Image Subtraction: A new image is obtained as a result of the difference between the
pixels in the same location of the two images being subtracted.
C=A-B; ie. Maximum value of A-B and zero. C(i,j,:) =max(A(i,j,:)-B(i,j,:),0).
Image subtraction is widely used for change detection. For detecting the missing
components in product assembly, Example: To detect the defects in the PCB. Image
subtraction is most beneficial in the area of medical image processing called mask
mode radiography.

Image Multiplication: Image multiplication is used to increase the average gray level of
the image by multiplying with a constant. It is used for masking operations. C=A.*B;

Image Division: Image division can be considered as multiplication of one image and the
reciprocal of other image. C=A.\B;

Logical Operations:
Logic operations similarly operate on a pixel-by-pixel basis. We need only be
concerned with the ability to implement the AND, OR, and NOT logic operators because
these three operators are functionally complete. When dealing with logic operations on
gray-scale images, pixel values are processed as strings of binary numbers. For
example, performing the NOT operation on a black, 8-bit pixel (a string of eight 0’s)
produces a white pixel(a string of eight 1’s). Intermediate values are processed the same
way, changing all 1’s to 0’s and vice versa.
Logical operations are done on pixel by pixel basis. The AND and OR operations are
used for selecting sub-images in an image . This masking operation is referred as
Region Of Interest processing.

Logical AND : To isolate the interested region from rest of the image portion logical AND
or OR is used. Consider a mask image L for the image A. To obtain the interested area,
D= and(L,A) ;We can use L&A also. The resulting image will be stored in D which
contains the isolated image part.

Logical OR: Syntax: D=or(L,A). We can also use L|A

Dr. Ganesh V Bhat Dept. of ECE CEC Page 12


MODULE-2 Digital Image Processing Quick Reference [17EC72]

2.9 Image averaging


Image averaging is obtained by finding the average of K images. It is applied in de-
noising the images. Suppose that we have an image f ( x, y) of size M  N pixels
corrupted by noise n( x, y) , so we obtain a noisy image as follow g ( x, y) = f ( x, y) + n( x, y)
Where noise has zero average value If an image g ( x, y ) is formed by averaging K
different noisy image
𝐾
1
𝑔̅ (𝑥, 𝑦) = ∑ 𝑔𝑖(𝑥,𝑦)
𝐾
𝑖=1
1 2
Then it follows that 𝐸{𝑔̅ (𝑥, 𝑦)} = 𝑓(𝑥, 𝑦) and  2 g ( x, y ) =
  ( x , y ) Where 𝐸{𝑔̅ (𝑥, 𝑦)} is
K
2
the expected value of 𝑔̅ and 𝜎𝑔̅(𝑥,𝑦) and  2( x , y ) are the variance of 𝑔̅ and n, all at
coordinates (x, y). The standard deviation at any point in the average image is
1
 g ( x, y ) =   ( x, y )
K
𝐸{𝑔̅ (𝑥, 𝑦)} = 𝑓(𝑥, 𝑦) means that 𝑔̅ (𝑥, 𝑦) (output)approaches 𝑓(𝑥, 𝑦) (input) as the
number of noisy images used in the averaging process increases. An important
application of image averaging is in the field of astronomy, where imaging with very
low light levels is routine, causing sensor noise frequently to render single images
virtually useless for analysis.

Spatial domain: Enhancement in the case of a single image

2.10 what is a mask operator how is it used for filtering of digital


images?
In image processing, a kernel, convolution matrix, or mask is a small matrix. It is used
for blurring, sharpening, embossing, edge detection, and more. This is accomplished by
doing a convolution between a kernel and an image. The general expression of a
convolution is
𝑎 𝑏

𝑔(𝑥, 𝑦) = 𝑤 ∗ 𝑓(𝑥, 𝑦) ∑ ∑ 𝑤(𝑠, 𝑡)𝑓(𝑥 + 𝑠, 𝑦 + 𝑡)


𝑠=−𝑎 𝑡=−𝑏
where is the filtered image𝑔(𝑥, 𝑦), is the original image 𝑓(𝑥, 𝑦), 𝜔is the filter kernel. Every element of the filter kernel is
considered by −𝑎 ≤ 𝑠 ≤ 𝑎 and −𝑏 ≤ 𝑡 ≤ 𝑏.Depending on the element values, a kernel can cause a wide range of effects.

Convolution is the process of adding each element of the


image to its local neighbors, weighted by the kernel. This is
related to a form of mathematical convolution. The matrix
operation being performed—convolution—is not traditional
matrix multiplication, despite being similarly denoted by *.
If the kernel is symmetric then place the center (origin) of the
kernel on the current pixel. The kernel will overlap the
neighboring pixels around the origin. Each kernel element
should be multiplied with the pixel value it overlaps with and
all of the obtained values should be summed. This resultant

Dr. Ganesh V Bhat Dept. of ECE CEC Page 13


MODULE-2 Digital Image Processing Quick Reference [17EC72]

sum will be the new value for the current pixel currently overlapped with the center of
the kernel.
If the kernel is not symmetric, it has to be flipped both around its horizontal and
vertical axis before calculating the convolution as above.

2.11 what is a linear filter how are they categorized in general?

Linear filter is a filter which operate the pixel value in the support region in linear
manner (i.e.,as weighted summation). The support region is specified by the ‘filter
matrix’ and be represent as H(i,j). The size of H is call ‘filter region’ and filter matrix has
its own coordinate system, i is column index and j is row index. The center of it is the
origin location and it is called the ‘hot spot’.

Smoothing Filter: (This filter has only positive


integer.)
Box filter: All members of this filter are the
same.
Gaussian filter: The weight of filter member
depend on the location of the member. The
center of the filter receive the maximum
weigh and it decreases with distance from
the center.

2.12 Give a brief note on types of Spatial Filters


Spatial Filtering technique is used directly on pixels of an image. Mask is usually
considered to be added in size so that it has specific center pixel. This mask is moved
on the image such that the center of the mask traverses all image pixels.
Classification on the basis of linearity:
There are two types:
1. Linear Spatial Filter
2. Non-linear Spatial Filter
General Classification:
Smoothing Spatial Filter: Smoothing filter is used for blurring and noise reduction in
the image. Blurring is pre-processing steps for removal of small details and Noise
Reduction is accomplished by blurring.
Types of Smoothing Spatial Filter:
1. Linear Filter (Mean Filter)
2. Order Statistics (Non-linear) filter
These are explained as following below.
1. Mean Filter:
Linear spatial filter is simply the average of the pixels contained in the
neighborhood of the filter mask. The idea is replacing the value of every pixel in an
image by the average of the grey levels in the neighborhood define by the filter
mask.
Types of Mean filter:

Dr. Ganesh V Bhat Dept. of ECE CEC Page 14


MODULE-2 Digital Image Processing Quick Reference [17EC72]

• (i) Averaging filter: It is used in reduction of the detail in image. All coefficients
are equal.
• (ii) Weighted averaging filter: In this, pixels are multiplied by different
coefficients. Center pixel is multiplied by a higher value than average filter.
2. Order Statistics Filter:
It is based on the ordering the pixels contained in the image area encompassed by
the filter. It replaces the value of the center pixel with the value determined by the
ranking result. Edges are better preserved in this filtering.
Types of Order statistics filter:
• (i) Minimum filter: 0th percentile filter is the minimum filter. The value of the
center is replaced by the smallest value in the window.
• (ii) Maximum filter: 100th percentile filter is the maximum filter. The value of
the center is replaced by the largest value in the window.
• (iii) Median filter: Each pixel in the image is considered. First neighboring
pixels are sorted and original values of the pixel is replaced by the median of
the list.
Sharpening Spatial Filter: It is also known as derivative filter. The purpose of the
sharpening spatial filter is just the opposite of the smoothing spatial filter. Its main
focus in on the removal of blurring and highlight the edges. It is based on the first and
second order derivative.
2.11 Smoothing Spatial Filters
Smoothing filters are used for blurring and for noise reduction. Blurring is used in pre-
processing steps, such as removal of small details from an image prior to (large) object
extraction, and bridging of small gaps in lines or curves. Noise reduction can be
accomplished by blurring with a linear filter and also by nonlinear filtering

➢ Smoothing Linear Filters


The idea behind smoothing filters is straightforward. By replacing the value of every
pixel in an image by the average of the gray levels in the neighborhood defined by the
filter mask, this process results in an image with reduced “sharp” transitions in gray
levels. Because random noise typically consists of sharp transitions in gray levels, the
most obvious application of smoothing is noise reduction. However, edges (which
almost always are desirable features of an image) also are characterized by sharp
transitions in gray levels, so averaging
filters have the undesirable side effect
that they blur edges.

Fig: Two 3x3 smoothing (averaging) filter masks. The


constant multiplier in front of each mask is equal to the
sum of the values of its coefficients, as is required to
compute the average

The general implementation for filtering an M*N image with a weighted averaging filter
of size m*n (m and n odd) is given by the expression

∑𝑎𝑠=−𝑎 ∑𝑏𝑡=−𝑏 𝑤(𝑠, 𝑡)𝑓(𝑥 + 𝑠, 𝑦 + 𝑡)


𝑔(𝑥, 𝑦) =
∑𝑎𝑠=−𝑎 ∑𝑏𝑡=−𝑏 𝑤(𝑠, 𝑡)

Dr. Ganesh V Bhat Dept. of ECE CEC Page 15


MODULE-2 Digital Image Processing Quick Reference [17EC72]

➢ Non-Linear Filters
Noise removing with smoothing filter (a linear filter) provide the result in burred of the image structure, line
and edge. Non-Linear Filters were used to solve this problem and it works in non-linear manner.
Type of non-linear filters
Minimum and Maximum Filters: The minimum and maximum value in
the moving region R of the original image is the result of the minimum
and maximum filter respectively. These filter were defined as given
below

Median Filter: The result was calculated in the same way as the
minimum and maximum filter. The median of all value in moving region
R is the result of the median filter. And this filter typically use for
remove salt and pepper noise in the image. This filter was defined as

Weight Median Filter: This similar to the median filter, The word
“Weight” means extension of each member in the kernel according to
weight matrix W. The position of the filter member near hot spot will
obtain the higher weight than others.

Dr. Ganesh V Bhat Dept. of ECE CEC Page 16


MODULE-2 Digital Image Processing Quick Reference [17EC72]

2.12 Sharpening Spatial Filters (High Pass)


Sharpening Spatial Filter: It is also known as derivative filter. The purpose of the
sharpening spatial filter is just the opposite of the smoothing spatial filter. Its main
focus in on the removal of blurring and highlight the edges. It is based on the first and
second order derivative.
First order derivative:
• Must be zero in flat segments.
• Must be non zero at the onset of a grey level step.
• Must be non zero along ramps.
First order derivative in 1-D is given by:
𝜕𝑓
= 𝑓(𝑥 + 1) − 𝑓(𝑥)
𝜕𝑥
Second order derivative:
• Must be zero in flat areas.
• Must be zero at the onset and end of a ramp.
• Must be zero along ramps.
Second order derivative in 1-D is given by:
𝜕 2 (𝑓)
= 𝑓(𝑥 + 1) + 𝑓(𝑥 − 1) − 2𝑓(𝑥)
𝜕𝑥 2
A second order derivative can also be used for extracting high frequency data. The
general properties of first and second order derivative filters are as given below

(1) First-order derivatives generally produce thicker edges in an image.


(2) Second-order derivatives have a stronger response to fine detail, such as thin lines
and isolated points.
(3) First order derivatives generally have a stronger response to a gray-level step.
(4) Second- order derivatives produce a double response at step changes in gray level.
We also note of second-order derivatives that, for similar changes in gray-level
values in an image, their response is stronger to a line than to a step and to a point
than to a line.

2.13 Use of Second Derivatives for Enhancement–The Laplacian


Development of the method: It can be shown that the simplest isotropic derivative
operator is the Laplacian, which, for a function (image) f(x, y) of two variables, is defined
as

Because derivatives of any order are linear operations, the Laplacian is a linear
operator. Taking into account that we now have two variables, we use the following
notation for the partial second-order derivative in the x-direction:

and, similarly in the y-direction, as

Dr. Ganesh V Bhat Dept. of ECE CEC Page 17


MODULE-2 Digital Image Processing Quick Reference [17EC72]

The digital implementation of the two-dimensional Laplacian in Eq. (3.7-1) is obtained


by summing these two components:

This equation can be implemented using the mask shown in figure below

Laplacian kernel, Laplacian kernel that includes the diagonal terms, and Two other Laplacian kernels.

Because the Laplacian is a derivative operator, its use highlights gray-level


discontinuities in an image and deemphasizes regions with slowly varying gray levels.
This will tend to produce images that have grayish edge lines and other discontinuities,
all superimposed on a dark, featureless background. Background features can be
“recovered” while still preserving the sharpening effect of the Laplacian operation
simply by adding the original and Laplacian images. If the definition used has a
negative center coefficient, then we subtract, rather than add, the Laplacian image to
obtain a sharpened result. Thus, the basic way in which we use the Laplacian for image
enhancement is as follows:

Simplifications: In the previous example, we implemented Eq. (3.7-5) by first computing


the Laplacian-filtered image and then subtracting it from the original image. The
coefficients of the single mask are easily obtained as

g ( x, y ) = f ( x, y ) − [ f ( x + 1, y ) + f ( x − 1, y ) + f ( x, y + 1) + f ( x, y − 1) + 4 f ( x, y )
= 5 f ( x, y ) − [ f ( x + 1, y ) + f ( x − 1, y ) + f ( x, y + 1) + f ( x, y − 1)]

2.15 Give a note relation between Frequency Domain and spatial


domain Image Enhancement techniques.

Dr. Ganesh V Bhat Dept. of ECE CEC Page 18


MODULE-2 Digital Image Processing Quick Reference [17EC72]

Image enhancement techniques are application oriented. There are two basic types of
methods - spatial domain methods and frequency domain methods.

Spatial domain methods: methods that directly modify pixel values, possibly using
intensity information from a neighborhood of the pixel. Examples include image
negatives, contrast stretching, dynamic range compression, histogram specification,
image subtraction, image averaging, and various spatial filters.
What is it good for? -> Smoothing, Sharpening, Noise removal edge detection

Frequency domain methods: Methods that modify the Fourier transform of the image.
First, compute the Fourier transform of the image. Then alter the Fourier transform of
the image by multiplying a filter transfer function. Finally, use inverse transform to get
the modified image (steps are described later in the text). The key is the filter transfer
function - examples include lowpass filter, highpass filter, and Butterworth filter.

Convolution Theorem: The Fourier Transform is used to convert images from the spatial
domain into the frequency domain and vice-versa. Convolution is one of the most
important concepts in Fourier theory. Mathematically, a convolution is defined as the
integral over all space of one function at x times another function at u-x.
 
f g =  f ( ) g (t −  )d =  g ( ) f (t − )d
− −

We are interested in what happens if we convolve two functions in frequency domain.


This is stated by the convolution theorem. The convolution theorem is useful because it
gives us a way to simplify many calculations. Convolutions can be very difficult to
calculate directly, but are often much easier to calculate using Fourier transforms and
multiplication.

There are two ways of expressing the convolution theorem:


The Fourier transform of a convolution is the product of the Fourier transforms.
The Fourier transform of a product is the convolution of the Fourier transforms.

Let  be the operator performing the Fourier transform such that e.g.  is the Fourier
transform of f (can be 1-D or 2-D). Then

 (f * g) =  (f) ·  (g) = F · G
Where • denotes the element-by-element multiplication. Also, the Fourier transform of a
product is the convolution of the Fourier transforms:

 (f · g) =  (f) *  (g) = F * G.
By using the inverse Fourier transform F -1, we can write
 (F · G) =
-1
f*g
 (F * G) =
-1
f · g.

A question that often arises in the development of frequency domain technique is the
issue of computational complexity. Why do in the frequency domain for what could be
done in the spatial domain using small spatial masks? First, since the frequency
carries with a significant degree of intuitiveness regarding how to specify filters. Second

Dr. Ganesh V Bhat Dept. of ECE CEC Page 19


MODULE-2 Digital Image Processing Quick Reference [17EC72]

part of the answer depends on the size of the spatial masks and is usually answered
with respect to comparable implementations. For example, use both approaches for
running software on the same machine, it turns out that the frequency domain
implementation runs faster for surprisingly small value of M and N. Also, some
experiments shown that some enhancement tasks that would be exceptionally difficult
or impossible to formulate directly in the spatial domain become almost trivial in the
frequency domain.

An image can be filtered either in the frequency or in the spatial domain. In theory, all
frequency filters can be implementing as a spatial filter, but in practice, the frequency
filters can only be approximated by the filtering mask in spatial domain. If there exist a
simple mask for the desired filter effect, it is computationally less expensive to perform
the filtering in the spatial domain. And if there is no straight forward mask can be
found in the spatial domain, frequency filtering is more appropriate.

2.16 Explain and illustrate the steps involved in frequency domain of


filtering
Before we discuss filtering, it’s important to understand what is high and low frequency
mean in an image: If an image has large values at high frequency components then the
data (grey level) is changing rapidly on a short distance scale. e.g. a page of text, edges
and noise. If the image has large low frequency components, then the large scale
features of the picture are more important. e.g. a single fairly simple object which
occupies most of the image. For color images, the measure the frequency content is
with regard to color: this shows if values are changing rapidly or slowly.
Filtering in the frequency domain is a common image and signal processing technique.
It can smooth, sharpen, de-blur, and restore some images. Essentially, filtering is equal
to convolving a function with a specific filter function. So one possibility to convolve two
functions could be to transform them to the frequency domain,
multiply them there and transform them back to spatial domain. The filtering
procedure is summarized in Figure

Figure 1: Frequency domain filtering procedure

Dr. Ganesh V Bhat Dept. of ECE CEC Page 20


MODULE-2 Digital Image Processing Quick Reference [17EC72]

Basic steps of filtering in the frequency domain:


1. Multiply the input image f (x, y) by (-1) (x + y) to center the transform, as
indicated as following equation:
 [f(x, y) (-1) (x + y) ] = F (u - M/2, υ - N/2).
2. Compute F (u, υ), the DFT of the input image from (1).
3. Multiply F (u, υ) by a filter function H (u, υ).
4. Compute the inverse DFT of the result in (3).
5. Obtain the real part (better take the magnitude) of the result in (4).
6. Multiply the result in (5) by (-1) (x + y).

1 M −1 N −1
In step 2, the Two-Dimensional DFT: F (u, v) =  
MN x=0 y =0
f ( x, y)e− j 2 (ux / M +vy / N ) ,

1 M −1 N −1
and its inverse: f ( x, y) =  
MN u =0 v=0
F (u, v)e j 2 (ux / M +vy / N ) .
In equation form, the Fourier transform of the filtered image in step 3 is given by:
G(u, υ) = F(u, υ)H(u, υ), where F(u, υ) and H(u, υ) denote the Fourier transform of the input
image f (x, y), and the filter function h(x, y), respectively. And G(u, υ) is the Fourier
Transform of the filtered image, which is the multiplication of two two-dimensional
functions H and F on an element-by-element basics. The important point to keep in
mind is that the filtering process is based on modifying the transform of an image
(frequency) in some way via a filter function, and then taking the inverse of the result to
obtain the filtered image: Filtered Image =  -1[G(u, υ)].

2.18 Smoothing frequency domain filters


As discussed before about the difference between the high and low frequency, we know
that edges and noises and other sharp transitions in the grey level contribute
significantly to the high frequency. Hence smoothing/blurring is achieved by
attenuating a specified range of high frequency components in the transform of a given
image, which can be done using a lowpass filter.
Lowpass filter is a filter that attenuates high frequencies and retains low frequencies
unchanged. This results a smoothing filter in the spatial domain since high frequencies
are blocked. Three types of lowpass filters will be discussed in this report are Ideal,
Gaussian and Butterworth.
A. Ideal lowpass filter: The simplest low pass filter is the ideal low pass. It
suppresses all frequencies higher than the cut-off
frequency r0 and leaves smaller frequencies unchanged:
r0 is called the cutoff frequency (nonnegative quantity), and
D(u, v) is the distance from point (u, v) to the frequency
rectangle. If the image is of size M x N, then

Dr. Ganesh V Bhat Dept. of ECE CEC Page 21


MODULE-2 Digital Image Processing Quick Reference [17EC72]

The lowpass filters considered here are radially symmetric about the origin.

(a) Perspective plot of an ideal lowpass-filter transfer function. (b) Function displayed as an image. (c) Radial cross section.
Use Figure c as the cross section that extending as a function of distance from the origin along a radial line, we get Figure a, which is the
perspective plot of an Ideal LPF transfer function. And Figure b is the filter displayed as an image.

The drawback of the ideal lowpass filter function is a ringing effect that occurs along
the edges of the filtered image. In fact, ringing behavior is a characteristic of ILPF (Ideal
Low Pass Filter). As mentioned earlier, multiplication in the Fourier domain
corresponds to a convolution in the spatial domain. Due to the multiple peaks of the
ideal filter in the spatial domain, the filtered image produces ringing along intensity
edges in the spatial domain. The cutoff frequency r0 of the ILPF determines the amount
of frequency components passed by the filter. Smaller the value of r0, more the number
of image components eliminated by the filter. In general, the value of r0 is chosen such
that most components of interest are passed through, while most components not of
interest are eliminated.
Example : ideal lowpass filtering:
As we can see, the filtered image is blured and ringing is
more severe as r0 become smaller. It is clear from this
example that ILPF is not very practical.
The next section introduce a lowpass filter which
smoothing a image can achieve blurring the image while
there is little or no ringing.

Original Image LPF, r0 = 26 LPF, r0 = 36 LPF, r0 = 57,

B. Butterworth lowpass filter:


A commonly used discrete approximation to the
Gaussian (next section) is the Butterworth filter. Applying this filter in the frequency
domain shows a similar result to the Gaussian smoothing in the spatial domain. The
transfer function of a Butterworth lowpass filter (BLPF) of order n, and with cutoff
frequency at a distance r0 from the origin, is defined as
1
H (u, v) = 2n
 D(u, v) 
1+  
 r0 
Where D(u ,v) is defined in ideal LPF , As we can see from below fig , frequency
response of the BLPF does not have a sharp transition as in the ideal LPF. And as the
filter order increases, the transition from the pass band to the stop band gets steeper.

Dr. Ganesh V Bhat Dept. of ECE CEC Page 22


MODULE-2 Digital Image Processing Quick Reference [17EC72]

Which means as the order of BLPF increase, it will exhibits the characteristics of the
ILPF.

See example below to see the different between two images with different orders but the
same cutoff frequency. In fact, order of 20 already shows the ILPF characteristic.
Example: BLPF with different orders but the same cutoff frequency:

Original r0 = 30, n=1 r0 = 30, n=2


Example : Butterworth lowpass filtering:

Figure : BLPF of order 1, 2, and 5.

Original Image BLPF, r0 = 10 BLPF, r0 = 13 BLPF, r0 = 18

Figure shows the comparison between the spatial representations of various orders with cutoff frequency of 5 pixels, also the
corresponding gray level profiles through the center of the filter. As we can see, BLPF of order 1 has no ringing. Order of 2 has
mild ringing. So, this method is more appropriate for image smoothing than the ideal lowpass filter. Ringing in the BLPF
becomes significant for higher order.

C. Gaussian lowpass filter: Gaussian filters are important in many signal processing,
image processing and communication applications. These filters are characterized by
narrow bandwidths, sharp cutoffs, and low overshoots. A key feature of Gaussian filters
is that the Fourier transform of a Gaussian is also a Gaussian, so the filter has the
same response shape in both the spatial and frequency domains. The form of a
H (u, v) = e− D (u,v)/2 ,
2 2
Gaussian lowpass filter in two-dimensions is given by
where D(u,v) is the distance from the origin in the frequency plane as defined earlier.
The parameter σ measures the spread or dispersion of the Gaussian curve as seen in
below fig . Larger the value of σ, larger the cutoff frequency and milder the filtering is.

Dr. Ganesh V Bhat Dept. of ECE CEC Page 23


MODULE-2 Digital Image Processing Quick Reference [17EC72]

(a) Perspective plot of a GLPF transfer function. (b) Function displayed as an image. (c) Radial cross sections for various values
of D0

When letting σ = r0, which leads a more familiar form as previous discussion. So above
− D2 (u ,v)/2r 2
Equation becomes: H (u, v) = e 0

When D(u, v) = r0, the filter is down to 0.607 of its maximum value of 1.
Example: Gaussian lowpass filtering:

Original σ = 1.0 σ = 4.0


(kernel size 5×5) (kernel size 15×15)

As mentioned earlier, the Gaussian has the same shape in the spatial and Fourier
domains and therefore does not incur the ringing effect in the spatial domain of the
filtered image. This is a advantage over ILPF and BLPF, especially in some situations
where any type of artifact is not acceptable, such as medical image. In the case where
tight control over transition between low and high frequency needed, Butterworth
lowpass filter provides better choice over Gaussian lowpass filter; however, tradeoff is
ringing effect.
The Butterworth filter is a commonly used discrete approximation to the Gaussian.
Applying this filter in the frequency domain shows a similar result to the Gaussian
smoothing in the spatial domain. But the difference is that the computational cost of
the spatial filter increases with the standard deviation (e.g the size of the filter kernel),
whereas the costs for a frequency filter are independent of the filter function. Hence,
the Butterworth filter is a better implementation for wide lowpass filters, while the
spatial Gaussian filter is more appropriate for narrow lowpass filters.

Dr. Ganesh V Bhat Dept. of ECE CEC Page 24


MODULE-2 Digital Image Processing Quick Reference [17EC72]

2.19. Sharpening frequency domain filters


Sharpening filters emphasize the edges, or the differences between adjacent light and
dark sample points in an image. A highpass filter yields edge enhancement or edge
detection in the spatial domain, because edges contain many high frequencies. Areas of
rather constant gray level consist of mainly low frequencies and are therefore
suppressed. We obtain a highpass filter function by inverting the corresponding
lowpass filter, e.g. an ideal highpass filter blocks all frequencies smaller than r0 and
leaves the others unchanged. The transfer function of lowpass filter and highpass filter
can be related as Hhp (u, v) = 1 – Hlp(u, v) ; Where Hhp (u, v) and Hlp(u, v) are the
transfer function of highpass and lowpass filter respectively.
➢ Ideal highpass filter: The transfer function of an ideal highpass filter with the
cutoff frequency r0 is:
0, if D(u, v)  r0
H(u, v) =
1, if D(u, v)  r0

Again, r0 is the cutoff frequency and D(u, v) is as defined earlier .

Figure : Perspective plot, image representation, and cross section of an IHPF.


Because the transfer functions of lowpass filter and highpass filter are related as shown
in above Eq, we can expect IHPF to have the same ringing properties as ILPF. This is
demonstrated clearly in the example below.
Example: Ideal highpass filtering:

Original Image HPF, r0 = 18 HPF, r0 = 26 HPF, r0 = 36

Dr. Ganesh V Bhat Dept. of ECE CEC Page 25


MODULE-2 Digital Image Processing Quick Reference [17EC72]

➢ Butterworth highpass filter: The transfer function of Butterworth highpass filter


(BHPF) of order n and with cutoff frequency r0 is given by:
1
H (u, v) = 2n
 r0 
1+  
 D(u, v) 

Where D(u, v) is defined earlier below Fig shows perspective plot, image representation,
and cross section of an BHPF.

Figure : Perspective plot, image representation, and cross section of a BHPF.

Example : Butterworth highpass filtering with order of 2:

Original Image BHPF, r0 = 18 BHPF, r0 = 26 BHPF, r0 = 36

The frequency response does not have a sharp transition as in the IHPF. As we compare
example 5 and 6 with r0 = 18, we can see that BHPF behave smoother and less
distortion than IHPF. Therefore, BHPF is more appropriate for image sharpening than
the IHPF. Also less ringing is introduced with small value of the order n of BHPF.

Example: BHPF with different orders but same cutoff frequency:

Original r0 = 30, n=1 r0 = 30, n=2

Dr. Ganesh V Bhat Dept. of ECE CEC Page 26


MODULE-2 Digital Image Processing Quick Reference [17EC72]

➢ Gaussian highpass filter: The transfer function of a Gaussian highpass filter


− D2 (u ,v)/2r 2
(GHPF) with the cutoff frequency r0 is given by H (u, v) = 1− e 0 ; Where D(u, v)

is defined earlier, and r0 is the distance from the origin in the frequency plane. The
parameter σ, measures the spread or dispersion of the Gaussian curve. Larger the
value of σ, larger the cutoff frequency and milder the filtering is.

Figure : Perspective plot, image representation, and cross section of a GHPF.

Example : Results of highpass filtering the image using GHPF of order 2:

Original r0 =15 r0 =30 r0 =80


The spatial kernel corresponding to a highpass filter transfer function in the frequency
domain is given by

Ideal, Gaussian, and Butterworth


highpass spatial filters obtained from
IHPF, GHPF, and BHPF frequency-
domain transfer functions. (The thin
image borders are not part of the data.)
and Horizontal intensity profiles through
the centers of the kernels is shown

Dr. Ganesh V Bhat Dept. of ECE CEC Page 27


MODULE-2 Digital Image Processing Quick Reference [17EC72]

2.20 Use of First Derivatives for Enhancement—The Gradient


First derivatives in image processing are implemented using the magnitude of the
gradient. For a function f(x, y), the gradient of f at coordinates (x, y) is defined as the
two-dimensional column vector

The magnitude of this vector is given by

The components of the gradient vector itself are linear operators, but the magnitude of
this vector obviously is not because of the squaring and square root operation.
Although it is not strictly correct, the magnitude of the gradient vector often is referred
to as the gradient.
For practical reasons this can be simplified as: f  G x + G y
There is some debate as to how best to calculate these gradients but we will use:
f  ( z7 + 2 z8 + z9 ) − ( z1 + 2 z2 + z3 ) + ( z3 + 2 z6 + z9 ) − ( z1 + 2 z4 + z7 )

Based on the previous equations we can derive the Sobel Operators

2.21 The Laplacian in the frequency Domain:


The Laplacian is a very useful and common tool in image process. This is a second
derivative operator designed to measure changes in intensity without being overly
sensitive to noise. The function produces a peak at the start of the change in intensity
and then at the end of the change. As we know, the mathematical definition of
derivative is the rate of change in a continuous function. But in digital image
processing, image is a discrete function f(x, y) of integer spatial coordinates. As a result
the algorithms will only be seen as approximations to the true spatial derivatives of the
original spatial-continuous image. The Laplacian of an image will highlight regions of
rapid intensity change and is therefore often used for edge detection (usually called the
Laplacian edge detector).

The Laplacian is often applied to an image that has first been smoothed with something
approximating a Gaussian smoothing filter in order to reduce its sensitivity to noise,
and hence the two variants will be described together here. The operator normally takes
a single gray level image as input and produces another gray level image as output.
The Laplacian of an image with pixel intensity values f(x, y) (original image) is given by:

Dr. Ganesh V Bhat Dept. of ECE CEC Page 28


MODULE-2 Digital Image Processing Quick Reference [17EC72]

 2 f ( x, y )  2 f ( x , y )  d n f ( x) 
 2 f ( x, y ) = + Since   = ( ju )n F (u )
x 2 y 2  dx 
n

Combine above two Equations we get

  2 f ( x, y )  = ( ju ) 2 F (u, v) + ( jv) 2 F (u, v)


= − ( u 2 + v 2 ) F (u, v)
we know that Laplacian can be implemented in the frequency domain by using the
filter:
H (u , v) = −(u 2 + v 2 ) .
For size of M x N image, the filter function at the center point of the frequency rectangle
will be:
 2
M  N 
2

H (u, v) = −  u −  +  v −  
 2   2  
Hence, the Laplacian-filtered image in the spatial domain can be obtained by:
 2 f ( x, y ) = −  H (u , v) F (u , v) 
So, how we use the Laplacian for image enhancement in the spatial domain? Here are
the basic ways where the g(x, y) is the enhanced image:

f ( x, y ) −  2 f ( x, y ) If the center coefficient of the mask is negative


g ( x, y ) =
f ( x, y ) +  2 f ( x, y ) If the center coefficient of the mask is positive

In frequency domain, g(x, y) the enhance image is also possible to be obtained by taking
the inverse Fourier transform of a single mask (filter)

H (u, v) = 1 + ( u − M / 2 ) + (v − N / 2) 2  
2

  
and the original image f(x, y):


g ( x, y ) = −1 1 + ( u − M / 2 ) + (v − N / 2) 2   F (u, v)
 
2
 
Example: example of the Laplacian filtering shows up more detail of in the ring of the Saturn.

In practice, the result image is identical when compute


using only spatial domain techniques or using only
frequency domain technique.

Dr. Ganesh V Bhat Dept. of ECE CEC Page 29


MODULE-2 Digital Image Processing Quick Reference [17EC72]

2.21 Explain the concept of unsharp masking and high boost filtering.
A process used for many years in the publishing industry to sharpen images consists of
subtracting a blurred version of an image from the image itself. This process, called
unsharp masking, is expressed as
f hp ( x, y ) = f ( x, y ) − f lp ( x, y )
where fs(x, y) denotes the sharpened image obtained by unsharp masking, and is a
blurred version of f(x, y). A slight further generalization of unsharp masking is called
high-boost filtering.A high-boost filtered image, fhb, is defined at any point (x, y) as

f hb ( x, y ) = Af ( x, y ) − f lp ( x, y ) Where A≥1
Above equation can be written as
f hb ( x, y ) = ( A − 1) f ( x, y ) − f lp ( x, y ) + f ( x, y )
f hb ( x, y ) = ( A − 1) f ( x, y ) + f hp ( x, y )
When A=1, high boost filter reduces to regular high pass filter.
Fhp (u , v) = F (u , v) − Flp (u , v)
Flp (u , v) = F (u , v) H lp (u , v)
Therefore, unsharp masking can be implemented directly in frequency domain by using
composite filter
H hp (u , v) = 1 − H lp (u , v)
Similarly, high boost filtering can be implemented with the composite filter (A≥1)
H hp (u , v) = ( A − 1) + H lp (u , v)

High frequency emphasis has a filter function given by

2.22 With a block diagram and equations, explain the homomorphic


filtering. How dynamic range compression and contrast enhancement is
simultaneously achieved?
An image f(x,y) can be defined as the product of illumination i(x,y) and reflectance r(x,y)

f ( x, y) = i( x, y)r ( x, y)
Because the fourier transform of the product of two function is not separable:
{ f ( x, y)  {i( x, y)r ( x, y)
Therefore taking natural logarithm on both side

Dr. Ganesh V Bhat Dept. of ECE CEC Page 30


MODULE-2 Digital Image Processing Quick Reference [17EC72]

[ z( x, y)] = ln( f ( x, y) = [ln i( x, y)] + [ln r ( x, y)]


Taking Fourier transform on both sides [ z ( x, y)] = [ln i( x, y)] + [ln r ( x, y)]

Z (u, v) = Fi (u, v) + Fr (u, v)

Where F (u, v) = ln i( x, y) Fr (u, v) = ln r ( x, y)


i

If we process Z(u,v) by means of filter function H(u,v) then,


S (u, v) = H (u, v) Fi (u, v) + H (u, v) Fr (u, v)
In spatial domain
s( x, y) =  −1{S (u, v)} +
s ( x, y ) = −1{H (u , v) Fi (u , v) + H (u , v) Fr (u , v)}
s( x, y) = i ' ( x, y) + r ' ( x, y)
Where i ' ( x, y ) = −1{H (u , v) Fi (u , v)} r ' ( x, y) = −1{H (u, v) Fr (u, v)}
Finally, as z(x,y) was formed by taking the logarithm of the original image f(x,y), the
inverse (exponential) operation yields the desired enhanced image, denoted by g(x,y),
that is
g ( x, y ) = e s ( x , y ) = e i ( x , y ) e r ( x , y ) = io ( x, y )ro ( x, y )
' '

ro ( x, y ) = e r ( x , y )
'

where io ( x, y ) = e
i' ( x , y )

This filtering technique is most famous for removing multiplicative noise and is carried
out as shown in fig

Figure: Block diagram of the process of Homomorphic filtering

The illumination components of an image generally characterized by slow spatail


variations, while the reflectance component tend to vary abruptly, particularly at the
junctions of dissimilar objects.

Low frequency------→ Illumination; High frequency--------→Reflectance

If the parameter  L and  H are chosen so that  L  1 and  H  1 , the filter function
shown in figure below trends to decrease the contribution made bey the slow
frequencies (illumination) and amplify the contribution made by high frequency

Dr. Ganesh V Bhat Dept. of ECE CEC Page 31


MODULE-2 Digital Image Processing Quick Reference [17EC72]

comonents(reflectance). The net result is simultaneous dynamic range compression and


contrast enhancement.

Figure: Filter Transfer Function of a 1Homomorphic Filter

Using a slightly modified form of the Gaussian filter gives us

H (u , v) = ( H −  L )[1 − e − c ( D ]+L
2
( u , v ) / D02 )

Where C is a constant and it controls the sharpness of the slope of the filter function

Dr. Ganesh V Bhat Dept. of ECE CEC Page 32


MODULE-2 Digital Image Processing Quick Reference [17EC72]

QUESTION BANK

# Module 2 Question bank


1. What is the importance of image enhancement in image processing?
2. Explain in brief any two point processing techniques implemented in image
processing.
3. Explain histogram equalization technique.
4. Illustrate histogram equalization for a 8 level 50x49 image with following nk values:
120,160,555,664,333,545,33,40
5. What is histogram matching (specification)? Explain the development and
implementation of the method.
6. Perform histogram equalization for the following image data, sketch the histogram of
the original image and histogram of equalized image.
7. Explain the following image enhancement techniques, highlighting their area of
application .
i) Bit – plane slicing. ii) AND and OR operation.
8. Explain mask operators for image filtering
9. With a block diagram and equations, explain the homomorphic filtering. How dynamic
range compression and contrast enhancement is simultaneously achieved?
10. Explain sharpening filters in the frequency domain
11. Explain lowpass filters in the frequency domain
12. Illustrate the working of averaging filter with a suitable example
13. Which filter removes the salt and pepper noise effectively? Illustrate with an example

14. Explain the concept of unsharp masking and high boost filtering.

FURTHER READING

Further reading: http://www.ent.mrt.ac.lk/~ranga/courses/en5204_2013/L01.pdf


NPTEL course Link: https://nptel.ac.in/courses/117/104/117104069/

Dr. Ganesh V Bhat Dept. of ECE CEC Page 33

You might also like