'Moon - Tif': Function
'Moon - Tif': Function
function grad(file)
a=im2double(imread(file));
b=0;
for m=2:size(a,1)-1
for n=2:size(a,2)-1
b(m,n)=-a(m-1,n-1)/8-2*a(m-1,n)/8-a(m-1,n+1)/8+a(m+1,n-1)/8+a(m+1,n-
1)/8+a(m,n)/8+a(m+1,n+1)/8;
c(m,n)=b(m,n)+a(m,n);
end
end
function gama(file)
subplot(1,3,1),imshow(a)
f=im2double(imread(file));
subplot(1,3,2),imshow(b)
subplot(2,2,1),
subplot(1,3,3),imshow(c)
imshow(f);
function contrast1 (file) xlabel('orginal ')
a=imread(file); f1=f.^.5;
subplot(1,2,1),imshow(a) subplot(2,2,2),
xlabel('orginal picture') imshow(f1);
for m=1:size(a,1) xlabel('gama=0.5')
for n=1:size(a,2) f2=f.^.8;
if a(m,n)<=80 subplot(2,2,3),
a(m,n)=a(m,n); imshow(f2);
elseif (a(m,n)>=80 && a(m,n)<=180) xlabel('gama=0.8')
a(m,n)=120; f3=f.^3;
else a(m,n)=a(m,n); subplot(2,2,4),
end imshow(f3);
end xlabel('gama=3')
end
subplot(1,2,2),imshow(a)
function filterrgb(file)
a=im2double(imread(file));
b=imnoise(a,'gaussian');
subplot(2,2,1),imshow(a)
subplot(2,2,2),imshow(b)
r=b(:,:,1);
r1=0;
g=b(:,:,2);
g1=0;
b=b(:,:,3);
b1=0;
for m=2:size(r,1)-1
for n=2:size(r,2)-1
r1(m,n)=(r(m-1,n-1)/8+r(m-1,n)/8+r(m-1,n+1)/8+r(m,n-
1)/8+r(m,n)/8+r(m,n+1)/8+r(m+1,n-1)/8+r(m+1,n)/8+r(m+1,n+1)/8);
end
end
for m=2:size(g,1)-1
for n=2:size(g,2)-1
g1(m,n)=(g(m-1,n-1)/8+g(m-1,n)/8+g(m-1,n+1)/8+g(m,n-
1)/8+g(m,n)/8+g(m,n+1)/8+g(m+1,n-1)/8+g(m+1,n)/8+g(m+1,n+1)/8);
end
end
for m=2:size(b,1)-1
for n=2:size(b,2)-1
b1(m,n)=(b(m-1,n-1)/8+b(m-1,n)/8+b(m-1,n+1)/8+b(m,n-
1)/8+b(m,n)/8+b(m,n+1)/8+b(m+1,n-1)/8+b(m+1,n)/8+b(m+1,n+1)/8);
end
end
p(:,:,1)=r1;
p(:,:,2)=g1;
p(:,:,3)=b1;
subplot(2,2,3),imshow(p)
function filter1(file)
a=imread(file);
function filter2(file)
a=im2double(a);
a=im2double(imread(file));
b=fft2(a); function contrast (file)
b=imnoise(a,'gaussian');
b1=abs(b); a=imread(file);
c=fft2(b);
b2=angle(b); subplot(1,2,1),imshow(a)
for m=1:size(a,1)
c=0; xlabel('orginal picture')
c1=0;for n=1:size(a,2) for m=1:size(a,1)
if (m<=1
for m=1:size(b,1) && n<=1) || (m>=200 && n>=200) for n=1:size(a,2)
c(m,n)=0;
for n=1:size(b,2) if a(m,n)<=80
else
if c(m,n)=c(m,n);
m<=200 && n<=200 a(m,n)=50;
a=imread('rice.png');
elseif (a(m,n)>=80 && a(m,n)<=180)
end c(m,n)=b(m,n);
b=dct2(a); a(m,n)=150;
end else c(m,n)=0;
c=idct2(b); else a(m,n)=250;
end end d=b; end
c=ifft2(c);
end e=b; end
subplot(1,3,1),imshow(a)
end f=b; end
subplot(1,3,2),imshow(b)
c=ifft2(c); d(abs(b)<50)=0;
subplot(1,2,2),imshow(a)
subplot(1,3,3),imshow(c)
for m=1:size(b,1) d=idct2(d);
for n=1:size(b,2) e(abs(b)>50 & abs(b)<200)=0;
if m>=50 && n>=50 e=idct2(e);
c1(m,n)=b(m,n); f(abs(b)>250)=0;
else c1(m,n)=0; f=idct2(f);
end subplot(2,3,1),imshow(a)
end xlabel('orginal picture')
end subplot(2,3,2),imshow(b)
c1=ifft2(c1); xlabel('DCT2 picture')
subplot(2,3,3),imshow(c,[0 255])
subplot(2,3,1),imshow(a) xlabel('IDCT2 picture')
xlabel('orginal picture') subplot(2,3,4),imshow(d,[0 255])
subplot(2,3,2),imshow(b1) xlabel('IDCT2 <50)=0 picture')
xlabel('abs fft2(a) picture') subplot(2,3,5),imshow(e,[0 255])
subplot(2,3,3),imshow(b2) xlabel('IDCT2 >50&<200)=0 picture')
xlabel('angle fft2(a) picture') subplot(2,3,6),imshow(f,[0 255])
subplot(2,3,4),imshow(c) xlabel('IDCT2 >250)=0 picture')
subplot(2,3,5),imshow(c1)
function average(file)
a=im2double(imread(file));
b=imnoise(a,'gaussian');
subplot(1,3,1),imshow(a)
subplot(1,3,2),imshow(b)
c=b;
for m=2:size(b,1)-1
for n=2:size(b,2)-1
c(m,n)=b(m-1,n-1)/9+ b(m-1,n)/9+ b(m-1,n+1)/9+ b(m,n-1)/9+ b(m,n)/9+ b(m,n+1)/9+
b(m+1,n-1)/9+ b(m+1,n)/9+ b(m+1,n+1)/9;
end
end
subplot(1,3,3),imshow(c)
M_Saki 87/04/22