Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calculating Glcm features for lung ROi

577 views
Skip to first unread message

Karthik

unread,
Nov 1, 2012, 12:52:07 PM11/1/12
to
hi all,

I have a lung image with nodules present in it, which is my ROI.
Now i need calculate the set of features of that ROI.

How to calculate the GLCM features/other features only on the LUNG ROI(which is of circular/sometimes irregular shape) alone & not on the entire image.

It ll be nice if i could get some Ideas and Suggestions.

Thanks,
Karthik.

Tomás

unread,
Nov 11, 2013, 11:16:07 AM11/11/13
to
"Karthik " <karth...@gmail.com> wrote in message <k6u9bn$eu5$1...@newscl01ah.mathworks.com>...
Hi Karthik, if I'm correct, the idea is to take into consideration only the pixels that are inside your ROI. Matlab has a build in function called graycomatrix, which computes de co-ocurrence gray level matrix but that function does not accept mask as an argument.

However, if you input the command >>edit graycomatrix in matlab, you will see the matlab code that actually runs that algorithm. There, you can see how this function will ignore any NaN values present in your image. Knowing that, it's easy to put the pixels outside your mask or ROIs to NaN and let graycomatrix do his magic.

I'm leaving here a function I'm using now:

function [c cor e h] = graycomatrix_descriptor( image, mask )

% First thing to do is put the values of image outside mask = NaN. This is because
% the matlab function graycomatrix will ignore NaN values when computing GLCM
image = double(image);
image(~mask) = NaN;

% Now get GLCM
kernel = [0 1; 0 -1; 1 0; -1 0];

warning('off','Images:graycomatrix:scaledImageContainsNan');
glcm = graycomatrix( image, 'NumLevels', 8, 'GrayLimits', [],'offset', kernel );
stats = graycoprops( glcm, 'Contrast Correlation Energy Homogeneity');
warning('on','Images:graycomatrix:scaledImageContainsNan');

c = mean( stats.Contrast );
cor = mean( stats.Correlation );
e = mean( stats.Energy );
h = mean( stats.Homogeneity );

end

Hope this helps
Tomás.

Tomás

unread,
Nov 11, 2013, 11:19:06 AM11/11/13
to
"Karthik " <karth...@gmail.com> wrote in message <k6u9bn$eu5$1...@newscl01ah.mathworks.com>...
Hi, I was dealing with the same problem. If you input command >>edit graycomatrix in matlab, you will see the matlab code that runs that algorithm. There, you can see how this function will ignore any NaN values present in your image. Knowing that, it's easy to put the pixels outside your mask to NaN and let graycomatrix do his magic.

I'm leaving here my function:

function [c cor e h] = graycomatrix_descriptor( image, mask )

% First thing to do is put the values of image outside mask = NaN. This is because
% the matlab function graycomatrix will ignore NaN values when computing GLCM
image = double(image);
image(~mask) = NaN;

% Now get GLCM
kernel = [0 1; 0 -1; 1 0; -1 0];

warning('off','Images:graycomatrix:scaledImageContainsNan');
glcm = graycomatrix( image, 'NumLevels', 8, 'GrayLimits', [],'offset', kernel );
stats = graycoprops( glcm, 'Contrast Correlation Energy Homogeneity');
warning('on','Images:graycomatrix:scaledImageContainsNan');

c = mean( stats.Contrast );
cor = mean( stats.Correlation );
e = mean( stats.Energy );
h = mean( stats.Homogeneity );

end

Tomas

harsha...@gmail.com

unread,
Jun 5, 2014, 6:43:12 AM6/5/14
to

Hi,
I am working on my project which includes identification of lung tumor from CT scan images and I am using GLCM for extracting the features..but I am facing some problems about how exactly these featyres are calculated?
So can you please help me..
Thanks
Harsha

jeevith...@gmail.com

unread,
Feb 7, 2016, 1:42:07 AM2/7/16
to
what is the mask here??

fred bnm

unread,
Aug 7, 2016, 2:41:10 PM8/7/16
to
"Tomás " <tomi...@gmail.com> wrote in message <l5r01q$6io$1...@newscl01ah.mathworks.com>...
Hi,Why did you compute mean of stats?
( c = mean( stats.Contrast );
0 new messages