Created
September 8, 2015 14:08
-
-
Save arsho/1390a8a886ea5e6d80a3 to your computer and use it in GitHub Desktop.
Proving SNR Improvement by averaging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Title : Demonstration of SNR improvement by averaging | |
% Date : 7/9/2015 | |
% Author : Shovon | |
clc; | |
image_object=ones(200,300,3); % (height, width) | |
image_size_ar=size(image_object); | |
image_height=image_size_ar(1); | |
image_width=image_size_ar(2); | |
% Creating the original image with uniform intensity | |
for i = 1:image_height | |
for j=1:image_width | |
image_object(i,j,:)=[0,0,1]; | |
end | |
end | |
mean=0; % set noise mean | |
var=0.2; % set noise variance | |
k=5; % set number of images | |
% Subplotting the original image | |
subplot(k+2,1,1); | |
imshow(image_object); | |
title('Original Image'); | |
first_noisy_image=imnoise(image_object,'gaussian',mean,var); | |
sum_image=first_noisy_image; | |
subplot(k+2,1,2); % (row,col,pos) | |
imshow(first_noisy_image); | |
title('Noisy Image'); | |
for i=2:k | |
temp_noisy_image=imnoise(image_object,'gaussian',mean,var); | |
subplot(k+2,1,i+1); % (row,col,pos) | |
imshow(temp_noisy_image); | |
title('Noisy Image'); | |
sum_image=sum_image+temp_noisy_image; | |
end | |
average_image=sum_image/k; | |
psignal=std(image_object(:)); % author: Shovon | |
pnoise=std(average_image(:)); | |
calculated_snr=10*log10(psignal/pnoise); | |
disp(calculated_snr); | |
subplot(k+2,1,k+2); % (row,col,pos) | |
imshow(average_image); | |
title(calculated_snr); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
smashing code. it helped me also in my semester assignment :) i recommend you to use red color instead of blue one.