You are on page 1of 11

Program -1

%%Calculate Image negative%%
clear all;
close all;
clc;
aa=imread('cameraman.tif');
a=double(aa);
c=255;
b=c-a;
figure(1) ;
colormap(gray);
imagesc(a);
figure(2) ;
colormap(gray);
imagesc(b);

a=p.Program -2 %%Program for thresholding%% clear all.j)=0. close all. clc. imshow(p).j)=255.j)<T) a(i. figure(2) . for i=1:1:row. [row col]=size(a). end end end figure(1) . . p=imread('cameraman. else a(i. for j=1:1:col if(p(i. T=input('Enter value of threshold:'). imshow(a).tif').

figure(4).Program -3 %%Ideal Low pass filters%% clear all. figure(3). if D<d H(u. x=vc. imagesc(H). N=c(1) d=input('Enter the cut-off frequency').*H. imshow(uint8(a)). imshow(uint8(X)). close all.v)=0. figure(2). c=size(a). vc=fftshift(vv). colormap(gray). else H(u.v)=1. b=imread('cameraman. clc. X=abs(ifft2(x)). end end end vv=fft2(a).tif'). a=double(b).5. . %%PLOTTING%% figure(1). for u=1:1:c(1) for v =1:1:c(2) D=((u-(N/2))^2+(v-(N/2))^2)^0. mesh(H).

clc. b=imread('cameraman. %%PLOTTING%% figure(1). X=abs(ifft2(x)). d=input('Enter the cut-off frequency'). N=c(1) n=input('Enter the order of the filter'). c=size(a). end end vv=fft2(a). for u=1:1:c(1) for v =1:1:c(2) D=((u-(N/2))^2+(v-(N/2))^2)^0.v)=1/(1+(D/d)^2*n). colormap(gray).Program -4 %%Low pass Butterworth filters%% clear all. vc=fftshift(vv). figure(2).tif'). figure(4).*H.5. a=double(b). imagesc(H). figure(3). mesh(H). imshow(uint8(X)). . close all. H(u. x=vc. imshow(uint8(a)).

tif'). colormap(gray). figure(4).*H.5. b=imread('cameraman. D2=D1*D1. %%PLOTTING%% figure(1). H(u. clc. figure(3). end end vv=fft2(a). for u=1:1:c(1) for v =1:1:c(2) D1=((u-(N/2))^2+(v-(N/2))^2)^0. imshow(uint8(a)). imshow(uint8(X)). close all. N=c(1) D=input('Enter the cut off frequency'). x=vc. .v)=exp(-D2/(2*D*D)). c=size(a). X=abs(ifft2(x)). figure(2). vc=fftshift(vv).Program -5 %%Low pass Gaussian filters%% clear all. a=double(b). mesh(H). imagesc(H).

figure(4). if D<set. mesh(H).v)=0.5. imshow(uint8(X)). [row col]=size(b).v)=1. else H(u.*H.tif'). for u=1:1:row for v =1:1:col D=((u-(row/2))^2+(v-(col/2))^2)^0. vc=fftshift(vv). . close all. X=abs(ifft2(x)). colormap(gray). clc. set=input('Cut-off frequency'). %%PLOTTING%% figure(1). end end end vv=fft2(b).Program-6 %%Ideal High Pass filter%% clear all. b=imread('cameraman. x=vc. figure(3). H(u. imagesc(H). figure(2). imshow(uint8(b)).

end end vv=fft2(a). %%PLOTTING%% figure(1).Program-7 %%Gaussian High Pass filters%% clear all. for u=1:1:c(1) for v =1:1:c(2) D1=((u-(N/2))^2+(v-(N/2))^2)^0. close all.*H. b=imread('cameraman. clc. imshow(uint8(a)). figure(3). a=double(b). N=c(1) D=input('Enter the cut off frequency').5. figure(4). c=size(a).tif'). mesh(H).v)=1-exp(-D2/(2*D*D)). vc=fftshift(vv). D2=D1*D1. . X=abs(ifft2(x)). imshow(uint8(X)). H(u. x=vc. figure(2). colormap(gray). imagesc(H).

c=size(a). x=vc.tif').5. close all. b=imread('cameraman. figure(4). vc=fftshift(vv). imagesc(H). clc. d=input('Enter the cut-off frequency'). N=c(1) n=input('Enter the order of the filter'). X=abs(ifft2(x)). .Program-8 %%Butterworth High Pass filter%% clear all. figure(3). mesh(H).*H. H(u.v)=1/((1+(d/D)^2*n). figure(2). colormap(gray). end end vv=fft2(a). %%PLOTTING%% figure(1). imshow(uint8(a)). imshow(uint8(X)). for u=1:1:c(1) for v =1:1:c(2) D=((u-(N/2))^2+(v-(N/2))^2)^0. a=double(b).

end end for x=s:1:row-s for y=s:1:col-s b(x. for x=1:1:row for y=1:1:col b(x.j)=1/n. clc. b=imread('cameraman. n=m^2. close all. m=input('Enter the Mask size'). a=double(b). end end for x=s:1:row-s for y=s:1:col-s for i=1:1:m for j=1:1:m .tif').Program-9 %%Arithematic Mean Filter%% %%Low pass filtering of an image using Averaging Technique%% clear all. end end s=(m+1)/2. [row col]=size(a).y)=0.y)=a(x.y). for i=1:1:m for j=1:1:m w(i.

y)=a(x-s+i.ys+j)*w(i.y). end end end end .j)+b(x.b(x.

f=double(f1).y)*f(x1. close all.y-1)*f(x. clc. end end figure(1). f1=imread('cameraman.y+1)*f(x.Program-10 %%Geometric mean Spatial filter%% clear all. for x=2:1:row-1 for y=2:1:col-1 g(x.y)*f(x+1. . [row col]=size(f).y)=(f(x-1.y)*f(x.y+1)*f(x+1. g=f.y1)*f(x+1.y-1)*f(x-1.y+1))^(1/g). imshow(uint8(g)).tif'). imshow(uint8(f)). figure(3).