+ All Categories
Home > Engineering > Filtering an image is to apply a convolution

Filtering an image is to apply a convolution

Date post: 16-Jul-2015
Category:
Upload: abhishek-mukherjee
View: 112 times
Download: 5 times
Share this document with a friend
33
Filtering an image is to apply a convolution operation to an image to achieve: blurring, sharpening , edge extraction or noise removal. FILTERING OF IMAGES
Transcript
Page 1: Filtering an image is to apply a convolution

Filtering an image is to apply a

convolution operation to an

image to achieve: blurring,

sharpening , edge extraction or

noise removal.

FILTERING OF IMAGES

Page 2: Filtering an image is to apply a convolution

INPUT MATRIX TO BE TAKEN:

Sumw=(w1+w2+w3+w4+w5+w6+w7+w8+w9)

Page 3: Filtering an image is to apply a convolution

RESULTANT MATRIX:

Page 4: Filtering an image is to apply a convolution

The simplest convolution kernel or filter is

of size 3x3 with equal weights and is

represented as follows:

Page 5: Filtering an image is to apply a convolution

LOW PASS FILTERS

This filter produces a simple average (or arithmetic

mean)of the nearest neighbors of each pixel in the

image.

It is one of a class of what are known as low pass filters.

They pass low frequencies in the image or equivalently

pass long wavelengths in the image

Page 6: Filtering an image is to apply a convolution

LOW PASS FILTERS

It correspond to abrupt changes in image intensity, i.e.

edges. Thus we get blurring.

Also, because it is replacing each pixel with an average

of the pixels in its local neighborhood, one can

understand why it tends to blur the image.

Blurring is typical of low pass filters.

Page 7: Filtering an image is to apply a convolution

CODE:

Page 8: Filtering an image is to apply a convolution

INPUT GRAYSCALE IMAGE:

Page 9: Filtering an image is to apply a convolution

MATLAB OUTPUT

Page 10: Filtering an image is to apply a convolution

EFFECT OF USING LARGER MATRIX:

The result of using a larger filter(here 10X10) will be that

the low pass filtered image is blurrier than for the 5x5

case and the high pass filtered image will have thicker

edges.

Page 11: Filtering an image is to apply a convolution

HIGH PASS FILTERS:

It passes only short wavelengths, i.e. where there

are abrupt changes in intensity

It removes long wavelengths, i.e. where the

image intensity is varying slowly.

Thus when applied to an image, it shows only

the edges in the image.

Page 12: Filtering an image is to apply a convolution

HIGH PASS FILTERS:

High pass filtering of an image can be achieved

by the application of a low pass filter to the

image and subsequently subtraction of the low

pass filtered result from the image

In abbreviated terms, this is H = I – L, where H =

highpass filtered image, I = original image and L

= low pass filtered image.

Page 13: Filtering an image is to apply a convolution

CODE:

j=zeros(5)

j(3,3)=1

h=ones(5)/25;

j=j-h;

g=filter2(j,gs,'same');

imshow(g/255)

Page 14: Filtering an image is to apply a convolution

OUTPUT:

Page 15: Filtering an image is to apply a convolution

3. FFT Filters:

FFT Filters provide precisely controlled low- and high-pass

filtering (smoothing and sharpening, respectively) using a

Butterworth characteristic.

The image is converted into spatial frequencies using a

Fast Fourier Transform, the appropriate filter is applied.

Then the image is converted back using an inverse FFT.

Page 16: Filtering an image is to apply a convolution

PREDEFINED FILTERS IN MATLAB:

Predefined function used is fspecial:

Types available:

Averaging

Page 17: Filtering an image is to apply a convolution

AVERAGING:

Code:

f = fspecial ('average')

I = imread ('tulips.jpg');

gs = rgb2gray(i);

o = filter2(f,gs);

imshow(o)

Page 18: Filtering an image is to apply a convolution

OUTPUT:

Page 19: Filtering an image is to apply a convolution

DISK(Circular averaging filter):

Code:

f = fspecial (‘disk‘,5)

I = imread ('tulips.jpg');

gs = rgb2gray(i);

o = filter2(f,gs);

imshow(o)

Page 20: Filtering an image is to apply a convolution

OUTPUT:

Page 21: Filtering an image is to apply a convolution

GAUSSIAN(Low pass filter)

Code:

f = fspecial (‘gaussian‘,5)

I = imread ('tulips.jpg');

gs = rgb2gray(i);

o = filter2(f,gs);

imshow(o)

Page 22: Filtering an image is to apply a convolution

LAPLACIAN:

Code:

f = fspecial (‘laplacian‘);

I = imread ('tulips.jpg');

gs = rgb2gray(i);

o = filter2(f,gs);

imshow(o)

Page 23: Filtering an image is to apply a convolution

OUTPUT:

Page 24: Filtering an image is to apply a convolution

LOG(Laplacian of Gaussian filter):

Code:

f = fspecial (‘log‘,5)

I = imread ('tulips.jpg');

gs = rgb2gray(i);

o = filter2(f,gs);

imshow(o)

Page 25: Filtering an image is to apply a convolution

OUTPUT:

Page 26: Filtering an image is to apply a convolution

MOTION(Linear motion of camera):

Code:

f = fspecial (‘motion‘)

I = imread ('tulips.jpg');

gs = rgb2gray(i);

o = filter2(f,gs);

imshow(o)

Page 27: Filtering an image is to apply a convolution

OUTPUT:

Page 28: Filtering an image is to apply a convolution

PREWITT(Horizontal edge detection):

Code:

f = fspecial (‘prewitt‘)

I = imread ('tulips.jpg');

gs = rgb2gray(i);

o = filter2(f,gs);

imshow(o)

Page 29: Filtering an image is to apply a convolution

OUTPUT:

Page 30: Filtering an image is to apply a convolution

SOBEL(A Better version of prewitt):

Code:

f = fspecial (‘sobel‘)

I = imread ('tulips.jpg');

gs = rgb2gray(i);

o = filter2(f,gs);

imshow(o)

Page 31: Filtering an image is to apply a convolution

OUTPUT:

Page 32: Filtering an image is to apply a convolution

UNSHARP(Contrast enhancing filter):

Code:

f = fspecial (‘unsharp‘,5)

I = imread ('tulips.jpg');

gs = rgb2gray(i);

o = filter2(f,gs);

imshow(o/255)

Page 33: Filtering an image is to apply a convolution

OUTPUT:


Recommended