Clustering of a matrix (homogeneity measurement) I have a 2 dim matrix, and I want to know e.g. all the higher values are in the upper left corner. I can't just project it into R^3 and use a standard clustering algorithm because I don't want to consider the value as a dimension by itself. 
Is there an algorithm I can use for this?
EDIT:
To reformulate it, suppose it was like

| High values ... low values |
| ...
| Low values ...  ...        |
| ...
| High values .. low values  |


I'd want to know that there's a "cluster" of high values in the upper left and lower left.
EDIT 2:
The matrix represents an image. The values of each cell represent the concentration of a substance at that coordinate. I want to know how homogeneous the image is (i.e. how well "mixed together" the substance is). Additionally, I would like to know where the non-homogeneity (if any) is coming from.
 A: This question is about spatial correlation.  Many methods exist to characterize and quantify this.  What they all have in common is comparing values at one location to those at nearby locations.  Usually, the reference distribution is some kind of spatial stochastic process where data are generated independently from point to point ("complete spatial randomness").  Some methods only characterize average behavior while others provide more detailed exploratory tools to identify clusters of extreme values.
For three different approaches, check out (1) the literature on geostatistics/kriging/variography; (2) other measures of spatial correlation such as Ripley's K and L functions or the Getis-Ord $G_i$ statistics ; and (3) geographically weighted regression.  Accessible, non-technical, and sort of correct explanations of all these can be found on ESRI.com .  The Wikipedia articles are scanty and of variable quality, unfortunately.
The first two approaches are well supported with R packages such as spatstat and geoRglm.  There is also free software for (2), of which some of the best known is Geoda and CrimeStat .  I know of no free implementation of GWR (#3), but there are good resources maintained by its inventors. 
A: You could also consider Moran's I which is available in the R package "ape".  And then simply use a weighting based on distance:
nRows <- 30
nCols <- 15

nPixels <- nRows * nCols

# Create a Random Image
image <- matrix(sample.int(256, nPixels, replace=TRUE),
                nrow=nRows, ncol=nCols) - 1L

# 1D to 2D Index Function
reverseIndex <- function ( vectorIdx, nRows, nCols )
{
  # If you're using row major for some odd reason, you'll
  # need to flip these.

  J <- floor((vectorIdx - 1L) / nCols)
  I <- (vectorIdx - 1L) - nCols*J

  # Return:
  c(I+1L, J+1L)
} 

# Distance Function
distFunc <- function(I, J)
{
  idx1 <- reverseIndex(I, nRows, nCols)
  idx2 <- reverseIndex(J, nRows, nCols)
  idDiff <- idx1 - idx2

  # Return:
  sqrt(idDiff %*% idDiff)
}

# Create Distance Matrix
matrix(mapply(distFunc, 
              rep(seq_len(nPixels), nPixels),
              rep(seq_len(nPixels), each=nPixels)),
       nrow=nPixels, ncol=nPixels)


# Invert Distance for Moran's I
invDist <- 1 / dist
diag(invDist) <- 0

# Compute Moran's I:
ape::Moran.I(as.vector(image), dist)

Note that this will simply provide a measure & test of association, it will not identify where that association is in your matrix.
A: The goal is just to find out a measure that will tell us how mixed up all the pixels are. Given 2 matrices of data with the exact same distribution of values, if the first one's values are ordered or clumped together in spatial groups and the 2nd one's values are well-dispersed (high points and not near other high points, low points not near other lows), what is the method of evaluating this dispersion/ clumpyness?
The matrices will have the exact same variance or standard deviation, so that is not a good method.
One idea is using the 2D Fourier Transform, because a more clumpy image intuitively has a lower frequency, but I'm not sure if that is actually a common or useful practice for this type of evaluation.
