Blurring an image using FFT (Fast Fourier Transform)
12 ビュー (過去 30 日間)
古いコメントを表示
I have an image of a ramp (Fig 1.1). Since every row of in this image is the same, I just picked the first row and ran FFT over it, then since convolution is equivalent to multiplication in the frequency domain, I multiplied it with the FFT of a gaussian vector. But when I run IFFT over the product, I don't get a blur image, instead I just get a completely white image (Fig 1.2) . What am I doing wrong?
Figure 1.1![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/750304/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/750304/image.png)
Figure 1.2 ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/750309/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/750309/image.png)
My Code:
%Import the image
I = imread("/MATLAB Drive/ramp.png");
%Convert to grayscale
I = rgb2gray(I);
imshow(I)
%Pick a row
row = I(1,:);
plot(row)
%Define the gaussian vector
time_vector = 1:500
gaussian_vector = gaussmf(time_vector,[1 0]);
%Compute IFFT(FFT()*FFT())
row_fill = ifft(fft(row).*fft(gaussian_vector))
plot(row_fill)
%Stack the resultant rows
I_fill = repmat(row_fill,500,1);
%Plot the resultant image
imshow(I_fill)
0 件のコメント
回答 (2 件)
Image Analyst
2021 年 9 月 27 日
Try []:
imshow(I_fill, [])
but you'll likely notice no difference at all because of how smooth the function already is.
0 件のコメント
yanqi liu
2021 年 9 月 27 日
sir, may be use the follows code to ref
clc
close all
clear all
%Import the image
I = imread("https://www.mathworks.com/matlabcentral/answers/uploaded_files/750304/image.png");
%Convert to grayscale
I = rgb2gray(I);
imshow(I)
%Pick a row
row = I(1,:);
figure;plot(row)
%Define the gaussian vector
time_vector = 1:500;
gaussian_vector = gaussmf(time_vector,[1 0]);
%Compute IFFT(FFT()*FFT())
row_fill = ifft(fft(row).*fft(gaussian_vector));
plot(row_fill)
%Stack the resultant rows
I_fill = repmat(row_fill,500,1);
%Plot the resultant image
figure; imshow(mat2gray(I_fill))
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!