Thread Subject: Noise measurment

Subject: Noise measurment

From: Tomas Fridrich

Date: 22 Jan, 2012 22:28:10

Message: 1 of 14

Hello,

I would like to calculate image nosie according to ISO 15739. I had taken 8 pics of the test chart and then calculated the average image. Then I calculated the average image. Acording to my opinion, this average image appears too dark. But the second step is to calculate standart deviation of the average image, but I don? know how? Could someone, please, help me? Best regards

Thanks

Subject: Noise measurment

From: ImageAnalyst

Date: 23 Jan, 2012 02:47:45

Message: 2 of 14

On Jan 22, 2:28 pm, "Tomas Fridrich" <fridrichto...@gmail.com> wrote:
> Hello,
>
> I would like to calculate image nosie according to ISO 15739. I had taken 8 pics of the test chart and then calculated the average image. Then I calculated the average image. Acording to my opinion, this average image appears too dark. But the second step is to calculate standart deviation of the average image, but I don? know how? Could someone, please, help me? Best regards
>
> Thanks

-----------------------------------------------------------------
Why did you calculate the average image again, after you already did
it?
Anyway, it might be too dark if you didn't cast your image to single
or double when you added them together. If you add uint8's, they clip
at 255, so if your sum would be greater than that, it won't be, so
dividing it by 8 will give a smaller value than you'd think.

Subject: Noise measurment

From: Tomas Fridrich

Date: 23 Jan, 2012 10:35:09

Message: 3 of 14

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <a31020b0-557e-4b7d-85af-b968badada3c@f1g2000yqi.googlegroups.com>...
> On Jan 22, 2:28 pm, "Tomas Fridrich" <fridrichto...@gmail.com> wrote:
> > Hello,
> >
> > I would like to calculate image nosie according to ISO 15739. I had taken 8 pics of the test chart and then calculated the average image. Then I calculated the average image. Acording to my opinion, this average image appears too dark. But the second step is to calculate standart deviation of the average image, but I don? know how? Could someone, please, help me? Best regards
> >
> > Thanks
>
> -----------------------------------------------------------------
> Why did you calculate the average image again, after you already did
> it?
> Anyway, it might be too dark if you didn't cast your image to single
> or double when you added them together. If you add uint8's, they clip
> at 255, so if your sum would be greater than that, it won't be, so
> dividing it by 8 will give a smaller value than you'd think.

Sorry the second calculating of average image is mistake.
I´ve turned images to rgb2gray . Anyway, I need to cast image to single or double and use uint8's and then sum them and dividet it by 8. Right?

Subject: Noise measurment

From: Steven_Lord

Date: 23 Jan, 2012 14:34:12

Message: 4 of 14



"Tomas Fridrich" <fridrichtomas@gmail.com> wrote in message
news:jfjd4t$la2$1@newscl01ah.mathworks.com...
> ImageAnalyst <imageanalyst@mailinator.com> wrote in message
> <a31020b0-557e-4b7d-85af-b968badada3c@f1g2000yqi.googlegroups.com>...
>> On Jan 22, 2:28 pm, "Tomas Fridrich" <fridrichto...@gmail.com> wrote:
>> > Hello,
>> >
>> > I would like to calculate image nosie according to ISO 15739. I had
>> > taken 8 pics of the test chart and then calculated the average image.
>> > Then I calculated the average image. Acording to my opinion, this
>> > average image appears too dark. But the second step is to calculate
>> > standart deviation of the average image, but I don? know how? Could
>> > someone, please, help me? Best regards
>> >
>> > Thanks
>>
>> -----------------------------------------------------------------
>> Why did you calculate the average image again, after you already did
>> it?
>> Anyway, it might be too dark if you didn't cast your image to single
>> or double when you added them together. If you add uint8's, they clip
>> at 255, so if your sum would be greater than that, it won't be, so
>> dividing it by 8 will give a smaller value than you'd think.
>
> Sorry the second calculating of average image is mistake. Ive turned
> images to rgb2gray . Anyway, I need to cast image to single or double and
> use uint8's and then sum them and dividet it by 8. Right?

y = uint8(100);
x1 = (y+y+y+y)/4
dy = double(y);
x2 = (dy+dy+dy+dy)/4

You might expect both x1 and x2 to be 100. In fact only x2 is 100 because
addition on uint8's saturates at intmax('uint8') = 255. In integer
arithmetic on uint8's, 255/4 is 64 and that's what you should have received
as x1.

http://www.mathworks.com/help/techdoc/matlab_prog/f2-12135.html#f2-52790

You'll also notice, if you look at WHOS, that y and x1 are both uint8
variables while dy and x2 are doubles.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Noise measurment

From: Tomas Fridrich

Date: 25 Jan, 2012 23:19:10

Message: 5 of 14

Well I´ve made with my friends this

img_gain = rgb2gray(imread('IMAG0177.jpg'));
img_gain_grey(:,:) = img_gain(:,:,1);
imtool(img_gain_grey);

disp('Crop left test field A.');
[img_field_A coor_field_A] = imcrop(img_gain_grey, []);
disp('Crop middle test field B.');
[img_field_B coor_field_B] = imcrop(img_gain_grey, []);
disp('Crop middle test field C.');
[img_field_C coor_field_C] = imcrop(img_gain_grey, []);

A_mean_value = mean(mean(img_field_A));
B_mean_value = mean(mean(img_field_B));
C_mean_value = mean(mean(img_field_C));

gain_estimate =((B_mean_value-A_mean_value)/(2*0.06*255))+((C_mean_value-B_mean_value)/(2*0.06*255));

img_1 = rgb2ycbcr(imread('IMAG0177.jpg'));
img_center_1(:,:) = double(imcrop(img_1(:,:,1), coor_field_B));
img_2 = rgb2ycbcr(imread('IMAG0178.jpg'));
img_center_2(:,:) = double(imcrop(img_2(:,:,1), coor_field_B));
img_3 = rgb2ycbcr(imread('IMAG0179.jpg'));
img_center_3(:,:) = double(imcrop(img_3(:,:,1), coor_field_B));
img_4 = rgb2ycbcr(imread('IMAG0180.jpg'));
img_center_4(:,:) = double(imcrop(img_4(:,:,1), coor_field_B));
img_5 = rgb2ycbcr(imread('IMAG0181.jpg'));
img_center_5(:,:) = double(imcrop(img_5(:,:,1), coor_field_B));
img_6 = rgb2ycbcr(imread('IMAG0182.jpg'));
img_center_6(:,:) = double(imcrop(img_6(:,:,1), coor_field_B));
img_7 = rgb2ycbcr(imread('IMAG0183.jpg'));
img_center_7(:,:) = double(imcrop(img_7(:,:,1), coor_field_B));
img_8 = rgb2gray(imread('IMAG0184.jpg'));
img_center_8(:,:) = double(imcrop(img_8(:,:,1), coor_field_B));


Where IMAG0177.jpg etc are images of test chart
How to calculate average image??

Subject: Noise measurment

From: ImageAnalyst

Date: 26 Jan, 2012 02:11:47

Message: 6 of 14

On Jan 25, 3:19 pm, "Tomas Fridrich" <fridrichto...@gmail.com> wrote:
> Where IMAG0177.jpg etc are images of test chart
> How to calculate average image??
--------------------------------------------------------
I know it sounds like maybe it's too trivial, but it really is. It's
not rocket science. Just sum them up and divide by the number of
images. The only trick is that the images need to be uint16, single,
or double before summing so that you won't get clipping like you will
if you sum uint8 images.

Subject: Noise measurment

From: Tomas Fridrich

Date: 30 Jan, 2012 19:16:10

Message: 7 of 14

> --------------------------------------------------------
> I know it sounds like maybe it's too trivial, but it really is. It's
> not rocket science. Just sum them up and divide by the number of
> images. The only trick is that the images need to be uint16, single,
> or double before summing so that you won't get clipping like you will
> if you sum uint8 images.


> --------------------------------------------------------
Well I tried this

img_center_average(:,:)=(uint16(img_center_1(:,:,1))+ uint16(img_center_2(:,:,1))+uint16(img_center_3(:,:,1))+uint16(img_center_4(:,:,1))+ uint16(img_center_5(:,:,1))+ uint16(img_center_6(:,:,1))+uint16(img_center_7(:,:,1))+ uint16(img_center_8(:,:,1)))/8;

but the result is just black image, although values of matrix is average of all images

Subject: Noise measurment

From: ImageAnalyst

Date: 30 Jan, 2012 19:45:36

Message: 8 of 14

On Jan 30, 2:16 pm, "Tomas Fridrich" <fridrichto...@gmail.com> wrote:
> Well I tried this
>
> img_center_average(:,:)=(uint16(img_center_1(:,:,1))+ uint16(img_center_2(:,:,1))+uint16(img_center_3(:,:,1))+uint16(img_center_4(:,:,1))+ uint16(img_center_5(:,:,1))+ uint16(img_center_6(:,:,1))+uint16(img_center_7(:,:,1))+ uint16(img_center_8(:,:,1)))/8;
>
> but the result is just black image, although values of matrix is average of all images
--------------------------------------------------------------------------------------
Tomas:
That's because all your values are in the range 0-255, assuming your
input values were in that range. However to display it, it sees a 16
bit image and uses the default of 0 = black and 65535 = white. So
your values are too low to be seen when mapped to the display. Try to
cast it back to uint8 after you've done the averaging, or else use []
in imshow like this:
imshow(img_center_average, []);
to have it scale the min and max of your array to 0-255.
ImageAnalyst

Subject: Noise measurment

From: Tomas Fridrich

Date: 30 Jan, 2012 22:12:10

Message: 9 of 14

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <1d641f64-bcae-4cd6-a082-6adc6a3ff6b4@x19g2000yqh.googlegroups.com>...
> On Jan 30, 2:16 pm, "Tomas Fridrich" <fridrichto...@gmail.com> wrote:
> > Well I tried this
> >
> > img_center_average(:,:)=(uint16(img_center_1(:,:,1))+ uint16(img_center_2(:,:,1))+uint16(img_center_3(:,:,1))+uint16(img_center_4(:,:,1))+ uint16(img_center_5(:,:,1))+ uint16(img_center_6(:,:,1))+uint16(img_center_7(:,:,1))+ uint16(img_center_8(:,:,1)))/8;
> >
> > but the result is just black image, although values of matrix is average of all images
> --------------------------------------------------------------------------------------
> Tomas:
> That's because all your values are in the range 0-255, assuming your
> input values were in that range. However to display it, it sees a 16
> bit image and uses the default of 0 = black and 65535 = white. So
> your values are too low to be seen when mapped to the display. Try to
> cast it back to uint8 after you've done the averaging, or else use []
> in imshow like this:
> imshow(img_center_average, []);
> to have it scale the min and max of your array to 0-255.
> ImageAnalyst


Thanks a lot. Works great. Thank You

Subject: Noise measurment

From: Tomas Fridrich

Date: 3 Feb, 2012 14:48:12

Message: 10 of 14

Me again.

Now I have average image and I want to calculate standart deviation of this average image. I have no idea how to do it. The only thing I know is formula of standart deviation.

Thanks

Subject: Noise measurment

From: Bjorn Gustavsson

Date: 3 Feb, 2012 15:20:12

Message: 11 of 14

"Tomas Fridrich" <fridrichtomas@gmail.com> wrote in message <jggs3c$6b7$1@newscl01ah.mathworks.com>...
> Me again.
>
> Now I have average image and I want to calculate standart deviation of this average image. I have no idea how to do it. The only thing I know is formula of standart deviation.
>
> Thanks

Well you can apply that formula straight off:

  for i1 = 1:number_of_images
    
    sigmaImage2 = sigmaImage2 + 1./( number_of_images - 1 ) .* ( ImgMean - Img_i1) ).^2;
    
  end

Hope I got that forumla right.

HTH.

Subject: Noise measurment

From: Tomas Fridrich

Date: 3 Feb, 2012 19:43:11

Message: 12 of 14

"Bjorn Gustavsson" <bjonr@irf.se> wrote in message <jggtvc$cvp$1@newscl01ah.mathworks.com>...
> "Tomas Fridrich" <fridrichtomas@gmail.com> wrote in message <jggs3c$6b7$1@newscl01ah.mathworks.com>...
> > Me again.
> >
> > Now I have average image and I want to calculate standart deviation of this average image. I have no idea how to do it. The only thing I know is formula of standart deviation.
> >
> > Thanks
>
> Well you can apply that formula straight off:
>
> for i1 = 1:number_of_images
>
> sigmaImage2 = sigmaImage2 + 1./( number_of_images - 1 ) .* ( ImgMean - Img_i1) ).^2;
>
> end
>
> Hope I got that forumla right.
>
> HTH.
Thanks.

Well but I need to calculate standart deviation of 1 single image. And advice which give me you is about standart deviation of more images? Or not??

Subject: Noise measurment

From: ImageAnalyst

Date: 3 Feb, 2012 23:55:49

Message: 13 of 14

On Feb 3, 2:43 pm, "Tomas Fridrich" <fridrichto...@gmail.com> wrote:
> Well but I need to calculate standart deviation of 1 single image. And advice which give me you is about standart deviation of more images? Or not??
---------------------------------------------------------------
Do you want this:?

SD_of_one_image = std(oneImageArray(:));

That's is the standard deviation over all pixels in that one single
image.

Subject: Noise measurment

From: Tomas Fridrich

Date: 8 Feb, 2012 11:35:23

Message: 14 of 14

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <4f3654fc-52cc-4fb9-be2e-75d30903e2b6@x6g2000pbk.googlegroups.com>...
> On Feb 3, 2:43 pm, "Tomas Fridrich" <fridrichto...@gmail.com> wrote:
> > Well but I need to calculate standart deviation of 1 single image. And advice which give me you is about standart deviation of more images? Or not??
> ---------------------------------------------------------------
> Do you want this:?
>
> SD_of_one_image = std(oneImageArray(:));
>
> That's is the standard deviation over all pixels in that one single
> image.

Well this is it.

Thanks


Here is my program for measuring noise accorind to ISO 15739

but i need i little help with some details. For example. I don't know if is my gain estimate of camera is good. I calculated 1.54. Is it small/big?
Please help.

Thanks


clc;
clear all;
close all;


img_gain = rgb2gray(imread('IMAG0177.jpg'));
img_gain_grey(:,:) = img_gain(:,:,1);
imtool(img_gain_grey);

disp('Crop left test field A.');
[img_field_A coor_field_A] = imcrop(img_gain_grey, []);
disp('Crop middle test field B.');
[img_field_B coor_field_B] = imcrop(img_gain_grey, []);
disp('Crop middle test field C.');
[img_field_C coor_field_C] = imcrop(img_gain_grey, []);

A_mean_value = mean(mean(img_field_A)); %mean(img_field_A(:))
B_mean_value = mean(mean(img_field_B));
C_mean_value = mean(mean(img_field_C));

gain_estimate =((B_mean_value-A_mean_value)/(2*0.06*255))+((C_mean_value-B_mean_value)/(2*0.06*255));



img_1 = rgb2ycbcr(imread('IMAG0177.jpg'));
img_center_1(:,:) = double(imcrop(img_1(:,:,1), coor_field_B));
img_2 = rgb2ycbcr(imread('IMAG0178.jpg'));
img_center_2(:,:) = double(imcrop(img_2(:,:,1), coor_field_B));
img_3 = rgb2ycbcr(imread('IMAG0179.jpg'));
img_center_3(:,:) = double(imcrop(img_3(:,:,1), coor_field_B));
img_4 = rgb2ycbcr(imread('IMAG0180.jpg'));
img_center_4(:,:) = double(imcrop(img_4(:,:,1), coor_field_B));
img_5 = rgb2ycbcr(imread('IMAG0181.jpg'));
img_center_5(:,:) = double(imcrop(img_5(:,:,1), coor_field_B));
img_6 = rgb2ycbcr(imread('IMAG0182.jpg'));
img_center_6(:,:) = double(imcrop(img_6(:,:,1), coor_field_B));
img_7 = rgb2ycbcr(imread('IMAG0183.jpg'));
img_center_7(:,:) = double(imcrop(img_7(:,:,1), coor_field_B));
img_8 = rgb2ycbcr(imread('IMAG0184.jpg'));
img_center_8(:,:) = double(imcrop(img_8(:,:,1), coor_field_B));
clear img_1; img_2; img_3; img_4; img_5; img_6; img_7; img_8;

img_center_average(:,:)=double(img_center_1(:,:,1)+img_center_2(:,:,1)+img_center_3(:,:,1)+img_center_4(:,:,1)+img_center_5(:,:,1)+ img_center_6(:,:,1)+img_center_7(:,:,1)+img_center_8(:,:,1))/8;
sigma_ave=std(img_center_average(:));
prumer=uint8(img_center_average);
figure(4);show=imshow(prumer);




img_center_diff_1 =std(img_center_average(:)-img_center_1(:));
img_center_diff_2 =std(img_center_average(:)-img_center_2(:));
img_center_diff_3 =std(img_center_average(:)-img_center_3(:));
img_center_diff_4 =std(img_center_average(:)-img_center_4(:));
img_center_diff_5 =std(img_center_average(:)-img_center_5(:));
img_center_diff_6 =std(img_center_average(:)-img_center_6(:));
img_center_diff_7 =std(img_center_average(:)-img_center_7(:));
img_center_diff_8 =std(img_center_average(:)-img_center_8(:));
img_center_average_diff=std((img_center_average(:)-img_center_1(:)).^2+(img_center_average(:)-img_center_2(:)).^2+(img_center_average(:)-img_center_3(:)).^2+(img_center_average(:)-img_center_4(:)).^2+...
(img_center_average(:)-img_center_5(:)).^2+(img_center_average(:)-img_center_6(:)).^2+(img_center_average(:)-img_center_7(:)).^2+(img_center_average(:)-img_center_8(:)));



 sigma_diff =((((img_center_diff_1).^2)+((img_center_diff_2).^2)+((img_center_diff_3).^2)+((img_center_diff_4).^2)+((img_center_diff_5).^2)+((img_center_diff_6).^2)+((img_center_diff_7).^2)+((img_center_diff_8).^2)).^1/2)./8;
 sigma_temp =(8/7.*sigma_diff).^1/2;
 sigma_fp = (img_center_average_diff.^2-(1/7.*sigma_diff)).^1/2;
 sigma_total = (sigma_fp.^2 + sigma_temp.^2).^1/2;

SNR_temp = 0.18*(gain_estimate*255./sigma_temp);
SNR_fp =0.18*(gain_estimate*255./sigma_fp);
SNR_total = 0.18*(gain_estimate*255./sigma_total);
SNR_DB=20*log10(SNR_total);

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
noise measurment Tomas Fridrich 22 Jan, 2012 17:29:11
iso 15739 Tomas Fridrich 22 Jan, 2012 17:29:11
rssFeed for this Thread

Contact us at files@mathworks.com