You are on page 1of 76

Outlines…

Spatial Processing of Digital Images


Basic Intensity Transformation Functions
Histogram of images
Spatial filtering
Histogram processing
Combining Spatial Enhancement Methods
Spatial Domain Image Processing
Image enhancement can be classified into Spatial
domain method and transform(frequency) domain
method.
Spatial domain method  refers to the image
plane itself, & this approaches are based on direct
manipulation of pixels in an image.
Frequency domain processing techniques are
based on modifying the Fourier transform of an
image.
Con’t…
spatial domain proceessing is doned by
g(x,y)=T[f(x,y)]
where f(x,y)is the input image and g(x,y)is
processed image , T is an operator on f,
defined over f(x,y).
T can be operate on the set of the input,
such as the pixe to pixel sumof k image to
reduce the noice of image.
Con’t…
 The spatial domain method is used to
enhance images.
 After image enhancement, the input image
becomes clearer and is used in the next
stages of the process to improve
performance.
What is Image Enhancement?
How we can enhance image?
Image enhancement
Brightness modification
 Increasing => g [m,n] = f [m,n] + k
 Decreasing => g [m,n] = f [m,n] – k
Contrast manipulation
 g[m,n] = f[m,n] * k

 Note:
 Brightness refers to the over all lightness or darkness of
the image.
 Increasing the brightness make every pixel in the frame
gets lighter.
 Contrast is the difference in brightness b/n objects in the image.
 Increasing the contrast makes light areas lighter & dark
area in the frame becomes much darker.
Image Enhancement
1. Image Negatives

This type of processing is particularly


suited for enhancing white or gray detail
embedded in dark regions of an image,
specially when the dark
areas are dominant in size.
➢Consists of 3 – steps:
1. Normalisation
2. Mapping
3. Denormalization
Image negative
Eg
Con’t…
Normalization:
Divide each numbers by the highest gray level values
Con’t…

B. Mapping:
➢ S = 1 – r , where r is the input gray level
value, and S = is the output gray level value.
Con’t…

C. Denormalization:
➢Multiply pixel value with the highest gray level
value.
Con’t…
Zooming
There are three methods of zooming that
we are going to see:
1. Pixel replication or (Nearest neighbor interpolation)
2. Zero order hold method
3. Zooming K times
Zooming…pixel replication
Pixel replication:
It is also known as Nearest neighbor interpolation.
we just replicate the neighboring pixels or the
gray level values.
zooming is nothing but increase amount of sample
or pixels.
In this method we create new pixels from the
already given pixels.
Each pixel is replicated in this method n times row
wise and column wise and you got a zoomed image.
Con’t…
E.g. if you have an image of 3 rows and 3
columns and you want to zoom it twice or
2 times using pixel replication, here how it
can be done.
Con’t…
ROW WISE ZOOMING:
➢When we zoom it row wise , we will just
simple copy the rows pixels to its adjacent
new cell.
Con’t…
COLUMN SIZE ZOOMING:
simply copy the column pixel to its adjacent
new column or simply below it.
Con’t…
(Original image rows * zooming factor, Original Image
cols * zooming factor)
ADVANTAGE
One of the advantage of this zooming technique is , it is
very simple.
You just have to copy the pixels and nothing else.
DISADVANTAGE
This technique is that image got zoomed but the output is very blurry.
And as the zooming factor increased , the image got more
and more blurred.
That would eventually result in fully blurred image
zooming... Zero order hold method
Zero order hold method:
Zero order hold method is another method of
zooming.
It is also known as zoom twice.
We pick two adjacent elements from the rows
respectively and then we add them and divide the
result by two, and place their result in between
those two elements.
We first do this row wise and then we do this
column wise.
Con’t…
Con’t…
First we zoom it row wise and column wise.
ROW WISE ZOOMING
Con’t…
Column wise zooming
Con’t…
The new image is formed(2*no of rows)-1 *(2*no
of column)-1
ADVANTAGES
This method does not produce a blurry image,
unlike the other methods
We can always double the image resolution
without any special effort.
It is easy to implement with zero computation
overhead.
Con’t…
 Disadvantage
This method can only run on the power of two.
Because of the power two, it doesn't allow us to
zoom images by custom resolution.
zooming... K-Times zooming
K-Times zooming:
K times is the third zooming method we
are going to discuss.
It is one of the most perfect zooming
algorithm discussed so far
It caters the challenges of both twice
zooming and pixel replication.
K in this zooming algorithm stands for
zooming factor.
Con’t…
WORKING:
1. take two adjacent pixels.
2. Then you have to subtract the smaller from the greater one. the
result is called op
3. Divide this op /output with the zooming factor (K).
4. Now you have to add the result (OP) to the smaller value and put
the result in between those two values.
Add the value OP again to the value you just put and place it
again next to the previous putted value.
You have to do it till you place k-1 values in it.
Repeat the same step for all the rows and the columns , and you
get a zoomed images.
Con’t…
Con’t…
ROW WISE ZOOMING
Take the first two adjacent pixels. Which are 15
and 30.
Subtract 15 from 30. 30-15 = 15.
Divide 15 by k. 15/k = 15/3 = 5. We call it OP.
(where op is just a name)
Add OP to lower number. 15 + OP = 15 + 5 = 20.
Add OP to 20 again. 20 + OP = 20 + 5 = 25.
We do that 2 times because we have to insert k-1
values.
Con’t…
Con’t…
COLUMN WISE ZOOMING:
The same procedure has to be performed column wise.
The procedure include taking the two adjacent
pixel values, and then Subtracting the smaller
from the bigger one
Then after that, you have to divide it by k.
Store the result as OP.
Add OP to smaller one, and then again add OP to
the value that comes in first addition of OP.
Insert the new values.
Con’t…
Con’t…
ADVANTAGES
The one of the clear advantage that k time
zooming algorithm has that it is able to compute
zoom of any factor which was the power of pixel
replication algorithm.
It gives improved result (less blurry) which was
the power of zero order hold method.
It comprises the power of the two algorithms.
DISADVANTAGE
The algorithm is it has to be sort in the end,
which is an additional step.
Thus, it increases the cost of computation.
Intensity Transformation Functions
Con’t…
For instance, the following two images show
an image before and after an intensity
transformation.
Originally, the camera man's jacket looked
black, but with an intensity transformation,
the difference between the black intensity
values, which were too close before, was
increased so that the buttons and pockets
became viewable.
Con’t…
Generally, making changes in the intensity is done
through Intensity Transformation
Functions.
Con’t…
1. photographic negative (linear or identity)
2. gamma transformation (power low)
3. logarithmic transformations (log)
The Photographic Negative is probably the easiest of
the intensity transformations to describe.
• Assume that we are working with grayscale double
arrays where black is 0 and white is 1.
• The idea is that 0's become 1's, 1's become 0's,
and any gradients in between are also reversed.
• In intensity, this means that the true black becomes
true white and vise versa.
Con’t…

The below shows a graph of the mapping


between the original values (x-axis) and the
imcomplements function.
The following is an example of a
photographic negative.
Notice how you can now see the writing in
the middle of the tire better than before:
S= (L-1)-r
Con’t…
Log Transformations
 mathematically log transformation can be expressed as
s=clog(1+r), where c is constant (scaling factor), r>=0
 Why we take 1+r in place of r?
 During log transformation, the dark pixels in an image are
expanded as compare to the higher pixel values.
 Log Transformations is expand or compress the gray level
 Log gives high contrast image and inverse log gives low
contrast image
Power – Law transformations
Two transformation is power law
transformations, that include nth power
and nth root transformation.
These transformations can be given by the
expression: s=crT
i
if Tis gamma.
T>1=nth power
T<1 = nth root
Intensity level slicing
Intensity level slicing can be stated as
Without background-clipping
With background
Intensity level slicing with two given values r1=2
and r2=4

Without background
S= L-1=7; 2<=r<=4
0 ; otherwise
Co’t…
r= 1,5,6,7 S= 0
r= 2,3,4 S= 7
The graph will be drawn and the digital
image output will be generated.
Intensity level slicing with background

The function can be written as


S= L-1=7 ; 2<=r<=4;
r ; otherwise;

r=2,3,4 S= 7;
r=1 S=1;
r=5 S=5;
r=6 S=6;
r=7 S=7;
Its graph can be drawn and out put image can be generated
Bit plane
Digital image
Convert into binary
MSB, CENTER, LSB
Contrast stretching

Assignment:(5%)
use the following digital image

Given r1=3 and r2=4


S1=3 and S2=6
1. Find the slope of alpha, gamma and betta where 0<=r<2, 2<=r<6 and
3<=r<7 respectively
2. Draw the graph of the points
3. Find an output digital image
Histogram of Image
 An image histogram is a graphical
representation of the number of pixels in an
image as a function of their intensity.
 Histogram of an image represents the relative
frequency of occurrence of various gray levels
in an image.
 Histogram of an image provides a global
description of the appearance of an image.
 Information obtained from histogram is very
large in quality.
Con’t…
You can consider histogram as a graph or plot,
which gives you an overall idea about the intensity
distribution of an image.
It is a plot with pixel values (ranging from 0 to
255, not always) in X-axis and corresponding
number of pixels in the image on Y-axis.
It is just another way of understanding the image.
By looking at the histogram of an image, you get
intuition about contrast, brightness, intensity
distribution etc of that image.
Con’t…

Left region of histogram shows


the amount of darker pixels in
image and right region shows
the amount of brighter pixels.
From the histogram, you can
see dark region is more than
brighter region, and amount of
midzones (pixel values in mid-
range, say around 127) are very
less.
Con’t…

let say the above image matrix contains the pixel


values at (i, j) position in the given x-y plane
which is the 2D image with gray levels.
 There are two ways to plot a
Histogram of an image:
 Method 1: In this method,
the x-axis has grey levels/
Intensity values and the y-
axis has the number of pixels
in each grey level. The
Histogram value
representation of the above
image is:
Con’t…

Explanation: The above


image has 1, 2, 3, 4, 5, 6,
and 8 as the intensity
values and the occurrence
of each intensity value in
the image matrix is 2, 1, 3,
2, 2, 3 and 3 respectively so
according to intensity value
and occurrence of that
particular intensity we
mapped them into a Graph.
Con’t…
Method 2: In this method, the x-axis represents
the grey level, while the y-axis represents the
probability of occurrence of that grey level.
Con’t…
Histogram Processing
There is different type of histogram processing.
histogram equalization
histogram maching
local histogram processing
static for image enhanced
Equalization of a Histogram
Con’t…
Con’t…

nk, no of pixel
gray no PDF=nk CDF= sk*7 histog
level of /sum SK ram sum=6+14+5=25.
pixe level cdf=cumulative
l
probability function is
0 0 0 0 0 0
for first pixel is 0
1 0 0 0 0 0
2 0 0 0 0 0
then add output of
3 6 6/25=0.2 0.24 1.68 2
CDF to pdf.
4 sk*7, the highest gray
4 14 14/25=0. 0.8 5.6 6 level in 8 bit.
56
histogram level= take
5 5 5/25=0.2 1 7 7
approxmation of
6 0 0 1 7 7
number to plot
7 0 0 1 7 7
Con’t…

4 4 4 4 4 6 6 6 6 6

3 4 5 4 3 2 6 7 6 2

3 5 5 5 3 2 7 7 7 2

3 4 5 4 3 2 6 7 6 2

4 4 4 4 4 6 6 6 6 6

input image output image


Con’t…
Spatial filtering
Spatial filtering modifies an image by replacing the value
of each pixel by a function of the values of the pixel and
its neighbors.
Mask is usually considered to be added in size so that
it has specific center pixel.
This mask is moved on the image such that the center of
the mask traverses all image pixels.
Filter refers to passing or rejecting some frequency
components.
The filter that pass lower frequency called low-pass filter
, used to blur or Smoothing used noise reduction in the
image.
Con
The spatial domain enhancement is based on
pixels in a small range (neighbor).
the transformed intensity is determined by the
gray values of those points within the
neighborhood, and thus the spatial domain
enhancement is also called neighborhood
operation or neighborhood processing.
The filtering process is to move the filter point-
by-point in the image function f (x, y) so that the
center of the filter coincides with the point (x,
y).
Con’t…
At each point (x, y), the filter’s response is calculated
based on the specific content of the filter and through a
predefined relationship called ‘template’ or ‘mask’ or
‘filter’ or ‘window’ or ‘kernel’.

The elements on the mask called coefficients


Con’t…
If the pixel in the neighborhood is calculated as a linear
operation, it is also called ‘linear spatial domain filtering’,
otherwise, it’s called ‘nonlinear spatial domain filtering’.
The figure shows the process of spatial filtering with a
3 × 3 template (also known as a filter, kernel, or window).
The coefficients of the filter in linear spatial filtering
give a weighting pattern. For example,for above figure,
the response ‘R’ to the template is:
Con’t…
In mathematics, this is known as element-wise matrix
multiplication.
The coefficient w(0,0) coincides with image value f(x,y),
indicating that the mask is centered at (x,y) when the
computation of sum of products takes place.
For a mask of size mxn, we assume that m-
2a+1 and n=2b+1, where a and b are
nonnegative integer. Then m and n are odd.
Con’t…
For a filter with a size of (2a+1, 2b+1), the
output response can be calculated with the
following function:
In general, linear filtering of an image f of
size MxN with a filter mask of size mxn is
given by the expression:
Con’t…
In spatial filtering we have two terms correlation
and convolution which is too related to each other
The first one is a process of moving the mask
element to the entire image step by step and
compute sum of product the pixel value.
The second one (convolution) is same as
convolution but before computing we have to
rotate the mask by 180 degree.
Spatial filters can be smoothing spatial filter or
sharpening spatial filter.
Linear smoothing

You might also like