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

Digital Image Processing (Chapter 3) PDF

The document discusses various techniques for image enhancement in the spatial domain, including single pixel operations, neighborhood operations, and geometric spatial transformations. Single pixel operations modify individual pixel values based on their own gray level, such as contrast stretching and log transformations. Neighborhood operations modify pixel values based on surrounding pixels using filters, and geometric transformations include operations like scaling and rotation. Histogram equalization and matching are also covered, which manipulate the histogram of pixel values to improve contrast.

Uploaded by

mna shourov
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
252 views

Digital Image Processing (Chapter 3) PDF

The document discusses various techniques for image enhancement in the spatial domain, including single pixel operations, neighborhood operations, and geometric spatial transformations. Single pixel operations modify individual pixel values based on their own gray level, such as contrast stretching and log transformations. Neighborhood operations modify pixel values based on surrounding pixels using filters, and geometric transformations include operations like scaling and rotation. Histogram equalization and matching are also covered, which manipulate the histogram of pixel values to improve contrast.

Uploaded by

mna shourov
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 84

3 Image Enhancement in the

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.
– Spatial domain refers to the image place itself.
– Frequency domain processing techniques are
based on modifying the Fourier transform of an
image.
Image Enhancement in the Spatial
Domain
• Find gray level transformation function T(r)
to obtain processed image from input image.
• g(x, y) =T[f(x, y)]
• Reasons:
– Contrast enhancement
– Visual improvement
– Image understanding
Spatial Operations
• Single pixel operations (Intensity
Transformation)
– Negative Image, contrast stretching etc.
• Neighborhood operations
– Averaging filter, median filtering etc.
• Geometric spatial transformations
– Scaling, Rotation, Translations etc.
Spatial Operations
• Single Pixel Operation (Point Processing)
– Enhancement at any point in the image depends
only on the gray level at that point.
• Neighborhood Operation (Mask processing or
Filtering)
– The values of mask (also referred to as filter,
kernel, template, window) coefficient determine
the nature of the enhance process.
Example: Single Pixel Operations
Example: Neighborhood Operations
Example: Geometric Spatial Operations
Some Basic Gray Level Transformation
Image Negatives
• s=L–1–r
– s is the output intensity value
– L is the highest intensity levels
– r is the input intensity value
• Particularly suited for enhancing white or gray detail
embedded in dark regions of an image, especially when
the black areas are dominant in size.
• Produces photographic negative.
• Some details are easier to spot if we go from black
and white to white and black.
Image Negative
Log Transformations
• s = clog(1 + r), c is constant.
• It maps a narrow range of low intensity values in the
input into a wide range of output levels.
• The opposite is true of higher values of input levels.
• It expands the values of dark pixels in an image while
compressing the higher level values.
• It compresses the dynamic range of images with large
variations in pixel values.
• The opposite is true of the inverse log
transformation.
Log Transformations

T (r)  c log(1 r)
Power Law (Gamma) Transformations
• s = crγ, c and γ are both positive constants.
• With fractional values(0<γ<1) of gamma map a
narrow range of dark input values into a wider
range of output values, with the opposite being true
for higher values (γ >1)of input levels.
• Variety of devices used for image capture, printing,
and display respond according to a power law.
• Process used to correct these power law response
phenomena is called gamma correction.
Power Law (Gamma) Transformations
Power Law (Gamma) Transformations
• CRT devices have
Intensity-voltage
response functions
that are power
functions.
• They vary in exponents
from 1.8 to 2.5.

T (r )  r 1/ 2.5
r 0.4
Power Law (Gamma) Transformations
• Images that are not corrected properly look either
bleached out or too dark.
• Varying gamma changes not only intensity, but also
the ratio of red to green to blue in a color images.

• Useful for general purpose contrast manipulation.


• Apply gamma correction on CRT (Television,
monitor), printers, scanners etc.
• Gamma value depends on device.
MRI of Fractured Spine
Aerial Image
Piecewise-Linear Transformation
Functions
• Low contrast images can result from poor
illuminations.
• Lack of dynamic range in the imaging sensor, or
even the wrong setting of a lens aperture during
image acquisition.
• Contrast Stretching:
– Increases the dynamic range of the gray levels in the
image being processed.
Contrast Stretching
Gray (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 in two ways:
1. To display only one value (say, white) 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.
Gray (Intensity)-Level Slicing
Gray (Intensity)-Level Slicing
Gray (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
Bit-Plane Slicing
Bit-Plane Slicing
Histogram Processing
• Histogram of a digital image with intensity levels in
the range [0,L-1] is a discrete function h(rk) = nk,
where rk is the kth intensity value and nk is the
number of pixels in the image with intensity rk.
• Normalized histogram p(rk)=nk/MN, for k = 0,1,2..…..
L-1. Spatial image resolution is M×N.
• Histogram manipulation can be used for image
enhancement.
• Information inherent in histogram is also quite useful
in other image processing applications, such as
image compression and segmentation.
Histogram

te
Histogram
Histogram
Histogram
Histogram

r 0 1 2 3 4 5 6 7
h(r) 8 4 3 2 2 0 1 5

Image matrix
h(r)
Number of pixels of intensity r

0 1 2 3 4 5 6 7
Intensity values r
HISTOGRAM

Histogram plots the number of pixels for each intensity value.


Histogram
Histogram Equalization
• Intensity mapping form
s  T (r), 0  r  L 1
Conditions:
a) T(r) is a monotonically increasing function in the
interval [0, L-1] and
b) 0  T (r)  L 1 for 0  r  L 1

In some formulations, we use the inverse in which case


r  T 1 (s), 0  s  1
(a) change to
aˊ) T(r) is a strictly monotonically increasing function in
Histogram Processing
Histogram Equalization
• Intensity levels in an image may be viewed as
random variables in the interval [0,L-1]
• Fundamental descriptor of a random variable
is its probability density function (PDF).
• Let pr(r) and ps(s) denote the PDFs of r and s
Respectively. p (s)  p (r)
dr
s r
r
ds
s  T (r)  (L 1)  pr (w)dw
0

ds dT (r) d  r   (L 1) p (r)


dr

dr
 (L 1)

dr  0
p r (w)dw
 r
Histogram Equalization
1
ps (s) 
L 1
k k nj
sk  T (rk )  (L 1)  pr (r j)  (L 1)  , k  0,1,2,...,L1
j0 j0 MN
Histogram Processing
Histogram Equalization
Histogram Equalization
Histogram Equalization
Histogram Equalization
• Transformation functions
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.
• In particular, it is useful sometimes to be able to specify the
shape of the histogram that we wish the processed image
to have.
• The method used to generate a processed image that has a
specified histogram is called histogram matching or
specification.
Histogram Matching (Specification)
• Histogram Specification Procedure:
1) Compute the histogram pr (r) of the given image, and use
it to find the histogram equalization transformation in
k nj
equation s  T (r )  (L 1)
k k 
j0 MN
, k  0,1,2,...,L1

and round the resulting values to the integer range [0, L-1]
2) Compute all values of the transqformation function G using
same equation G(z q )  (L 1) p z (ri ) = sq, q  0,1,2,..., L 
and round values of G. i0

3) For every value of sk, k = 0,1,…,L-1, use the stored values


of G to find the corresponding value of zq so that G(zq) is
closet to sk and store these mappings from s to z.
Histogram Matching (Specification)
• Histogram Specification Procedure:
4) Form the histogram-specified image by first histogram-
equalizing the input image and then mapping every
equalized pixel value, sk , of this image to the corresponding
value zq in the histogram-specified image using the
mappings found in step 3.
Histogram Matching
Histogram Matching
Histogram Matching
rk Sk G(Zq)
0 1 0
1 3 0
2 5 0
3 6 1
4 6 2
5 7 5
6 7 6
7 7 7
Histogram Matching
Histogram Matching
Histogram Matching
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 square or rectangular
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.
• 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.
Local Histogram Processing
Spatial Filtering
• Also called spatial masks, kernels, templates, and windows.
• It consists of (1) a neighborhood (typically a small window),
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
center of the neighborhood.
• If operation is linear, then filter is called a linear spatial filter
otherwise nonlinear.
Mechanics of Spatial Filtering
Mechanics of Spatial Filtering
• The result (or response), R, of linear filtering with the
filter mask at a point (x,y) in the image is:
• 𝑅 = 𝑤 −1, −1 𝑓 𝑥 − 1, 𝑦 − 1 + 𝑤 −1,0 𝑓 𝑥 − 1, 𝑦 +
⋯ + 𝑤 0,0 𝑓 𝑥, 𝑦 + ⋯ + 𝑤 1,0 𝑓 𝑥 − 1, 𝑦 − 1 +
𝑤 1,1 𝑓 𝑥 + 1, 𝑦 + 1
Smoothing Spatial Linear Filters
• The output of a smoothing linear spatial filter is
simply the average of the pixels contained in the
neighborhood of the linear mask.
• 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.
• Also called Lowpass filter.
• Random noise typically consists of sharp transition.
• Reduce “sharp” transition in intensities.
• If all coefficients are equal in filter then it is also
called a box filter.
Smoothing Spatial 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 Filter
Order-Statistic (Nonlinear) Filters
• Median filter : 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.
• Replace the value of a center pixel by the median of the
intensity values in the neighborhood of that pixel.
• Use to remove impulse or salt-pepper noise.
Median Filter (Nonlinear)
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.
• Edges also characterized by sharp intensity transitions, so
averaging filters have the undesirable side effect that they
blur edge.
• Thus, image differentiation enhances edges and other
discontinuities (such as noise) and deemphasizes areas
with slowly varying intensities.
Foundation
• Definition for a first order 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.
• For a second order derivatives (1) must be zero in
constant areas (2) must be nonzero at the onset and (3)
must be zero along ramps of constant slope.
• First order derivative of a one dimensional function f(x) is
the difference of f(x+1) – f(x).
• Second order = f(x+1) + f(x-1) -2f(x)
Second Derivatives-The Laplacian
Second Derivatives - The Laplacian
Second Derivatives-The Laplacian
Unsharp Masking and High boost
• Unsharp Masking Filtering
– Read Original Image f(x,y)
– Blurred original image fˊ(x,y)
– Mask = f(x,y) – fˊ(x,y)
– fs(x,y) = f(x,y) + Mask
– Use publishing industry to sharpen image
• High Boost Filtering
– Read Original Image f(x,y)
– Blurred original image fˊ(x,y)
– fhb(x,y) = Af(x,y) – fˊ(x,y), where A>1
– Use when input image is darker than desired
Unsharp Masking and High boost
Filtering
Unsharp Masking and High boost
Filtering
First Derivative – The Gradient
First Derivative – The Gradient
• The center point f(x,y) denotes z5, f(x-1,y-1)
denotes z1 and so on.
• First-order derivative approximates:
– Gx = (z8 – z5) and Gy = (z6 – z5)
– 𝛻𝑓 ≈ 𝐺𝑥 + 𝐺𝑦 = 𝑧8 − 𝑧5 + 𝑧6 − 𝑧5
Other Masks

• Robert cross-gradient operators:


– Gx = (z9 – z5) and Gy = (z8 – z6)
– 𝛻𝑓 ≈ 𝐺𝑥 + 𝐺𝑦 = 𝑧9 − 𝑧5 + 𝑧8 − 𝑧6
• Sobel operators:
– Gx = (z7 + 2z8 – z9) – (z1 + 2z2 – z3)
– Gy = (z3 + 2z6 – z9) – (z1 + 2z4 – z7)
– 𝐺𝑥 + 𝐺𝑦 = 𝑧7 + 2𝑧8 + 𝑧9 − 𝑧1 + 2𝑧2 + 𝑧3
+ 𝑧3 + 2𝑧6 + 𝑧9 − 𝑧1 + 2𝑧4 + 𝑧7
Combining Spatial Enhancement
Methods
Combining Spatial Enhancement
Methods

You might also like