File Exchange

image thumbnail


version (3.72 KB) by Carl
3D statistical texture algortihm


Updated 05 Mar 2008

No License

reads in a 3D intensity matrix and returns both the Haralick features as well as the co-occurrence matrices themselves.

Cite As

Carl (2020). cooc3d (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (11)

Belhadj Naima



thanks for sharing the algorithm. Saved me a lot of time.

As mentioned before the performance of the code is not optimal. If you put the line
"[I1, I2, I3] = size(I);"
in graycooc3d from the innermost loop right in front of the first for loop, you will archive the 3x performance boost mentioned by Rik Wisselink.

Javaid Iqbal

How can we save these feature values in the .mat file using MATLAB?

Hello, thank you so much! The algorithm look awesome. Just a question:
I trying to use, but I am little confused in how implemente.

My code look like this:

filename, pathname, filterindex] = uigetfile('*.mha', 'Pick an data.ima - file');
nom_arch = strcat(pathname,filename);
[featureVector,coocMat] = cooc3d (v1);

its correct? or how I supposed to send the data to the function?.

Tommaso Di Noto

Hello! Thank you very much! The algorithm seems great. Just a question:
I didn't get very weel how it deals with Nan elements. I have a tumoral mass where only central slices have all values in the 3D stack, while external slices have less so I filled all nun-tumoral elements with Nan.

Does the algorithm work anway? Thank you very much


This is a nice submission: it is way better documented than the vast majority of FEX submission.

However, sorely lacks speed. I have 512x512x108 uint8 images I need to analyze, and that takes way too long with this code to calculate the GLCM, which is why I now wrote an implementation myself (which completes in 35% of the original time). The speed for the feature calculation is fine.

One annoying thing is that the options are the same as for graycomatrix, but the labels are slightly different. As the comment by Elena Syerko proves, this output makes it very easy to make mistakes. Having the output being a struct array would solve this issue, as you could simply name the fields without the need to resort to a legend in the help text.

I'll either write a reworked version from this, or finalize the GLCM3D I wrote. I'll post a link to whichever of the two I'll upload to the FEX.

Elena Syerko

Unlike stated at the beginning of the file for the order of features, pay attention that Homogeneity is the 5th feature with other features after shifted(and not: Energy, Entropy, Correlation, Contrast, Variance, SumMean, Inertia,
Cluster Shade, Cluster tendendy, Homogeneity, MaxProbability,
Inverse Variance)

Besides, compared to graycomatrix, the calculated GLCMs have the same form but dispersed (sparse).

Mark Mulvey

line 342 should change from
tempGen = tempGen+ value/(1+abs(1-j));
tempGen = tempGen+ value/(1+abs(i-j));

Sebastian Z

Pradeep Kuamr

thanks so much for making this available. I will test it out and comment on this..

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: BiofilmQ, ImageAnalyzer

Community Treasure Hunt

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

Start Hunting!