DIP Module2
DIP Module2
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
Scheme: 2017
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.
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.
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.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.
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.
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
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.
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.
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
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.
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.
15
Q9. Write a note on Mechanics of Spatial Filtering.
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
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:
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.
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.
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
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.
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
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
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
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:
2. 2. Subtract the blurred image from the original (the resulting difference is called the mask.)
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
29
Similarly
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.
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
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).
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