有什么方法可以使用fft过滤rgb图像中的噪声并返回彩色图像作为matlab中的输出输出

问题描述 投票:0回答:1

这是我想出的代码。我发现了许多其他过滤方法,但我只是尝试仅使用傅立叶变换对图像进行过滤。itriend将图像分为三个通道,然后对每个图像进行fft并记录变换,但是当我尝试重新组合反移位器图像时,无法获得滤波后的图像。enter image description here

clear all;
rgbImage = imread('simg.jpg');
clear all;
rgbImage = imread('simg.jpg');
figure(1);imshow(rgbImage); title('Original Image');
% Get the dimensions of the image.  numberOfColorBands should be = 3.
[rows, columns, numberOfColorBands] = size(rgbImage);
% Display the original color image.
subplot(3, 4, 1);
imshow(rgbImage);
title('Original color Image', 'FontSize', 12);

% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Display the individual red, green, and blue color channels.
subplot(3, 4, 2);
imshow(redChannel);
title('Red Channel', 'FontSize', 12);
subplot(3, 4, 3);
imshow(greenChannel);
title('Green Channel', 'FontSize', 12);
subplot(3, 4, 4);
imshow(blueChannel);
title('Blue Channel', 'FontSize', 12);

fr1 = fft2(redChannel);
fr2 = fft2(greenChannel);
fr3 = fft2(blueChannel);

%FSF = cat(3,fr1,fr2,fr3);
Fsh1 = fftshift(fr1);
Fsh2 = fftshift(fr2);
Fsh3 = fftshift(fr3);
%subplot(3, 4, 5);
%imshow((Fsh1));
%title('Fsh1', 'FontSize', 12);


log1 = log(1+abs(Fsh1));
log2 = log(1+abs(Fsh2));
log3 = log(1+abs(Fsh3));
%subplot(3, 4, 6);
%imshow(real(log1));
%title('log1', 'FontSize', 12);



%FSF = cat(3, log1, log2, log3);
%FSF = cat(3,Fsh1,Fsh2,Fsh3);
%subplot(3, 4, 7);
%imshow(real(FSF));
%title('fsf', 'FontSize', 12);


frr1 = ifftshift(Fsh1);
frr2 = ifftshift(Fsh2);
frr3 = ifftshift(Fsh3);
FR = cat(3,frr1,frr2,frr3);
subplot(3, 4, 6);
imshow(abs(FR));
subplot(3, 4, 7);
logR = log(1+abs(FR));
imshow(real(FR));

f = ifft2(FR);
subplot(3, 4, 8);
imshow(abs(f))
title('final', 'FontSize', 12);
matlab image-processing fft matlab-figure noise-reduction
1个回答
0
投票

似乎是数字类型的问题,应该是uint8。试试:

final = uint8(abs(f));
imshow(final)
© www.soinside.com 2019 - 2024. All rights reserved.