# Means and Standard Deviations of Box Pixels

Now you need to choose one box from each step to calculate the variance and mean intensity for each box.

Suppose you have obtained the the average of the bias-corrected images ** sc** and the variance image

**:**

`var`figure(1) imagesc(sc) figure(2) imagesc(var)

Then we invoke the procedure ** box_vals**. When calling

**, you'll need to click and drag on the image to define a box. You should do so on**

`box_vals`**(figure 1) instead of**

`sc`**(figure 2), since it's easier to see the edges of steps on**

`var`**.**

`sc`The function ** box_vals** requires two input, which is

**and**

`sc`**in this case:**

`var`box_vals(sc, var)

It will give you the following output:

mean intensity = 9879.664, std of intensity = 56.295 mean variance = 1189.840, std of variance = 1625.585

Now you can save the mean intensity (** avm**) and the variance (

**) to the vectors**

`dfm`**and**

`xvec`**:**

`yvec`xvec(1) = 9879.664; yvec(1) = 1189.840;

Recall that ** xvec(1)** means the first element of vector

**, which corresponds to your first measurement, or data from the first step. Don't forget to change the number inside the parentheses when you are measuring the other steps!**

`xvec`Repeat this process for all 9 steps, and you'll be able to plot the variance vs. the mean intensity:

figure(3) plot(xvec, yvec)

The slope of this plot gives you the gain of your CCD. To calculate the slope, we can use the MATLAB function ** polyfit**:

coef = polyfit(xvec, yvec, 1)

coef = 0.1206 5.8303

which will fit ** xvec** and

**into a polynomial of degree 1,**

`yvec`**yvec = a*xvec + b**, where

**is**

`coef(1)`**and**

`a`**is**

`coef(2)`**.**

`b`You can also overplot the fitted formula on your measured data by using ** hold**:

figure(3) hold on plot(xvec, coef(1)*xvec+coef(2), 'r--')

The third parameter defines the line property, and ** r--** here means red dashed line. The default line property is

**: blue straight line.**

`b-`