From: Randall Flagg on
Hi everyone,

I want to use a chi squared two sample test to compare two images. One of them is the original (expected) picture and I want to obtain a measure of how good the other image fits it. I tried corrcoef but it's not robust and sensitive to outliers. I also tried spearmans rank correlation coefficient but it has problems with homogeneous image background regions.
Can I use a chi2 test for that purpose? And how can I do that? chi2gof can only test one sample against a normal distribution, how can I test two samples against each other?

Thanks a lot.
From: ImageAnalyst on
Why not use PSNR like most people?
From: Randall Flagg on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <f793e121-b5e3-4963-8468-9e321c019807(a)d2g2000yqa.googlegroups.com>...
> Why not use PSNR like most people?

Because it depends on scaling:
PSNR(A,B) ~= PSNR(42 * A, B)

The second image is not a corrupted version of the first one, but a reconstuction from other data. I need a measure like the correlation coefficient, that takes B being a linear transformation of A into account, just more robust.
From: ImageAnalyst on
And chi square wouldn't depend on scaling????
Anyway, I would think intensity scaling is something you'd want to
know about.
From: Peter Perkins on
On 2/21/2010 6:02 PM, Randall Flagg wrote:

> Can I use a chi2 test for that purpose? And how can I do that? chi2gof
> can only test one sample against a normal distribution, how can I test
> two samples against each other?

Randall, I don't know much about image processing, or if a chi-squared test is approporate in your context or not, but CHI2GOF certainly can do more than test against a normal distribution, and has a provision for testing against a distribution that has been estimated:

>> help chi2gof
CHI2GOF Chi-square goodness-of-fit test.
[snip]
The following options determine the null distribution for the test. You
should not specify both 'cdf' and 'expected'.

Name Value
'cdf' A fully specified cumulative distribution function. This
can be a ProbDist object, a function handle, or a function.
name. The function must take X values as its only argument.
Alternately, you may provide a cell array whose first
element is a function name or handle, and whose later
elements are parameter values, one per cell. The function
must take X values as its first argument, and other
parameters as later arguments.
'expected' A vector with one element per bin specifying the
expected counts for each bin.
'nparams' The number of estimated parameters; used to adjust
the degrees of freedom to be NBINS-1-NPARAMS, where
NBINS is the number of bins.