If you convert your binary image to greyscale - 0 remaining 0, 1 becoming 255 - your algorithm can be used. Though the contrast information is useless. (You'll see why.)
Whether your interpretation of "homogeneity" will result in useful information for binary images is to be seen.
GLCM: as the name denotes it is Gray Level Co-occurrence Matrix. So, the image must be in gray scale. I believe measuring Kurtosis or the fourth moment of the binary image will do the job. A binary image with Kurtosis less than 3 means it produces fewer and less extreme outliers than does the normal distribution which means its pixels are more homogeneous and with less contrast while a binary image with Kurtosis greater than 3 produces more outliers than the normal distribution which means its pixels are less homogeneous and with more contrast.
Contrast and Homogeneity are texture(statistical) features. It will not give any significant description on binary image as there is no surface(pixel) variation in it. Anyway the co-occurrence matrix for binary image can be computed by counting how many 00, 01, 10 and 11 pixels are occurring in horizontal, vertical and diagonal direction.
I really doubt that GLCM is of any good for binary images just as pointed out already by others. GLCM is a technique for obtaining second order statistics of images, depending on the variation or distribution of pixel values. Hence, I largely think GLCM is a waste in the context of binary images which have just 0s and 1s as attributes. In all, I'm yet to come across any literature that describes or proposes the use of GLCM for binary images.
Hi all, Thanks for all your answers. I recently found some spatial statistical parameters like pair correlation, Directional Dist Function which gives more meaningful info on homogeneity. Thanks again all.