Dumb Matlab Issue
<p>I'm sure this is something simple, but I'm rather stumped on it. I'm taking in sets of images, each with taken with a different exposure time, and measuring the mean value of the output (in DN) and the RMS of the signal. The whole point is to construct a photon transfer curve. The issue I'm running into, is that when I try to average either the signal or RMS of a window, or even a single pixel, the value stored is laughably different. This should be rather straight forward, which is why it's been so frustrating. Any insight would be appreciated. </p>

<p>Here's my code:</p>

<pre><code>stacklength = 25;
frame = [];
frameMean = [];
framerms = [];
frameRMS = [];
t = 1;
stacknum = 99;
stackdepth = 15;
imagewidth=1944;
imageheight=2592;
uStart = 1001;
uEnd = 1001;
vStart = 1001;
vEnd = 1001;
tic;
for i=1:stacklength
    filename=sprintf('PTLstack_%d.mat' ,i);  %name files one at a time
    load(filename); 
    for u = uStart:uEnd
        for v = vStart:vEnd
            pix = double(squeeze(pixel(u,v,:)));
            pixmean = mean(pix);
            pixrms = rms(pix);
            frame(t) = pixmean;
            framerms(t) = abs(pixrms-pixmean);
            t = t+1;
        end
    end
    frameMean(i) = mean(frame);
    frameRMS(i) = mean(framerms);
    t = 1;
    disp(i);
end
toc;
</code></pre>

<p>And here are a few values I had it display for me:</p>

<pre><code>pix
    16
    18
    21
    19
    22
    17
    19
    18
    16
    20
    18
    21
    23
    17
    20

pixmean
    19

pixrms
frame(t)
    19

framerms(t)
    18.8880

mean(frame)
    0.4404

frameMean(i)
    0.4404

**********
frameRMS(i)
    0.4404

**********
</code></pre>

<p>Please let me know if you'd like clarification on any of this. I know it can be annoying to look at a chunk of code and be expected to figure out everything that's going on in it.</p>

<p>Thanks a 10^6.</p>