Code for a picture to apply filters in frequency domain to it.
21 次查看(过去 30 天)
显示 更早的评论
Apply the following filters to any image you prefer in the frequency domain. a. Average filter b. Gaussian filter c. Sharpening filter d. Sobel filter
- To do that: Find the FFT transform of the image,
- Find the FFT transform of the filter (you need to extend the size of the transformed filter so that it’s becomes same as transformed image size)
- Pointwise Multiply the transformed image and transformed filter.
- Find the inverse FFT transformation of the filtered image.
- For every filter give the following: o Original image and its FFT transform o Filter and its FFT transform o Filtered image in frequency domain o Filtered image in spatial domain.
I have tried to figure out this code multiple times, and nothing seems to be working. If someone could help me on this, that would be amazing and I would be forever greatful!
0 个评论
回答(1 个)
Prachi Kulkarni
2021-10-20
Hi,
Please refer to the following example for a sample code.
I = imread("cameraman.tif"); % image of size 256x256
I = im2double(I);
F = fspecial("average",3); % average filter of size 3x3
Ipad = padarray(I,[3-1 3-1],0,"post"); % zero padding
Fpad = padarray(F,[256-1 256-1],0,"post"); % zero padding
Ifft = fft2(Ipad);
Ffft = fft2(Fpad);
Offt = Ifft.*Ffft;
Opad = ifft2(Offt);
O = Opad(2:end-1,2:end-1); % remove padding
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!