I'm new to Image processing and started using MATLAB for Astrophotography processing. I'm trying to process 10 corrupted images (Same Image but mixed with different noise) of Planet Saturn using MATLAB. I learned that by stacking the 10 images together leads to a noise reduced picture with high PSNR and tried the below coding to make it work.
Can you please look at the code and point me where i went wrong.
%% 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);