Skip to content

Instantly share code, notes, and snippets.

@vieirin
Created May 17, 2016 19:29
Show Gist options
  • Save vieirin/e8d1145d55556cf8b918d934fce2f709 to your computer and use it in GitHub Desktop.
Save vieirin/e8d1145d55556cf8b918d934fce2f709 to your computer and use it in GitHub Desktop.
cv::Mat glcm(256, 256, CV_8UC1);
int glcmMat[256][256];
for (int i = 0; i < inputImg.rows - 1; ++i)
for (int j = 0; j < inputImg.cols - 1; ++j)
glcmMat[(int)inputImg.at<uchar>(i,j)][(int)inputImg.at<uchar>(i, j+1)]++;
for (int i = 0; i < 256; ++i)
for (int j = 0; j < 256; ++j)
glcm.at<uchar>(i,j) = (uchar)glcmMat[i][j];
cv::FileStorage fs(filename, cv::FileStorage::WRITE);
fs << "glcmMat" << glcm;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment