Unit Ii - CC
Unit Ii - CC
Unit Ii - CC
• For example:
• This can include reducing noise, sharpening details (revealing blurred details), adjusting
contrast and brightness, and highlighting specific areas of interest.
• Frequency domain
SRM Institute of Science and Technology 06-02-2024 4
EX - IMAGE ENHANCEMENT
Image Smoothing
Edge Enhancement 5
SRM Institute of Science and Technology
06-02-2024
HOW TO DO IMAGE ENHANCEMENT?
• Spatial domain
• Frequency domain
• Spatial domain refers to the image plane itself, and techniques involve the
direct manipulation of pixel values within the image.
• These methods operate on individual pixel values and their neighboring
pixels.
• They include techniques like histogram equalization, contrast stretching,
filtering (e.g., Gaussian, median, or mean filtering), and edge enhancement
(e.g., using the Laplacian or Sobel operators).
• These methods work directly with the pixel values and can be intuitive to
understand and implement.
SRM Institute of Science and Technology 06-02-2024 7
ILLUSTRATION OF SPATIAL DOMAIN FOR GRAYSCALE IMAGE
An image can be represented in the form of a 2D matrix where each element of the matrix
represents pixel intensity. This state of 2D matrices that depict the intensity distribution of an
image is called Spatial Domain. It can be represented as shown below-
• This transformation allows the image's frequency components (high and low
frequencies) to be analyzed and manipulated.
• Once in the frequency domain, enhancements can be applied, such as noise reduction
through frequency filtering or sharpening using high-frequency emphasis.
• After applying the desired enhancements, the image can be transformed back to the
spatial domain using the inverse Fourier Transform.
• T: Represents the transformation of converting the image from spatial domain to frequency
domain using mathematical operations.
• Ex of transformation: Fourier transform, Inverse Fourier transform
regions.
• Spatial domain methods are procedures that operate directly on these pixels.
• T is an operator on f (Different operations are carried out in this value)defined over some
neighborhood of (x, y). Ex: Addition 5 to all pixels
• g(x, y) is the processed image / g (x,y) is the new intensity after adding 5 to I(x,y)
• T can process a group of input images, such as calculating the sum of pixel values for K images on a
neighborhood around the coordinates (x, y) to reduce noise.
The center of the sub image 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.
06-02-2024 16
SRM Institute of Science and Technology
CATEGORIES OF SPATIAL DOMAIN
where r is the pixels of the input image and s is the pixels of the output image.
Transformation is a function that takes the values of pixels from one set and maps
them to another set through specific operations.
SRM Institute of Science and Technology 06-02-2024 19
EX OF IMAGE TRANSFORMATION – CONTRAST STRETCHING
For instance, if the function T(r) follows the pattern illustrated in Fig. 2(a), it would enhance the contrast of an
image. This is achieved by making darker levels even darker and brighter levels even brighter compared to
the original image.
This process, known as contrast stretching, involves compressing pixel values below a threshold "m" into a
narrower range, which makes them appear darker.
Conversely, pixel values above "m" are spread out, making them appear brighter. In the case shown in Fig.
2(b), T(r) can even produce a two-level (binary) image, creating distinct regions with just two levels of
brightness. Such a mapping is termed a thresholding function.
06-02-2024 20
SRM Institute of Science and Technology
GRAY LEVEL TRANSFORMATION / INTENSITY TRANSFORMATION
Its done for image enhancement.
It involves applying a function to the pixel values of an image to achieve desired changes in
contrast, brightness, or other visual properties. The goal of gray-level transformation is to enhance
or modify the appearance of an image for better visualization or analysis by adjust contrast, and
reveal important details.
Mathematically, gray-level transformation can be represented as follows:
s=T(r)
where:
• r is the original pixel value (input intensity / before processing).
• s is the transformed pixel value (output intensity / after processing).
• T is the transformation function that maps input intensities to output intensities.
• Linear Transformation - This involves applying a linear function to the pixel values
• A common example is contrast stretching, where pixel values are linearly mapped to
• Non-Linear
transformation.
Applications
Comparing transformed images to the original using the identity
transformation helps evaluate the impact of different techniques both
numerically and visually.
The identity transformation acts as a benchmark during the development of
image processing algorithms, aiding in testing and verifying the transformations.
06-02-2024 26
SRM Institute of Science and Technology
NEGATIVE TRANSFORMATION
06-02-2024 28
SRM Institute of Science and Technology
LOGARITHMIC TRANSFORMATION
The main benefit of using Gamma is the more natural look of images
and the ability to differentiate between dark tones in a darker
image.
06-02-2024 32
SRM Institute of Science and Technology
GAMMA / POWER-LAW TRANSFORMATION
06-02-2024 33
SRM Institute of Science and Technology
WHAT IS HISTOGRAM?
In digital image processing, the histogram is used for graphical representation of a digital image. A graph is
a plot by the number of pixels for each tonal value. Nowadays, image histogram is present in digital
cameras. Photographers use them to see the distribution of tones captured.
In a graph, the horizontal axis of the graph is used to represent tonal variations whereas the vertical axis is
used to represent the number of pixels in that particular pixel.
Black and dark areas are represented in the left side of the horizontal axis, medium grey color is
represented in the middle, and the vertical axis represents the size of the area.
Spatial Domain Methods: Histogram Processing
Histogram equalization, Matching
Local Histogram Processing
Statistics for histogram
Fundamentals of Spatial Filtering : Smoothing Spatial filters - linear Filters
Order statistics nonlinear filters -Sharpening spatial filters
Combined spatial enhancement methods
Frequency Domain methods: Basics of filtering in frequency domain
image smoothing, image sharpening, selective filtering,
Homomorphic filtering, A model of image degradation/ restoration
Process, Noise models, Adaptive filters, Band reject Filters, Band pass Filters, Inverse Filtering – Wiener, Singular
value decomposition
Applications of Histograms
1. In digital image processing, histograms are used for simple calculations in software.
2. It is used to analyze an image. Properties of an image can be predicted by the detailed study of the histogram.
3. The brightness of the image can be adjusted by having the details of its histogram.
4. The contrast of the image can be adjusted according to the need by having details of the x-axis of a histogram.
5. It is used for image equalization. Gray level intensities are expanded along the x-axis to produce a high contrast
image.
PROCESSIN
G
TECHNIQUE
S
Histogram
Stretching
HISTOGRAM EQUALIZATION
Histograms are the basis for numerous spatial domain processing
techniques. Histogram manipulation can be used for image
enhancement, as shown in this section.
As an introduction to histogram processing for intensity
transformations, consider the below Diagram
four basic intensity characteristics: dark, light, low contrast, and
high contrast. The right side of the figure shows the histograms
corresponding to these images. The horizontal axis of each
histogram plot corresponds to intensity values, The vertical axis
corresponds to values of or if the values are normalized. Thus,
histograms may be viewed graphically simply as plots of
h(rk) = nk.rk
p(rk) = nk>MN
H= horizontal, rk- intensity values , nk- number of pixels
h(rk) = nk is the discrete function
P(rk) = probability of the occurrence based on the intensity rk
M and N are the row and column dimension of the image.
Result :
The sum of all components of a normalized histogram is
equal to 1.
42
Statistics obtained directly from an image histogram can be used for image enhancement. Let r
denote a discrete random variable representing intensity values in the range(0, L-1) and let p(ri)
denote the normalized histogram
mn(r) = a L-1 i=0 (ri - m) np(ri)
As image shows the level of statistics based on the grey scale.
43
There are several basic concepts underlying the use of spatial filters for image processing. Spatial
filtering is one of the principal tools used in this field for a broad spectrum of applications, so it is
highly advisable that you develop a solid understanding of these concepts,
The name filter is borrowed from frequency domain processing where “filtering” refers to
accepting (passing) or rejecting certain frequency components. For example, a filter that passes
low frequencies is called a lowpass filter which means blur or otherwise called as smooth of an
image.
We can accomplish a similar smoothing directly on the image itself by using spatial filters (also
called spatial masks, kernels, templates, and windows).
44
Spatial filter consists of (1) a neighborhood,
(typically a small rectangle), and (2) a predefined
operation that is performed on the image pixels
encompassed by the neighborhood.
A processed (filtered) image is generated as the
center of the filter visits each pixel in the input
image. If the operation performed on the image
pixels is linear, then the filter is called a linear
spatial filter Otherwise, the filter is nonlinear
45
Smoothing filters are used for blurring and for noise reduction.
Blurring is used in preprocessing tasks, 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.
46
The output (response) of a smoothing, linear spatial filter is simply the average of the pixels
contained in the neighborhood of the filter mask. These filters sometimes are called averaging
filters.
The idea behind smoothing filters is straightforward.
By replacing the value of every pixel in an image , the average of the intensity levels in the
neighborhood is defined by the filter mask, this process results in an image with reduced “sharp”
transitions in intensities.
Because random noise typically consists of sharp transitions in intensity levels, the most obvious
application of smoothing is noise reduction.
However, edges (which almost always are desirable features of an image) also are characterized
by sharp intensity transitions, so averaging filters have the undesirable side effect that they blur
edges.
47
Order-statistic filters are nonlinear spatial filters whose
response is based on ordering (ranking) the pixels
contained in the image area encompassed by the filter, and
then replacing the value of the center pixel with the value
determined by the ranking result.
The best-known filter in this category is the median filter,
which, as its name implies, replaces the value of a pixel by
the median of the intensity values in the neighborhood of
that pixel.
Median filters are particularly effective in the presence of
impulse noise, also called salt-and-pepper noise because
of its appearance as white and black dots superimposed on
an image.
48
The principal objective of sharpening is to highlight transitions in intensity.
Uses:
1.Electronic printing
2.medical imaging
3.Industrial inspection
4.Autonomous guidance in military systems
Fundamentally, the strength of the response of a derivative operator is proportional to the degree
of intensity in sharpening.
Thus, image differentiation enhances edges and other discontinuities (such as noise) and
deemphasizes areas with slowly varying intensities.
49
In this section we illustrate by means of an example how to
combine several of the approaches developed thus far in this
chapter to address a difficult image enhancement task.
With a few exceptions, like combining blurring with
thresholding.
The image given below 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 by
bringing out more of the skeletal detail. The narrow dynamic
range of the intensity levels and high noise content make this
image difficult to enhance.
50
51
We begin with lowpass filters. Edges and other sharp intensity transitions (such as noise) in an
image contribute significantly to the high frequency content of its Fourier transform.
Hence, smoothing (blurring) is achieved in the frequency domain by high-frequency attenuation;
that is, by lowpass filtering.
we consider three types of lowpass filters: ideal, Butterworth, and Gaussian.
These three categories cover the range from very sharp (ideal) to very smooth (Gaussian) filtering.
The Butterworth filter has a parameter called the filter order.
so all filter functions, (u, v), are understood to be discrete functions of size that is, the discrete
frequency variables are in the range
u = 0, 1, 2, Á , P - 1 v = 0, 1, 2, Á , Q - 1.
52
IMAGE ENHANCEMENT IN THE
FREQUENCY DOMAIN
Types
Smoothing Frequency-Domain Filters
Sharpening Frequency-Domain Filters
Homomorphic Filtering
What is frequency domain
• The frequency domain
refers to the plane of the
two dimensional discrete
Fourier transform of an
image.
• The purpose of the Fourier
transform is to represent a
signal as a linear
combination of sinusoidal
signals of various
frequencies.
INTRODUCTION TO THE FOURIER TRANSFORM
AND THE FREQUENCY DOMAIN
• The one-dimensional Fourier transform and its inverse
– Fourier transform (continuous case)
F (u) f ( x)e j 2uxdx where j 1
Lowpass filter
Circular symmetry
Highpass filter
Some Basic Filters and Their Functions
Low frequency filters: eliminate the gray-level detail and keep the general
gray-level appearance. (blurring the image)
High frequency filters: have less gray-level variations in smooth areas and
emphasized transitional (e.g., edge and noise) gray-level detail.
(sharpening images)
CORRESPONDENCE BETWEEN FILTERING IN THE SPATIAL AND FREQUENCY
DOMAIN
Convolution theorem:
The discrete convolution of two functions f(x,y) and h(x,y) of
size M N is defined as
1 M 1 N 1
f ( x, y ) h ( x, y )
MN m0 n 0
f (m, n)h( x m, y n)
M 1 N 1
1
MN
h(m, n) f ( x m, y n)
m0 n 0
s( x, y) ( x, y) s(0,0)
x 0 y 0
The shifting property of impulse
function
where ( x, y) : a unit impulse located at the origin
• The Fourier transform of a unit impulse at the origin
M 1 N 1
1 1
F (u, v)
MN
( x,
x 0 y 0
y ) e j 2 ( ux / M vy / N )
MN
f ( x, y) ( x, y)
Let , then the convolution
1 M 1 N 1
f ( x, y ) h ( x, y )
MN m0 n 0
(m, n)h( x m, y n)
1
h ( x, y )
MN
Combine,we obtain:
f ( x, y ) h( x, y ) F (u , v) H (u , v)
( x, y ) h( x, y ) ( x, y )H (u , v)
1 1
h ( x, y ) H (u , v)
MN MN
h( x, y ) H (u , v)
That is to say, the response of
impulse input is the transfer
function of filter.
The distinction and links between spatial and frequency
filtering
If the size of spatial and frequency filters is same, then the
computation burden in spatial domain is larger than in
frequency domain;
However, whenever possible, it makes more sense to filter in the
spatial domain using small filter masks.
Filtering in frequency is more intuitive. We can specify filters in
the frequency, take their inverse transform, and the use the
resulting filter in spatial domain as a guide for constructing
smaller spatial filter masks.
Fourier transform and its inverse are linear process, so the
following discussion is limited to linear processes.
There is two reasons that filters based on Gaussian functions are of
particular importance: 1) their shapes are easily specified; 2) both
the forward and inverse Fourier transforms of a Gaussian are real
Gaussian function.
Let H(u) denote a frequency domain, Gaussian filter
function given the equation
u 2 / 2 2
H (u) Ae
where : the standard deviation of the Gaussian curve.
The corresponding filter in the spatial domain is
2 2 2 x 2
h( x) 2 Ae
u 2 / 212 u 2 / 2 22
H (u) Ae Be ,( A B,1 2 )
The corresponding filter in the spatial domain is
Filtering in frequency domain is usually used for the guides to design the
filter masks in the spatial domain.
Some important properties of Gaussian filters functions
One very useful property of the Gaussian function is that both it and its
Fourier transform are real valued; there are no complex values
associated with them.
In addition, the values are always positive. So, if we convolve an image
with a Gaussian function, there will never be any negative output
values to deal with.
There is also an important relationship between the widths of a
Gaussian function and its Fourier transform. If we make the width of
the function smaller, the width of the Fourier transform gets larger.
This is controlled by the variance parameter 2 in the equations.
These properties make the Gaussian filter very useful for lowpass
filtering an image. The amount of blur is controlled by 2. It can be
implemented in either the spatial or frequency domain.
Other filters besides lowpass can also be implemented by using two
different sized Gaussian functions.
TYPE 1: SMOOTHING FREQUENCY-DOMAIN FILTERS
1
D(u, v) (u M / 2) 2 (v N / 2) 2 2
cutoff frequency
f ( x, y) h( x, y) F (u, v) H (u, v)
Notation: the radius of center
component and the number of spatial
circles per unit distance from
the origin are inversely
proportional to the value of the spatial
cutoff frequency.
The BLPF may be viewed as a transition between ILPF AND GLPF, BLPF of
order 2 is a good compromise between effective lowpass filtering and
acceptable ringing characteristics.
Butterworth Lowpass
Filters (BLPFs)
n=2
D0=5,15,30,80,and 230
Butterworth Lowpass Filters (BLPFs)
Spatial Representation
D 2 ( u ,v ) / 2 D02
H (u, v) e
Gaussian Lowpass
Filters (FLPFs)
D0=5,15,30,80,and 230
Additional Examples of Lowpass Filtering
Character recognition in machine perception: join the broken character
segments with a Gaussian lowpass filter with D0=80.
Application in “cosmetic processing” and produce a smoother,
softer-looking result from a sharp original.
Gaussian lowpass filter for reducing the horizontal sensor scan lines and
simplifying the detection of features like the interface boundaries.
86
(or)
is the IDFT
F(u,v) is the DFT of the input image
F(x,y), H(u,v) is the filter function
G(x,y) is the filtered image
Functions F,H are arrays of size M * N
H(u,v) and F(u,v) is formed using array multiplication.
Low frequencies in the transform are related to slowly varying
intensity components in an image
High frequencies are caused by sharp transitions such as edges and
noise
DFT is a complex array