Get Haralick Features on masked Image

2 ビュー (過去 30 日間)
Jason
Jason 2012 年 7 月 24 日
回答済み: Antonio Mendes 2019 年 8 月 30 日
I have a grayscale (uint8) image and I want to get the Coocurrence matrix for it but I want graycomatrix to ignore certain pixels (according to a logical mask). I have this code:
if true
% code
gray_im = imread('test.bmp');
mask_im = im2bw(imread('test_mask.bmp'));
I = gray_im;
I(~mask_im) = NaN; %make NaN the pixels that are not inside the mask. Doesn't work for uint8.
[glcm,SI] = graycomatrix(I,'NumLevels',32,'Offset',[-2 2]); %[2 0]
stats =graycoprops(glcm , {'contrast', 'homogeneity', 'energy'} );
end
According to the documentation graycomatrix ignores NaN values but I can't put NaN values in a uint8 matrix (they get converted to zero and aren't ignored). I also tried to convert the image to double first but graycomatrix returned an unexpected result. Thanks in advance.

回答 (1 件)

Antonio Mendes
Antonio Mendes 2019 年 8 月 30 日
Did you solve it?

製品

Community Treasure Hunt

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

Start Hunting!

Translated by