Calculating Halarick/GLCM features for just an image segment.

3 views (last 30 days)
Hello, I have an image mask that I would like to apply to an image. I then want to calculate the Halarick texture features (GLCM features) for just this region. Is this possible? If so, what would the code look like?
I currently have a segmented image that contain my area of interest, but then has a large black region on the outside (see below). I'm worried this large black outside region will give me incorrect texture measurements if I input just this image into a graycomatrix.
I tried using code like:
GLCM = graycomatrix(I(I~=0));
but this doesn't keep the right orientation of the image.
Is there an easy solution? Thanks in advance!

Answers (1)

Image Analyst
Image Analyst on 28 Apr 2015
Just use the whole image. Then to get rid of the effect that the zero gray level has, just zero out the first row and first column of the GLCM.
  1 Comment
Jake
Jake on 28 Apr 2015
Edited: Jake on 28 Apr 2015
The current code I am using is:
gray = rgb2gray(imageSegment);
offsets = [0 1; 0 2; 0 3; ...
-1 1; -2 2; -3 3; ...
-1 0; -2 0; -3 0; ...
-1 -1; -2 -2; -3 -3; ...
0 -1; 0 -2; 0 -3; ...
1 1; 2 2; 3 3; ...
1 0; 2 0; 3 0; ...
1 -1; 2 -2; 3 -3];
GLCM2 = graycomatrix(gray,'Offset',offsets);
Would this implementation be correct? :
GLCM2(1,:) = 0;
GLCM2(:,1) = 0;
My goal is to compare across multiple segmented images. So I don't want to calculate any features based on the background black of these images.
Thanks again.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!