title: Computing grayscale images' standard deviation at each pixel
body: <p>The following is part of a homework problem:</p>
  
  <p>Compute a matrix holding the grayscale images’ standard deviation at each pixel (i.e., X(i,j) holds the standard deviation across all the images’ gray pixel intensities at row i, column j).</p>
  
  <p>I have (or believe I have) the average image in grayscale. I also have the average image in color, but do not think that is relevant to this problem. I know that standard deviation requires I go through and sum the difference between each value and the average value, but not sure how to get there.</p>
  
  <pre><code>% Matrix initialization
  setsum1 = zeros(215, 300, 3, 'double');
  % Loop through all the image files in one directory and store in the matrix
  filelist = dir('set1\*.jpg');
  for i=1:length(filelist)
  imname = ['\set1\' filelist(i).name];
  nextim = imread(imname);
  setsum1 = setsum1 + im2double(nextim);
  end
  % Compute the average image in color
  setsum1_rgb = setsum1./length(filelist);
  % Compute the average image in grayscale
  setsum1_gray = rgb2gray(setsum1_rgb);
  % grayscale images’ standard deviation at each pixel
  deviation_setsum1_gray = sqrt(sum(power(??? - setsum1_gray, 2)));
  </code></pre>
  
  <p>I am trying to figure out how to get what should go in place of ???. Suggestions in the right direction would be much appreciated.</p>