I'm trying to calculate various image features from the Gray-Level Co-occurence Matrix (GLCM) in MatLab using the graycomatrix
function.
I = [0 0 1 1; 0 0 1 1; 0 2 2 2; 2 2 3 3];
glcm = graycomatrix(I, 'GrayLimits', [0 3], 'NumLevels', 4, 'Symmetric', true);
How can I apply this function to a series of sub-windows assuming a larger image (640x480 for example) than the trivial example and a sliding window size of 5x5?
I'm not sure a filtering approach is possible. I think you mean sth like this (let im be your grayscale image):
for ii=3:size(im,1)-2
for jj=3:size(im,2)-2 % a loop for every pixel that a 5x5 window can be defined
temp_im=im(ii-2:ii+2,jj-2:jj+2); % crop a small window around pixel
glcm=graycomatrix(temp_im); % default parameters
glcm_feat_struct=graycoprops(glcm);
% extract features from struct and do anything you want
end
end