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
2011-1-26
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 个评论
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 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!