# Statistical measure for if an image consists of spatially connected separate regions

Consider these two grayscale images:

The first image shows a meandering river pattern. The second image shows random noise.

I am looking for a statistical measure that I can use to determine if it is likely that an image shows a river pattern.

The river image has two areas: river = high value and everywhere else = low value.

The result is that the histogram is bimodal:

Therefore an image with a river pattern should have a high variance.

However so does the random image above:

River_var = 0.0269, Random_var = 0.0310


On the other hand the random image has low spatial continuity, whereas the river image has high spatial continuity, which is clearly shown in the experimental variogram:

In the same way that the variance "summarizes" the histogram in one number, I am looking for a measure of spatial contiuity that "summarizes" the experimental variogram.

I want this measure to "punish" high semivariance at small lags harder than at large lags, so I have come up with:

$\ svar = \sum_{h=1}^n \gamma(h)/h^2$

If I only add up from lag = 1 to 15 I get:

River_svar = 0.0228, Random_svar = 0.0488


I think that a river image should have high variance, but low spatial variance so I introduce a variance ratio:

$\ ratio = var/svar$

The result is:

River_ratio = 1.1816, Random_ratio = 0.6337


My idea is to use this ratio as a decision criteria for if an image is a river image or not; high ratio (e.g. > 1) = river.

Any ideas on how I can improve things?

EDIT: Following the advice of whuber and Gschneider here are the Morans I of the two images calculated with a 15x15 inverse distance weight matrix using Felix Hebeler's Matlab function:

I need to summarize the results into one number for each image. According to wikipedia: "Values range from −1 (indicating perfect dispersion) to +1 (perfect correlation). A zero value indicates a random spatial pattern." If I sum up the square of the Morans I for all pixels I get:

River_sumSqM = 654.9283, Random_sumSqM = 50.0785


There is a huge difference here so Morans I seem to be a very good measure of spatial continuity :-).

And here is a histogram of this value for 20 000 permutations of the river image:

Clearly the River_sumSqM value (654.9283) is unlikely and the River image is therefore not spatially random.

-
Interesting question. One bit of advice that comes to mind immediately is to focus on the short-range part of the variogram: that is the crucial part and will do the best job distinguishing pairs of images like these. (Closely related statistics are Moran's I and Geary's C.) It's hard to give specific advice, though, unless you can more clearly characterize the kinds of images you anticipate processing. –  whuber Jun 8 '12 at 12:59
+1 whuber, Moran's I seems like a good start in this case. Then maybe consider a permutation test to see how "extreme" your image is. –  Gschneider Jun 8 '12 at 13:15
@Gschneider The permutation test is a nice idea, especially because no permutations need to be conducted! It's straightforward to calculate the distribution of the variogram (or Moran's I or Geary's C or whatever) under permutations of the values in the image: there are so many values that the CLT applies. (E.g., the variogram will look like the green points; twice their constant height is the variance of the image values.) The problem becomes more challenging when a "river" pattern needs to be distinguished from other patterns such as a "lake" or "rivers" can have widely varying widths. –  whuber Jun 8 '12 at 13:40
Sorry but I am not sure I follow: are you telling me to permute the image being tested pixel per pixel in some random fashion and then compare the Moran's I value of the permuted image with that of the image being tested? –  Andy Jun 8 '12 at 13:52
What I had in mind was first define some sort of (probably simple) neighborhood structure and compute Moran's I. Then you can compute K, say 200,000, possible permutations of the pixels, computing Moran's I for each permutation. Once you've got these 200,000 Moran's I, see where your observed statistic lies. But, whuber's method sounds easier :). –  Gschneider Jun 8 '12 at 16:27

I was thinking that a Gaussian blur acts as a low-pass filter leaving the large-scale structure behind and removing the high wave-number components.

You could also look at the scale of wavelets required to generate the image. If all the information is living in the small scale wavelets then it is likely not the river.

You might consider some sort of auto-correlation of one line of the river with itself. So if you took a row of pixels of the river, even with noise, and found the cross-correlation function with the next row, then you could both find the location and value of the peak. This value is going to be much higher than what you are going to get with the random noise. A column of pixels is not going to produce much of a signal unless you pick something from the region where the river is.

http://en.wikipedia.org/wiki/Cross-correlation

-
Some interesting ideas here! Could I persuade you to flesh out this answer by applying one or more of your approaches to the sample images to (1) show how your methods work and (2) evaluate how well they perform? –  whuber Mar 26 at 15:43
It is from my Thesis. (Mechanical Engineering) I put a Gaussian blur on the position of a nonlinear pendulum, and then used the convolution method to back out the position from an image and compare it to the analytic. I tried it with several levels of noise. As long as the noise was below a threshold related to the size of the gaussian, there was very good reconstruction. link Figure 11 was the relevant graph for the reconstruction. Figure 6 and equation 2 indicate response to noise. –  EngrStudent Mar 27 at 4:48
Thanks! So it looks like you are in a great position to flesh out this answer and demonstrate how effective it really is. :-) –  whuber Mar 27 at 4:52
Sorry for the double comment. I think it is "clever" to use part of an object as a pseudo "mother-wavelet" for itself. It seems self referential, but also poetic. Self Adjoint. –  EngrStudent Mar 27 at 4:54