box_vals.m - What does the function do?
(You don't need to enter the commands below. They are already included in the code box_vals.m. This document is only for you to learn what's inside the blackbox.)
The function box_cursor allows you to select the region of the image in which you want to carry out the calculation, and save the location of the box in (x0,y0) and the box size in (nx,ny).
[x0,y0,nx,ny] = box_cursor;
The function box_vals.m takes two input, av as the cleaned intensity map, and difs as the variance map. Now, recall that the colon operator (:) returns a range of subscripts defined by the numbers before and after it. Therefore x:(x+nx) gives the values from subscript x to subscript x+nx. The following commands:
avbox = av(y0:(y0+ny), x0:(x0+nx)); difbox = difs(y0:(y0+ny), x0:(x0+nx));
generate a box avbox as a subarray of data array av, and a box difbox as a subarray of data array difs.
After we construct the two boxes we want to analyze, we can apply those MATLAB commands for numerical arrays on them. The mean value of each box can be calculated by using the MATLAB internal function mean:
avm = mean(avbox(:)); dfm = mean(difbox(:));
Similarly, the MATLAB function std is applied here to calculate the standard deviations:
sigav = std(avbox(:)); sigdif = std(difbox(:));
The last two commands are just to print out those values evaluated in this function.
fprintf(1,'mean intensity = %0.3f, std of intensity = %0.3f\n', avm, sigav); fprintf(1,'mean variance = %0.3f, std of variance = %0.3f\n', dfm, sigdif);