Clear Filters
Clear Filters

GLCM feature extracted image display

17 views (last 30 days)
Vimal Raj
Vimal Raj on 30 Apr 2024
Commented: Vimal Raj on 30 Apr 2024
i want to view the output images for GLCM calculated features for optical images like in the figure attached. help me with the code.

Answers (1)

Amish
Amish on 30 Apr 2024
Edited: Amish on 30 Apr 2024
Hi Vimal,
You can output images for GLCM calculated features for optical images by using MATLAB script. You will need to read the images, convert them into grayscale versions and the calculate GLCM and then get the GLCM features. You can then display the calculated features or use imagesc to display any direct outputs as an image.
Here is a generic script that you can refer to:
img = imread('your_image.jpg');
% convert it to grayscale
if size(img, 3) == 3
img = rgb2gray(img);
end
% an example GLCM with a distance of 1 and four angles (0, 45, 90, and 135 degrees):
offsets = [0 1; -1 1;-1 0;-1 -1];
glcm = graycomatrix(img, 'Offset', offsets);
% extract features
features = graycoprops(glcm, {'contrast', 'correlation', 'energy', 'homogeneity'});
disp(features);
% OR display any direct outputs
figure;
subplot(2,2,1);
imagesc(glcm(:,:,1));
title('0 degrees');
colorbar;
subplot(2,2,2);
imagesc(glcm(:,:,2));
title('45 degrees');
colorbar;
subplot(2,2,3);
imagesc(glcm(:,:,3));
title('90 degrees');
colorbar;
subplot(2,2,4);
imagesc(glcm(:,:,4));
title('135 degrees');
colorbar;
Here are some documentation links that you may find to be useful:
Hope this helps!
  1 Comment
Vimal Raj
Vimal Raj on 30 Apr 2024
Thank You Amish,
But could you please help me to precise in duplicating the image attached for our own data.
.ie for example, i want to see mean, varaiance, entropy, homogeneity results as image ( not as value) for the given image.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!