0% found this document useful (0 votes)
107 views37 pages

L17 - Mask Processing - 1

Spatial filtering involves applying a filter mask to an image to process pixels based on their neighboring pixel values. Common types of spatial filters include smoothing filters for blurring and noise reduction, as well as sharpening filters to enhance edges and details. Smoothing filters average pixel values, while sharpening filters use differentiation to highlight discontinuities. Median filters provide effective noise reduction while preserving edges. Laplacian filters can be used to sharpen by adding the original image to the second derivative image.

Uploaded by

ramadevi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views37 pages

L17 - Mask Processing - 1

Spatial filtering involves applying a filter mask to an image to process pixels based on their neighboring pixel values. Common types of spatial filters include smoothing filters for blurring and noise reduction, as well as sharpening filters to enhance edges and details. Smoothing filters average pixel values, while sharpening filters use differentiation to highlight discontinuities. Median filters provide effective noise reduction while preserving edges. Laplacian filters can be used to sharpen by adding the original image to the second derivative image.

Uploaded by

ramadevi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 37

MASK PROCESSING

Spatial Filtering
 A pixel value is computed from its old value and the
values of pixels in its vicinity.
 We define the neighborhood operations by defining a
neighbourhood of the image pixels
 A sub image having the same size as the defined
neighborhood is called a filter, mask, kernel,
template or window.
 The values in a filter sub image are referred to as
coefficients and the process is termed as spatial
filtering.
Spatial Filtering Cont..

 Processing is done by moving the


filter mask from point to point in
the image.
 At each point the response of the
filter at that point is calculated
using a predefined relationship.
Processing
 For each pixel in the input image, the mask is
conceptually placed on top of the image with its
origin lying on that pixel.
 The values of each input image pixel under the
mask are multiplied by the values of the
corresponding mask weights.
 The results are summed together to yield a single
output value that is placed in the output image at
the location of the pixel being processed on the
input.
Processing Cont..
 For a 3x3 filter mask the response, R at the point
(x,y) in the image is
 R = w1 f(x-1,y-1) + w2 f(x-1,y) + …….+ w9 f(x+1,y+1) .
 In general filtering of an image f(x,y) of size MxN
with a filter mask of size mxn is given by the
expression
a b

  w(s, t ) f ( x  s, y  t )
g ( x, y )  s  a t b
a b

  w( s, t )
s   at   b
Smoothing Spatial Filters
(Low Pass Filters)

 Used for blurring and noise reduction.


 It finds the average of the pixels contained in
the neighbourhood of the filter mask.

 Masks used for


simple averaging and
weighted averaging.
Example - Blurring

Filtered images
using 3,5,9,15 & 35
pixels.
Example
Example – Noise Reduction
Order Statistics Filter
 Spatial filters whose response is based on ordering (ranking)
the pixels contained in the image area encompassed by the
filter.
 Replaces the value of the central pixel with the value
determined by the ranking result.
 Typical example is a median filter, which replaces the value of
the pixel by the median of the gray levels in the neighbourhood
of the pixel.
 Median filters provide excellent noise reduction with less
blurring than linear smoothing filters of the same size
especially in the presence of impulse noise (salt and pepper
noise). This is due to the appearance as black and white dots
superimposed on an image.
Median Filtering
Example
Median Filtering – Noise reduction
Example
Sharpening Spatial Filters
 Objective is to highlight fine detail in an image or to enhance
detail that has been blurred, either in error or as a natural
effect of a particular method of image acquisition.

 Sharpening is accomplished by spatial diffentiation.

 The strength of the response of a differential operator is


proportional to the degree of discontinuity of the image at
that point.

 Thus image differentiation enhances edges and other


discontinuities (such as noise) and deemphasizes areas with
slowly varying gray level values.
Derivative Approximations Using
Tailor Series
 If we consider a 1-D signal f(x) discretized as f(xi),
where, xi = x0+iΔx = x0+ih. h = | Δx |
 Let f(xi) – fi ; f(xi+h) – fi+1 ; f(xi-h) – fi-1
 Then from Taylor series we have,
''2 '' '
3
' f h f h
f i 1  fi  fi h  i  i  .....
2! 3!
'' 2 '' '
3
' f h f h
f i 1  f i  f i h  i  i  .....
2! 3!
First Derivative Approximations
Forward difference f i 1  f i
'

fi   o( h)
approximation: h
 Uses the first equation to derive fi’

 Backward difference ' f i 1  f i


fi   o( h)
approximation: h
 Uses the second equation to
derive fi’

Central difference ' f i 1  f i 1



fi   o( h 2 )
approximation: 2h
 Subtracting equations 1 & 2
Second Derivative Approximation
 Central Difference approximation:
 Adding the two equations

''f i 1  f i 1  2 f i
fi  2
 o ( h 2
)
h
Sharpening using first order
derivative operators
 The mask operators corresponding to the 1-D discrete
data can be written as [1 -1*], [1* -1] and ½[1 0 -1].
 In two dimensions the operators such as Dx = ½[1 0 -1]
and Dy = ½[1 0 -1]T detect edges which lie
perpendicular to the direction of the operator. But we
want an operator which detects edges independent of
their orientation (isotropic edge detector).
 So we form the vector operator, the gradient operator.
Sharpening using first order
derivative operators Cont..
 The gradient operator is defined as

 The magnitude and direction are given by

2 1/ 2
 f   f  
2
 f / y 
f          tan  1 
 x   y    f / x 
Sharpening using first order
derivative operators Cont..
 But due to the computational burden of implementing
the actual equation over the entire image, it is
approximated as
f  G x  G y
 An approximation using absolute z1 z2 z3
value at point z5 using a 3x3 Sobel z4 z5 z6
mask is z7 z8 z9
f   z7  2 z8  z9    z1  2 z2  z3    z3  2 z6  z9    z1  2 z4  z7 
Prewitt And Sobel Operators
-1 -1 -1 -1 0 1
0 0 0 -1 0 1
1 1 1 -1 0 1

-1 -2 -1 -1 0 1
0 0 0 -2 0 2
1 2 1 -1 0 1
Example
Sharpening
Using Sobel
mask
Sharpening using second order
derivative operators
 The simplest isotropic derivative operator is the
Laplacian.
 For the 2-D image function f(x,y) can be defined as
 2
f  2
f
 f 2  2
2

x y
 The partial second derivative in the x-direction can
be written as
2 f
 f ( x  1, y )  f ( x  1, y )  2 f ( x, y )
x 2
Sharpening using second order
derivative operators Cont..
 Similarly the partial second derivative in the y-
direction can be written as
2 f
 f ( x, y  1)  f ( x, y  1)  2 f ( x, y )
y 2

 So the digital implementation of the 2-D Laplacian


operator is obtained by summing the two
components as
 2 f   f ( x  1, y )  f ( x  1, y ) f ( x, y  1)  f ( x, y  1)  4 f ( x, y )
Filter masks used to implement
Laplacian operator
Example
Implementation
 The Laplacian operator produce images that have grayish edge
lines and other discontinuities, all superimposed on a dark
featureless background.
 The background can be preserved by adding the original image
and the Laplacian image.

 f ( x, y )   f ( x, y )
2
if the centre coefficien t is  ve 

g ( x, y )   

 f ( x, y )   f ( x, y )
2
if the centre coefficien t is  ve 

 If we substitute in the above equation for the Laplacian we get a
single equation to implement the operator given by

 2 f  5 f ( x, y )   f ( x  1, y )  f ( x  1, y ) f ( x, y  1)  f ( x, y  1)
Example
Sharpening using Laplacian
operators
Unsharp Masking & High boost Filtering
 Subtracts a blurred version of the image from the
image itself, ie, fs(x,y) = f(x,y) - f’(x,y), where f’(x,y)
is a blurred version of f(x,y) and fs(x,y) is the
sharpened image obtained by unsharp masking.
 A generalization of the above method is known as
high boost filtering. A high boost filtered image fhb is
defined by,
 Fhb(x,y) = A f(x,y) – f’(x,y) where A ≥ 1
 Fhb(x,y) = (A-1) f(x,y) + f(x,y) – f’(x,y)
 Fhb(x,y) = (A-1) f(x,y) + fs(x,y)
High boost filtering
Assignment
 Read a 256x256 image. Do the following operations.
 Filtering using simple averaging masks
 Median filtering
 Gaussian filtering
 Triangular filters (Pyramidal filter, cone filter).
 Compare your results.
 Read a 256x256 image. Add different types of noise to the image. Do
the noise removal using the following operations.
 Simple addition.
 Filtering using simple averaging masks
 Median filtering
 Gaussian filtering
 Triangular filters (Pyramidal filter, cone filter).
 Compare your results.
Assignment
 Read a 256x256 image. Sharpen the image using the following
operators.
 Gradient operators.

 Laplacian operators.

 Write a program to extract 8 bit planes of an image. Apply it for


different types of images and compare the information content
in each type of images in the different bit planes. (Compare the
results for natural images which contains low frequency details
and computer generated images containing mostly high
frequency details.)
 Develop an algorithm to do
 Histogram equalization

 Histogram specification.
Assignment

 Write simple programs to do the following point


processing operations.
 Basic Transformations (image negative, power low,

log)
 Contrast stretching using piecewise linear
transformation.
 Gray level slicing.

 Apply the results to some test images which need these


kind of processing and comment on your results.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy