0% found this document useful (0 votes)
81 views

DIP Module2

This document contains information about a Digital Image Processing course at B.N.M. Institute of Technology in Bengaluru, India. The course is part of the 7th semester Electronics and Communication Engineering program. The document provides details about the course code, faculty, and Module 2 which covers image transformation in the spatial and frequency domains. It includes questions and answers about intensity transformation functions in the spatial domain, including the concepts of linear, logarithmic, power law, and piecewise linear transformations. Spatial domain methods like contrast stretching and thresholding directly manipulate pixel values, while frequency domain techniques modify the image's Fourier transform.

Uploaded by

jay b
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views

DIP Module2

This document contains information about a Digital Image Processing course at B.N.M. Institute of Technology in Bengaluru, India. The course is part of the 7th semester Electronics and Communication Engineering program. The document provides details about the course code, faculty, and Module 2 which covers image transformation in the spatial and frequency domains. It includes questions and answers about intensity transformation functions in the spatial domain, including the concepts of linear, logarithmic, power law, and piecewise linear transformations. Spatial domain methods like contrast stretching and thresholding directly manipulate pixel values, while frequency domain techniques modify the image's Fourier transform.

Uploaded by

jay b
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

B.N.M.

Institute of Technology
Approved by AICTE, Affiliated to VTU, Accredited as Grade A Institution by NAAC.
All UG branches – CSE, ECE, EEE, ISE & Mech.E Accredited by NBA for academic years 2018-19 to 2020-21 & valid upto 30.06.2021
Post box no. 7087, 27th cross, 12th Main, Banashankari 2nd Stage, Bengaluru- 560070, INDIA
Ph: 91-80- 26711780/81/82 Email: [email protected], www.bnmit.org
ELECTRONICS AND COMMUNICATION ENGINEERING

Semester: VII Sem ECE

Scheme: 2017

Course: Digital Image Processing

Course Code: 17EC72

Faculty: Dr. P. A. Vijaya, Mrs. Keerti Kulkarni

1
Module -2
Image Transformation in the Spatial and Frequency
Domain
Spatial Domain

Q1. Explain the Concepts of Intensity Transformation functions in the Spatial Domain.

Image enhancement approaches fall into two broad categories: spatial domain methods and
frequency domain methods. The term 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 an image. Enhancing an image provides better contrast and a more detailed image as compare to
non enhanced image. Image enhancement has very good applications. It is used to enhance medical
images, images captured in remote sensing, images from satellite e.t.c. As indicated previously, the
term spatial domain refers to the aggregate of pixels composing an image. Spatial domain
methods are procedures that operate directly on these pixels. Spatial domain processes will be
denoted by the expression.
g(x,y) = T[f(x,y)]
where f(x, y) is the input image, g(x, y) is the processed image, and T is an operator on
f, defined over some neighborhood of (x, y). The principal approach in defining a neighborhood
about a point (x, y) is to use a square or rectangular subimage area centered at (x, y), as Fig.
2.1 shows. The center of the subimage is moved from pixel to pixel starting, say, at the top left
corner. The operator T is applied at each location (x, y) to yield the output, g, at that location.
The process utilizes only the pixels in the area of the image spanned by the neighborhood.

Figure 1.1: 3x3 neighborhood about a point (x,y) in an image.


2
The simplest form of T is when the neighborhood is of size 1*1 (that is, a single pixel). In this
case, g depends only on the value of f at (x, y), and T becomes a gray-level (also called an
intensity or mapping) transformation function of the form

s=T(r)
where r is the pixels of the input image and s is the pixels of the output image. T is a
transformation function that maps each value of „r‟ to each value of „s‟.
For example, if T(r) has the form shown in Fig. 1.2(a), the effect of this transformation would
be 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. In this technique, known as contrast
stretching, the values of r below m are compressed by the transformation function into a narrow
range of s, toward black. The opposite effect takes place for values of r above m.
In the limiting case shown in Fig. 1.2(b), T(r) produces a two-level (binary) image. A
mapping of this form is called a thresholding function.
One of the principal approaches in this formulation is based on the use of so-called
masks (also referred to as filters, kernels, templates, or windows). Basically, a mask is a small
(say, 3*3) 2-D array, such as the one shown in Fig. 2.1, 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.

Figure 1.2. Intensity level transformation functions for contrast enhancement.


Image enhancement can be done through gray level transformations which are
discussed below.
Q2. Explain the three Basic Intensity Level Transformation functions with relevant graphs,
equation and examples.
• Image negative
• Log transformations
• Power lawtransformations
• Piecewise-Linear transformationfunctions
LINEAR TRANSFORMATION:

3
First we will look at the linear transformation. Linear transformation includes simple
identity and negative transformation.
Identity transition is shown by a straight line. In this transition, each value of the input
image is directly mapped to each other value of output image. That results in the same input
image and output image. And hence is called identity transformation. It has been shown below:

Fig 2.1 Linear transformation between input and output.


IMAGE NEGATIVE TRANSFORMATION:
The second linear transformation is negative transformation, which is invert of identity
transformation. In negative transformation, each value of the input image is subtracted from
the L-1 and mapped onto the output image
IMAGE NEGATIVE: The image negative with gray level value in the range of [0, L-1] is obtained by
negative transformation given by S = T(r) or
S = L -1 – r
Where r= gray level value at pixel (x,y)
L is the largest gray level consists in the image
It results in getting photograph negative. It is useful when for enhancing white details embedded in dark
regions of the image.
The overall graph of these transitions has been shown below.

Input gray level, r

Fig 2.2 . Some basic gray-level transformation functions used for image enhancement.

4
In this case the following transition has been done.

s = (L – 1) – r
since the input image of Einstein is an 8 bpp image, so the number of levels in this image are
256. Putting 256 in the equation, we get this

s = 255 – r
So each value is subtracted by 255 and the result image has been shown above. So what
happens is that, the lighter pixels become dark and the darker picture becomes light. And it
results in image negative.
It has been shown in the graph below.

Fig 2.3. Negative transformations.


LOGARITHMIC TRANSFORMATIONS:
Logarithmic transformation further contains two type of transformation. Log transformation
and inverse log transformation.
LOG TRANSFORMATIONS:
The log transformations can be defined by this formula
s = c log(r + 1).
Where s and r are the pixel values of the output and the input image and c is a constant. The
value 1 is added to each of the pixel value of the input image because if there is a pixel intensity
of 0 in the image, then log (0) is equal to infinity. So 1 is added, to make the minimum value
at least 1.
During log transformation, the dark pixels in an image are expanded as compare to the higher
pixel values. The higher pixel values are kind of compressed in log transformation. This result
in following image enhancement.
An another way of representing LOG TRANSFORMATIONS: Enhance details in the darker regions of an
image at the expense of detail in brighter regions.
T(f) = C * log (1+r)
• Here C is constant and r ≥ 0.

5
• The shape of the curve shows that this transformation maps the narrow range of low gray level
values in the input image into a wider range of output image.
• The opposite is true for high level values of input image.

POWER – LAW TRANSFORMATIONS:


There are further two transformation is power law transformations, that include nth
power and nth root transformation. These transformations can be given by the expression:
s=crγ
This symbol γ is called gamma, due to which this transformation is also known as
gamma transformation.
Variation in the value of γ varies the enhancement of the images. Different display
devices / monitors have their own gamma correction, that‟s why they display their image at
different intensity.
γ
where c and g are positive constants. Sometimes Eq. (6) is written as S = C (r +ε) to
account for an offset (that is, a measurable output when the input is zero). Plots of s versus r
for various values of γ are shown in Fig. 2.4. As in the case of the log transformation, power-
law curves with fractional values of γ map a narrow range of dark input values into a wider
range of output values, with the opposite being true for higher values of input levels. Unlike
the log function, however, we notice here a family of possible transformation curves obtained
simply by varying γ.
In Fig that curves generated with values of γ>1 have exactly The opposite effect as those
generated with values of γ<1. Finally, we Note that Eq. (6) reduces to the identity
transformation when c=γ=1.

Fig. 2.4 Plot of the equation S = crγ for various values of γ (c =1 in all cases).
This type of transformation is used for enhancing images for different type of display devices.
The gamma of different display devices is different. For example Gamma of CRT lies in
6
between of 1.8 to 2.5, that means the image displayed on CRT is dark. Varying gamma (γ)
obtains family of possible transformation curves S = C* r γ

Here C and γ are positive constants. Plot of S versus r for various values of γ is
γ > 1 compresses dark values
Expands bright values
γ < 1 (similar to Log transformation)
Expands dark values
Compresses bright values
When C = γ = 1 , it reduces to identity transformation .

CORRECTING GAMMA:
s=crγ
s=cr (1/2.5)
The same image but with different gamma values has been shown here.
Q3. Explain Piecewise-Linear Transformation Functions.
• Contrast Stretching

• Intensity Level Slicing or Grey Level Slicing

• Bit Plane Slicing

A complementary approach to the methods discussed in the previous three sections is


to use piecewise linear functions. The principal advantage of piecewise linear functions over
the types of functions we have discussed thus far is that the form of piecewise functions can be
arbitrarily complex.
The principal disadvantage of piecewise functions is that their specification requires
considerably more user input.
Contrast stretching: One of the simplest piecewise linear functions is a contrast-stretching
transformation. Low-contrast images can result from poor illumination, lack of dynamic range
in the imaging sensor, or even wrong setting of a lens aperture during image acquisition.
S= T(r )
Figure 3.1(a) shows a typical transformation used for contrast stretching. The
locations of points (r1, s1) and (r2, s2) control the shape of the transformation
Function. If r1=s1 and r2=s2, the transformation is a linear function that produces No
changes in gray levels. If r1=r2, s1=0and s2= L-1, the transformation Becomes a thresholding
function that creates a binary image.
Intermediate values of ar1, s1b and ar2, s2b produce various degrees Of spread in the
7
gray levels of the output image, thus affecting its contrast. In general, r1≤ r2 and s1 ≤ s2 is
assumed so that the function is single valued and Monotonically increasing.

Fig. 3.1 Contrast stretching. (a) Form of transformation function. (b) A low-contrast stretching.
(c) Result of contrast stretching. (d) Result of thresholding (original image courtesy of
Dr.Roger Heady, Research School of Biological Sciences, Australian National University
Canberra Australia.
Figure 3.1(b) shows an 8-bit image with low contrast. Fig. 3.1(c) shows the result of contrast
stretching, obtained by setting (r1, s1 )=(rmin, 0) and (r2, s2)=(rmax,L-1) where rmin and rmax
denote the minimum and maximum gray levels in the image, respectively. Thus, the
transformation function stretched the levels linearly from their original range to the full range
[0, L-1]. Finally, Fig. 3.1(d) shows the result of using the thresholding function defined
previously,
with r1=r2=m, the mean gray level in the image. The original image on which these results are
based is a scanning electron microscope image of pollen, magnified approximately 700 times.
Intensity-level slicing:
Highlighting a specific range of gray levels in an image often is desired. Applications
include enhancing features such as masses of water in satellite imagery and enhancing flaws in
X-ray images.
There are several ways of doing level slicing, but most of them are variations of two
basic themes. One approach is to display a high value for all gray levels in the range of interest

8
and a low value for all other gray levels.

This transformation, shown in Fig. 3.2(a), produces a binary image. The second
approach, based on the transformation shown in Fig.3.2 (b), brightens the desired range of gray
levels but preserves the background and gray-level tonalities in the image. Figure 3.2(c) shows
a gray-scale image, and Fig. 3.2(d) shows the result of using the transformation in Fig.
3.2(a).Variations of the two transformations shown in Fig. are easy to formulate.

Fig. 3.2(a)This transformation highlights range [A,B] of gray levels and reduces all others to a
constant level (b) This transformation highlights range [A,B] but preserves all other levels.
(c) An image . (d) Result of using the transformation in (a).
Figure 1.2 is also an example of Intensity Level Transformations.

Q4. Explain Bit-Plane Slicing.


Instead of highlighting gray-level ranges, highlighting the contribution made to total
image appearance by specific bits might be desired. Suppose that each pixel in an image is
represented by 8 bits. Imagine that the image is composed of eight 1-bit planes, ranging from
bit-plane 0 for the least significant bit to bit plane 7 for the most significant bit. In terms of 8-
bit bytes, plane 0 contains all the lowest order bits in the bytes comprising the pixels in the
image and plane 7 contains all the high-order bits.
Figure 4.1 shows the various bit planes for any image shown. Note that the higher-order
bits (especially the top four) contain the majority of the visually significant data. The other bit
planes contribute to more subtle details in the image. Separating a digital image into its bit
planes is useful for analyzing the relative importance played by each bit of the image, a process
that aids in determining the adequacy of the number of bits used to quantize each pixel.

9
Figure 4.1 : Bit Plane representation of an 8-bit image.

In terms of bit-plane extraction for an 8-bit image, it is not difficult to show that the
(binary) image for bit-plane 7 can be obtained by processing the input image with a
thresholding gray-level transformation function that (1) maps all levels in the image between 0
and 127 to one level (for example, 0); and (2) maps all levels between 129 and 255 to another
(for example, 255).
Q5. Explain Histogram Processing.
The histogram of a digital image with gray levels in the range [0, L-1] is a discrete
function of the form
H(rk)=nk
where rk is the kth gray level and nk is the number of pixels in the image having the
level rk.. A normalized histogram is given by the equation
p(rk)=nk/n for k=0,1,2,…..,L-1
P(rk) gives the estimate of the probability of occurrence of gray level rk.
The sum of all components of a normalized histogram is equal to 1.
The histogram plots are simple plots of H(rk)=nk versus rk.

In the dark image the components of the histogram are concentrated on the low (dark) side of
the gray scale. In case of bright image the histogram components are baised towards the high
side of the gray scale. The histogram of a low contrast image will be narrow and will be
centered towards the middle of the gray scale.
The components of the histogram in the high contrast image cover a broad range of the gray
scale. The net effect of this will be an image that shows a great deal of gray levels details and
has high dynamic range.

10
Figure 5.1 : Different types of Images and their Histograms
Q6. Explain Histogram Equalization:
Histogram equalization is a common technique for enhancing the appearance of images.
Suppose we have an image which is predominantly dark. Then its histogram would be skewed
towards the lower end of the grey scale and all the image detail are compressed into the dark
end of the histogram. If we could stretch out the grey levels at the dark end to produce a more
uniformly distributed histogram then the image would become much clearer.
Let there be a continuous function with r being gray levels of the image to be enhanced. The
range of r is [0, 1] with r=0 repressing black and r=1 representing white. The transformation
function is of the form
S=T(r) where 0<r<1

11
It produces a level s for every pixel value r in the original image.

Figure 6.1 : Different Functions

The transformation function is assumed to fulfill two condition T(r) is single valued and
monotonically increasing in the internal 0<T(r)<1 for 0<r<1.The transformation function
should be single valued so that the inverse transformations should exist. Monotonically
increasing condition preserves the increasing order from black to white in the output
image. The second conditions guarantee that the output gray levels will be in the same
range as the input levels. The gray levels of the image may be viewed as random variables
in the interval [0.1]. The most fundamental descriptor of a random variable is its
probability density function (PDF) Pr(r) and Ps(s) denote the probability density functions
of random variables r and s respectively. Basic results from an elementary probability
theory states that if Pr(r) and Tr are known and T-1(s) satisfies conditions (a), then the
probability density function Ps(s) of the transformed variable is given by the formula

Thus the PDF of the transformed variable s is the determined by the gray levels PDF of
the input image and by the chosen transformations function.
A transformation function of a particular importance in image processing

This is the cumulative distribution function of r.


L is the total number of possible gray levels in the image.
Q7. Write a note on Local Histogram Processing.

The histogram processing methods discussed in the previous two sections are global, in the
12
sense that pixels are modified by a transformation function based on the intensity distribution
of an entire image. Although this global approach is suitable for overall enhancement, there are
cases in which it is necessary to enhance details over small areas in an image. The number of
pixels in these areas may have negligible influence on the computation of a global
transformation whose shape does not necessarily guarantee the desired local enhancement. The
solution is to devise transformation functions based on the intensity distribution in a
neighborhood of every pixel in the image. The histogram processing techniques previously
described are easily adapted to local enhancement. The procedure is to define a neighborhood
and move its center from pixel to pixel. At each location, the histogram of the points in the
neighborhood is computed and either a histogram equalization or histogram specification
transformation function is obtained. This function is then used to map the intensity of the pixel
centered in the neighborhood. The center of the neighborhood region is then moved to an
adjacent pixel location and the procedure is repeated. Because only one row or column of the
neighborhood changes during a pixel-to-pixel translation of the neighborhood, updating the
histogram obtained in the previous location with the new data introduced at each motion step
is possible. This approach has obvious advantages over repeatedly computing the histogram of
all pixels in the neighborhood region each time the region is moved one pixel location. Another
approach used sometimes to reduce computation is to utilize nonoverlapping regions, but this
method usually produces an undesirable “blocky” effect.

Q8. How can Histogram Statistics be used for Image Enhancement.

Statistics obtained directly from an image histogram can be used for image enhancement. Let
r denote a discrete random variable representing intensity values in the range and let denote the
normalized histogram component corresponding to value As indicated previously, we may
view as an estimate of the probability that intensity occurs in the image from which the
histogram was obtained. The nth moment of r about its mean is defined as

where m is the mean (average intensity) value of r (i.e., the average intensity of the pixels in
the image):

13
The second moment is particularly important:

Whereas the mean is a measure of average intensity, the variance (or standard deviation) is a
measure of contrast in an image. Observe that all moments are computed easily using the
preceding expressions once the histogram has been obtained from a given image.

When working with only the mean and variance, it is common practice to estimate them directly
from the sample values, without computing the histogram. Appropriately, these estimates are
called the sample mean and sample variance. They are given by the following familiar
expressions from basic statistics:

for x = 0,1,2,,….M-1 and y = 0,1, 2….N-1. In other words, as we know, the mean intensity of
an image can be obtained simply by summing the values of all its pixels and dividing the sum
by the total number of pixels in the image.
Explain the functions of rods and cones along with the human eye structure and its details.
The eye is nearly a sphere, with an average diameter of approximately 20 mm. Three membranes enclose
the eye: the cornea and sclera outer cover; the choroid; and the retina. The cornea is a tough, transparent
tissue that covers the anterior surface of the eye. Continuous with the cornea, the sclera is an opaque
membrane that encloses the remainder of the optic globe. The choroid lies directly below the sclera. This
membrane contains a network of blood vessels that serve as the major source of nutrition to the eye.
Even superficial injury to the choroid, often not deemed serious, can lead to severe eye damage as a
result of inflammation that restricts blood flow. The choroid coat is heavily pigmented and hence helps
to reduce the amount of extraneous light entering the eye and the backscatter within the optic globe. At
its anterior extreme, the choroid is divided into the ciliary body and the iris. The latter contracts or
expands to control the amount of light that enters the eye. The central opening of the iris (the pupil)
varies in diameter from approximately 2 to 8 mm. The front of the iris contains the visible pigment of
the eye, whereas the back contains a black pigment. The lens is made up of concentric layers of fibrous
cells and is suspended by fibers that attach to the ciliary body. It contains 60 to 70% water, about 6%
fat, and more protein than any other tissue in the eye. The lens is colored by a slightly yellow
pigmentation that increases with age. In extreme cases, excessive clouding of the lens, caused by the
affliction commonly referred to as cataracts, can lead to poor color discrimination and loss of clear
vision. The lens absorbs approximately 8% of the visible light spectrum, with relatively higher
14
absorption at shorter wavelengths. Both infrared and ultraviolet light are absorbed appreciably by
proteins within the lens structure and, in excessive amounts, can damage the eye. The innermost
membrane of the eye is the retina, which lines the inside of the wall’s entire posterior portion. When the
eye is properly focused, light from an object outside the eye is imaged on the retina. Pattern vision is
afforded by the distribution of discrete light receptors over the surface of the retina. There are two classes
of receptors: cones and rods. The cones in each eye number between 6 and 7 million. They are located
primarily in the central portion of the retina, called the fovea, and are highly sensitive to color. Humans
can resolve fine details with these cones largely because each one is connected to its own nerve end.
Muscles controlling the eye rotate the eyeball until the image of an object of interest falls on the fovea.
Cone vision is called photopic or bright-light vision. ght-light vision. The number of rods is much larger:
Some 75 to 150 million are distributed over the retinal surface. The larger area of distribution and the
fact that several rods are connected to a single nerve end reduce the amount of detail discernible by these
receptors. Rods serve to give a general, overall picture of the field of view. They are not involved in
color vision and are sensitive to low levels of illumination. For example, objects that appear brightly
colored in daylight when seen by moonlight appear as colorless forms because only the rods are
stimulated. This phenomenon is known as scotopic or dim-light vision.

Figure 14 : Simplified diagram of a cross section of the human eye.

Figure 15 : Distribution of rods and cones in the retina.

15
Q9. Write a note on Mechanics of Spatial Filtering.

A spatial filter consists of (1) a neighborhood,(typically a small rectangle),and (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. If the operation performed on the
image pixels is linear, then the filter is called a linear spatial filter.

Figure 9.1 illustrates the mechanics of linear spatial filtering using a neighborhood. At any
point (x,y) in the image, the response, ,of the filter is the sum of products of the filter
coefficients and the image pixels encompassed by the filter:

16
Figure 9.1 : Mechanics of Spatial Filtering

Q9. Write a note on Spatial Correlation and Convolution.

17
Figure 9.2 : Illustration of Convolution and Correlation

we have that the correlation of a filter of size with an image , denoted as is given by the equation
listed at the end of the last section, which we repeat here for convenience:

And the equation for convolution is given by.

Q10. Write a note on Vector Representation of Linear Filtering

18
When interest lies in the characteristic response, R, of a mask either for correlation or
convolution, it is convenient sometimes to write the sum of products as

where the s are the coefficients of an filter and the zs are the corresponding image intensities
encompassed by the filter.

Figure 10.1: Another representation of a general filter mask.

Generating an linear spatial filter 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

In some applications, we have a continuous function of two variables, and the objective is to
obtain a spatial filter mask based on that function. For example,a Gaussian function of two
variables has the basic form

19
Generating a nonlinear filter requires that we specify the size of a neighborhood and the
operation(s) to be performed on the image pixels contained in the neighborhood.

Q11. Write a note on Smoothing Spatial Filters.

1. Smoothing Linear Filters

The output (response) of a smoothing, linear spatial filter is simply the average of the pixels
contained in the neighborhood of the filter mask. These filters sometimes are called averaging
filters. They also are referred to a lowpass filters.

The idea behind smoothing filters is straightforward. 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, 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 intensity transitions, so averaging filters have the
undesirable side effect that they blur edges. Another application of this type of process includes
the smoothing of false contours that result from using an insufficient number of intensity levels

Figure 11.1 : Two 3x3 smoothing (averaging) filter masks. The constant multiplier in front of
each mask is equal to 1 divided by the sum of the values of its coefficients, as is required to
compute an average. The idea here is that it is computationally more efficient to have
coefficients valued 1.At the end of the filtering process the entire image is divided by 9.An
mask would have a normalizing constant equal to mn.A spatial averaging filter in which all

20
coefficients are equal sometimes is called a box filter. The second mask in Fig.11.1 is a little
more interesting. This mask yields a so called weighted average, terminology used to indicate
that pixels are multiplied by different coefficients,thus giving more importance (weight) to
some pixels at the expense of others. the pixel at the center of the mask is multiplied by a higher
value than any other, thus giving this pixel more importance in the calculation of the average.
The other pixels are inversely weighted as a function of their distance from the center of the
mask. The diagonal terms are further away from the center than the orthogonal neighbors (by
a factor of ) and, thus, are weighed less than the immediate neighbors of the center pixel. The
basic strategy behind weighing the center point the highest and then reducing the value of the
coefficients as a function of increasing distance from the origin is simply an attempt to reduce
blurring in the smoothing process. , the general implementation for filtering an image with a
weighted averaging filter of size (m and n odd) is given by the expression

Q12. Write a note on Order-Statistic (Nonlinear) 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. The best-known filter in
this category is the median filter, which, as its name implies, 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. Although the
median filter is by far the most useful order-statistic filter in image processing, it is by no means
the only one. The median represents the 50th percentile of a ranked set of numbers, but recall
from basic statistics that ranking lends itself to many other possibilities. For example, using the
100th percentile results in the so-called max filter, which is useful for finding the brightest
points in an image. The response of a max filter is given by

The 0th percentile filter is the min filter, used for the
21
opposite purpose.

Q13. Explain the use of Derivatives as sharpening filters.

The derivatives of a digital function are defined in terms of differences. There are various ways
to define these differences. However, we require that any definition we use for a first derivative
(1) must be zero in areas of constant intensity; (2) must be nonzero at the onset of an intensity
step or ramp; and (3) must be nonzero along ramps. Similarly, any definition of a second
derivative (1) must be zero in constant areas; (2) must be nonzero at the onset and end of an
intensity step or ramp; and (3) must be zero along ramps of constant slope. Because we are
dealing with digital quantities whose values are finite, the maximum possible intensity change
also is finite, and the shortest distance over which that change can occur is between adjacent
pixels. A basic definition of the first-order derivative of a one-dimensional function is the
difference

We define the second-order derivative of as the difference

22
Figure 13.1: Illustration of the first and second derivatives of a 1-D digital function representing
a section of a horizontal intensity profile from an image. In (a) and (c) data points are joined
by dashed lines as a visualization aid.

Let us consider the properties of the first and second derivatives as we traverse the profile from
left to right. First, we encounter an area of constant intensity and, as Figs.13.1(b)and (c) show,
both derivatives are zero there, so condition (1) is satisfied for both. Next, we encounter an
intensity ramp followed by a step, and we note that the first-order derivative is nonzero at the
onset of the ramp and the step; similarly, the second derivative is nonzero at the onset and end
of both the ramp and the step; therefore, property (2) is satisfied for both derivatives. Finally,
we see that property (3) is satisfied also for both derivatives because the first derivative is
nonzero and the second is zero along the ramp. Note that the sign of the second derivative
changes at the onset and end of a step or ramp. In fact, we see in Fig.13.1(c) that in a step
23
transition a line joining these two values crosses the horizontal axis midway between the two
extremes.

Q14. Explain the use of the Second Derivative for Image Sharpening—The Laplacian

We are interested in isotropic filters, whose response is independent of the direction of the
discontinuities in the image to which the filter is applied. In other words, isotropic filters are
rotation invariant, in the sense that rotating the image and then applying the filter gives the
same result as applying the filter to the image first and then rotating the result. The Laplacian
is defined as

In the x-direction, we have

and, similarly, in the y-direction we have

Therefore, it follows from the preceding three equations that the discrete Laplacian of two
variables is

24
Figure 14.1 : (a) Filter mask used to implement Eq.(3.6-6). (b) Mask used to implement an
extension of this equation that includes the diagonal terms. (c) and (d) Two other
implementations of the Laplacian found frequently in practice.

Thus,the basic way in which we use the Laplacian for image sharpening is

Q15. Write a note on Unsharp Masking and High Boost Filtering.

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, consists of the following steps:

1. Blur the original image.

2. 2. Subtract the blurred image from the original (the resulting difference is called the mask.)

3. Add the mask to the original.

25
Letting denote the blurred image, unsharp masking is expressed in equation form as
follows. First we obtain the mask:

Then we add a weighted portion of the mask back to the original image:

where we included a weight, for generality. When we have unsharp masking, as defined
above. When the process is referred to as highboost filtering.Choosing de-emphasizes the
contribution of the unsharp mask.

Figure 3.39 explains how unsharp masking works. The intensity profile in Fig.15.1(a)can
be interpreted as a horizontal scan line through a vertical edge that transitions from a dark
to a light region in an image. Figure 15.1 (b) shows the result of smoothing, superimposed
on the original signal (shown dashed) for reference.Figure 15.1 (c) is the unsharp
mask,obtained by subtracting the blurred signal from the original. By comparing this result
with the section of Fig. 15.1 (c)corresponding to the ramp in Fig.3.36(a),we note that the
unsharp mask in Fig. 15.1 (c) is very similar to what we would obtain using a secondorder
derivative. Figure 15.1 (d) is the final sharpened result, obtained by adding the mask to the
original signal. The points at which a change of slope in the intensity occurs in the signal
are now emphasized (sharpened). Observe that negative values were added to the
original.Thus,it is possible for the final result to have negative intensities if the original
image has any zero values or if the value of k is chosen large enough to emphasize the
peaks of the mask to a level larger than the minimum value in the original. Negative values
would cause a dark halo around edges,which,if kis large enough,can produce objectionable
results.

26
Figure 15.1: 1-D illustration of the mechanics of unsharp masking. (a) Original signal.(b)
Blurred signal with original shown dashed for reference.(c) Unsharp mask.(d) Sharpened
signal, obtained by adding (c) to (a).

Q16. Explain the Use of First-Order Derivatives for (Nonlinear) Image Sharpening—
The Gradient.

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

This vector has the important geometrical property that it points in the direction of the
greatest rate of change of f at location (x, y). The magnitude (length) of vector denoted as
M(x, y),where
27
is the value at (x, y) of the rate of change in the direction of the gradient vector.Note that
M(x,y) is an image of the same size as the original,created when x and y are allowed to
vary over all pixel locations in f.It is common practice to refer to this image as the gradient
image (or simply as the gradient when the meaning is clear).

Because the components of the gradient vector are derivatives,they are linear operators.
However, the magnitude of this vector is not because of the squaring and square root
operations.On the other hand,the partial derivatives in Eq.(3.6-10) are not rotation invariant
(isotropic),but the magnitude of the gradient vector is.In some implementations,it is more
suitable computationally to approximate the squares and square root operations by absolute
values:

This expression still preserves the relative changes in intensity,but the isotropic property is
lost in general.

Figure 16.1: A region of an image (the zs are intensity values). (b)–(c) Roberts cross
gradient operators. (d)–(e) Sobel operators.All the mask coefficients sum to zero,as
expected of a derivative operator.

28
Approximations to and using a neighborhood centered on are as follows:

Problems
Histogram Equalization/Linearization
P1. For the 3 bit image as shown below, draw the original Histogram, the transformation
function and the equalized Histogram along with the steps involved in brief. Image has totally
4096 pixels.

rk 0 1 2 3 4 5 6 7
nk 790 1023 850 656 329 245 122 81

Solution: Formula to be used for calculating sk

29
Similarly

And so on. We get the following values.

These are the values of the equalized histogram. Observe that there are only five distinct intensity
levels. Because was mapped to there are 790 pixels in the histogram equalized image with this value.
Also, there are in this image 1023 pixels with a value of and 850 pixels with a value of However
both and were mapped to the same value,6,so there are pixels in the equalized image with this value.
Similarly, there are pixels with a value of 7 in the histogram equalized image. Dividing these
numbers by yielded the equalized histogram.

Histogram Specification(Matching)
We may summarize the histogram-specification procedure as follows:
1. Compute the histogram of the given image, and use it to find the histogram equalization
transformation in the following Equation.

Round the resulting values, to the integer range [0, L-1]

30
2. Compute all values of the transformation function G, using the Equation below, for q =
0,1,2….L-1, where pz(zi) are the values of the specified histogram. Round the values of G to
integers in the range [0-L-1] . Store the values of G in a table.

3. For every value of use the stored values of G from step 2 to find the corresponding value of zq, so
that G(zq) is closest to and store these mappings from s to z. When more than one value of sk satisfies
the given sk(i.e.,the mapping is not unique),choose the smallest value by convention.

4. Form the histogram-specified image by first histogram-equalizing the input image and then
mapping every equalized pixel value sk, of this image to the corresponding value zq in the histogram-
specified image using the mappings found in step 3.As in the continuous case, the intermediate step
of equalizing the input image is conceptual.

P2. Consider again the hypothetical image from Example above, whose histogram is calculated
above. It is desired to transform this histogram so that it will have the values specified in the
second column of Table below. Figure 2.1 shows a sketch of this histogram.

Table P2.1

Solution :

The first step in the procedure is to obtain the scaled histogram-equalized values, which we did
in Equalization problem.

31
In the next step, we compute all the values of the transformation function, G, using Equation

These fractional values are converted to integers in our valid range,[0,7].The results are:

These results are summarized in Table P2.1, and the transformation function is sketched in
Fig.P2.1(c)

In the third step, we find the smallest value of zq so that the value G(zq) is the closest to sk. We do
this for every value of sk to create the required mappings from s to z. For example, s0 = 1 and we see
that G(z3) = 1which is a perfect match in this case, so we have the correspondence s0 → z3. That is,
every pixel whose value is 1 in the histogram equalized image would map to a pixel valued 3 (in the
corresponding location) in the histogram-specified image. Continuing in this manner, we arrive at
the mappings in Table P2.2.

32
Table P2.2 : All possible values of the transformation function G scaled, rounded,and ordered
with respect to z.

In the final step of the procedure, we use the mappings in Table P2.3 to map every pixel in the
histogram equalized image into a corresponding pixel in the newly created histogram-specified
image. The values of the resulting histogram are listed in the third column of Table P2.1, and the
histogram is sketched in Fig. 2.1(d). The values of were obtained using the same procedure as in
Example P1 .For instance, we see in Table P2.2 that maps to and there are 790 pixels in the
histogram-equalized image with a value of 1.Therefore,

Figure P2.1 : (a) Histogram of a 3-bit image.(b) Specified histogram. (c) Transformation
function obtained from the specified histogram. (d) Result of performing histogram
specification. Compare (b) and (d).

Table P2.3 : Mappings of all the values of sk into corresponding values of zq.

33
P3. Consider the following 2-bit image of size 5 * 5. Calculate the mean.

Solution:
Use the Formula :

The pixels are represented by 2 bits; therefore, and the intensity levels are in the range [0,3].The total
number of pixels is 25,so the histogram has the components.

Letting denote the preceding array and using Equation below, we obtain

34
IMAGE ENHANCEMENT IN FREQUENCY DOMAIN
BLURRING/NOISE REDUCTION: Noise characterized by sharp transitions in image
intensity. Such transitions contribute significantly to high frequency components of Fourier
transform. Intuitively, attenuating certain high frequency components result in blurring and
reduction of image noise.
Q17. Write a note on Ideal Low-Pass Filter.
Cuts off all high-frequency components at a distance greater than a certain distance
from origin (cutoff frequency).
H (u,v) = 1, if D(u,v) ≤ D0
0, if D(u,v) ˃ D0
Where D0 is a positive constant and D(u,v) is the distance between a point (u,v) in the
frequency domain and the center of the frequency rectangle; that is

D(u,v) = [(u-P/2)2 + (v-Q/2)2] 1/2

Where as P and Q are the padded sizes from the basic equations
Wraparound error in their circular convolution can be avoided by padding these
functions with zeros,
VISUALIZATION: IDEAL LOW PASS FILTER:
Aa shown in fig.below

Fig 17.1: ideal low pass filter 3-D view and 2-D view and line graph.

35
EFFECT OF DIFFERENT CUTOFF FREQUENCIES:
Fig.below17.2(a) Test pattern of size 688x688 pixels, and (b) its Fourier spectrum. The
spectrum is double the image size due to padding but is shown in half size so that it fits in the
page. The superimposed circles have radii equal to 10, 30, 60, 160 and 460 with respect to the
full- size spectrum image. These radii enclose 87.0, 93.1, 95.7, 97.8 and 99.2% of the padded
image power respectively.

Fig: 17.2(a) Test patter of size 688x688 pixels (b) its Fourier spectrum

Fig: (a) original image, (b)-(f) Results of filtering using ILPFs with cutoff frequencies
set at radii values 10, 30, 60, 160 and 460, as shown in fig.2.2.2(b). The power removed by
these filters was 13, 6.9, 4.3, 2.2 and 0.8% of the total, respectively.

36
As the cutoff frequency decreases,
• image becomes more blurred
• Noise becomes increases
• Analogous to larger spatial filter sizes
The severe blurring in this image is a clear indication that most of the sharp detail information
in the picture is contained in the 13% power removed by the filter. As the filter radius is
increases less and less power is removed, resulting in less blurring. Fig. (c ) through
(e) are characterized by “ringing” , which becomes finer in texture as the amount of high
frequency content removed decreases.
Q18. What is Ringing ? Why is it caused ?
Ideal low-pass filter function is a rectangular function
The inverse Fourier transform of a rectangular function is a sinc function.

Fig 18.1. Spatial representation of ILPFs of order 1 and 20 and corresponding intensity
profiles through the center of the filters( the size of all cases is 1000x1000 and the cutoff
frequency is 5), observe how ringing increases as a function of filter order.
BUTTERWORTH LOW-PASS FILTER:
Transfor funtion of a Butterworth lowpass filter (BLPF) of order n, and with cutoff
frequency at a distance D0 from the origin, is defined as

37
-

Transfer function does not have sharp discontinuity establishing cutoff between
passed and filtered frequencies.
Cut off frequency D0 defines point at which H(u,v) = 0.5

Fig. 18.2 (a) perspective plot of a Butterworth lowpass-filter transfer function. (b)
Filter displayed as an image. (c)Filter radial cross sections of order 1 through 4.
Unlike the ILPF, the BLPF transfer function does not have a sharp discontinuity that
gives a clear cutoff between passed and filtered frequencies.
Q19. Wite a note on Butterworth Low-Pass Filters Of different Frequencies:

Fig. 19.1(a) Original image.(b)-(f) Results of filtering using BLPFs of order 2, with cutoff
frequencies at the radii

38
Fig. shows the results of applying the BLPF of eq. to fig.(a), with n=2 and D0 equal to
the five radii in fig.(b) for the ILPF, we note here a smooth transition in blurring as a function
of increasing cutoff frequency. Moreover, no ringing is visible in any of the images processed
with this particular BLPF, a fact attributed to the filter’s smooth transition between low and
high frequencies.
A BLPF of order 1 has no ringing in the spatial domain. Ringing generally is
imperceptible in filters of order 2, but can become significant in filters of higher order.
Fig.shows a comparison between the spatial representation of BLPFs of various orders
(using a cutoff frequency of 5 in all cases). Shown also is the intensity profile along a horizontal
scan line through the center of each filter. The filter of order 2 does show mild ringing and
small negative values, but they certainly are less pronounced than in the ILPF. A butter worth
filter of order 20 exhibits characteristics similar to those of the ILPF (in the limit, both filters
are identical).

Fig.19.2 (a)-(d) Spatial representation of BLPFs of order 1, 2, 5 and 20 and


corresponding intensity profiles through the center of the filters (the size in all cases is 1000 x
1000 and the cutoff frequency is 5) Observe how ringing increases as a function of filter order.
Q20. Write a note on Gaussian Lowpass Filters:
The form of these filters in two dimensions is given by

• This transfer function is smooth , like Butterworth filter.


• Gaussian in frequency domain remains a Gaussian in spatial domain
• Advantage: No ringing artifacts.

39
Where D0 is the cutoff frequency. When D(u,v) = D0, the GLPF is down to 0.607 of its
maximum value. This means that a spatial Gaussian filter, obtained by computing the IDFT of
above equation., will have no ringing. Fig..shows a perspective plot, image display and radial
cross sections of a GLPF function.

Fig. 20.1(a) Perspective plot of a GLPF transfer function. (b) Filter displayed as an
image. (c). Filter radial cross sections for various values of D0

Fig.20.2(a) Original image. (b)-(f) Results of filtering using GLPFs with cutoff
frequencies at the radii shown

40
Fig. 20.3(a) Original image (784x 732 pixels). (b) Result of filtering using a GLPF with
D0 = 100. (c) Result of filtering using a GLPF with D0 = 80. Note the reduction in fine skin
lines in the magnified sections in (b) and (c).
Fig. shows an application of lowpass filtering for producing a smoother, softer- looking
result from a sharp original. For human faces, the typical objective is to reduce the sharpness
of fine skin lines and small blemished.
Q21. Write a note on Image Sharpening Using Frequency Domain Filters.
An image can be smoothed by attenuating the high-frequency components of its Fourier
transform. Because edges and other abrupt changes in intensities are associated with high-
frequency components, image sharpening can be achieved in the frequency domain by high
pass filtering, which attenuates the low-frequency components without disturbing high-
frequency information in the Fourier transform.
The filter function H(u,v) are understood to be discrete functions of size PxQ; that is
the discrete frequency variables are in the range u = 0,1,2,…….P-1 and v = 0,1,2,…….Q-1.
The meaning of sharpening is
• Edges and fine detail characterized by sharp transitions in image intensity
• Such transitions contribute significantly to high frequency components of
Fourier transform
• Intuitively, attenuating certain low frequency components and preserving high
frequency components result in sharpening.
Intended goal is to do the reverse operation of low-pass filters
• When low-pass filter attenuated frequencies, high-pass filter passes them

41
• When high-pass filter attenuates frequencies, low-pass filter passes them.
A high pass filter is obtained from a given low pass filter using the equation.
H hp (u,v) = 1- Htp (u,v)
Where Hlp (u,v) is the transfer function of the low-pass filter. That is when the low-
pass filter attenuates frequencies, the high-pass filter passed them, and vice-versa.
We consider ideal, Butter-worth, and Gaussian high-pass filters. As in the previous
section, we illustrate the characteristics of these filters in both the frequency and spatial
domains. Fig.. shows typical 3-D plots, image representations and cross sections for these
filters. As before, we see that the Butter-worth filter represents a transition between the
sharpness of the ideal filter and the broad smoothness of the Gaussian filter. Fig.discussed in
the sections the follow, illustrates what these filters look like in the spatial domain. The spatial
filters were obtained and displayed by using the procedure used.

Fig 21.1: Top row: Perspective plot, image representation, and cross section of a typical
ideal high-pass filter. Middle and bottom rows: The same sequence for typical butter-worth and
Gaussian high-pass filters.
Q22. Write a note on Ideal High-Pass Filter:
A 2-D ideal high-pass filter (IHPF) is defined as
H (u,v) = 0, if D(u,v) ≤ D0
1, if D(u,v) ˃ D0

42
Where D0 is the cutoff frequency and D(u,v) is given by eq. As intended, the IHPF is
the opposite of the ILPF in the sense that it sets to zero all frequencies inside a circle of
radius D0 while passing, without attenuation, all frequencies outside the circle. As in case of
the ILPF, the IHPF is not physically realizable.
SPATIAL REPRESENTATION OF HIGHPASS FILTERS:

Fig.22.1 Spatial representation of typical (a) ideal (b) Butter-worth and (c) Gaussian
frequency domain high-pass filters, and corresponding intensity profiles through their centers.

We can expect IHPFs to have the same ringing properties as ILPFs. This is demonstrated
clearly in Fig.. which consists of various IHPF results using the original image in Fig.(a) with
D0 set to 30, 60,and 160 pixels, respectively. The ringing in Fig. (a) is so severe that it
produced distorted, thickened object boundaries (e.g.,look at the large letter “a”). Edges of the
top three circles do not show well because they are not as strong as the other edges in the
image (the intensity of these three objects is much closer to the background intensity, giving
discontinuities of smaller magnitude).
FILTERED RESULTS: IHPF:

Fig.22.2. Results of high-pass filtering the image in Fig.(a) using an IHPF with D0 =
30, 60, and 160.

43
The situation improved somewhat with D0 = 60. Edge distortion is quite evident still,
but now we begin to see filtering on the smaller objects. Due to the now familiar inverse
relationship between the frequency and spatial domains, we know that the spot size of this filter
is smaller than the spot of the filter with D0 = 30. The result for D0 = 160 is closer to what a
high-pass filtered image should look like. Here, the edges are much cleaner and less distorted,
and the smaller objects have been filtered properly.
Of course, the constant background in all images is zero in these high-pass filtered
images because highpass filtering is analogous to differentiation in the spatial domain.
Q23. Write a note on Butter-Worth High-Pass Filters.
A 2-D Butter-worth high-pass filter (BHPF) of order n and cutoff frequency D0 is defined as

Where D(u,v) is given by Eq.(3). This expression follows directly from Eqs.(3) and (6).
Butter-worth high-pass filter to behave smoother than IHPFs. The performance of a BHPF of
order 2 and with D0 set to the same values as before. The boundaries are much less distorted.
even for the smallest value of cutoff frequency.
FILTERED RESULTS: BHPF:

Fig 23.1. Results of high-pass filtering the image in Fig.(a) using a BHPF of order 2
with D0 = 30, 60, and 160 corresponding to the circles in Fig.(b). These results are much
smoother than those obtained with an IHPF.
Q24. Write a note on Gaussian High-Pass Filters.
The transfer function of the Gaussian high-pass filter(GHPF) with cutoff frequency
locus at a distance D0 from the center of the frequency rectangle is given by

44
Where D(u,v) is given by Eq.(4). This expression follows directly from Eqs.(2) and (6).
The third row in Fig.below. shows a perspective plot, image and cross section of the GHPF
function. Following the same format as for the BHPF,. comparable results using GHPFs. As
expected, the results obtained are more gradual than with the previous two filters.
FILTERED RESULTS:GHPF:

Fig 24.1 . Results of high-pass filtering the image in fig.(a) using a GHPF with D0 =
30, 60 and 160, corresponding to the circles in Fig.(b).

45

You might also like