GLCM feature extracted image display
13 次查看(过去 30 天)
显示 更早的评论
i want to view the output images for GLCM calculated features for optical images like in the figure attached. help me with the code.
0 个评论
回答(1 个)
Amish
2024-4-30
编辑:Amish
2024-4-30
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!
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!