Comparing Images by Defining a Reference Model I have a microscopy system which periodically captures an image to be used for shading correction.  Because these images are captured on tissue slides containing, well, tissue, as well as possibly debris, I would like to define a known, good image as the reference with which to compare subsequent images.

These images are captured over clear glass using a line scan camera, so, optimally, there will be little variation across the Y axis, and a quadratic like curve across the X which models the light drop-off at the edges of the field of view of the camera.  An intensity profile, averaged along each column, looks like this:



As you can see, I'm currently using a quadratic fit to model the data.  What I'm now grappling with is what measures to use to compare this image to a future sample.  My initial approach was/is statistical in nature; mainly, comparing residuals.  The difference in residuals between the reference and an arbitrary sample is currently my strongest measure, but I'm not a statistical whiz, and I'm not convinced it is the correct approach yet.

For reference, here are a few samples which should be rejected.  I can add raw data if needed, but I'm really just looking for ideas from the DSP side of things.  The green line is the plot of the reference image, the red line the fit for the image in question.  That last one was captured over faint tissue, and it's a bugger if I continue to use a quadratic fit model.  I may end up using a different approach for that situation.
When looking at your data I want to say that when you have a good image the intensity along the x axis will be somewhat symetric and be much more random when you have a bad image. 
The third order statistical moment, the skewness (1rst and second being mean and variance), is a good measure of assymetry. You may want to compare your image based on the skewness of the intensity along the x axis. Set some thresold either manualy or with basic machine learning.