glcm

Using skimage for non-rectangular image areas

纵然是瞬间 提交于 2019-12-11 05:47:26
问题 Let's say I'm concerned with part of an image that I'm wanting to calculate a GLCM for that's not rectangular. How should I go about this? I've made a masking procedure that zeroes out the portion of the image that I don't care about, I just don't know how to take this "masked" image without considering the zeroed out portions of the image... Thanks for your help! 回答1: If you are able to assign the zero intensity value to background pixels, you can obtain the GLCM of the region of interest by

Black space in GLCM image

為{幸葍}努か 提交于 2019-12-10 11:00:32
问题 I'm trying to calculate some textural measures using the GLCM described by Haralick (energy, homogeneity, etc.) for a series of 4 band (R, G, B, NIR) aerial photographs that I have. I have tried this on a subset but am ending up with an image that is mostly blank. My current understanding is that it has to do with the greyscaling and the levels parameter but I can't figure it out. My date is very large (several GB) so I'm trying to be efficient by using the module RIOS (reads an image in as a

How to convert C++ implementation of GLCM into Java?

末鹿安然 提交于 2019-12-10 00:32:58
问题 I got the following snippet from GitHub to compute the gray level co-occurrence matrix (GLCM) through OpenCV: float energy=0,contrast=0,homogenity=0,IDM=0,entropy=0,mean1=0; int row=img.rows,col=img.cols; Mat gl=Mat::zeros(256,256,CV_32FC1); //creating glcm matrix with 256 levels,radius=1 and in the horizontal direction for(int i=0;i<row;i++) for(int j=0;j<col-1;j++) gl.at<float>(img.at<uchar>(i,j),img.at<uchar>(i,j+1))=gl.at<float>(img.at<uchar>(i,j),img.at<uchar>(i,j+1))+1; // normalizing

GLCM in opencv2 (Gray-Level Co-occurrence Matrices)

匆匆过客 提交于 2019-12-06 13:34:01
问题 The legacy function GLCM does not perform yet in opencv2. I use the following code: #import <opencv2/legacy.hpp> cv::Mat inputIm = [in_image CVMat]; cv::Mat grayIm = [in_image CVGrayscaleMat]; // cv::cvtColor(inputIm, grayIm, cv::COLOR_RGB2GRAY); // here I get an error: "no matching function..." !!! CvGLCM* glcm = cvCreateGLCM(grayIm, 1, NULL, 4, CV_GLCM_OPTIMIZATION_LUT); cvCreateGLCMDescriptors(glcm, CV_GLCMDESC_OPTIMIZATION_ALLOWDOUBLENEST); double d = cvGetGLCMDescriptor(glcm, 0, CV

Sliding window in Python for GLCM calculation

醉酒当歌 提交于 2019-12-06 07:02:56
I am trying to do texture analysis in a satellite imagery using GLCM algorithm. The scikit-image documentation is very helpful on that but for GLCM calculation we need a window size looping over the image. This is too slow in Python. I found many posts on stackoverflow about sliding windows but the computation takes for ever. I have an example shown below, it works but takes forever. I guess this must be a a naive way of doing it image = np.pad(image, int(win/2), mode='reflect') row, cols = image.shape feature_map = np.zeros((M, N)) for m in xrange(0, row): for n in xrange(0, cols): window =

How to convert C++ implementation of GLCM into Java?

你离开我真会死。 提交于 2019-12-04 23:32:20
I got the following snippet from GitHub to compute the gray level co-occurrence matrix (GLCM) through OpenCV: float energy=0,contrast=0,homogenity=0,IDM=0,entropy=0,mean1=0; int row=img.rows,col=img.cols; Mat gl=Mat::zeros(256,256,CV_32FC1); //creating glcm matrix with 256 levels,radius=1 and in the horizontal direction for(int i=0;i<row;i++) for(int j=0;j<col-1;j++) gl.at<float>(img.at<uchar>(i,j),img.at<uchar>(i,j+1))=gl.at<float>(img.at<uchar>(i,j),img.at<uchar>(i,j+1))+1; // normalizing glcm matrix for parameter determination gl=gl+gl.t(); gl=gl/sum(gl)[0]; The code above is in C++. I need

GLCM in opencv2 (Gray-Level Co-occurrence Matrices)

梦想与她 提交于 2019-12-04 19:51:09
The legacy function GLCM does not perform yet in opencv2. I use the following code: #import <opencv2/legacy.hpp> cv::Mat inputIm = [in_image CVMat]; cv::Mat grayIm = [in_image CVGrayscaleMat]; // cv::cvtColor(inputIm, grayIm, cv::COLOR_RGB2GRAY); // here I get an error: "no matching function..." !!! CvGLCM* glcm = cvCreateGLCM(grayIm, 1, NULL, 4, CV_GLCM_OPTIMIZATION_LUT); cvCreateGLCMDescriptors(glcm, CV_GLCMDESC_OPTIMIZATION_ALLOWDOUBLENEST); double d = cvGetGLCMDescriptor(glcm, 0, CV_GLCMDESC_HOMOGENITY ); double a = 1; double *ave = &a; double s = 1; double *sd = &s;

Calculating entropy from GLCM of an image

岁酱吖の 提交于 2019-12-03 00:02:28
I am using skimage library for most of image analysis work. I have an RGB image and I intend to extract texture features like entropy , energy , homogeneity and contrast from the image. Below are the steps that I am performing: from skimage import io, color, feature from skimage.filters import rank rgbImg = io.imread(imgFlNm) grayImg = color.rgb2gray(rgbImg) print(grayImg.shape) # (667,1000), a 2 dimensional grayscale image glcm = feature.greycomatrix(grayImg, [1], [0, np.pi/4, np.pi/2, 3*np.pi/4]) print(glcm.shape) # (256, 256, 1, 4) rank.entropy(glcm, disk(5)) # throws an error since entropy

Black line in GLCM result

最后都变了- 提交于 2019-12-02 05:21:20
It is the result of GLCM matrix. What is the meaning of black horizontal and vertical lines in GLCM image? Are they a problem? N = numel(unique(img)); % img is uint8 glcm = graycomatrix(img, 'NumLevels', N); imshow(glcm) I suspect this is the problem: For the function graycomatrix , You have supplied a 'NumLevels' argument which is larger than the number of unique graylevels in your image. For instance, a 256-level (8-bit) image will have only 256 graylevels. Asking for 1000 levels in the output means 744 levels will have no data! i.e. Yes, this is a problem. You can check how many graylevels

Calculating energy using MATLAB

这一生的挚爱 提交于 2019-12-01 01:58:42
Energy, which is as follows: can be found based on the MATLAB documentation using: stats = graycoprops(glcm, properties) For example, I typed this: >> a = [1 2; 3 4] a = 1 2 3 4 >> stats = graycoprops(a, {'energy'}) stats = Energy: 0.3000 If we want to do this manually , how did we get the energy value shown above? This is the part I didn't get clearly. If I'm not wrong: ans=sum(a(:).^2)/sum(a(:)).^2 来源: https://stackoverflow.com/questions/14599816/calculating-energy-using-matlab