%fft protect
%load imagin
img=imread('temfig.jpg');
img=rgb2gray(img);
img=double(img)/256;
subplot(3,3,1);
imshow(img);
%fft tran Abs
f_img=fft2(img);
f_img_abs=abs(f_img);
f_img_a=(f_img_abs-min(min(f_img_abs)))/(max(max(f_img_abs))-min(min(f_img_abs)))*256;
f_img_a=fftshift(f_img_a);
subplot(3,3,2);
imshow(f_img_a);
%fft tran angle
f_img_angle=angle(f_img);
f_img_an=(f_img_angle-min(min(f_img_angle)))/(max(max(f_img_angle))-min(min(f_img_angle)))*256;
f_img_anglee=exp(i*f_img_angle);
f_img_an=fftshift(f_img_an);
subplot(3,3,3);
imshow(f_img_an);
%load key image
kimg=imread('fprint.jpg');
kimg=rgb2gray(kimg);
kimg=double(kimg)/256;
subplot(3,3,4);
imshow(kimg);
%fft tran Abs
f_kimg=fft2(kimg);
f_kimg_abs=abs(f_kimg);
f_kimg_a=(f_kimg_abs-min(min(f_kimg_abs)))/(max(max(f_kimg_abs))-min(min(f_kimg_abs)))*256;
f_kimg_a=fftshift(f_kimg_a);
subplot(3,3,5);
imshow(f_kimg_a);
%fft tran angle
f_kimg_angle=angle(f_kimg);
f_kimg_an=(f_kimg_angle-min(min(f_kimg_angle)))/(max(max(f_kimg_angle))-min(min(f_kimg_angle)))*256;
f_kimg_an=fftshift(f_kimg_an);
subplot(3,3,6);
imshow(f_kimg_an);
%fft protect
f_pimg_abs=f_img_abs;
f_pimg_angle=f_img_angle+f_kimg_angle;
f_pimg_anglee=exp(i*f_pimg_angle);
f_pimg_an=(f_pimg_angle-min(min(f_pimg_angle)))/(max(max(f_pimg_angle))-min(min(f_pimg_angle)))*256;
subplot(3,3,7);
imshow(f_pimg_an);
%ifft protect
f_pimg=f_kimg_abs.*f_pimg_anglee;
if_pimg=ifft2(f_pimg);
subplot(3,3,8);
imshow(if_pimg);
%ifft origine
f_oimg=f_img_abs.*f_img_anglee;
if_oimg=ifft2(f_oimg);
subplot(3,3,9);
imshow(if_oimg);
评论1
最新资源