Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
24 views

Module 2 (WWW - Vtuloop.com)

1) Image enhancement in the spatial domain refers to direct manipulation of pixel values in an image. This involves applying operators over neighborhoods of pixels. 2) The simplest operator is a gray-level transformation that maps input pixel values to output values. Basic transformations include contrast stretching, logarithmic, power-law, and negative transformations. 3) Contrast stretching increases contrast by darkening pixels below a threshold and brightening pixels above it, compressing the dynamic range. Log and power-law transforms expand low pixel values and compress high values.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Module 2 (WWW - Vtuloop.com)

1) Image enhancement in the spatial domain refers to direct manipulation of pixel values in an image. This involves applying operators over neighborhoods of pixels. 2) The simplest operator is a gray-level transformation that maps input pixel values to output values. Basic transformations include contrast stretching, logarithmic, power-law, and negative transformations. 3) Contrast stretching increases contrast by darkening pixels below a threshold and brightening pixels above it, compressing the dynamic range. Log and power-law transforms expand low pixel values and compress high values.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN

1
Module 2

Module 2
IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
Prepared By,
Sandesha Karanth P.K & Ragavendra Katagall
Assistant Professors, Dept. Of CSE,
VCET, Puttur
writetokaranth@gmail.com1,rkk4691@gmail.com2

Image enhancement approaches fall into two broad categories: spatial domainmethods
and frequency domain methods.The term spatial domainrefers to theimage plane itself, and
approaches in this category are based on direct manipulationof pixels in an image. Frequency

M
domain processing techniques are basedon modifying the Fourier transform of an image.

CO
P.
The term spatial domain refers to the aggregate ofpixels composing an image. Spatial
O
domain methods are procedures that operatedirectly on these pixels. Spatial domain processes
LO

will be denoted by theexpression


TU
.V

g (x, y) = T [f (x, y)]


W

where f(x, y) is the input image, g(x, y) is the processed image, and T is anoperator on f,
W
W

defined over some neighborhood of (x, y). In addition,T can operateon a set of input images,
such as performing the pixel-by-pixel sum of Kimages for noise reduction.

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 shown in below figure 1.

Figure 1: 3*3neighborhoodabout a point (x, y) in an image.

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
2
Module 2

The center of the subimage is moved from pixel to pixel starting, say, at the topleft
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.Although
other neighborhood shapes, such as approximations to a circle, sometimes are used, square and
rectangular arrays areby far the most predominant because of their ease of implementation.

The simplest form of T is when the neighborhood is of size 1*1 (that is, asingle pixel). In
this case, g depends only on the value of f at (x, y), and T becomesa gray-level (also called an
intensity or mapping) transformation functionof the forms = T(r)where, for simplicity in
notation, r and s are variables denoting, respectively, the gray level of f(x, y) and g(x, y) at any
point (x, y).

M
For example, if T(r) has the form shown in Fig. 2(a), the effect of this transformation

CO
would be to produce an image of higher contrast than the original by darkening the levels
P.
belowm and brightening the levels above m in the original image. In this technique,known as
O

contrast stretching, the values of r below m are compressed by thetransformation function into a
LO

narrow range of s, toward black.The opposite effecttakes place for values of r above m. In the
TU

limiting case shown in Fig. 2(b),T(r) produces a two-level (binary) image.A mapping of this
.V

form is called a thresholding function.


W
W
W

Figure 2a,b : Gray level transformation functions for contrast enhancement.

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
3
Module 2

Some Basic Gray Level Transformations:


1. Image Negatives:
The negative of an image with gray levels in the range [0,L-1]is obtained by using the
negative transformation shown in Fig. 3.3, which is given by the expression
s= L-1–r

M
CO
P.
O
LO

Figure 3: Some basic gray-level transformation functions used for image enhancement.
TU

Reversing the intensity levels of an image produces the equivalentof a photographic


.V

negative. This type of processing is particularly suitedfor enhancing white or gray detail
W
W

embedded in dark regions of an image, especiallywhen the black areas are dominant in size.
W

2. Log Transformations:
The general form of the log transformation
s = c log (1 + r)

where c is a constant, and it is assumed that r ≥ 0.

The shape of the log curve in Fig. 3 shows that this transformation maps a narrow range
of low gray-levelvalues in the input image into a wider range of output levels. The opposite is
true of higher values of input levels.We would use a transformation of this type toexpand the
values of dark pixels in an image while compressing the higher-levelvalues.The opposite is true
of the inverse log transformation.

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
4
Module 2

3. Power-Law Transformations
Power-law transformations have the basic form
s = c rγ
where c and γ are positive constants, Also can be represented as
s = c (r+ε)γ
An offset measurable when input is zero
We see in Fig. 4 that curves generated with values of g>1 have exactlythe opposite effect
as those generated with values of g<1.Finally, wenote that from above equation reduces to the
identity transformation when c=g=1.

M
CO
P.
O
LO
TU
.V
W
W

Figure 4: Plots of the equation s = c rγ for various values of g (c=1 in all cases).
W

Plots of s versus r for variousvalues of g are shown in Fig. 4. As in the case of the log
transformation,power-law curves with fractional values of g map a narrow range of dark
inputvalues into a wider range of output values, with the opposite being true for higher values of
input levels.
A variety of devices used for image capture, printing, and display respond accordingto a
power law. By convention, the exponent in the power-law equationis referred to as gamma. The
process used to correct this power-law response phenomenon is called gamma
correction.Gamma correctionis straightforward. All we need to do is preprocess the inputimage
before inputting it into the monitor by performing the transformation

s = r1/2.5 = r0.4

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
5
Module 2

Gamma correction is important if displaying an image accurately on a computer screen is


of concern. Images that are not corrected properly can look eitherbleached out, or, what is more
likely, too dark.
For example, cathode ray tube (CRT) devices have an intensity-to-voltage response that
is a power function, with exponents varying from approximately 1.8 to 2.5.With reference to the
curve for g=2.5 in Fig. 3.6, wesee that such display systems would tend to produce images that
are darker than intended.

M
CO
P.
O
LO
TU
.V
W
W
W

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. The idea
behind contrast stretching is to increase the dynamic range of the gray levels in the image being
processed.
 If r1,s1 and r2,s2 control the shape of the transformation function and if r1=s1 and r2=s2
the transformation is a linear function that produces no changes in intensity levels !
 If r1=r2 and s1=0 and s2 =L-1, the transformation becomes a thresholding function that
creates a binary image.

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
6
Module 2

 In general r1≤r2 and s1 ≤s2 is assumed so that the function is single valued and
monotonically increasing.This preserves the order of intensity levels, thus preventing the
creation of intensity artifacts in the processed image.

Gray level slicing


It is highlighting a specific range of intensities in an image often is of interest. Its
applications include enhancing features such as masses of water in satellite imagery and
enhancing flaws in X-ray images.
 The intensity level slicing process can be implemented for these defects/noise etc.
 It can be done in several ways
Ex: One is to display in one value (say, white), all the values in the range of interest and
in another (say, black), all other intensities.

M
Bit-plane slicing CO
P.
O
Instead of highlighting gray-level ranges, highlighting the contribution made tototal
LO

image appearance by specific bits might be desired. Suppose that eachpixel in an image is
TU

represented by 8 bits. Imagine that the image is composedof eight 1-bit planes, ranging from bit-
.V

plane 0 for the least significant bit to bitplane7 for the most significant bit. In terms of 8-bit
W

bytes, plane 0 contains allthe lowest order bits in the bytes comprising the pixels in the image
W

and plane7 contains all the high-order bits.


W

Figure 5: Bit-plane representation of an 8-bit image.

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
7
Module 2

Decomposing an image into its bit planes is useful for analyzing the
relative importance of each bit in the image, a process that aids in
determining the adequacy of the number of bits used to quantize the image.
It is useful in image compression.
 The reconstruction is done by using few planes only.
 It is done by multiplying the pixels of the nth plane by a constant 2n-1.
 All the generated planes are added together (few of 8 planes)
 If we use bit plane 7 and 8, multiply bit plane 8 by 128 and plane 7 by
64 and then added together.

Histogram Processing
The histogram of a digital image with gray levels in the range [0, L-1] is

M
a discrete function h(rk)=nk, where rk is the kth gray level and nk is the

CO
number of pixels in the image having gray level r k. Histograms are the basis
P.
O
for numerous spatial domain processing techniques.Histogram manipulation
LO

can be used effectively for image enhancement. Histograms are simple to


TU

calculate in software and also lendthemselves to economic hardware


.V

implementations, thus making them a popular tool for real-time image processing.
W

The horizontal axis of each histogram plot corresponds to gray level values, r k. The
W

vertical axis corresponds to values of


W

H(rk)=nk or p(rk)=nk/n if the values are normalized.


Thus, as indicated previously, these histogram plots are simply plots of h(rk)=nk versus rk
or p(rk)=nk/n versus rk.

Histogram Equalization
Consider for a moment continuous functions, and let the variable r represent the gray
levels of the image to be enhanced. In the initial part of our discussion we assume that r has been
normalized to the interval [0, 1], with r=0 representing black and r=1 representing white. Later,
we consider a discrete formulationand allow pixel values to be in the interval [0, L-1].For any r
satisfying the aforementioned conditions, we focus attention on transformations of the form
s=T(r) 0≤r≤1 ……(1)

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
8
Module 2

that produce a level s for every pixel value r in the original image. For reasons that will become
obvious shortly, we assume that the transformation function T(r) satisfies the following
conditions:
a. T(r) is a monotonically increasing function in the interval 0 ≤ r ≤ L-1:
T(r) be single valued is needed to guarantee that the inverse transformation will exist, and
the monotonicity condition preserves the increasing order from black to white in the
output image.
b. 0 ≤ T(r) ≤ L-1 for 0 ≤ r ≤ L-1:
It guaranteesthat the output gray levels will be in the same range as the input levels.
Figure6 gives an example of a transformation function that satisfies these twoconditions.

M
CO
P.
O
LO

Figure 6 A gray-level transformation functions that is both single valued and monotonically increasing.
The inverse transformation from s back to r is denoted
TU

r = T-1(s) 0 ≤ s ≤1 ……(2)
.V

The gray levels in an image may be viewed as random variables in the interval[0, 1]. One
W
W

of the most fundamental descriptors of a random variable isits probability density function
W

(PDF). Let pr(r) and ps(s) denote the probability density functions of random variables r and s,
respectively, where the subscriptson p are used to denote that pr and ps are different functions. A
basic result from an elementary probability theory is that, if p r(r) and T(r) are known andT-1(s)
satisfies condition(a) specified, then the probability density function ps(s) of the transformed
variable s can be obtained using a rather simple formula:

………(3)
A transformation function of particular importance in image processinghas the form

……….(4)
where w is a dummy variable of integration. From Leibniz’s rule in calculus

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
9
Module 2

……….(5)

Substituting this result for dr/ds into Eq. (3), and keeping in mind that allprobability values are
positive, yields

….(6)

M
CO
For discrete values we deal with probabilities and summations instead ofprobability
P.
density functions and integrals. The probability of occurrence of gray level r k in an image is
O
LO

approximated by
TU
.V

……(7)
W
W

The discrete version of the transformationfunction


W

…..(8)
The transformation (mapping) given in Eq.(8) is called histogram equalizationor
histogram linearization.

The inverse transformation from s back to r is denoted by

…….(9)
Histogram Matching

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
10
Module 2

As indicated in the preceding discussion, histogram equalization automaticallydetermines


a transformation function that seeks to produce an output imagethat has a uniform
histogram.When automatic enhancement is desired, this isa good approach because the results
from this technique are predictable and themethod is simple to implement. But in few
applications, its required to extract specified histogram then the methodused to generate a
processed image that has a specified histogram is called histogram matching or histogram
specification.
Let us return for a moment to continuous gray levels r and z and let pr(r) and pz(z) denote
their corresponding continues probability density functions. In this notation, r and z denotethe
gray levels of the input and output (processed) images, respectively. We can estimate p r(r) from
the given input image, while pz(z) is the specified probabilitydensity function that we wish the

M
output image to have.

CO
Let s be a random variable with the property P.
O

…….(10)
LO

Where ‘w’(omega)is a dummy variable of integration.


TU

Suppose nextthat we define a random variable z with the property


.V
W

……(11)
W
W

wheret is a dummy variable of integration. It then follows from these two equations that
G(z)=T(r) and, therefore, that z must satisfy the condition

…..(12)
The transformation T(r) can be obtained from Eq. (10) once p r(r) has been estimated from the
input image. Similarly, the transformation function G(z) can be obtained using Eq. (11) because
pz(z) is given.
The discrete formulation of Eq. (3.3-10) is given by Eq. (3.3-8), which we repeathere for
convenience:

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
11
Module 2

….(13)
Where n is the total number of pixels in the image, nj is the number of pixels with gray level r j ,
and L is the number of discrete gray levels. Similarly, the discrete formulation of Eq. (11) is
obtained from the given histogram pz(zi),i=0,1, 2,p ,L-1, and has the form

…..(14)
Finally,the discrete version of Eq. (12) is given by

……(15)

M
or, from Eq. (13),

CO …….(16)
P.
O
LO
TU
.V
W
W
W

Figure 7(a) Graphical interpretation of mapping from rk to sk via T(r). (b) Mapping of zq to its corresponding value vq via
G(z). (c) Inverse mapping from sk to its corresponding value of zk.

The procedure we have just developed for histogram matching may be summarized as follows:

1. Obtain the histogram of the given image.

2. Use Eq. (13) to pre-compute a mapped level sk for each level rk.

3. Obtain the transformation function G from the given pz(z) using Eq. (14).

4. Pre-compute zk for each value of sk using the iterative scheme defined in connection with Eq.

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
12
Module 2

5. For each pixel in the original image, if the value of that pixel is r k, map this value to its
corresponding level sk; then map level sk into the final level zk. Use the pre-computed values
from Steps (2) and (4) for these mappings.

Enhancement Using Arithmetic/Logic Operations


Arithmetic/logic operations involving images are performed on a pixel-by-pixel basis
between two or more images (this excludes the logic operation NOT, which is performed on a
single image).Logic operations similarly operate on a pixel-by-pixel basis.We need onlybe
concerned with the ability to implement the AND, OR, and NOT logic operators because these
three operators are functionally complete.When dealing with logic operations on gray-scale
images, pixel valuesare processed as strings of binary numbers. For example, performing the
NOToperation on a black, 8-bit pixel (a string of eight 0’s) produces a white pixel(a string of

M
eight 1’s). Intermediate values are processed the same way, changing all 1’s to 0’s and vice versa.

CO
The four arithmetic operations, subtraction and addition (in that order) arethe most useful
P.
for image enhancement.
O
LO
TU
.V
W
W

Image Subtraction:
W

The difference between two images f(x, y) and h(x, y), expressed as
g(x, y) = f(x, y) - h(x, y),
And it is obtained by computing the difference between all pairs of corresponding pixels from f
and h. The key usefulness of subtraction is the enhancement of differences between images.
One of the most commercially successful and beneficial uses of image subtraction is in
the area of medical imaging called mask mode radiography. In thiscase h(x, y), the mask, is an
X-ray image of a region of a patient’s body capturedby an intensified TV camera (instead of
traditional X-ray film) located oppositean X-ray source.The procedure consists of injecting a
contrast medium into the patient’s blood stream, taking a series of images of the same
anatomical regionas h(x, y), and subtracting this mask from the series of incoming imagesafter
injection of the contrast medium. The net effect of subtracting the maskfrom each sample in the

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
13
Module 2

incoming stream of TV images is that the areas that aredifferent between f(x, y) and h(x, y)
appear in the output image as enhanceddetail.

Image Averaging:
Consider a noisy image g(x, y) formed by the addition of noise h(x, y) to an original
image f(x, y); that is,
g(x, y) = f(x, y) + h(x, y
where the assumption is that at every pair of coordinates (x, y) the noise is uncorrelatedand has
zero average value.The objective of the following procedureis to reduce the noise content by
adding a set of noisy images, {gi(x, y)}.
If the noise satisfies the constraints just stated, it can be shown that if an image is

M
formed by averaging K different noisy images,

CO
P.
O

An important application of image averaging is in the field of astronomy,where imaging


LO

with very low light levels is routine, causing sensor noise frequentlyto render single images
TU

virtually useless for analysis.


.V
W
W

Multiplication and Division:


W

We consider division of two imagessimply as multiplication of one image by the


reciprocal of the other.Aside fromthe obvious operation of multiplying an image by a constant to
increase its averagegray level, image multiplication finds use in enhancement primarily as
amasking operation that is more general than the logical masks discussed in theprevious
paragraph. In other words, multiplication of one image by another canbe used to implement gray-
level, rather than binary, masks.

Basics of Spatial Filtering:


Some neighborhood operations work with the valuesof the image pixels in the
neighborhood andthe corresponding values of asubimage that has the same dimensions as the

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
14
Module 2

neighborhood.The subimage iscalled a filter, mask, kernel, template, or window, with the first
three terms beingthe most prevalent terminology.The values in a filter subimage are referred to
as coefficients, rather than pixels.
The mechanics of spatial filtering are illustrated in Fig 8. The process consists simply of
moving the filter mask from point to point in an image. At eachpoint (x, y), the responseof the
filter at that point is calculated using a predefinedrelationship. For linear spatial,the response is
given by a sum of products of the filter coefficients and thecorresponding image pixels in the
area spanned by the filter mask.

M
CO
P.
O
LO
TU
.V
W
W
W

Figure 8The mechanics of spatial filtering. The magnified drawing shows a 3*3 mask and the image section directly under
it; the image section is shown displaced out from under the mask for ease of readability.

For the 3*3mask shown in Fig. 3.32, the result (or response), R, of linear filtering with thefilter
mask at a point (x, y) in the image is

which we see is the sum of products of the mask coefficients with the correspondingpixels
directly under the mask. Note in particular that the coefficient w(0, 0) coincides with image value

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
15
Module 2

f(x, y), indicating that the mask is centeredat (x, y) when the computation of the sum of products
takes place. For a maskof size m*n, we assume that m=2a+1 and n=2b+1, where a and b
arenonnegative integers. All this says is that our focus in the following discussionwill be on
masks of odd sizes, with the smallest meaningful size being 3*3 (weexclude from our discussion
the trivial case of a 1*1 mask).
In general, linear filtering of an image f of size M*N with a filter mask ofsize m*n is
given by the expression:

where, from the previous paragraph, a=(m-1)/2 and b=(n-1)/2. Togenerate a complete filtered
image this equation must be applied for x=0, 1,2, p , M-1 and y=0, 1, 2, p , N-1.
When interest lies on the response, R, of an m*n mask at any point (x, y),and not on the

M
CO
mechanics of implementing mask convolution, it is commonpractice to simplify the notation by
using the following expression:
P.
O
LO
TU
.V

where the w’s are mask coefficients, the z’s are the values of the image graylevels corresponding
W

to those coefficients, and mn is the total number of coefficients in the mask.


W
W

Smoothing Spatial Filter


Smoothing filters are used for blurring and for noise reduction. Blurring is usedin
preprocessing steps, such as removal of small details from an image prior to(large) object
extraction, and bridging of small gaps in lines or curves. Noise reduction can be accomplished by
blurring with a linear filter and also by nonlinear filtering.
Smoothing Linear Filters:
The output (response) of a smoothing, linear spatial filter is simply the averageof the
pixels contained in the neighborhood of the filter mask. These filters sometimes are called
averaging filters.
The idea behind smoothing filters is straightforward. By replacing the value of every
pixel in an image by the average of the gray levels in the neighborhood defined by the filter

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
16
Module 2

mask, this process results in an image with reduced“sharp” transitions in gray levels. Because
random noise typically consists ofsharp transitions in gray levels, the most obvious application of
smoothing isnoise reduction. However, edges (which almost always are desirable features of
an image) also are characterized by sharp transitions in gray levels, so averagingfilters have the
undesirable side effect that they blur edges.
A major use of averaging filters is in the reduction of “irrelevant” detail in animage. By
“irrelevant” we mean pixel regions that are small with respect to thesize of the filter mask.The
Figure shows two 3*3 smoothing filters. Use of the first filter yields thestandard average of the
pixels under the mask.

M
This is the average of the gray levels of the pixels in the 3*3 neighborhood defined by the mask.

CO
Note that, instead of being 1_9, the coefficients of the filterare all 1’s. An m*n mask would have
P.
a normalizing constant equal to 1_mn. A spatial averaging filter in which all coefficients are
O

equal is sometimes calleda box filter.


LO
TU
.V
W
W
W

Figure 9 Two 3*3 smoothing (averaging) filter masks. The constant multiplier in front of each mask is equal to the sum of
the values of its coefficients, as is required to compute an average.

The second mask shown in Fig. 9 is a little more interesting. This mask yields a so-called
weighted average, terminology used to indicate that pixels aremultiplied by different
coefficients, thus giving more importance (weight) tosome pixels at the expense of others. In the
mask shown in Fig. 9(b) 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
pixelsare inversely weighted as a function of their distance from the center of the mask.
The general implementation for filtering an M*N image with a weighted averaging filter
of size m*n (m and n odd) is given by the expression

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
17
Module 2

For x=0, 1, 2, p , M-1 and y=0, 1, 2, p , N-1.


Order-Statistics Filters
Order-statistics 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 example in this category is the median filter, which, as its name implies,
replaces the value of a pixel by the median of the gray levels in the neighborhood of that pixel
(the original value of the pixel is included in the computation of the median). Median filters are

M
quite popular because, for certain types of random noise, they provide excellent noise-reduction

CO
capabilities, with considerably less blurring than linear smoothing filters of similar size. Median
P.
filters are particularly effective in the presence of impulse noise, also called salt-and-pepper
O
noise because of its appearance as white and black dots superimposed on an image. The median,
LO

j, of a set of values is such that half the values in the set are less than or equal to j, and half are
TU

greater than or equal to j. In order to perform median filtering at a point in an image, we first sort
.V

the values of the pixel in question and its neighbors, determine their median, and assign this
W

value to that pixel. For example, in a 3*3 neighborhood the median is the 5th largest value, in a
W
W

5*5 neighborhood the 13th largest value, and so on.When several valuesin a neighborhood are
the same, all equal values are grouped.
For example, suppose that a 3*3 neighborhood has values (10, 20, 20, 20, 15, 20, 20, 25,
100). These values are sorted as (10, 15, 20, 20, 20, 20, 20, 25, 100), which results in a median of
20. Thus, the principal function of median filters is to force points with distinct gray levels to be
more like their neighbors. In fact, isolated clusters of pixels that are light or dark with respect to
their neighbors, and whose area is less than n 2/2 (one-half the filter area), are eliminated by an
n*n median filter. In this case “eliminated” means forced to the median intensity of the
neighbors. Larger clusters are affected considerably less. Although the median filter is by far the
most useful order-statistics 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 the reader will recall from basic
statistics that ranking lends itself to many other possibilities. For example, using the 100th

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
18
Module 2

percentile results in the so-called max filter, which is useful in finding the brightest points in an
image. The response of a 3*3 max filter is given by R=max (zk|k=1, 2,p , 9).The 0th percentile
filter is the min filter, used for the opposite purpose.

Sharpening Spatial Filters:


The principal objective of sharpening is to highlight fine detail in an image or to enhance
detail that has been blurred, either in error or as a natural effect of a particular method of image
acquisition.
Image sharpening vary and include applications ranging from electronic printing and
medical imaging to industrial inspection and autonomous guidance in military systems.
Sharpening filters that are based on first- and second-order derivatives. The derivatives

M
of a digital function are defined in terms of differences. There are various ways to define these

CO
differences. However, we require that any definition we use for a first derivative (1) must be zero
P.
in flat segments (areas of constant gray-level values); (2) must be nonzero at the onset of a gray-
O
LO

level step or ramp; and (3) must be nonzero along ramps. Similarly, any definition of a second
TU

derivative (1) must be zero in flat areas; (2) must be nonzero at the onset and end of a gray-level
step or ramp; and (3) must be zero along ramps of constant slope.
.V
W

A basic definition of the first-order derivative of a one-dimensional function f(x)


W

is the difference
W

Similarly, we define a second-order derivative as the difference

It is easily verified that these two definitions satisfy the conditions stated
previouslyregarding derivatives of the first and second order.

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
19
Module 2

Figure 10 Simplified profile (the points are joined by dashed lines to simplify

M
interpretation).

CO
P.
Figure 10 shows a simplification of the profile, with just enough numbers to make it
O
LO

possible for us to analyze how the first- and second-order derivativesbehave as they encounter a
TU

noise point, a line, and then the edge of anobject. In our simplified diagram the transition in the
ramp spans four pixels, thenoise point is a single pixel, the line is three pixels thick, and the
.V
W

transition intothe gray-level step takes place between adjacent pixels.The number of gray
W

levelswas simplified to only eight levels.


W

Let us consider the properties of the first and second derivatives as we traversethe profile
from left to right.
1. The first-order derivative is nonzero along the entire ramp,
2. The second-order derivative is nonzero only at the onset and end of the ramp.
We conclude that first-order derivatives produce “thick” edges and second-order
derivatives, much finer ones.
3. We encounter the isolated noise point. Here, the response at and around the point is
much stronger for the second- than for the first-order derivative.
4. A second-order derivative is much more aggressive than a first-order derivative in
enhancing sharp changes. Thus, we can expect a second-order derivative to enhance
fine detail (including noise) much more than a first-order derivative.
5. The thin line is a fine detail, and we see essentially the same difference between the
two derivatives. If the maximum gray level of the line had been the same as the

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
20
Module 2

isolated point, the response of the second derivative would have been stronger for the
latter.
6. Finally, in this case, the response of the two derivatives is the same at the gray-level
step. We also note that the second derivative has a transition from positive back to
negative.
Comparison B/N first- and second-order derivatives response
1. First-order derivatives generallyproduce thicker edges in an image.
2. Second-order derivatives have astronger response to fine detail, such
as thin lines and isolated points.
3. Firstorderderivatives generally have a stronger response to a gray-level
step.
4. Second-order derivatives produce a double response at step changes

M
in gray level.

CO
P.
Use of Second Derivatives for Enhancement–The Laplacian
O

The approach basically consists of defininga discrete formulation of the second-order


LO

derivative and then constructinga filter mask based on that formulation.We are interested in
TU

isotropic filters,whose response is independent of the direction of the discontinuities in the


.V

imageto which the filter is applied. In other words, isotropic filters are rotation invariant,in the
W
W

sense that rotating the image and then applying the filter gives thesame result as applying the
W

filter to the image first and then rotating the result.


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

……(1)
Because derivatives of any order are linear operations, the Laplacian is a linear operator.
The definition of the digital second derivative given in that section is one of the most
used.Taking intoaccount that we now have two variables, we use the following notation for
thepartial second-order derivative in the x-direction:

…..(2)

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
21
Module 2

and, similarly in the y-direction, as

…..(3)

The digital implementation of the two-dimensional Laplacian in Eq. (1) isobtained by summing
these two components:

…..(4)

This equation can be implemented using the mask shown in Fig. 3.39(a),

M
CO
P.
O
LO
TU
.V
W
W
W

Figure 11Filter mask used to implement the digital Laplacian, as defined in Eq. (4). (b) Mask used to implement an
extension of this equation that includes the diagonal neighbors. (c) and (d) Two other implementations of the
Laplacian.

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


in an image and deemphasizes regions with slowly varying graylevels. This will tend to produce
images that have grayish edge lines and otherdiscontinuities, all superimposed on a dark,
featureless background. Backgroundfeatures can be “recovered” while still preserving the
sharpening effect of the Laplacian operation simply by adding the original and Laplacian images.

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
22
Module 2

Asnoted in the previous paragraph, it is important to keep in mind which definition of the
Laplacian is used. If the definition used has a negative center coefficient, then we subtract, rather
than add, the Laplacian image to obtain asharpened result.Thus, the basic way in which we use
the Laplacian for image enhancement is as follows:

….(5)

Unsharp masking and high-boost filtering

M
A process used for many years in the publishing industry to sharpen imagesconsists of

CO
subtracting a blurred version of an image from the image itself. This process, called unsharp
P.
masking, is expressed as
O
LO

….(7)
TU

where fs(x, y) denotes the sharpened image obtained by unsharp masking, and is a
.V

blurred version of f(x, y).The origin of unsharp masking is in dark room photography, where it
W

consists of clamping together a blurred negative toa corresponding positive film and then
W

developing this combination to producea sharper image.


W

A slight further generalization of unsharp masking is called high-boostfiltering. A high-


boost filtered image, fhb, is defined at any point (x, y) as

…..(8)
whereA ≥ 1 and, as before, is a blurred version of f. This equation may be written as

…..(9)
By using Eq. (7), we obtain

…..(10)
as the expression for computing a high-boost-filtered image. Equation (10) is applicable in
general and does not state explicitly howthe sharp image is obtained. If we elect to use the

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
23
Module 2

Laplacian, then we know that fs(x, y) can be obtained using Eq. (5). In this case, Eq. (10)
becomes

…(11)

Use of First Derivatives for Enhancement—The Gradient

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

M
CO
P.
O
LO
TU

…(12)
.V

The magnitude of this vector is given by


W
W
W

….(13)
The components of the gradient vector itself are linear operators, but the magnitudeof this
vector obviously is not because of the squaring and square root operations. On the other hand,
the partial derivatives in Eq. (3.7-12) are not rotationinvariant (isotropic), but the magnitude of
the gradient vector is. Althoughit is not strictly correct, the magnitude of the gradient vector
often isreferred to as the gradient.
The computational burden of implementing Eq. (13) over an entire imageis not trivial,
and it is common practice to approximate the magnitude of the gradientby using absolute values
instead of squares and square roots:

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
24
Module 2

….(14)
This equation is simpler to compute and it still preserves relative changes in gray levels,
but the isotropic feature property is lost in general. However, as in the case of the Laplacian, the
isotropic properties of the digital gradient defined in the following paragraph are preserved only
for a limited number of rotational increments that depend on the masks used to approximate the
derivatives. As it turns out, the most popular masks used to approximate the gradient give the
same result only for vertical and horizontal edges and thus the isotropic properties of the gradient
are preserved only for multiples of 90°. These results are independent of whether Eq. (13) or (14)
is used, so nothing of significance is lost in using the simpler of the two equations. Two other
definitions proposed by Roberts, in the early development ofdigital image processing use cross
differences:

M
CO
P. ….(15)
If we elect to use Eq. (13), then we compute the gradient as
O
LO

…...(16)
TU

If we use absolute values, then substituting the quantities in Eq. (15)


.V

into Eq. (14) gives us the following approximation to the gradient:


W
W

…..(17)
W

These masks are referred to as the Roberts cross-gradient operators. Masks


of even size are awkward to implement. The smallest filter mask in which we
are interested is of size 3*3. An approximation using absolute values, still at
point z5 , but using a 3*3 mask, is

…….(18)

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
25
Module 2

M
CO
P.
Figure 12 A 3*3 region of an image (the z’s are gray-level values) and masks used to compute the gradient at point
O
labeled z5 . All masks coefficients sum to zero, as expected of a derivative operator.
LO
TU

The difference between the third and first rows of the 3*3 image region approximates the
.V

derivative in the x-direction, and the difference between the third and first columns approximates
W

the derivative in the y-direction. The masks shown in above, called the Sobel operators, can be
W

used to implement Eq. (18) via the mechanics given in Eq. (1). The idea behind using a weight
W

value of 2 is to achieve some smoothing by giving more importance to the center point. Note that
the coefficients in all the masks shown in Fig. 3.44 sum to 0, indicating that they would give a
response of 0 in an area of constant gray level, as expected of a derivative operator.

Combining Spatial Enhancement Methods


Frequently, a given enhancement task will require application of several complementary
enhancement techniques in order to achieve an acceptable result. In this section we illustrate by
means of an example how to combine several of the approaches developed in this chapter to
address a difficult enhancement task.
The image shown in Fig. 13(a) is a nuclear whole body bone scan, used to detect diseases
such as bone infection and tumors. Our objective is to enhance this image by sharpening it and

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
26
Module 2

by bringing out more of the skeletal detail. The narrow dynamic range of the gray levels and high
noise content make this image difficult to enhance. The strategy we will follow is to utilize the
Laplacian to highlight fine detail, and the gradient to enhance prominent edges.
Figure 13(b) shows the Laplacian of the original image. We can obtain a sharpened image
at this pointsimply by adding Figs. 13(a) and (b), which are an implementation of the second line
in Eq. (5) (we used a mask with a positive center coefficient). Just by looking at the noise level in
(b), we would expect a rather noisy sharpened image if we added Figs. 13(a) and (b), a fact that
is confirmed by the result shown in Fig. 13(c). One way that comes immediately to mind to
reduce the noise is to use a median filter. However, median filtering is a nonlinear process
capable of removing image features. This is unacceptable in medical image processing.
Figure 13(d) shows the Sobel gradient of the original image, computed using Eq. (14).

M
Components Gx and Gy were obtained using the masks in Figs. 14(d) and (e), respectively. The

CO
fact that Figs. 13(d) and (e) are much brighter than Fig. 13(b) is again evidence that the gradient
P.
of an image with significant edge content has values that are higher in general than in a
O
LO

Laplacian image. The product of the Laplacian and smoothed-gradient image is shown in Fig.
13(f). Note the dominance of the strong edges and the relative lack of visible noise, which is the
TU

key objective behind masking the Laplacian with a smoothed gradient image. Adding the product
.V

image to the original resulted in the sharpened image shown in Fig. 13(g).
W
W
W

Figure 13: (a) Image of whole body bone scan. (b) Laplacian of (a). (c) Sharpened image obtained by adding (a) and
(b). (d) Sobel of (a).

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur


IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
27
Module 2

M
CO
P.
Figure 13(Continued) (e) Sobel image smoothed with a 5*5 averaging filter. (f) Mask image formed by the product
of (c) and (e). (g) Sharpened image obtained by the sum of (a) and (f). (h) Final result obtained by applying a power-
O
law transformation to (g). Compare (g) and (h) with (a). (Original image courtesy of G.E. Medical Systems.)
LO
TU
.V
W
W
W

writetokaranth@gmail.com1| rkk4691@gmail.com| VCET, Puttur

You might also like