Finding energy from co-occurrence matrix

I am trying to find energy of an image using co occurrence matrix. Is this code correct? Is the method of calculating gray level co occurrence matrix correct?
offsets = [ 0 1; -1 1; -1 0; -1 -1];
T(i).energy = 0; %initial energy of image (T(i)) is 0
Imag = T(i).data; %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);

답변 (2개)

Sean de Wolski
Sean de Wolski 2011년 1월 26일

0 개 추천

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

댓글 수: 1

fathi
fathi 2013년 4월 26일
편집: fathi 2013년 4월 26일
yes i think it is correct answer

댓글을 달려면 로그인하십시오.

A
A 2025년 2월 4일

0 개 추천

offsets = [ 0 1; -1 1; -1 0; -1 -1];
T(i).energy = 0; %initial energy of image (T(i)) is 0
Imag = T(i).data; %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);

카테고리

도움말 센터File Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

태그

질문:

2011년 1월 26일

답변:

A
A
2025년 2월 4일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by