Black image when blurring image using LPF
2 ビュー (過去 30 日間)
古いコメントを表示
I get black resulting image after doing LPF ??
What may be the problem !
3 件のコメント
回答 (1 件)
Image Analyst
2020 年 5 月 17 日
編集済み: Image Analyst
2020 年 5 月 17 日
Only the (1,1) pixel (upper left corner) has any magnitude, most of the rest are less than 1/256 so they just don't show up. By the way, the code you posted doesn't run. I've fixed several errors and the code below does run.
clc; % Clear the command window.
fprintf('Beginning to run %s.m.\n', mfilename);
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 18;
rgbImage=imread('peppers.png');
imdata=rgb2gray(rgbImage);
subplot(2, 3, 1);
imshow(rgbImage);
title('Original RGB Image', 'fontSize', fontSize);
subplot(2, 3, 2);
imshow(imdata);
title('Gray Scale Image', 'fontSize', fontSize);
F=fft2(imdata);
Fsh=fftshift(F);
Fourier_transform=log(1+abs(Fsh));
a=0.9
x =zeros(41,41);
for col = 1:41
for row = 1:41
x(row,col)=a.^((row-1)+(col-1))*1;
end
end
F=fft2(x);
Fsh=fftshift(F);
LPF=log(1+abs(Fsh));
[rowsf, colsf, numberOfColorChannelsf] = size(Fourier_transform);
[rowsl, colsl, numberOfColorChannelsl] = size(LPF);
if rowsl ~= rowsf || colsf ~= colsl
LPF = imresize(LPF, [rowsf colsf]);
end
subplot(2, 3, 3);
imshow(Fourier_transform,[]);
title('Magnitude Fourier transform of an image', 'fontSize', fontSize);
subplot(2, 3, 4);
imshow(LPF,[]);
title('Magnitude of the Frequency Response of the filter', 'fontSize', fontSize);
Convolution = Fourier_transform.*LPF;
Convolution=log(1+abs(Convolution));
subplot(2, 3, 5);
imshow(Convolution,[]);
title('Magnitude after processing', 'fontSize', fontSize);
inverseFFTImage = ifft2(Convolution);
inverseFFTImage = log(1+abs(inverseFFTImage));
subplot(2, 3, 6);
imshow(inverseFFTImage,[]);
title('Resulting image', 'fontSize', fontSize);
g = gcf;
g.WindowState = 'maximized';

See my attached demos that work (different than your code).
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!