0% found this document useful (0 votes)
35 views22 pages

Topic - 4 - Basic Image Processing Operations

The document covers intensity transformation and spatial filtering in image processing, detailing basic methods such as image enhancement, restoration, compression, and segmentation. It explains various techniques including gray level transformation, linear and non-linear mapping, and spatial domain methods like point and spatial operations. Additionally, it discusses filtering techniques, including mean, median, and Gaussian filters, along with their applications in enhancing image quality and features.
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)
35 views22 pages

Topic - 4 - Basic Image Processing Operations

The document covers intensity transformation and spatial filtering in image processing, detailing basic methods such as image enhancement, restoration, compression, and segmentation. It explains various techniques including gray level transformation, linear and non-linear mapping, and spatial domain methods like point and spatial operations. Additionally, it discusses filtering techniques, including mean, median, and Gaussian filters, along with their applications in enhancing image quality and features.
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/ 22

Topic - 4: Intensity Transformation & Spatial Filtering

Lesson Agenda:

● Basic Image Processing Methods Name.


● image enhancement & types of image enhancement.
● image enhancement technique.
● Spatial Domain
● Gray Level Transformation
● Linear Mapping
● contrast stretching & it’s types.
● Non-Linear Mapping

Basic Image Processing Methods Name


The Basic Image Processing Methods Are
Image Enhancement.
Image Restoration
Image Compression
Image Segmentation

image enhancement:

● Image enhancement improves original data's quality and information content


before processing.

● or to provide `better' input for other automated image processing techniques.


For example, you can remove noise, and sharpen, or brighten an image, making it
easier to identify key features.

There are two primary categories of image enhancement techniques:

Image enhancement techniques can be divided into two broad categories:

1. Spatial domain methods, which operate directly on pixels, and


2. frequency domain methods, which operate on the Fourier transform of an image.

Which is the best image enhancement technique?

A top-selling method for image enhancement is histogram equalization (HE)

Spatial domain techniques are further divided into 2 categories:

○ Point operations (linear operation) / s=T(r)

○ Spatial operations (non-linear operation) / g(x,y) = f(x,y) + b

Gray Level Transformation


All Image Processing Techniques focused on gray level transformation as it
operates directly on pixels.
The gray-level image involves 256 levels of gray and in a histogram, the
horizontal axis spans from 0 to 255, and the vertical axis depends on the
number of pixels in the image.

The simplest formula for the image enhancement technique is:

1. s = T * r

Where T is transformation, r is the value of pixels, s is pixel value before and after
processing.
Let,

1. r = f(x,y)
2. s = g(x,y)

'r' and 's' are used to denote gray levels of f and g at(x,y)

There are three types of transformation:

1. Linear

2. Logarithmic

3. Power - law

The overall graph is shown below:

Linear Transformation
The linear transformation includes identity transformation and negative
transformation.

In identity transformation, each value of the image is directly mapped to each other
values of the output image.

Negative transformation is the opposite of identity transformation. Here, each


value of the input image is subtracted from L-1 and then it is mapped onto the
output image

Logarithmic transformations

Logarithmic transformation is divided into two types:

1. Log transformation

2. Inverse log transformation

The formula for Logarithmic transformation

1. s = c log(r + 1)

Here, s and r are the pixel values for input and output image. And c is constant. In
the formula, we can see that 1 is added to each pixel value this is because if pixel
intensity is zero in the image then log(0) is infinity so, to have minimum value one
is added.
In the above image (a) Fourier Spectrum and (b) result of applying Log
Transformation.

Power - Law transformations

Power Law Transformation is of two types of transformation nth power


transformation and nth root transformation.

Formula:

1. s = cr ^ γ

Here, γ is gamma, by which this transformation is known as gamma


transformation.

All display devices have their own gamma correction. That is why images are
displayed at different intensities.

These transformations are used for enhancing images.


For example:

the Gamma of CRT is between 1.8 to 2.5

Spatial Domain Methods:

The Spatial domain process can be donated by the expression:


g(x,y)= T[f(x,y)]
● Where and y are Spatial (Plane) Coordinates.
● (x,y) is the intensity/gray level image at that point.
● f(x,y) is the input image.
● g(x,y) is the output imag.
● T is an Operator.

Spatial domain techniques are further divided into 2 categories:

○ Point operations (linear operation)

○ Spatial operations (non-linear operation)

Point Operations:

● Point Operations is a Simple Method of Image Enhancement.


● Point Processing Technique, Which results Depend only on the intensity at a
point.
● Point operations are often used to change the grayscale range and
distribution.
● This Point processing function of the form:
s=T(r)
Where
s refers to the processed image
r refers to the original Image
T is a Transformation
● The Point Processing Function is Also Called is an intensity transformation /
Gray Level Mapping Function.
● The Point Processing Function can be further categorized into two ways:
Linear-function
Non-Linear-function
Linear Mapping

🟂 A grayscale image f(x,y) can be transformed into image g(x,y) using a linear
function given as
g(x,y) = f(x,y) + b

🟂 If b > 0 the image is made brighter else the image is darkened.


🟂 b is known as “bias”
🟂 A grayscale image f(x,y) can be transformed into image g(x,y) using a linear
gain function given as
g(x,y) = a * f(x,y)

🟂 If a > 1 the image is made brighter else the image is darkened


🟂 a is known as “gain”
Examples
a) b) c) d) e)
a)Original
b)bias = +55
c)bias = -55
d)gain = +1.5
e)gain = -2.0

contrast stretching
Contrast stretching is a simple technique to enhance the contrast of a digital
image by mapping the pixel values to a wider range.
It can improve the visibility of details and features in an image, especially
when the original image has low contrast or poor lighting.
Contrast stretching can be done using different methods, such as linear,
logarithmic, exponential, or histogram equalization.
Contrast Enhancement methods can be divided into Linear and Non-Linear.
The linear method includes Contrast-Stretching transformation that uses
Piecewise Linear functions while Non-linear method includes Histogram
Equilisation, Gaussian Stretch etc.
A linear mapping that enhances the contrast of an image without removing
any detail.

Non-Linear Mapping

🟂A grayscale image f(x,y) can be transformed into image g(x,y) using various
non-linear mappings.
🟂 Require any mapping to be true a function. For any pixel f(x,y), T(x,y)
results in a unique deterministic value.

🟂 Common non-linear gray-scale mappings include


🟂 log compression: enhances the contrast of darker areas
🟂 exponential mapping: enhances the contrast of brighter areas
Log (dynamic range) Compression:

Log compression takes a range of values and “boosts” the lower end.

Notice that the higher end is “compressed” into a small range of output values.

Log Compression Example

Notice how the darker areas appear brighter and contain more easily viewed
details. The brighter areas loose some detail but remain largely unchanged.
Exponential Mapping
Exponential Mapping takes a range of values and “boosts” the upper end.

Notice that the lower range is “compressed” into a small range of output values.

Spatial Domain|| Point Operation - - -> Histogram equalization and modeling.


Histogram Equalization

Histogram equalization is used to enhance contrast. Contrast doesn't need to always

be increase in this. There may be some cases where histogram equalization can be

worse. In those cases, the contrast is decreased.

Lets start histogram equalization by taking this image below as a simple image.

Image

Histogram of this image


The histogram of this image has been shown below.

Now we will perform histogram equalization to it.


Question: How it is Implement?

Perform the Histogram Equalization for an 8 X 8 Image Shown Below:


Gray Levels(rK) 0 1 2 3 4 5 6 7

No. OF Pixels(nK) 9 8 11 4 10 15 4 3

1. Draw the Histogram for the input Image.

Gray No. OF P(nK)=nK SK SK X 7 R.O.V No. Of


Levels(rK Pixels /n CDF Pixels
) (nK) PDF
0 9 .141 .141 .987 1 9
1 8 .125 .266 1.862 2 8
2 11 .172 .438 3.066 3 11
3 4 .0625 .5005 3.5035 4 4
4 10 .156 .6565 4.5955 5 10
5 15 .234 .8905 6.2335 6 15
6 4 .0625 .953 6.671 7 7
7 3 .047 1 7 7 7
Question: Perform the Histogram Equilization for the following Image:

1 2 1 1 1
2 5 3 5 2
2 5 5 5 2
1 1 1 2 1

Histogram matching in digital image processing


Histogram matching(Specification)
Given Below are two histogram (i) & (ii). Modify the Histogrm (i)as given by histogram (ii).
i)
Gray Levels(rK) 0 1 2 3 4 5 6 7

No. OF Pixels(nK) 80 100 90 60 30 20 10 0

ii)
Gray Levels(rK) 0 1 2 3 4 5 6 7

No. OF Pixels(nK) 0 0 0 60 80 100 80 70

For i)

Geay No. OF P(nK)=nK SK SK X 7 R.O.V No. Of


Levels(rK Pixels /n CDF Pixels
) (nK) PDF
0 80 .20 .20 1.4 1
1 100 .25 .45 3.15 3
2 90 .23 .68 4.76 5
3 60 .15 .83 5.81 6
4 30 .07 .9 6.3 6
5 20 .05 .95 6.65 7
6 10 .02 .97 6.79 7
7 0 0 .97 6.79 7

For ii)
Geay No. OF P(nK)=nK/n SK SK X 7 R.O.V
Levels(rK) Pixels PDF CDF
(nK)
0 0 0 0 0 0
1 0 0 0 0 0
2 0 0 0 0 0
3 60 .15 .15 1.05 1
4 80 .20 .35 2.45 2
5 100 .25 .6 4.2 4
6 80 .20 .8 5.6 6
7 70 .17 .97 6.79 7

Geay Levels(rK) R.O.V R.O.V No. Of


Pixels
0 0 1 80
1 0 3 100
2 0 5 90
3 1 6 90
4 2 6 90
5 4 7 30
6 6 7 30
7 7 7 30
Gray Levels(rK) 0 1 2 3 4 5 6 7

No. OF Pixels(nK) 0 0 0 80 80 100 90 30

Neighborhood (Spatial) Operations


🟂 Neighborhood operations modify pixel values based on the values of
nearby pixels. Convolution and Correlation are fundamental
neighborhood operations.

Convolution is used to filter images for specific reasons – to remove noise, to


remove motion blur, to enhance image features, etc…
🟂 Convolution will have different effects depending upon the values of the
Kernel.
Correlation is used to determine the similarity of regions of an image to other
regions of interest. Used in pattern recognition, motion analysis and image
registration.
Question:
Let I={0,0,1,0,0} be an image .Using the Kernel k={3,2,8} perform the
convolution & Correlation.
Spatial Filtering and its Types
● The Spatial Filtering technique is used directly on pixels of an image.
● The concept of a mask is also known as spatial filtering.
● Mask is a type of filter which operates directly on the image.
● The filter mask is also known as the convolution mask.
● Mask is usually considered to be added in size so that it has a specific
center pixel.
● This mask is moved on the image such that the center of the mask
traverses all image pixels.
● Filtering is a way of tuning image frequencies – much like a graphic equalizer
○ Low Pass Filtering: allows only the “low-frequency signals through”
○ High Pass Filtering: allows only the “high-frequency signals through”

There are two types of filters:

1. Mean filtering: it is often used to reduce noise in images.


2. Median filter: Median filters are useful in reducing random
noise.
3. Min Filters: The minimum filter is typically applied to an
image to remove positive outlier noise.or, Used to find the
darkest points in an image.
4. maximum filter: Used to find the brightest points in an
image.
5. Gaussian Filter: A Gaussian Filter is a low-pass filter used
for reducing noise (high-frequency components) and
blurring regions of an image.

Question: Consider the pixel Values and Calculate the Output of


the Pixel (2,2) if smoothing is done using 3 X3 neighborhoods
Using all the filters below:
1. Mean/Box Filtering/Avg. Filtering
2. Weighted Avg. Filtering
3. Median Filtering
4. Min Filtering
5. Max Filtering
6. Gaussian Filtering

Mean/Box Filtering

= 1/9 X (7+7+4+6+4+3+1+0+7)
=4.33
=4
Weighted Avg. Filtering

Question: What is the difference between High Pass & Low Pass
Filter.

Sharpening Spatial Filter

● It is also known as a derivative filter.


● The purpose of the sharpening spatial filter is just the opposite of the
smoothing spatial filter.
● Its main focus is on the removal of blurring and highlighting the
edges.
● It is based on the first and second order derivative.
1. First order derivative: f' = f(x+1) - f(x)
2. Second order derivative: f'' = f(x+1) + f(x-1) -
2f(x)
● The difference between smoothing and sharpening spatial filters is
that in smoothing we try to smooth noise and ignore edges and in
sharpening we try to enhance edges and ignore noise.

● Application of image sharpening includes electronic printing, medical imaging, industrial


inspection, and autonomous guidance in the military system.


Laplacian filter
● Laplacian filter is a second-order derivative filter used in edge detection, in digital
image processing.
● . In 1st order derivative filters, we detect the edge along with horizontal and
vertical directions separately and then combine both. But using the Laplacian
filter we detect the edges in the whole image at once.

Note:The sum of all values of the filter is always 0.

Question1: Apply Laplacian Filter on the given image on the center


pixel:

245
567
456
Question2: Apply Enhance Laplacian Filter on the given image on the
center pixel:

245
567
456

You might also like