Professional Documents
Culture Documents
Image Imread ('Input - JPG') Image - RGB Rgb2gray (Image) F fft2 (Double (Image - RGB) ) Imshow (Abs (Fftshift (F) ), (24 100000) )
Image Imread ('Input - JPG') Image - RGB Rgb2gray (Image) F fft2 (Double (Image - RGB) ) Imshow (Abs (Fftshift (F) ), (24 100000) )
jpg')
>> image_rgb = rgb2gray(image)
>> F = fft2(double(image_rgb))
>> imshow(abs(fftshift(F)),[24 100000])
>> F=fft2(double(I))
>> imshow(abs(fftshift(F)),[24 100000])
>> FA=abs(F)
>> FB=exp(i*angle(F))
% inverse Fourier transform of FA (magnitude) and FB (phase):
>> IA = ifft2(FA)
%image reconstructed using magnitude information
>> IB = ifft2(FB)
%image reconstructed using phase information
% iift color ranges have to be set using imshow
>> cmin = min(min(abs(IA)))
>> cmax = max(max(abs(IA)))
% imshow works automatically for natural images but for reconstruction, proper color limits should be
% set to display sufficient amount of detail in the image since FFT are infinite.
>> imshow(abs(FB), [dmin dmax])
% 64 gray-level image
>> [IM5,map5]=gray2ind(im1,64)
% 16 gray-level image
>> [IM4,map4]=gray2ind(im1,16)
% 8 gray-level image
>> [IM3,map3]=gray2ind(im1,8)
% 4 gray-level image
>> [IM2,map2]=gray2ind(im1,4)
% 2 gray-level image
>> [IM1,map1]=gray2ind(im1,2)
>> figure(2), subplot(221), subimage(im1), title('original'), subplot(222), subimage(IM5,map5),
title('gray-level=64'),subplot(223), subimage(IM4,map4), title('gray-level=16'),subplot(224),
subimage(IM3,map3), title('gray-level=8'),pause
>> mf =ones(11,11)/121
>> y = filter2(mf,img1)
>> imshow(y)
>>z=sqrt(x.^2+y.^2)
>>c=z>10
>> af1=af.*c
>> af1iifft2(af1)
>> ifftshow(af1i)
>> fftshow(af1)
>> imshow(pedge/255)
>> A=imread('ariana.jpg');
>> B=rgb2gray(A);
>> C=double(B);
>> for i=1:size(C,1)-2
for j=1:size(C,2)-2
%Sobel mask for x-direction:
Gx=((2*C(i+2,j+1)+C(i+2,j)+C(i+2,j+2))-(2*C(i,j+1)+C(i,j)+C(i,j+2)));
%Sobel mask for y-direction:
Gy=((2*C(i+1,j+2)+C(i,j+2)+C(i+2,j+2))-(2*C(i+1,j)+C(i,j)+C(i+2,j)));
B(i,j)=sqrt(Gx.^2+Gy.^2);
end
end
>> figure,imshow(B); title('Sobel gradient');
>> a=imread('ariana.jpg');
>> a=rgb2gray(a);
>> b=im2double(a);
>> [m,n]=size(a)
>> N(1:m,1:n)=0
for i=1:m-2;
for j=1:m-2;
N(i,j)=-1*b(i,j)-1*b(i,j+1)-1*b(i,j+2)+0+0+0+1*b(i+2,j)+1*b(i+2,j+1)+1*b(i+2,j+2);
end;
end;
>> O(1:m,1:n)=0
>> for i=1:m-2;
for j=1:m-2;
O(i,j)=-1*b(i,j)+0+1*b(i,j+2)-1*b(i+2,j)+0+1*b(i+1,j+2)-1*b(i+2,j)+0+1*b(i+2,j+2);
end;
end;
>> Z=N+O;
>> imshow(Z);
>> a=imread('ariana.jpg');
>> b=im2double(a);
>> [m,n]=size(a);
>> L(1:m,1:n)=0
>> for i=1:m-2;
for j=1:m-2;
L(i,j)=-1*b(i,j)+0+0+1*b(i+1,j+1);
end;
end;
>> M(1:m,1:n)=0
>> for i=1:m-2;
for j=1:m-2;
M(i,j)=0-1*b(i,j+1)+1*b(i+1,j)+0;
end;
end;
>> N=M+L;
>> imshow(N);