使用 MATLAB 进行降噪的图像堆叠

Image Stacking for noise reduction using MATLAB

我是图像处理新手,开始使用 MATLAB 进行天文摄影处理。我正在尝试使用 MATLAB 处理土星的 10 个损坏图像(相同图像但混合了不同的噪声)。我了解到,通过将 10 张图像堆叠在一起会产生具有高 PSNR 的降噪图像,并尝试使用以下编码使其工作。

但是输出看起来像一个不清晰的饱和图像,没有降噪。

你能看看下面的代码并告诉我哪里出错了吗?

%% We are going to stack the 10 corrupted images and finally calculate the PSNR SSIM
clearvars;% Clear all the variables
close all;

load('planetdata.mat'); %to load the corrupted Image set (4-D uint8)
Clean = imread('Clean Image of Saturn.jpg');%Clean Image of Saturn.600x800x3 uint8
planet1(: , :, :)   = planetdata(1, :, :, :);%One corrupted Image as reff

% Set the number of images to stack is 10
stack_number = 10;

% Lets use Clean image as reference of dimensions required
im_x = size(Clean, 1);
im_y = size(Clean, 2);
im_z = size(Clean, 3);

% Lets Generate a blank image for image stacking
resultIM = uint8(zeros(im_x, im_y, im_z));

% Iterate through the images to stack
for i = 1:1:stack_number

% Read in the target object image
 CorruptIM(: , :, :)   = planetdata(i, :, :, :);

% Perform image stacking using the target object image
 resultIM = resultIM + CorruptIM;

end

% resultIM = resultIM / stack_number; 

%% Lets Display Results
workspace;  % to Make sure the work space panel is showing.
fontSize = 15;
figure;
subplot(1, 3, 1);
imshow(Clean);
title('Clean Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Position', get(0,'Screensize')); 
% Give a name to the title bar.
set(gcf,'name','Stacking','numbertitle','off')

% Display one corrupt image as reference
subplot(1, 3, 2);
imshow(planet1);
title('Corrupt Image 1 : Ref', 'FontSize', fontSize);

% Display Stacked image
subplot(1, 3, 3);
imshow(resultIM);
title('Stacked Image', 'FontSize', fontSize);

%% PSNR AND SSIM Calculation
%Lets Find PSNR for For Resultant Image

[row,col]   = size(Clean);
size_host   = row*col;
o_double    = double(Clean);
w_double    = double(resultIM);

s=0;
for j = 1:size_host % the size of the original image

s = s+(w_double(j) - o_double(j))^2 ; 
end

mes     =s/size_host;
psnr    =10*log10((255)^2/mes);
fprintf('The PSNR value for Stacked Image is %0.4f.\n',psnr);


%Lets Find SSIM for resultant Image
[ssimval, ssimmap] = ssim(uint8(resultIM),Clean);
fprintf('The SSIM value for Stacked Image is %0.4f.\n',ssimval);

我认为这句话几乎说明了一切(强调我的):

But the output looks like an unclear saturated image with no noise reduction.

看起来您的图像实际上在 uint8 变量的上限饱和,这是结果图像 resultIM 和数据矩阵 planetdata 的数据类型.随着您不断添加图像,对于无符号 8 位整数类型,像素值在最大值 255 处饱和。

您需要做的是为您的中间计算转换为更大的数据类型,例如更大的 integer type or a floating point type。然后,一旦您的计算完成(例如,将总和除以图像堆栈大小以获得平均图像),您可以根据需要缩放 and/or 舍入数据并将其转换回 uint8 类型。