I am currently learning how to filter images using Fourier transform in Matlab. I managed to apply a low pass filter on an image, the problem is, I cannot do the same with high pass filter. Here are codes and images that I got. Could you help me?
clc
clear
A=imread('3.tif'); % image size is 200 x 200
B=fftshift(fft2(A));
mask=zeros(200);
mask(80:120,80:120)=1;
C=mask.*B;
D=ifft2(C);
D=uint8(D);
imshow(D);
Here the results:
https://i.stack.imgur.com/Y2UaI.png
The problem occures when I try to apply an inverse mask, like so:
clc
clear
A=imread('3.tif'); % image size is 200 x 200
B=fftshift(fft2(A));
mask=zeros(200);
mask=mask+255;
mask(80:120,80:120)=0;
C=mask.*B;
D=ifft2(C);
D=uint8(D);
imshow(D);
Results:
https://i.stack.imgur.com/NzYNG.png
What is wrong?