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

5_Image Enhancement in Spatial Domain

The document discusses image enhancement techniques in the spatial domain, focusing on direct pixel manipulation methods such as intensity transformations, spatial filtering, and histogram processing. It covers various techniques including image negatives, log transformations, power-law transformations, contrast stretching, and local histogram processing. Additionally, it explains smoothing and sharpening filters, emphasizing their applications in enhancing image quality and detail.

Uploaded by

Sathvik Reddy
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)
6 views

5_Image Enhancement in Spatial Domain

The document discusses image enhancement techniques in the spatial domain, focusing on direct pixel manipulation methods such as intensity transformations, spatial filtering, and histogram processing. It covers various techniques including image negatives, log transformations, power-law transformations, contrast stretching, and local histogram processing. Additionally, it explains smoothing and sharpening filters, emphasizing their applications in enhancing image quality and detail.

Uploaded by

Sathvik Reddy
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/ 77

Image

Enhancement in
Spatial Domain
Image Enhancement

 The objective of image enhancement is to process an image so that the


result is more suitable than the original image for a specific application.
 There are two main approaches:
 Image enhancement in spatial domain: Direct manipulation of pixels
in an image
Point processing: Change pixel intensities
Spatial filtering
 Image enhancement in frequency domain: Modifying the Fourier
transform of an image
Image enhancement in spatial domain

• The term spatial domain refers to the image plane itself


• Image processing in this category are based on direct manipulation of
pixels
• Efficient in computational aspect
Image enhancement in spatial domain
Image enhancement in spatial domain

• g (x, y) = T [f (x, y)], T is the operator on some neighborhood


of (x, y)

• If the neighborhood only consist of the pixel itself, it is known as


intensity/gray-level/mapping transformation function
s =T (r )
Image enhancement in spatial domain

• Otherwise, in case of a neighborhood it is known as spatial filtering.

• The operator is known as spatial filter/ spatial mask/ kernel/ template


/ window
Intensity Transformation Functions
Intensity Transformations
Image Negatives
• s=L-1-r
• s is the output intensity value
• L is the highest intensity levels
• r is the input intensity value
• Reversing the intensity levels of an image produces the equivalent of
a photographic negative
• This technique is helpful for enhancing white or gray detail embedded
in dark regions, when the black areas are dominant in size
Image Negatives

181 167 245 192 74 88 10 63


192 41 87 65 63 214 168 190
70 30 149 129 185 225 106 126
173 127 57 178 82 128 198 77
Image Negatives
Log Transformations

• s=c log (1+r), c is a constant


Log Transformations

•The shape of the log curve shows that this transformation maps a narrow range of low intensity
values (input) into a wider range of output levels.
• The opposite is true of higher values of input levels.
•This technique is used to expand the values of dark pixels while compressing the higher-level
values.

The opposite is true for inverse log


transformation
Log Transformations

• Fourier spectrum with values in the range 0 to 1.5 × 106


• In case of scaled linearly for display in an 8-bit system, the brightest pixels will dominate the
display, at the expense of lower, ( and just as important) values of the spectrum
• Using log transformation, the range of values becomes 0 to 6.2; thus more details are visible.
Power-Law (Gamma) Transformations
• Gamma transformations have the basic form 𝑠 = 𝑐𝑟 𝛾
where c and 𝛾 are positive constants.
• Similar to log-transformation characteristics; but a family of possible transformation
curves are obtained by varying gamma.
Power-Law (Gamma) Transformations
Power-Law (Gamma) Transformations
Power-Law (Gamma) Transformations

• A variety of devices for image capture, printing and display


respond according to power-law (CRT, printers, scanners)
• CRT devices have an intensity-to-voltage response that is a power
function, with exponents varying from 1.8 to 2.5 approx.
Power-Law (Gamma) Transformations
• The process used to correct these power-law response phenomena is
called gamma correction.
• Gamma correction is performed for better quality visualization in CRT
devices.
• The input image is transformed as

1/2.5 0.4
𝑠=𝑟 =𝑟
Power-Law (Gamma) Transformations
Piecewise-linear Transformation functions

• Advantage: the form of transformation can be arbitrarily complex

• Disadvantage: their specification requires considerably more user


input
Contrast stretching
• Low-contrast images can result from
poor illumination
lack of dynamic range in the imaging sensor
wrong setting of a lens aperture during image acquisition

• Contrast stretching is a process that expands


the range of intensity values in an image (input)

full intensity range of the recording medium or display device


(output)
Contrast stretching
• Thresholding → when r1=r2, s1=0 and s2=L-1
• Contrast stretching is obtained by setting
(r1,s1) = (rmin , 0) and (r2,s2) = (rmax , L-1)
Intensity Level Slicing

 Highlighting specific range of intensities in an image.


 Enhances features such as masses of water in satellite imagery and enhancing
flaws in X-ray images.
 It can be Implemented two ways:
1) To display only one value (say, white) all the values in the range of interest
and rests are black which produces binary image.
2) brightens (or darkens) the desired range of intensities but leaves all other
intensity levels in the image unchanged.
Intensity Level Slicing
Intensity Level Slicing
Bit Plane Slicing
 Pixels are digital numbers composed of bits.
 256 gray scale image is composed of 8 bits.
 Instead of highlighting intensity level ranges, we could highlight the
contribution made to total image appearance by specific bits.
 8-bit image may be considered as being composed of eight 1-bit planes, with
plane 1 containing the lowest order bit of all pixels in the image and plane 8 all
the highest-order bits.
Bit Plane Slicing
Bit Plane Slicing
Bit Plane Slicing
Histogram processing
• The histogram of a digital image, intensity range [0, L-1], is a
discrete function
ℎ 𝑟𝑘 = 𝑛𝑘

kth intensity the no of pixels in the image with


value intensity value rk

• Normalization: dividing each of its components by the total number of


pixels, MN
• A normalized histogram is given by
𝑛𝑘
𝑝(𝑟𝑘 ) = 𝑘 = 0,1,2, . . . , 𝐿 − 1
𝑀𝑁
𝑝(𝑟𝑘 ) is an estimate of the probability of occurrence of intensity level 𝑟𝑘
Histogram processing

• The sum of all components of a normalized histogram is equal to 1


• Histograms may be viewed graphically simply as plots of frequency of
occurrence vs. intensity value
• Histogram manipulation can be used for image enhancement.
• Information inherent in histogram also is quite useful in other image
processing applications, such as image compression and
segmentation.
Histogram processing

Observation:
• If the histogram is distributed uniformly, the image
will have an appearance of high contrast

•It will exhibit a lot of gray-level detail and high


dynamic range

• To develop a transformation function that can


automatically achieve this effect, only using the
histogram of the input image.
Histogram Equalization
Histogram Equalization
Histogram Equalization
Histogram Equalization
Histogram Equalization
Histogram Equalization
Histogram Matching/Specification
• Histogram equalization automatically determines a transformation
function produce uniform histogram
• When automatic enhancement is desired, equalization is a good
approach
• There are some applications in which attempting to base enhancement
on a uniform histogram is not the best approach
• To obtain uniform distribution may not be the best approach always
• It is useful to specify the shape of the histogram for the processed
image
• The method generates a processed image that has a specified
histogram, is called histogram matching or specification
Histogram Matching/Specification
Histogram Matching/Specification
Histogram Matching/Specification
Histogram Matching/Specification
Histogram Matching/Specification
Local Histogram Processing

 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.
 There are some cases in which it is necessary to enhance detail over small areas
in an image.
 This procedure is to define a neighborhood and move its center 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.
Local Histogram Processing

 Map the intensity of the pixel centered in the neighborhood.


 Center of the neighborhood region is then moved to an adjacent pixel location
and the procedure is repeated.
 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 non
overlapping regions, but this method usually produces an undesirable “blocky”
effect.
Local Histogram Processing
Image Enhancement: Spatial filtering

The operator is known as spatial filter or spatial mask, kernel, template or


window
Spatial filtering
• Filter: a frequency domain concept. It refers to accepting or rejecting certain
frequency components
Example: a filter that passes low frequencies is called a lowpass filter. Its
effect is to blur/smooth an image
• We can accomplish a similar smoothing directly on the image using spatial
filters
• Spatial filters can be used for nonlinear filtering (frequency domain can’t) –
median filter
•Also called spatial masks, kernels, templates, and windows.
•Filtering creates a new pixel with coordinates equal to the center of the
neighborhood.
Mechanics of spatial filtering

• Spatial filter: (1) neighborhood


(2) a predefined operation
• The center of the neighborhood/mask is at the pixel to be processed
• The center of the mask is moved to each pixel in the input image, to
generate the output image using filtering operation
• If the operation performed on the image pixels is linear, then the
filter is called a linear spatial filter; otherwise it is nonlinear
Mechanics of linear spatial filtering

𝑔(𝑥, 𝑦) = 𝑤(−1, −1)𝑓(𝑥 − 1, 𝑦 − 1) + 𝑤 −1,0 𝑓 𝑥 − 1, 𝑦 +. . .


𝑤(0,0)𝑓(𝑥, 𝑦)+. . . +𝑤(1,1)𝑓(𝑥 + 1, 𝑦 + 1)

When m=2a+1, n=2b+1


𝑎 𝑏

𝑔(𝑥, 𝑦) = ෍ ෍ 𝑤(𝑠, 𝑡)𝑓(𝑥 + 𝑠, 𝑦 + 𝑡)


𝑠=−𝑎 𝑡=−𝑏
Smoothing linear filters
• Smoothing filters are used for blurring and for noise reduction
• Blurring→ removal of small details prior to object extraction and
bridging of small gaps in lines or curves

• The output of a smoothing filter is simply the average of the pixels


under the mask (also known as averaging/lowpass filter)
• Sharp transitions in intensity levels are removed: along with noise,
edges also affected
Smoothing linear filters
 Also called averaging filters or Lowpass filter.
 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.
 Reduced “sharp” transition in intensities.
 Random noise typically consists of sharp transition.
 Edges also characterized by sharp intensity transitions, so
averaging filters have the undesirable side effect that they blur
edges.
 If all coefficients are equal in filter than it is also called a box filter.
Smoothing linear filters
 The other mask is called weighted average, terminology used to
indicate that pixels are multiplied by different coefficient.
 Center point is more weighted than any other points.
 Strategy behind weighing the center point the highest and then
reducing value of the coefficients as a function of increasing
distance from the origin is simply an attempt to reduce blurring in
the smoothing process.
 Intensity of smaller object blends with background.
Smoothing linear filters

To reduce blurring during smoothing process


(give more weight to center pixel)
Smoothing linear filters
Smoothing linear filters
Order-statistic (Nonlinear) filters
• Its response is based on ordering (ranking) the pixels contained under the
mask; and then finding the output based on the ranking.
• Median filter widely used: median of the ranked pixel sequence is used

• For impulse/salt-and-pepper noise, median filter is more effective than


averaging filter
• Its principal function is to force pixels with distinct intensity levels to be more
like their neighbors
Order-statistic (Nonlinear) filters
Sharpening spatial filters
 Objective of sharpening is to highlight transitions in intensity.
 Uses in printing and medical imaging to industrial inspection and
autonomous guidance in military systems.
 Averaging is analogous to integration, so sharpening is analogous to
spatial differentiation.
 Thus, image differentiation enhances edges and other discontinuities
(such as noise) and deemphasizes areas with slowly varying
intensities.
Sharpening spatial filters

• Image differentiation
• Enhances edges and other discontinuities (noise)
• De-emphasizes smooth areas

• Differentiation → difference in digital domain


Sharpening spatial filters

Requirements
First derivative
• zero in areas of constant intensity
• nonzero at the onset of an intensity step or ramp
• nonzero along ramps

Second derivative
• zero in constant areas
• nonzero at the onset and end of an intensity step or ramp
• zero along ramps of constant slope
Sharpening spatial filters

• Definition: the first order derivative of a one-dimensional function f


(x) is
𝜕𝑓
= 𝑓(𝑥 + 1) − 𝑓(𝑥)
𝜕𝑥

•The second order derivative of a one-dimensional function f (x) is

𝜕2𝑓
2
= 𝑓(𝑥 + 1) + 𝑓(𝑥 − 1) − 2𝑓(𝑥)
𝜕𝑥
Sharpening spatial filters
Sharpening spatial filters
• The second order derivative is useful for edge detection

• Zero crossing property

• Single pixel edges compared to thick edges of first order derivative


Laplacian filter

• Approach: discrete formulation of second order derivative and then


constructing a filter mask
𝜕 2𝑓 𝜕 2𝑓
∇2 𝑓 = 2 + 2
𝜕𝑥 𝜕𝑦

• Isotropic filters: response is independent of discontinuity directions in


the image

𝜕2𝑓
2
= 𝑓(𝑥 + 1, 𝑦) + 𝑓(𝑥 − 1, 𝑦) − 2𝑓(𝑥, 𝑦)
𝜕𝑥
Laplacian filter

• Laplacian ( a linear) operator is an example of isotropic filter


2 2
2
𝜕 𝑓 𝜕 𝑓
∇ 𝑓= 2+ 2
𝜕𝑥 𝜕𝑦
• Discrete formulation:
𝜕2𝑓
2
= 𝑓(𝑥 + 1, 𝑦) + 𝑓(𝑥 − 1, 𝑦) − 2𝑓(𝑥, 𝑦)
𝜕𝑥
𝜕2𝑓
2
= 𝑓(𝑥, 𝑦 + 1) + 𝑓(𝑥, 𝑦 − 1) − 2𝑓(𝑥, 𝑦)
𝜕𝑦
∇2 𝑓 = 𝑓(𝑥 + 1, 𝑦) + 𝑓(𝑥 − 1, 𝑦) + 𝑓(𝑥, 𝑦 + 1) + 𝑓(𝑥, 𝑦 − 1)
−4𝑓(𝑥, 𝑦)
Laplacian filter

𝑔(𝑥, 𝑦) = 𝑓(𝑥, 𝑦) + 𝑐[∇2 𝑓(𝑥, 𝑦)]


𝑐 = −1 𝑜𝑟 + 1
Laplacian filter
Unsharp masking
• Unsharp masking has been used for many years by printing and
publishing industry
• Blur the original image
• Subtract the blurred image from the original (create the mask)
• Add the mask to the original
Unsharp masking

ሜ 𝑦)
𝑔𝑚𝑎𝑠𝑘 (𝑥, 𝑦) = 𝑓(𝑥, 𝑦) − 𝑓(𝑥,

𝑔(𝑥, 𝑦) = 𝑓(𝑥, 𝑦) + 𝑘 ∗ 𝑔𝑚𝑎𝑠𝑘 (𝑥, 𝑦)

• If k=1, we have unsharp masking


• If k>1, the process is known as highboost filtering
• If K<1, deemphasizes the contribution of the unsharp mask
Unsharp masking
Unsharp masking

k=4.5
The gradient- first-order derivative
𝜕𝑓
𝑔𝑥 𝜕𝑥
∇𝑓 ≡ 𝑔𝑟𝑎𝑑 𝑓 = 𝑔 = 𝜕𝑓
𝑦
𝜕𝑦

𝑀(𝑥, 𝑦) = 𝑚𝑎𝑔(∇𝑓) = 𝑔𝑥2 + 𝑔𝑦2

• It is the value at (x, y) of the rate of change in the direction of the gradient
vector,
•Magnitude of gradient at every pixel forms the gradient image
• It is a nonlinear operator
The gradient- first-order derivative
𝑀(𝑥, 𝑦) ≈ 𝑔𝑥 + 𝑔𝑦
The gradient- first-order derivative

• Used for automated inspection


• Preprocessing removes smooth areas; only highlights edge portions which can be
easily detected
•Enhances small discontinuities

You might also like