270 likes | 475 Views
Spatial Filtering (Applying filters directly on Image). By Engr. Muhammad Saqib. Two types of filtering Linear Filtering Non Linear Filtering. High Frequency and Low frequency components in Image.
E N D
Spatial Filtering(Applying filters directly on Image) By Engr. Muhammad Saqib
Two types of filtering • Linear Filtering • Non Linear Filtering
High Frequency and Low frequency components in Image • Fundamentally, the frequencies of an image are the amount by which grey values change with distance High frequency components are characterized by large changes in grey values over small distances; example of high frequency components are edges and noise. • Low frequency components, on the other hand, are parts of the image characterized by little change in the grey values.
The filter2 function does the job of linear filtering for us; its use is filter2(filter,image,shape) and the result is a matrix of data type double. The parameter shape is optional, it describes the method for dealing with the edges
filter2(filter,image,'same') is the default; it produces a matrix of equal size to the original image matrix. It uses zero padding:
filter2(filter,image,'valid') applies the mask only to inside pixels. We can see that the result will always be smaller than the original:
Using Padding • Obtaining a Full image using zero padding
Gaussian filter (low pass filter) • Using fspecial we can create Gaussian filter • Different gaussian filter
Assignment#3 • Question#1 Apply these filters on image and discuss the results
Salt and pepper noise Also called impulse noise, shot noise, or binary noise. This degradation can be caused by sharp, sudden disturbances in the image signal; its appearance is randomly scattered white or black (or both) pixels over the image.
Demonstration of Salt and Pepper noise • To add Salt and Pepper noise
Cleaning Salt and Pepper • Using Averaging filter • Using a filter of 7 by 7 and see the result
Median Filtering • Using Median Filtering • Adding more noise • See the effect of Applying 5x5 filter
Edge Detection • Edges contain some of the most useful information in an image. We may use edges to measure the size of objects in an image; to isolate particular objects from their background; to recognize or classify objects. There are a large number of edge-nding algorithms in existence, and we shall look at some of the more straightforward of them.
Using Prewitt Filter • Reading Image • Applying Px • Applying Py
Using Prewitt Filter • Creating Image containing all the edges • Binary Image can be created as follow • Single Command for applying Prewitt Filter