You are on page 1of 64

Practical-1

Introduction to image processing toolbox


Introduction.
WHAT IS THE IMAGE PROCESSING TOOLBOX?

The image processing Toolbox is a collection of functions that extend the capability of
MATLAB.

The toolbox support wide range of image processing, including

• Spatial image transformation

• Morphological operations

• Neighbourhood and block operations

• Linear filtering and filter design

• Transforms

• Image analysis and enhancement

• Image registration

• Deblurring

• Region of interest operations

Many of the toolbox functions are matlab M-files. A Series of MATLAB statements that
implement specialised image processing algorithms. You can view matlab codes for these
functions using the statement

type function _name.


Related Products

The Math Works provides several product products that are especially relevant to the
kinds of tasks you can perform with image processing toolbox.

For more information about any of these products see either

• The online documentations for that product if it is installed or if you are reading
the documentation on CD.

• The Math works Web site at htto://www.mathworks.com; see the products


section.

The toolboxes listed below all include function that extends MATLAB.

The block sets all include block that extend simulink.

Product Description

Dsp Blockset Design and simulate dsp system

Image acquisition toolbox Connect to image acquisition hardware and


bring frames of image data into matlab
workspace

Mapping toolbox Analyze and visualize geographically based


information

Signal processing toolbox Perform signal processing ,analysis and


algorithm development

Wavelet toolbox Analyze, compress and denoise signals and


images using wavelet techniques
Practical -2
DIGITAL IMAGE FUNDAMENTALS
Objectives:

• Read and display image.

• Write the image

>> i=imread('cameraman.tif'); %it reads the image and store it in a variable i.

>> imshow(i); %it display image cameraman.tif.

OUTPUT:

OUTPUT:

>> imwrite(i,'cameraman.png'); %writes the image to file & you can specify othe format also.
OUTPUT:

>> imfinfo('cameraman.png') %return information about image.

ans =

Filename: 'cameraman.png'

FileModDate: '19-Jul-2009 13:58:47'

FileSize: 38267

Format: 'png'

FormatVersion: []

Width: 256

Height: 256

BitDepth: 8

ColorType: 'grayscale'

FormatSignature: [137 80 78 71 13 10 26 10]

Colormap: []
Histogram: []

InterlaceType: 'none'

Transparency: 'none'

SimpleTransparencyData: []

BackgroundColor: []

RenderingIntent: []

Chromaticities: []

Gamma: []

XResolution: []

YResolution: []

ResolutionUnit: []

XOffset: []

YOffset: []

OffsetUnit: []

SignificantBits: []

ImageModTime: '19 Jul 2009 08:28:47 +0000'

Title: []

Author: []

Description: []

Copyright: []

CreationTime: []

Software: []

Disclaimer: []

Warning: []

Source: []
Comment: []

OtherText: []

%To read image, to display image and its histogram in same plot

Solution:

a=imread('cameraman.tif');

subplot(1,2,1);

imshow(a);

subplot(1,2,2);

imhist(a);

OUTPUT:
% To display image in separate figure..

a=imread('moon.tif'); % To display each image in a separate figure

figure(1);

imshow(a);

b=imread('tire.tif');

figure(2);

imshow(b);

c=imread('trees.tif');

figure(3);

imshow(c);
OUTPUT:

% To display image in same figure...

a=imread('moon.tif'); %To display multiple images in the same figure

subplot(1,3,1);

imshow(a);

b=imread('tire.tif');

subplot(1,3,2);

imshow(b);

c=imread('trees.tif');

subplot(1,3,3);

imshow(c);

OUTPUT:
• Objectives...

→ Image Sampling

→ Image Cropping.

→ Flipping of image..

→ Rotate image by 30®.

→ Adjust contrast using histogram equalization...

→ Create negative image.

→Adjusting contrasts....

Solution:

a=imread('cameraman.tif');

subplot(2,2,1);
b=imshow(a);

subplot(2,2,2);

imhist(a); %it will plot histogram

c=a(1:2:a(1),1:2:a(2));

subplot(2,2,3);

imshow(c);

subplot(2,2,4);

imhist(c);

OUTPUT:

% Image Cropping.

a=imread('moon.tif'); %To crop image by selecting interested area using mouse.

imcrop(a);

OUTPUT:
%Cropping the image

% Flipping of image...

a=imread('cameraman.tif'); %Flip image by 180

subplot(2,2,1);

imshow(a);

subplot(2,2,2);

imhist(a);

b=size(a); %it will show size of image

c=a(b(1):-1:1,b(2):-1:1);

subplot(2,2,3);

imshow(c);

subplot(2,2,4);

imhist(c);
OUTPUT:

%Flip the image

OUTPUT:

% Rotate image by 30®.

a=imread('cameraman.tif'); %Rotating the image by 35 counter clockwise

subplot(2,2,1);

imshow(a);

subplot(2,2,2);

imhist(a);

subplot(2,2,3);

b=imrotate(a,35);

imshow(b);
subplot(2,2,4);

imhist(b);

OUTPUT:

% Adjust contrast using histogram equalization...

a=imread('pout.tif'); %It shows the graph and contrast also.

subplot(2,2,1);

imshow(a);

subplot(2,2,2);

imhist(a);

b=histeq(a);

subplot(2,2,3);

imshow(b);

subplot(2,2,4);
imhist(b);

OUTPUT:

% Create negative image..

a=imread('cameraman.tif'); %It shows negative image of original image.

subplot(2,2,1);

imshow(a);

subplot(2,2,2);

imhist(a);

b=imadjust(a,[0 1],[1 0]);

subplot(2,2,3);

imshow(b);

subplot(2,2,4);

imhist(b);
OUTPUT:

%Adjusting contrasts....

i=imread('tire.tif');

a=imadjust(i,[0 0.5],[0 1]);

b=imadjust(i,[0.2 0.3],[0.3 0.7]);

c=imadjust(i,[],[0.2 0.5]);

d=imadjust(i,[0 1],[1 0]);

subplot(5,2,1);

imshow(i);

subplot(5,2,2);

imhist(i);

subplot(5,2,3);
imshow(a);

subplot(5,2,4);

imhist(a);

subplot(5,2,5);

imshow(b);

subplot(5,2,6);

imhist(b);

subplot(5,2,7);

imshow(c);

subplot(5,2,8);

imhist(c);

subplot(5,2,9);

imshow(d);

subplot(5,2,10);

imhist(d);

OUTPUT.
500

0
0 50 100 150 200 250

1000
500
0
0 50 100 150 200 250

5000

0
0 50 100 150 200 250

1000

0
0 50 100 150 200 250

500

0
0 50 100 150 200 250

Conclusion: ...................................................................................................................................................
..........................................................................................................................................................................
..........................................................................................................................................................................
..........................................................................................................................................................................
.....................................................................................................................................................

Practical-3
Image Enhancement In The Spatial Domain.
1) Program to increase the contrast in a low contrast grayscale image and display the
histogram of the output image. Compare the histogram before and after intensity adjustments.

Solution:-

Read and display the original image


I=imread('trees.tif');
figure(1);
subplot(2,2,1);
imshow(I);
title('Original image');
% Obtaining the histogram of the original image
J=imhist(I);
subplot(2,2,2);
plot(J);
title('Histogram of the original image');
% Increasing the contrast of the adjusted image
K=imadjust(I);
subplot(2,2,3);
imshow(K)
title('Intensity Adjusted image');
% Obtaining the histogram of the adjusted image
L=imhist(K);
subplot(2,2,4);
plot(L);
title('Histogram of the Adjusted image');

OUTPUT:
2] Program to display an image with and without gamma correction

→Find absolute difference of two images

X=imread('forest.tif');
figure(1);
subplot(1,3,1);
imshow(X);
% Gamma correction is applied & the value of gamma is taken as 0.5.
b=imadjust(a,[],[],0.5);
subplot(1,3,3);
imshow(b);
title('Image after gamma correction');
figure(2);
subplot(1,3,1);
imshow(a);
title('Image before gamma correction');
subplot(1,3,2);
imshow(b);
title('Image after gamma correction');
K=imabsdiff(a,b);
subplot(1,3,3);
imshow(K,[]);
title('Absolute difference between two images');

Output:

Intensityformat image Imageaftergammacorrection


Imagebeforegammacorrection Imageaftergammacorrection Additionoftwoimages

3] Program to adjust intensity values using:-

a) Histogram Equalization

b) Contrast-Limited Adaptive Histogram Equalization

Solution:-

I=imread('cameraman.tif');
subplot(3,2,1);
imshow(I);
title('Original image');
J=imhist(I);
subplot(3,2,2);
plot(J);
title('Histogram of the original image');
% Adjusting intensity values using Histogram equalization
K=histeq(I);
subplot(3,2,3);
imshow(K);
title('Histogram equalized image');
L=imhist(K);
subplot(3,2,4);
plot(L);
title('Histogram of the Equalized Image');
% Adjusting intensity values using contrast-Limited Adaptive Histogram Equalization
M=adapthisteq(I);
subplot(3,2,5);
imshow(M);
title('Contrast- Limited Adaptive Histogram Equalized image');
N=imhist(M);
subplot(3,2,6);
plot(N);
title('Histogram of the Contrast-Limited adaptive Equalized Image');

OUTPUT:
• Enhance contrast of an intensity image using histogram equalization. Display the
histogram of the original image and compare it with histogram of the processed image.

i=imread('cameraman.tif');
subplot(2,2,1);
imshow(i);
subplot(2,2,2);
imhist(i);
title('histogram of original');
subplot(2,2,3);
b=histeq(i);
imshow(b);
subplot(2,2,4);
imhist(b);
title('histogram of histequalization.');
Conclusion: ...................................................................................................................................................
..........................................................................................................................................................................
..........................................................................................................................................................................
..........................................................................................................................................................................
.....................................................................................................................................................

Practical-4
Filtering in spatial domain
• Create 3x3 mask in m file without using its function and implement on image.

%creating 3x3 mask


a=imread('tire.tif');
subplot(2,1,1);
imshow(a);
title('original image');
[k l]=size(a);
for i=2:(k-1);
for j=2:(l-1);
result(i,j)=(a(i-1,j-1)/9 + a(i-1,j)/9 + a(i-1,j+1)/9 + a(i,j-1)/9 + a(i,j)/9 + a(i,j+1)/9 + a(i+1,j-1)/9
+ a(i+1,j)/9 + a(i+1,j+1)/9);
end
end
subplot(2,1,2);
imshow(result);
title('smoothed image using average filter of 3x3');
• Program to illustrate the effect of smoothing filter as a function of filter size. Obtain the
result of filtering with mask of 8, 16, 64, 128. Plot difference between the original and
filtered image and their corrosponding histogram.

Solution:

i=imread('cameraman.tif');
figure();
subplot(3,2,1);
imshow(i);
title('original image');
%smoothing mask of 8x8
h=fspecial('average',8);
result1=imfilter(i,h,'replicate');
subplot(3,2,2);
imshow(result1);
title('smoothing with mask of 8x8');
h=fspecial('average',16);
result2=imfilter(i,h,'replicate');
subplot(3,2,3);
imshow(result2);
title('smoothing with mask of 16x16');
h=fspecial('average',35);
result3=imfilter(i,h,'replicate');
subplot(3,2,4);
imshow(result3);
title('smoothing with mask of 35x35');
h=fspecial('average',64);
result4=imfilter(i,h,'replicate');
subplot(3,2,5);
imshow(result4);
title('smoothing with mask of 64x64');
%absolute difference between original and using mask of 8,16,35,64
a=imabsdiff(i,result1);
figure();
subplot(1,2,1);
imshow(a);
title('difference between original and the filtered 8');
b=imhist(result1);
subplot(1,2,2);
plot(b);
title('histogram of filter size 8');
a=imabsdiff(i,result2);
figure();
subplot(1,2,1);
imshow(a);
title('difference between original and the filtered 16');
b=imhist(result2);
subplot(1,2,2);
plot(b);
title('histogram of filter size 16');
a=imabsdiff(i,result3);
figure();
subplot(1,2,1);
imshow(a);
title('difference between original and the filtered 35');
b=imhist(result3);
subplot(1,2,2);
plot(b);
title('histogram of filter size 35');
a=imabsdiff(i,result4);
figure();
subplot(1,2,1);
imshow(a);
title('difference between original and the filtered 64');
b=imhist(result4);
subplot(1,2,2);
plot(b);
title('histogram of filter size 64');
• Program to illustrate the grayscale image and to obtain the following types of filtered
images.Motion blurred image, Blurred image, Sharpened image, Sobeled image,
Laplaced image, Gaussianed image, Avereged image.

Solution:

i=imread('cameraman.tif');
subplot(3,3,1);
imshow(i);
title('original image');
%obtaining motion blurred image
h=fspecial('motion',15,45);
motion=imfilter(i,h,'replicate');
subplot(3,3,2);
imshow(motion);
title('image formed due to motion');
%blurred image
h=fspecial('disk',15);
disk=imfilter(i,h,'replicate');
subplot(3,3,3);
imshow(disk);
title('image formed due to disk');
%sharpened image
h=fspecial('unsharp');
sharp=imfilter(i,h,'replicate');
subplot(3,3,4);
imshow(sharp);
title('image formed due to sharpining');
%averaged image
h=fspecial('average',3);
average=imfilter(i,h,'replicate');
subplot(3,3,5);
imshow(average);
title('image formed due to averaging');
%sobeled image
h=fspecial('sobel');
sobel=imfilter(i,h,'replicate');
subplot(3,3,6);
imshow(sobel);
title('image formed due to sobel');
%gaussianed image
h=fspecial('gaussian',[3 3],0.4);
gaussian=imfilter(i,h,'replicate');
subplot(3,3,7);
imshow(gaussian);
title('image formed due to gaussian');
%laplaced image
h=fspecial('laplacian',0.3);
laplacian=imfilter(i,h,'replicate');
subplot(3,3,8);
imshow(laplacian);
title('image formed due to laplaced');
• Program to illustrate median filtering over averaging filter in sitution when image is
corrupted with salt and pepper noise.

Solution:

i=imread('cameraman.tif');
figure();
subplot(1,2,1);
imshow(i);
title('original image');
%adding the salt and pepper noise to original image
j=imnoise(i,'salt & pepper',0.02);
subplot(1,2,2);
imshow(j);
title('salt and pepper noise');
%filtering the image with 3x3 averaging filter
h=fspecial('average',3);
average=imfilter(i,h,'symmetric');
figure();
subplot(1,2,1);
imshow(average);
title('averaged image with filter size of 3x3');
median=medfilt2(i,[3 3],'symmetric');
subplot(1,2,2);
imshow(median);
title('median image with mask of 3x3');
%absolute difference between the original and averaged image
x=imabsdiff(i,average);
figure();
subplot(1,2,1);
imshow(x);
title('difference between original median image');
y=imabsdiff(i,median);
subplot(1,2,2);
imshow(y);
title('difference between original image and median filtered image');
Conclusion: ...................................................................................................................................................
..........................................................................................................................................................................
..........................................................................................................................................................................
..........................................................................................................................................................................
.....................................................................................................................................................
PRACTICAL – 5

IMAGE ENHANCEMENT IN THE FREQUENCY DOMAIN

%Low pass filter function[Ideal, butterworth, Gaussian low pass filter]

function [H,D] = lpfilter(type,M,N,D0,n);

for u=1:M
for v=1:N
D(u,v) = sqrt((u-M/2)^2+(v-N/2).^2);
end
end

D=fftshift(D);

switch type
case 'Ideal'
H = double(D<=D0);
case 'Butterworth'
if nargin == 4;
n = 1;
end
H = 1./(1 + (D./D0).^(2*n));
case 'Gaussian'
H = exp(-(D.^2)./(2*(D0^2)));
otherwise
error('Unknown filter type.')
end

1] Program to illustrate the results of following low pass filters with cut of
frequencies set at radii values of 5,15,30,80 resp. Also obtain the corresponding
frequency spectrum and filter displayed as an image.
• Ideal low pass filter
• Gaussian low pass filter
• Butterworth low pass filter

%Ideal Low pass filtered image with cutoff frequecy set at radius value of 5
clc
clear all
ip = imread('peppers.png');
ip=rgb2gray(ip);
[M,N] = size(ip);
ip=double(ip);
f_ip = fft2(ip);
ip=uint8(ip);
lf_ip=fftshift(f_ip);
lf_ip = log(1 + abs(lf_ip));

subplot(1,2,1);
imshow(lf_ip,[])
title('Frequency Spectrum')
subplot(1,2,2);
imshow(ip)
title('Original Image')
figure;

filt = lpfilter('Ideal',M,N,5);
f_op = filt.*f_ip;
op = real(ifft2(f_op));

filt=fftshift(filt);
lf_op=log(1+abs(f_op));

subplot(1,2,1);
imshow(filt,[]);
title('Filter Frequency domain')
subplot(1,2,2);
imshow(op,[]);
title('Ideal Lowpass filtered image [cutoff freq=5]')
%Ideal Low pass filtered image with cutoff frequecy set at radius value of 15
figure;

filt = lpfilter('Ideal',M,N,15);
f_op = filt.*f_ip;
op = real(ifft2(f_op));
filt=fftshift(filt);
lf_op=log(1+abs(f_op));

subplot(1,2,1);
imshow(filt,[]);
title('Filter Frequency domain')
subplot(1,2,2);
imshow(op,[]);
title('Ideal Lowpass filtered image [cutoff freq=15]')
%Ideal Low pass filtered image with cutoff frequecy set at radius value of 30
figure;

filt = lpfilter('Ideal',M,N,30);
f_op = filt.*f_ip;
op = real(ifft2(f_op));
filt=fftshift(filt);
lf_op=log(1+abs(f_op));

subplot(1,2,1);
imshow(filt,[]);
title('Filter Frequency domain')
subplot(1,2,2);
imshow(op,[]);
title('Ideal Lowpass filtered image [cutoff freq=30]')
%Ideal Low pass filtered image with cutoff frequecy set at radius value of 80
figure;

filt = lpfilter('Ideal',M,N,80);
f_op = filt.*f_ip;
op = real(ifft2(f_op));

filt=fftshift(filt);
lf_op=log(1+abs(f_op));

subplot(1,2,1);
imshow(filt,[]);
title('Filter Frequency domain')
subplot(1,2,2);
imshow(op,[]);
title('Ideal Lowpass filtered image [cutoff freq=80]')
%Low pass filtered image with cutoff frequecy set at radius value of 230
figure;

filt = lpfilter('Ideal',M,N,230);
f_op = filt.*f_ip;
op = real(ifft2(f_op));

filt=fftshift(filt);
lf_op=log(1+abs(f_op));

subplot(1,2,1);
imshow(filt,[]);
title('Filter Frequency domain')
subplot(1,2,2);
imshow(op,[]);
title('Ideal Lowpass filtered image [cutoff freq=230]')

OUTPUT:
FrequencySpectrum Original Image
FilterFrequencydomain Ideal Lowpassfilteredimage[cutofffreq=5]

FilterFrequencydomain Ideal Lowpassfilteredimage[cutoff freq=15]


Filter Frequency domain Ideal Lowpass filtered image [cutoff freq=30]
FilterFrequencydomain Ideal Lowpassfilteredimage[cutoff freq=80]
FilterFrequencydomain IdealLow
passfilteredimage[cutofffreq=230]

%Gaussian Low pass filtered image with cutoff frequecy set at radius value of 5
clc
clear all
ip = imread('peppers.png');
ip=rgb2gray(ip);
[M,N] = size(ip);
ip=double(ip);
f_ip = fft2(ip);
ip=uint8(ip);
lf_ip=fftshift(f_ip);
lf_ip = log(1 + abs(lf_ip));

subplot(1,2,1);
imshow(lf_ip,[])
title('Frequency Spectrum')
subplot(1,2,2);
imshow(ip)
title('Original Image')
figure;
filt = lpfilter('Gaussian',M,N,5);
f_op = filt.*f_ip;
op = real(ifft2(f_op));
filt=fftshift(filt);
lf_op=log(1+abs(f_op));

subplot(1,2,1);
imshow(filt,[]);
title('Filter Frequency domain')
subplot(1,2,2);
imshow(op,[]);
title('Gaussian Lowpass filtered image [cutoff freq=5]')

%Gaussian Low pass filtered image with cutoff frequecy set at radius value of 15
figure;
filt = lpfilter('Gaussian',M,N,15);
f_op = filt.*f_ip;
op = real(ifft2(f_op));
filt=fftshift(filt);
lf_op=log(1+abs(f_op));

subplot(1,2,1);
imshow(filt,[]);
title('Filter Frequency domain')
subplot(1,2,2);
imshow(op,[]);
title('Gaussian Lowpass filtered image [cutoff freq=15]')
%Gaussian Low pass filtered image with cutoff frequecy set at radius value of 30
figure;
filt = lpfilter('Gaussian',M,N,30);
f_op = filt.*f_ip;
op = real(ifft2(f_op));
filt=fftshift(filt);
lf_op=log(1+abs(f_op));

subplot(1,2,1);
imshow(filt,[]);
title('Filter Frequency domain')
subplot(1,2,2);
imshow(op,[]);
title('Gaussian Lowpass filtered image [cutoff freq=30]')

%Gaussian Low pass filtered image with cutoff frequecy set at radius value of 80
figure;
filt = lpfilter('Gaussian',M,N,80);
f_op = filt.*f_ip;
op = real(ifft2(f_op));
filt=fftshift(filt);
lf_op=log(1+abs(f_op));
subplot(1,2,1);
imshow(filt,[]);
title('Filter Frequency domain')
subplot(1,2,2);
imshow(op,[]);
title('Gaussian Lowpass filtered image [cutoff freq=80]')

%Guassian Low pass filtered image with cutoff frequecy set at radius value of 230
figure;
filt = lpfilter('Gaussian',M,N,230);
f_op = filt.*f_ip;
op = real(ifft2(f_op));
filt=fftshift(filt);
lf_op=log(1+abs(f_op));

subplot(1,2,1);
imshow(filt,[]);
title('Filter Frequency domain')
subplot(1,2,2);
imshow(op,[]);
title('Gaussian Lowpass filtered image [cutoff freq=230]')
FrequencySpect Original Img
FilterFreqdomain GaussianLpfilteredimg[cutoff freq=5]
FilterFreqdomain GaussianLpfilteredimg[cutoff freq=15]
FilterFreqdomain GaussianLpfilteredimg[cutoff freq=30]
FilterFreqdomain GaussianLpfilteredimg[cutoff freq=80]
FilterFrequencydomain GaussianLowpassfilteredimage[cutoff freq=230]

%Butterworth Low pass filtered image with cutoff frequecy set at radius value of 5

clc
clear all
ip = imread('onion.png');
ip=rgb2gray(ip);
[M,N] = size(ip);
ip=double(ip);
f_ip = fft2(ip);
ip=uint8(ip);
lf_ip=fftshift(f_ip);
lf_ip = log(1 + abs(lf_ip));

subplot(1,2,1);
imshow(lf_ip,[])
title('Frequency Spectrum')
subplot(1,2,2);
imshow(ip)
title('Original Image')
figure;
filt = lpfilter('Butterworth',M,N,5);
f_op = filt.*f_ip;
op = real(ifft2(f_op));
filt=fftshift(filt);
lf_op=log(1+abs(f_op));

subplot(1,2,1);
imshow(filt,[]);
title('Filter Frequency domain')
subplot(1,2,2);
imshow(op,[]);
title('Butterworth Lowpass filtered image [cutoff freq=5]')

%Butterworth Low pass filtered image with cutoff frequecy set at radius value of 15
figure;
filt = lpfilter('Butterworth',M,N,15);
f_op = filt.*f_ip;
op = real(ifft2(f_op));
filt=fftshift(filt);
lf_op=log(1+abs(f_op));

subplot(1,2,1);
imshow(filt,[]);
title('Filter Frequency domain')
subplot(1,2,2);
imshow(op,[]);
title('Butterworth Lowpass filtered image [cutoff freq=15]')
%Butterworth Low pass filtered image with cutoff frequecy set at radius value of 30
figure;
filt = lpfilter('Butterworth',M,N,30);
f_op = filt.*f_ip;
op = real(ifft2(f_op));
filt=fftshift(filt);
lf_op=log(1+abs(f_op));

subplot(1,2,1);
imshow(filt,[]);
title('Filter Frequency domain')
subplot(1,2,2);
imshow(op,[]);
title('Butterworth Lowpass filtered image [cutoff freq=30]')

%Butterworth Low pass filtered image with cutoff frequecy set at radius value of 80
figure;
filt = lpfilter('Butterworth',M,N,80);
f_op = filt.*f_ip;
op = real(ifft2(f_op));
filt=fftshift(filt);
lf_op=log(1+abs(f_op));

subplot(1,2,1);
imshow(filt,[]);
title('Filter Frequency domain')
subplot(1,2,2);
imshow(op,[]);
title('Butterworth Lowpass filtered image [cutoff freq=80]')

%Guassian Low pass filtered image with cutoff frequecy set at radius value of 230
figure;
filt = lpfilter('Butterworth',M,N,230);
f_op = filt.*f_ip;
op = real(ifft2(f_op));
filt=fftshift(filt);
lf_op=log(1+abs(f_op));

subplot(1,2,1);
imshow(filt,[]);
title('Filter Frequency domain')
subplot(1,2,2);
imshow(op,[]);
title('Butterworth Lowpass filtered image [cutoff freq=230]')
FrequencySpectrum Original Image
FilterFrequencydomain ButterworthLowpassfilteredimage[cutofffreq=5]
FilterFrequencydomain ButterworthLowpassfilteredimage[cutoff freq=15]
FilterFrequencydomain ButterworthLowpassfilteredimage[cutofffreq=30]
FilterFrequencydomain ButterworthLowpassfilteredimage[cutoff freq=80]
FilterFrequencydomain ButterworthLowpassfilteredimage[cutoff freq=230]

\Conclusion:
...................................................................................................................................................................
...................................................................................................................................................................
...................................................................................................................................................................
...................................................................................................................................................................
.........................................................................................................................

You might also like