0% found this document useful (0 votes)
5 views37 pages

Digital Image Processing Concepts Explained

Uploaded by

mangatha935
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views37 pages

Digital Image Processing Concepts Explained

Uploaded by

mangatha935
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

B.N.M.

Institute of Technology
ELECTRONICS AND COMMUNICATION ENGINEERING

Semester: V Sem ECE

Scheme: 2022

Course: Digital Image Processing

Course Code: 22ECE51

Faculty: Dr. Keerti Kulkarni


Digital Image Processing (22ECE151)

Module -2
Image Enhancement

Q1. Explain the concepts of Sampling and Quantization with respect to Image Processing.

Figure 1: Image, sampling, quantization and digitization


Digitizing the coordinate values is called sampling. Digitizing the amplitude values is called
quantization.
This digitization process requires that decisions be made regarding the values for M, N, and for the
number, L, of discrete intensity levels. There are no restrictions placed on M and N, other than they have
to be positive integers. However, due to storage and quantizing hardware considerations, the number of
intensity levels typically is an integer power of 2:
𝐿 = 2𝑘
We assume that the discrete levels are equally spaced and that they are integers in the interval
Sometimes, the range of values spanned by the gray scale is referred to informally as the dynamic range.
This is a term used in different ways in different fields. Here, we define the dynamic range of an imaging
system to be the ratio of the maximum measurable intensity to the minimum [0, L - 1].
The number, b, of bits required to store a digitized image is M x N x k
Q2. Define the terms - Spatial Resolution and Intensity Resolution.
Spatial resolution is a measure of the smallest discernible detail in an image. Quantitatively,spatial
resolution can be stated in a number of ways, with line pairs per unit distance, and dots (pixels) per unit
Dr. Keerti Kulkarni, ECE, BNMIT Page 1 of 36
Digital Image Processing (22ECE151)

distance being among the most common measures. A widely used definition of image resolution is the largest
number of discernible line pairs per unit distance (e.g., 100 lines pairs per mm). Dots per unit distance
is a measure of image resolution used commonly in the printing and publishing industry. Reducing the
spatial resolution of an images reduces the quality of an image, producing a checkerboard effect.
Intensity resolution similarly refers to the smallest discernible change in intensity level. Unlike spatial
resolution, which must be based on a per unit of distance basis to be meaningful, it is common practice
to refer to the number of bits used to quantize intensity as the intensity resolution. For example, it is
common to say that an image whose intensity is quantized into 256 levels has 8 bits of intensity
resolution. Because true discernible changes in intensity are influenced not only by noise and saturation
values but also by the capabilities of human perception, saying than an image has 8 bits of intensity
resolution is nothing more than a statement regarding the ability of an 8-bit system to quantize intensity
in fixed increments of units of intensity amplitude.
Reducing the intensity resolution causes false contouring. It is caused by the use of an insufficient
number of intensity levels in smooth areas of a digital image.
Q3. Describe Brightness Adaptation and Discrimination
As the digital images are displayed as a discrete set of intensities, the eye’s ability to discriminate
between different intensity levels is an important consideration in presenting image processing results.
The range of light intensity levels to which the human visual system can adapt is enormous—on the
order of 1010 from the scotopic threshold to the glare limit. Experimental evidence indicates that
subjective brightness (intensity as perceived by the human visual system) is a logarithmic function of
the light intensity incident on the eye.
Figures 2a and 2b shows the brightness sensation curve and variation of weber ratio as a function of
intensity. The long solid curve represents the range of intensities to which the visual system can adapt.
In photopic vision alone, the range is about the transition from scotopic to photopic vision is gradual
over the approximate range from 0.001. to 0.1 millilambert (to in the log scale), as the double branches
of the adaptation curve in this range show.
The essential point in interpreting the impressive dynamic range is that the visual system cannot operate
over such a range simultaneously. Rather, it accomplishes this large variation by changing its overall
sensitivity, a phenomenon known as brightness adaptation. The total range of distinct intensity levels
the eye can discriminate simultaneously is rather small when compared with the total adaptation range.
For any given set of conditions, the current sensitivity level of the visual system is called the brightness
adaptation level, which may correspond, for example, to brightness. The short intersecting curve
represents the range of subjective brightness that the eye can perceive when adapted to this level. This
range is rather restricted, having a level at and below which all stimuli are perceived as indistinguishable

Dr. Keerti Kulkarni, ECE, BNMIT Page 2 of 36


Digital Image Processing (22ECE151)

blacks. The upper portion of the curve is not actually restricted but, if extended too far, loses its meaning
because much higher intensities would simply raise the adaptation level higher than B a.

Fig 2a: Range of Subjective Brightness Fig 2b: Weber Ratio as a function of Intensity

Q4. What are Isotropic Curves? Explain with a diagram.


Sets of three types of images - Facial image of Lena, Cameraman and crowd were generated by varying
N and k,and observers were then asked to rank them according to their subjective quality. Results were
summarized in the form of so-called isopreference curves in the Nk-plane. Each point in the Nk-plane
represents an image having values of N and k equal to the coordinates of that point. Points lying on an
isopreference curve correspond to images of equal subjective quality. It was found in the course of the
experiments that the isopreference curves tended to shift right and upward, but their shapes in each of
the three image categories were similar. This is not unexpected, because a shift up and right in the curves
simply means larger values for N and k, which implies better picture quality.
The key point of interest in the context of the present discussion is that isopreference curves tend to
become more vertical as the detail in the image increases. This result suggests that for images with a
large amount of detail only a few intensity levels may be needed. For example, the isopreference curve
corresponding to the crowd is nearly vertical. This indicates that, for a fixed value of N, the perceived
quality for this type of image is nearly independent of the number of intensity levels used. It is of interest
also to note that perceived quality in the other two image categories remained the same in some intervals
in which the number of samples was increased, but the number of intensity levels actually decreased.
The most likely reason for this result is that a decrease in k tends to increase the apparent contrast, a
visual effect that humans often perceive as improved quality in an image.

Dr. Keerti Kulkarni, ECE, BNMIT Page 3 of 36


Digital Image Processing (22ECE151)

Figure 3: Isotropic Curves


Q5. What is Image Interpolation? Explain in detail .
Interpolation is a basic tool used extensively in tasks such as zooming, shrinking, rotating and geometric
corrections. Fundamentally, interpolation is the process of using known data to estimate values at
unknown locations. Suppose that an image of size pixels has to be enlarged 1.5 times to pixels. A simple
way to visualize zooming is to create an imaginary grid with the same pixel spacing as the original, and
then shrink it so that it fits exactly over the original image. Obviously, the pixel spacing in the shrunken
grid will be less than the pixel spacing in the original image. To perform intensity-level assignment for
any point in the overlay, we look for its closest pixel in the original image and assign the intensity of
that pixel to the new pixel in the grid. When we are finished assigning intensities to all the points in the
overlay grid, we expand it to the original specified size to obtain the zoomed image. The method just
discussed is called nearest neighbor interpolation because it assigns to each new location the intensity
of its nearest neighbor in the original image. A more suitable approach is bilinear interpolation, in which
we use the four nearest neighbors to estimate the intensity at a given location. Let (x, y) denote the
coordinates of the location to which we want to assign an intensity value (think of it as a point of the
grid described previously), and let v(x, y) denote that intensity value. For bilinear interpolation the
assigned value is obtained using the equation

where the four coefficients are determined from the four equations in four unknowns that can be written
using the four nearest neighbors of point. Bilinear interpolation gives much better results than nearest
neighbor interpolation, with a modest increase in computational burden. The next level of complexity is
bicubic interpolation, which involves the sixteen nearest neighbors of a point. The intensity value
assigned to point is obtained using the equation

Dr. Keerti Kulkarni, ECE, BNMIT Page 4 of 36


Digital Image Processing (22ECE151)

where the sixteen coefficients are determined from the sixteen equations in sixteen unknowns that can
be written using the sixteen nearest neighbors of point.
Q6. Explain some basic relationships between pixels with respect to neighbors of a pixel.
A pixel p at coordinates (x, y) has four horizontal and vertical neighbors whose coordinates are given
by

This set of pixels, called the 4-neighbors of p is denoted by N4(p). Each pixel is at a unit distance from
(x, y) and some of the neighbor locations of p lie outside the digital image if (x, y) is on the border of
the image.
The four diagonal neighbors of p have coordinates

and are denoted by ND(p).


These points, together with the 4-neighbors, are called the 8-neighbors of p, denoted by N8(p). Some of
the neighbor locations may fall outside the image if (x, y) is on the border of the image.
Q7. Explain 4-Adjacency, 8- adjacency and m-adjacency.
Let V be the set of intensity values used to define adjacency.
Binary image consists of only 2 intensity values, where 0 represents black and 1 represents white. In a
binary image, V = {1}, if we are referring to adjacency of pixels with value 1. In a gray-scale image, the
idea is the same, but set V typically contains more elements. For example, in the adjacency of pixels
with a range of possible intensity values 0 to 255, set V could be any subset of these 256 values. We
consider three types of adjacency:
(a) 4-adjacency. Two pixels p and q with values from V are 4-adjacent if q is in the set N4(p)
(b) 8-adjacency. Two pixels p and q with values from V are 8-adjacent if q is in the set N8(p)
(c) m-adjacency (mixed adjacency). Two pixels p and q with values from V are m-adjacent if
(i) q is in N4(p) or (ii) q is in ND(p) and the set N4(p) ∩ N4(q) has no pixels whose values are from V.
Mixed adjacency is a modification of 8-adjacency. It is introduced to eliminate the ambiguities that often
arise when 8-adjacency is used.

Dr. Keerti Kulkarni, ECE, BNMIT Page 5 of 36


Digital Image Processing (22ECE151)

Figure 4: Binary image, ambiguity in 8-adjacency, m-adjacency, Connected regions, closed path
for the pixed, closed path of 0.
Q8. Explain the different Distance Measures along with formulae.
For pixels p, q and z, with coordinates (x, y), (s, t) and (v, w) respectively, D is a distance function or
metric if

The Euclidean distance between p and q is defined as

For this distance measure, the pixels having a distance less than or equal to some value r from (x, y) are
the points contained in a disk of radius r centered at (x, y).
The City block distance (D4 distance) between p and q is defined as

In this case, the pixels having a distance from (x, y) less than or equal to some value r form a diamond
centered at (x, y). For example, the pixels with distance from (x, y) (the center point) form the following
contours of constant distance:

Dr. Keerti Kulkarni, ECE, BNMIT Page 6 of 36


Digital Image Processing (22ECE151)

The pixels with D4 = 1 are the 4-neighbors of (x, y).


The chessboard distance (D8 distance) between p and q is defined as

In this case, the pixels with D8 distance from (x, y) less than or equal to some value r form a square
centered at 0. For example, the pixels with D8 distance ≤ 2 from (x, y) (the center point) form the
following contours of constant distance as shown below.

Q9. For the following figure, find the length of the shortest 4-path, 8-path and m-path.

Solution: When V = {0, 1}, 4-path does not exist between p and q because it is impossible to get from p
to q by traveling along points that are both 4-adjacent and also have values from V . Figure (a) shows
this condition, it is not possible to get to q.
The shortest 8-path is shown in Fig. (b). its length is 4.
The length of the shortest m- path (shown dashed) is 5. Both of these shortest paths are unique in this
case.
(b) One possibility for the shortest 4-path when V = {1, 2} is shown in Fig. (c), its length is 6. It is easily
verified that another 4-path of the same length exists between p and q.
One possibility for the shortest 8-path (it is not unique) is shown in Fig. (d) and its length is 4.
The length of a shortest m-path (shown dashed) is 6. This path is not unique.

Dr. Keerti Kulkarni, ECE, BNMIT Page 7 of 36


Digital Image Processing (22ECE151)

Q10. Considering m-adjacency, find the Dm distance between p and p4 in the following example.

Solution:
Dm distance between two points is defined as the shortest m-path between the points. In this case, the
distance between two pixels will depend on the values of the pixels along the path, as well as the values
of their neighbors.
Suppose that we consider adjacency of pixels valued 1 (i.e, V = {1}). If p1 and p3 are 0, the length of
the shortest m-path (the distance) between p and p4 is 2. If p1 is 1,then p2 and p will no longer be m-
adjacent and the length of the shortest m-path becomes 3 (the path goes through the points pp1p2p4 ).
Similar comments apply if p3 is 1 (and p1 is 0);in this case, the length of the shortest m-path also is 3.
Finally, if both p1 and p3 are 1, the length of the shortest m-path between p and p4 is 4. In this case, the
path goes through the sequence of points pp1p2p3p4
Q11. Explain Linear and Non Linear Operations with examples
Consider a general operator, H, that produces an output image, g(x, y), for a given input image, f(x, y):

H is said to be a linear operator if

Dr. Keerti Kulkarni, ECE, BNMIT Page 8 of 36


Digital Image Processing (22ECE151)

Where ai, aj, fi (x, y) and fj (x, y) are arbitrary constants and images (of the same size), respectively. The
above equation indicates that the output of a linear operation due to the sum of two inputs is the same as
performing the operation on the inputs individually and then summing the results. In addition, the output
of a linear operation to a constant time an input is the same as the output of the operation due to the
original input multiplied by that constant. The first property is called the property of additivity and the
second is called the property of homogeneity.
As a simple example, suppose that H is the sum operator, that is, the function of this operator is simply
to sum its inputs.

Example: Sum operator is linear and max operator is non-linear. The example below shows that a max
operator is a non-linear operator. Consider the following two images

and suppose that we let a1 = 1 and a2 = -1. To test for linearity, we again start with the left side of the
equation described above

Working next with the right side, we obtain

Dr. Keerti Kulkarni, ECE, BNMIT Page 9 of 36


Digital Image Processing (22ECE151)

Spatial Domain

Q12. 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. 5
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.

Dr. Keerti Kulkarni, ECE, BNMIT Page 10 of 36


Digital Image Processing (22ECE151)

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


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. 6(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. 6(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. 6, 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 6: Intensity level transformation functions for contrast enhancement.


Image enhancement can be done through gray level transformations which are
discussed below.
Q13. Define Linear transformation. Explain the following three Basic Intensity Level
Transformation functions with relevant graphs, equation and examples.
• Image negative
• Log transformations
• Power law transformations

Dr. Keerti Kulkarni, ECE, BNMIT Page 11 of 36


Digital Image Processing (22ECE151)

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 7: Linear transformation between input and output.

3 Basic Intensity Transformation:


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.

Dr. Keerti Kulkarni, ECE, BNMIT Page 12 of 36


Digital Image Processing (22ECE151)

Input gray level, r

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

Dr. Keerti Kulkarni, ECE, BNMIT Page 13 of 36


Digital Image Processing (22ECE151)

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 9. 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.
Dr. Keerti Kulkarni, ECE, BNMIT Page 14 of 36
Digital Image Processing (22ECE151)

• 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 is 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. 10. 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. 10 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.

Dr. Keerti Kulkarni, ECE, BNMIT Page 15 of 36


Digital Image Processing (22ECE151)

The gamma of different display devices is different. For example, Gamma of CRT lies in
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.
Q14. 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.

Dr. Keerti Kulkarni, ECE, BNMIT Page 16 of 36


Digital Image Processing (22ECE151)

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

Fig. 11: Contrast stretching. (a) Form of transformation function. (b) A low-contrast
stretching. (c) Result of contrast stretching. (d) Result of thresholding.

Figure 11(b) shows an 8-bit image with low contrast. Fig. 11(c) shows the result of contrast
stretching, obtained by setting (r 1, 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. 11(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
Dr. Keerti Kulkarni, ECE, BNMIT Page 17 of 36
Digital Image Processing (22ECE151)

and a low value for all other gray levels.

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

Fig. 12(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).

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

Dr. Keerti Kulkarni, ECE, BNMIT Page 18 of 36


Digital Image Processing (22ECE151)

Figure 13 : 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).
Q15. 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(r k)=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.

Dr. Keerti Kulkarni, ECE, BNMIT Page 19 of 36


Digital Image Processing (22ECE151)

Figure 14 : Different types of Images and their Histograms


Q16. 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
Dr. Keerti Kulkarni, ECE, BNMIT Page 20 of 36
Digital Image Processing (22ECE151)

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

Q17. Explain Histogram Specification (Matching) with an example.


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]

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 [Link] in the continuous case, the intermediate step
of equalizing the input image is conceptual.

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

Dr. Keerti Kulkarni, ECE, BNMIT Page 21 of 36


Digital Image Processing (22ECE151)

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

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.

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

Dr. Keerti Kulkarni, ECE, BNMIT Page 22 of 36


Digital Image Processing (22ECE151)

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

Q20. 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:

Dr. Keerti Kulkarni, ECE, BNMIT Page 23 of 36


Digital Image Processing (22ECE151)

Figure 16a : Mechanics of Spatial Filtering

Dr. Keerti Kulkarni, ECE, BNMIT Page 24 of 36


Digital Image Processing (22ECE151)

Q21. Write a note on Spatial Correlation and Convolution.

Figure 16b : 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.

Dr. Keerti Kulkarni, ECE, BNMIT Page 25 of 36


Digital Image Processing (22ECE151)

Q22. Write a note on Vector Representation of Linear Filtering

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 17: 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

Dr. Keerti Kulkarni, ECE, BNMIT Page 26 of 36


Digital Image Processing (22ECE151)

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.

Q23. 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 18 : 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

Dr. Keerti Kulkarni, ECE, BNMIT Page 27 of 36


Digital Image Processing (22ECE151)

its coefficients, as is required to compute an average. The idea here is that it is computationally
more efficient to have coefficients valued [Link] the end of the filtering process the entire image
is divided by [Link] mask would have a normalizing constant equal to mn.A spatial averaging
filter in which all coefficients are equal sometimes is called a box filter. The second mask in
Fig.18 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

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

Dr. Keerti Kulkarni, ECE, BNMIT Page 28 of 36


Digital Image Processing (22ECE151)

We define the second-order derivative of as the difference

Figure 19: 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.

Dr. Keerti Kulkarni, ECE, BNMIT Page 29 of 36


Digital Image Processing (22ECE151)

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.19(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.19(c) that in a step
transition a line joining these two values crosses the horizontal axis midway between the two
extremes.

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

Dr. Keerti Kulkarni, ECE, BNMIT Page 30 of 36


Digital Image Processing (22ECE151)

Figure 20 : (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

Q26. 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:

Dr. Keerti Kulkarni, ECE, BNMIT Page 31 of 36


Digital Image Processing (22ECE151)

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.

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 21 explains how unsharp masking works. The intensity profile in Fig.21(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 21 (b) shows the result of smoothing, superimposed on
the original signal (shown dashed) for reference. Figure 21 (c) is the unsharp mask,
obtained by subtracting the blurred signal from the original. By comparing this result with
the section of Fig. 21(c)corresponding to the ramp in Fig.21(a), we note that the unsharp
mask in Fig. 21(c) is very similar to what we would obtain using a second order derivative.
Figure 21(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 k is large enough, can produce objectionable results.

Dr. Keerti Kulkarni, ECE, BNMIT Page 32 of 36


Digital Image Processing (22ECE151)

Figure 21: 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).

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

Dr. Keerti Kulkarni, ECE, BNMIT Page 33 of 36


Digital Image Processing (22ECE151)

M(x, y),where

is the value at (x, y) of the rate of change in the direction of the gradient [Link] 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 [Link] 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
[Link] the other hand,the partial derivatives in Eq.(3.6-10) are not rotation invariant
(isotropic),but the magnitude of the gradient vector [Link] 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 22: A region of an image (the zs are intensity values). (b)–(c) Roberts cross
gradient operators. (d)–(e) Sobel [Link] the mask coefficients sum to zero,as
Dr. Keerti Kulkarni, ECE, BNMIT Page 34 of 36
Digital Image Processing (22ECE151)

expected of a derivative operator.

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

Q28. Write a note on Local Histogram Processing.

The histogram processing methods discussed in the previous two sections are global, in the
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

Dr. Keerti Kulkarni, ECE, BNMIT Page 35 of 36


Digital Image Processing (22ECE151)

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.

Q29. 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
opposite purpose.

Dr. Keerti Kulkarni, ECE, BNMIT Page 36 of 36

You might also like