You are on page 1of 1

offsets = [ 0 1; -1 1; -1 0; -1 -1]; T(i).energy = 0; Imag = T(i).

data; %initial energy of image (T(i)) is 0 %Reading image into Imag

glcm = graycomatrix(Imag,'Of',offsets); %calculating gray level co-occurrence matrix glcm [r c] = size(glcm); for ctr=1:1:r for ctr2=1:1:c T(i).energy = T(i).energy+(glcm(ctr,ctr)).^2; end end fprintf('energy is %li\n\n',T(i).energy);

Just a quick comment: your line inside the for-loop never references ctr2, probably typo. You could vectorize both forloops with the simple:
T(i).energy = sum(gclm(:).^2);

You might also like