0% found this document useful (0 votes)
4 views13 pages

DIP - BEC613C - Module 3 - Spatial Domain Notes

The document discusses image enhancement techniques in both spatial and frequency domains, focusing on methods such as histogram processing, gray level transformations, and filtering. It explains various transformations including negative, logarithmic, and power-law transformations, as well as techniques like contrast stretching and histogram equalization to improve image quality. The document emphasizes the importance of these techniques in applications such as medical imaging and remote sensing.

Uploaded by

karansat737
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)
4 views13 pages

DIP - BEC613C - Module 3 - Spatial Domain Notes

The document discusses image enhancement techniques in both spatial and frequency domains, focusing on methods such as histogram processing, gray level transformations, and filtering. It explains various transformations including negative, logarithmic, and power-law transformations, as well as techniques like contrast stretching and histogram equalization to improve image quality. The document emphasizes the importance of these techniques in applications such as medical imaging and remote sensing.

Uploaded by

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

UNIT -III

IMAGE ENHANCEMENT

Image enhancement (spatial domain) :Introduction, Image Enhancement in Spatial


Domain, Histogram Processing - Enhancement Through Point Operation, Types of Point
Operation, Histogram Manipulation, gray level Transformation, local or neighborhood
operation, median filter, spatial domain high- pass filtering.
Image enhancement (Frequency domain): Filtering in Frequency Domain, Obtaining
Frequency Domain Filters from Spatial Filters, Generating Filters Directly in the Frequency
Domain, Low Pass (smoothing) and High Pass (sharpening) filters in Frequency Domain

Image enhancement in 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.

1
Fig.: 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. 2.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 Figure, 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 Figure, in which the values of the mask coefficients determine
the nature of the process, such as image sharpening. Enhancement techniques based on this type
of approach often are referred to as mask processing or filtering.

2
Fig: Gray level transformation functions for contrast enhancement.
Image enhancement can be done through gray level transformations which are discussed
below.
BASIC GRAY LEVEL TRANSFORMATIONS:
• Image negative
• Log transformations
• Power law transformations
• Piecewise-Linear transformation functions

LINEAR TRANSFORMATION:
First we will look at the linear transformation. Linear transformation includes simple
identity and negative transformation. Identity transformation has been discussed in our tutorial of
image transformation, but a brief description of this transformation has been given here.
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. Linear transformation between input and output.


NEGATIVETRANSFORMATION:
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
IMAGENEGATIVE: 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

3
regions of the image.
The overall graph of these transitions has been shown below.

Input gray level, r

Fig. Some basic gray-level transformation functions used for image enhancement.
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. 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

4
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.
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.
• The shape of the curve shows that this transformation maps the narrow range of low gray level
values in the input image in to a wide range of output image.
• The opposite is true for high level values of input image.

Fig. log transformation curve input vs output


POWER – LAW TRANSFORMATIONS:
There are further two transformation is power law transformations, that include nth
power and nth root transformation. These transformations can be given by the expression:
s=crγ
This symbol γ is called gamma, due to which this transformation is also known as gamma
transformation.
Variation in the value of γ varies the enhancement of the images. Different display devices /
monitors have their own gamma correction, that’s why they display their image at different
intensity.
where c and g are positive constants. Sometimes Eq. (6) is written as S = C (r +ε) γ to account
for an offset (that is, a measurable output when the input is zero). Plots of s versus r for various values of γ

5
are shown in Figure. 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: 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 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 Logtransformation)
Expands dark values
Compresses bright values
When C = γ = 1 , it reduces to identity transformation .

CORRECTING GAMMA:
s=crγ
s=cr(1/2.5)
6
The same image but with different gamma values has been shown here.
Piecewise-Linear Transformation Functions:
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 which 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 x(a) shows a typical transformation used for contrast stretching. The locations of
points (r1, s1) and (r2, s2) control the shape of the transformation
Function. If r1=s1 and r2=s2, the transformation is a linear function that produces No
changes in gray levels. If r1=r2, s1=0and s2= L-1, the transformation Becomes a thresholding
function that creates a binary image, as illustrated In fig. 2.2(b).
Intermediate values of ar1, s1b and ar2, s2b produce various degrees Of spread in the gray
levels of the output image, thus affecting its contrast. In general, r1≤ r2 and s1 ≤ s2 is assumed so
that the function is single valued and monotonically increasing.

7
Fig: Contrast stretching. (a) Form of transformation function. (b) A low-contrast stretching. (c)
Result of high contrast stretching. (d) Result of thresholding (original image courtesy of Dr.Roger
Heady, Research School of Biological Sciences, Australian National University Canberra
Australia.
Figure x(b) shows an 8-bit image with low contrast. Fig. x(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. x(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.
Gray-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 and a

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

Fig. y (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-orderbits.
Figure 3.12 illustrates these ideas, and Fig. 3.14 shows the various bit planes for the image
shown in Fig. 3.13. Note that the higher-order bits (especially the top four) contain the majority of
the visually significant data. The other bit planes contribute to more subtle details in the image.
Separating a digital image into its bit planes is useful for analyzing the relative importance played
by each bit of the image, a process that aids in determining the adequacy of the number of bits
used to quantize each pixel.

9
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).The binary
image for bit-plane 7 in Figure was obtained in just this manner.
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 p(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
grayscale.

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

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 endof the
histogram. If we could ‘stretch out’ the grey levels at the dark end to produce a more

11
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 representing black and r=1 representing white. The transformation
function is of the form
S=T(r) where 0<r<1
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

12
This is the cumulative distribution function of r.
L is the total number of possible gray levels in the image.

13

You might also like