% Calculate the mean and Standard Deviation of the images for each R, G, B components
% 

clear;
% load the image


Net41 = imread('net41.jpg', 'jpg');
Net42 = imread('net42.jpg', 'jpg');
Net43 = imread('net43.jpg', 'jpg');
Net44 = imread('net44.jpg', 'jpg');
Net45 = imread('net45.jpg', 'jpg');
Net46 = imread('net46.jpg', 'jpg');

% Noise analysis 1. Compute the mean and Standard deviation

[ M, N ] = size( Net41(:, :, 1) );

% Statistical data of the images

% RGB mean values
AvgNet41_R = mean2( Net41(:, :, 1) );
AvgNet41_G = mean2( Net41(:, :, 2) );
AvgNet41_B = mean2( Net41(:, :, 3) );

AvgNet42_R = mean2( Net42(:, :, 1) );
AvgNet42_G = mean2( Net42(:, :, 2) );
AvgNet42_B = mean2( Net42(:, :, 3) );

AvgNet43_R = mean2( Net43(:, :, 1) );
AvgNet43_G = mean2( Net43(:, :, 2) );
AvgNet43_B = mean2( Net43(:, :, 3) );

AvgNet44_R = mean2( Net44(:, :, 1) );
AvgNet44_G = mean2( Net44(:, :, 2) );
AvgNet44_B = mean2( Net44(:, :, 3) );

AvgNet45_R = mean2( Net45(:, :, 1) );
AvgNet45_G = mean2( Net45(:, :, 2) );
AvgNet45_B = mean2( Net45(:, :, 3) );

AvgNet46_R = mean2( Net46(:, :, 1) );
AvgNet46_G = mean2( Net46(:, :, 2) );
AvgNet46_B = mean2( Net46(:, :, 3) );


AVG_R = [ AvgNet41_R AvgNet42_R AvgNet43_R AvgNet44_R AvgNet45_R AvgNet46_R  ]
AVG_G = [ AvgNet41_G AvgNet42_G AvgNet43_G AvgNet44_G AvgNet45_G AvgNet46_G ]
AVG_B = [ AvgNet41_B AvgNet42_B AvgNet43_B AvgNet44_B AvgNet45_B AvgNet46_B ]

figure(1);
subplot(3,1, 1);
bar(AVG_R );
title(' Histogram of the Average values of Red vs. Noise ');
grid;
subplot(3,1, 2);
bar(AVG_G );
title(' Histogram of the Average values of Green vs. Noise');
grid;
subplot(3, 1,3);
bar( AVG_B);
title(' Histogram of the Average values of Blue vs. Noise');
xlabel(' Noise ');
grid;

% Standard Deviation of the noise
stdNet41_R = std2( Net41(:, :, 1) );
stdNet41_G = std2( Net41(:, :, 2) );
stdNet41_B = std2( Net41(:, :, 3) );

stdNet42_R = std2( Net42(:, :, 1) );
stdNet42_G = std2( Net42(:, :, 2) );
stdNet42_B = std2( Net42(:, :, 3) );

stdNet43_R = std2( Net43(:, :, 1) );
stdNet43_G = std2( Net43(:, :, 2) );
stdNet43_B = std2( Net43(:, :, 3) );

stdNet44_R = std2( Net44(:, :, 1) );
stdNet44_G = std2( Net44(:, :, 2) );
stdNet44_B = std2( Net44(:, :, 3) );

stdNet45_R = std2( Net45(:, :, 1) );
stdNet45_G = std2( Net45(:, :, 2) );
stdNet45_B = std2( Net45(:, :, 3) );

stdNet46_R = std2( Net46(:, :, 1) );
stdNet46_G = std2( Net46(:, :, 2) );
stdNet46_B = std2( Net46(:, :, 3) );

STD_R = [ stdNet41_R stdNet42_R stdNet43_R stdNet44_R stdNet45_R stdNet46_R ]
STD_G = [ stdNet41_G stdNet42_G stdNet43_G stdNet44_G stdNet45_G stdNet46_G ]
STD_B = [ stdNet41_B stdNet42_B stdNet43_B stdNet44_B stdNet45_B stdNet46_B ]



figure(2);
subplot( 3,1,1);
bar( STD_R);
title(' Histogram of Standard Deviation of Red vs. Noise');
grid;
subplot(3, 1, 2);
bar( STD_G );
title('Histogram of Standard Deviation of Green vs. Noise');
grid;
subplot(3, 1, 3);
bar( STD_B );
title(' Histogram of Standard Deviation of Blue vs. Noise ');
grid;

figure(3);
subplot(3,1,1);
plot( Net41(1, :, 1) );
title(' Original Image ');
grid;
subplot(3,1,2);
plot( Net42(1, :, 1) );
title(' Image with Gaussian Noise variance = 0.02 ');
grid;
subplot(3,1,3);
plot( Net43(1, :, 1) );
title(' Image with Gaussian Noise variance = 0.05 ');
grid;

figure(4);
subplot(3,1,1);
plot( Net44(1, :, 1) );
title(' Image with Gaussian Noise variance = 0.1 ');
grid;
subplot(3,1,2);
plot( Net45(1, :, 1) );
title(' Image with Gaussian Noise variance = 0.2 ');
grid;
subplot(3,1,3);
plot( Net46(1, :, 1) );
title(' Image with Gaussian Noise variance = 0.5 ');
grid;

