[Insight-users] Re: co-occurrence matrix

Zachary Pincus zpincus at stanford.edu
Wed Jun 30 14:39:22 EDT 2004


Tanja,

(I hope you don't mind that I've forwarded your original question on 
the the Insight-users list so that anyone else with the same question 
can get this answer.)

The grey level co-occurrence matrix generator only iterates over pixels 
where any (pixel, offset) pair would be fully within the image's 
buffered region.

So if the input image is:

1 2 1 2 1
1 2 1 2 1
1 2 1 2 1
1 2 1 2 1
1 2 1 2 1

and we have an offset of (0, -1), we could potentially get measurements 
from the following pixels: (*'s represent pixels where we can't get 
meaningful measurements.)

* * * * *
1 2 1 2 1
1 2 1 2 1
1 2 1 2 1
1 2 1 2 1

but if we have offset (0, 1) we could get measurements from:

1 2 1 2 1
1 2 1 2 1
1 2 1 2 1
1 2 1 2 1
* * * * *

So if we want to keep everything symmetric so that passing in (0, 1) as 
the offset produces the same matrix as if we pass in (0, -1), we can 
only iterate over the following pixels:

* * * * *
1 2 1 2 1
1 2 1 2 1
1 2 1 2 1
* * * * *

I think it's reasonable to want the matrices to be the same for the (0, 
1) and (0, -1) case because the "pixel" <-> "offset" relation should be 
transitive.

Now, what if we have two offsets: (0, 1) and (1, 0). It seems 
reasonable that we should calculate the histogram over the same set of 
pixels, so we just iterate over:

* * * * *
* 2 1 2 *
* 2 1 2 *
* 2 1 2 *
* * * * *

which will generate the histogram provided in the test.
In fact, even if we pass in only (0, 1), we will only iterate over 
those central pixels, so as to be consistent with other possible runs 
of the matrix generator. Note that if we passed in (0, 2), we would 
only iterate over the single center pixel!

I apologize for this being so poorly-documented in the 
ScalarImageToGreyLevelCooccurrenceMatrixGenerator class. I'll try to 
fix that soon.

Now, I'm not 100% convinced that this is the right way to do things. It 
might be better to iterate over the full image with all offsets, and 
ONLY ignore a measurement when an offset pixel would fall off the edge 
of the image. The downside is that the co-occurrence matrix is then 
generated over slightly different image regions for each offset, and 
would not be the same if we passed in the negative of all of the 
offsets. If you or anyone else has any suggestions about the best way 
of doing things, I'd be most receptive...

Zach Pincus

Department of Biochemistry and Program in Biomedical Informatics
Stanford University School of Medicine



More information about the Insight-users mailing list