Created
April 14, 2019 10:14
-
-
Save vtta/a8be109a862f5bab8856a283b24b0ca5 to your computer and use it in GitHub Desktop.
Gray Level Co-occurrence Matrix in Octave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Y=glcm(X, dx, dy, grayScale) | |
% (dx, dy): | |
% ( 1, 0) 0° | |
% ( 0, 1) 45° | |
% ( 1, 1) 90° | |
% (-1, 1) 135° | |
[m, n] = size(X); | |
maxGrayScale = max(X) + 1; | |
X = floor(X.*grayScale./maxGrayScale); | |
Y = zeros(grayScale,grayScale); | |
for i = 1:m-dy | |
for j = 1:n-dx; | |
r = X(i,j)+1; | |
c = X(i+dy, j+dx)+1; | |
Y(r,c) = Y(r,c)+1; | |
end | |
end | |
Y = Y./(m*n); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment