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

Assignment For Image Processing: Blurring

1. Blurring, also known as smoothing, is used to make an image smooth by reducing edges. It is done by applying spatial filters that average pixel values in a neighborhood. 2. Blurring can be used for pre-processing tasks like noise reduction before object extraction. It works by applying a convolution with a kernel (filter) that averages pixels, changing pixel values to be closer to neighbors. 3. Edge detection identifies points where the image intensity changes sharply, such as boundaries of objects. It aims to detect step edges, ramp edges, and roof edges which model real blurred and noisy edges in images.

Uploaded by

Manan Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

Assignment For Image Processing: Blurring

1. Blurring, also known as smoothing, is used to make an image smooth by reducing edges. It is done by applying spatial filters that average pixel values in a neighborhood. 2. Blurring can be used for pre-processing tasks like noise reduction before object extraction. It works by applying a convolution with a kernel (filter) that averages pixels, changing pixel values to be closer to neighbors. 3. Edge detection identifies points where the image intensity changes sharply, such as boundaries of objects. It aims to detect step edges, ramp edges, and roof edges which model real blurred and noisy edges in images.

Uploaded by

Manan Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Manan Sharma Image Processing Roll no :-3

Assignment for Image processing

Blurring

Blurring is also known as Smoothing Spatial Filters


Smoothing filters are used for blurring and for noise reduction.

Blurring is used in pre-processing tasks, such as removal of small details from an image
prior to (large) object extraction.

Definition of blurring in technical terms

In Digital image processing, blurring is used to make an image smooth in which edges are
not observed. Suppose, we have an image in which there are 508*340=172,720 pixels. If we
want to blur this image, then all the 172,720-pixel values will be changed by using the
blurring technique and convolution as we know that in an image, there are 8 pixels around it.
When these pixels are combined as 8+1=9, a 3x3 matrix is formed. In our image, there are
172,720 pixels, so there will be 172,720 matrices of 3x3 orders. By applying convolution in
all 172,720 matrices with a common matrix called the kernel. The kernel is a special matrix,
it changes the pixels using convolution to make an image blur. A low pass filter is used for
blurring as it allows the low frequency to allow and stop the high frequency. The term
frequency means to change the value of the pixel.

Definition of blurring in Textbook terms


If a blurred image is observed carefully then a common thing to notice is that image is
smooth meaning edges are not observed. A filter used for blurring is also called low pass
filter, because it allows low frequency to enter and stop high frequency. Here frequency
means the change of pixel value. Around edge pixel value changes rapidly as blur image is
smooth so high frequency should be filtered out.
For blur purpose a filter with every call having value 1 is used because to blur image a
pixel value should be close to neighbor value.
Manan Sharma Image Processing Roll no :-3

In filter it is divided by 9 for normalization otherwise value of a pixel will increase resulting
in more contrast which is not the goal.

Tree diagram for Smoothing Spatial Filtering

 Smoothing Linear 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, 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
Manan Sharma Image Processing Roll no :-3

1. Smoothing Linear Filters –Average 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, 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

Explanation
 Use of the first filter yields the standard average of the pixels under the mask.
 Which is the average of the intensity levels of the pixels in the neighborhood defined
by the mask
 A spatial averaging filter in which all coefficients are equal sometimes is called a box
filter.
 Two 3x3 smoothing (averaging) filter masks.
 The constant multiplier in front of each mask is equal to 1 divided by the sum of the
values of its coefficients, as is required to compute an average.
 The second mask in Figure is a little more interesting.
 This mask yields a so called weighted average, terminology used to indicate that
pixels are multiplied by different coefficients, thus giving more importance (weight) to
some pixels at the expense of others.
Manan Sharma Image Processing Roll no :-3

Formula
 The general implementation for filtering an M X N image with a weighted averaging
filter of size m x n (m and n odd) is given by the expression-

 It is understood that the complete filtered image is obtained by applying above


equation for x=0,1,2,3…,M-1 ad y=0,1,2,3,….N-1.
 The denominator is simply the sum of the mask coefficients and, therefore, it is a
constant that needs to be computed only once.

Implementation and Example


 An important application of spatial averaging is to blur an image for the purpose of
getting a gross representation of objects of interest, such that the intensity of smaller
objects blends with the background and larger objects become “bloblike” and easy to
detect.
 The size of the mask establishes the relative size of the objects that will be blended
with the background.
 We see that a number of objects have either blended with the background or their
intensity has diminished considerably.
 It is typical to follow an operation like this with thresholding to eliminate objects based
on their intensity.
Manan Sharma Image Processing Roll no :-3

The above image shows us the before and after changes of the filter (i.e Average filter)

 Linear filters blurs all image structures points, edges and lines, reduction of image
quality
 Linear filters thus not used a lot for removing noise
Manan Sharma Image Processing Roll no :-3

2. Smoothing Order-Statistic (Nonlinear) Filters

 Order-statistic filters are nonlinear spatial


 The 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.

 Smoothing Nonlinear Filters – Median

 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 (the original value of the pixel is included in the
computation of the median).
 Median filters are quite popular because, for certain types of random noise, they
provide excellent noise-reduction capabilities, with considerably less blurring than
linear smoothing filters of similar size.
 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.
 The median, of a set of values is such that half the values in the set are less than
or equal to the median and half are greater than or equal to the median.

Explanation
 The median filter works by moving through the image pixel by pixel, replacing
each value with the median value of neighbouring pixels.
 The pattern of neighbours is called the "window", which slides, pixel by pixel
over the entire image 2 pixel, over the entire image.
 In order to perform median filtering at a point in an image, we first sort the
values of the pixel in the neighborhood, determine their median, and assign
that value to the corresponding pixel in the filtered image.
Manan Sharma Image Processing Roll no :-3

 Note that noise pixels are considered to be very different from the median.
Using this idea median filter can remove this type of noise problems while
preserving edges.

Implementation with an example


Manan Sharma Image Processing Roll no :-3

Edge Detection

Edge Detection
 Edge detection is the approach used most frequently for segmenting images based
on abrupt change in intensity.
 Ideally, edges should be 1 pixel thin. In practice, they are blurred and noisy.
 Edge Models- classified according to their intensity profiles

o Step Edge
 A step edge involves a transition between two intensity levels occurring
over a distance of single pixel.

o Ramp Edge
 Digital images are having edges that are blurred and noisy.
 The slope of ramp is inversely proportional to the degree of blur.
 Edge point is not well defined but contained in any point in the ramp.

o Roof Edge
 Models of lines through a region.
Manan Sharma Image Processing Roll no :-3

Ways in which you can detect the edges in your image


 We know that the first derivative is positive at the onset of the ramp and at points on
the ramp and it is zero at the area of constant intensity.
 The second derivative is positive at the beginning of the ramp, negative at the end of
the ramp, zero at points of the ramp and zero at points of constant intensity.
 The intersection between the zero intensity axis and the line extending between the
extrema of the second derivative marks a point called the zero crossing of the
second derivative can be used to locate the centre of the thick edges
Manan Sharma Image Processing Roll no :-3

Embossing Implementation

What is Embossing in image Processing


 Image embossing is a computer graphics technique in which each pixel of an image
is replaced either by a highlight or a shadow, depending on light/dark boundaries on
the original image. Low contrast areas are replaced by a gray background.
 The filtered image will represent the rate of colour change at each location of the
original image. Applying an embossing filter to an image often results in an image
resembling a paper or metal embossing of the original image, hence the name.

Implementation of Embossing
Python code for implementation of Embossing

#Importing libraries

import streamlit as st #(open source app framework)

from PIL import Image #( for importing an image)

import matplotlib.pyplot as plt #(for plotting and displaying of image)

from PIL import Image, ImageFile, ImageDraw, ImageChops, ImageFilter

#Embossing function

image = Image.open("0205.jpg") # (getting the image and assigning it as a


varibale )

fig = plt.figure() #(for plotting)

emb = image.filter(ImageFilter.EMBOSS) #(applying embossing function


on the variable image)

plt.imshow(emb) # (plotting of animage)

st.pyplot(fig) #(to plot in the browser using streamlit)


Manan Sharma Image Processing Roll no :-3

Output:-

Original Image:-

Embossed Image:-

You might also like