CP texture analysis/haralick features explaination

Hi all,

I am using the texture tool on cellprofiler that gives haralick feature analysis outputs, I was wondering if anyone here was more of an expert in this analysis and could provide a more “haralick features for dummies” explanation. I have read the papers and the equations and have a vague idea, but some parts I find a bit confusing.


Haralick features are statistics derived from grey-level co-occurrence matrices. These matrices indicate how often a given intensity value (grey level) occurs at some position relative to another pixel. To see how to compute them, see for example this short tutorial (from the Julia language ImageFeatures package). The statistics derived are things like correlation, variance, entropy…


Thanks! So this line of description “Each entry of the GLCM[i,j] holds the count of the number of times that pair of intensities appears in the image with the defined spatial relationship” would explain why sometimes for each output for these features using cellprofiler (eg for correlation, contrast etc) there can be different number of results depending on the input picture detail?

I don’t understand what you mean by “different number of results”. The same number of features is computed for all objects (I think CP computes 13 Haralick features so you should get 13 values) but the actual value of a given feature can be different for different objects.

Sorry, I wasn’t clear. The 13 features are clearly labeled in the output, but, depending on the input image there could be multiple values for each of the 13 haralick features depending on input image.

I am not quite sure why there isn’t just one value for each haralick feature.

I suspect this may have to do with the way you’ve built your pipeline. There is this comment in the MeasureTexture module:

Note that any input objects specified will have their texture measured against all input images specified, which may lead to image-object texture combinations that are unnecessary. If you do not want this behavior, use multiple MeasureTexture modules to specify the particular image-object measures that you want.

For my pipeline, I am using the quantify 3D image and using a large image (on average 80 z stacks). I initially first threshold the image, but now use directly the grayscale raw file.

For the texture settings I am measuring the whole image (not objects as I cannot identify objects in the 3D mode) I have used the maximum number of gray levels to quantify (256) and have the texture scale to measure 10.
The description for the texture scale I find confusing, for example I do not know why I would need to add multiple scales?

The scale parameter is the distance in pixel/voxel that is used to compute the co-occurence matrix. Having multiple scales could also explain why you get multiple values, one for each scale. I haven’t used these features for whole images so I don’t know what a good scale value would be. I guess it depends on the scale of the texture patterns you’re trying to characterize. In this case trying different scales can make sense.

I haven’t tried multiple scales, but I have put different values for the texture scale (all providing me with the same number of outputs/haralick feature) but I can play around with it more and see.
My understanding is that if I take an average of each of the outputs/feature it will give an overall picture to the texture of the image, particularly as I think that the multiple results are from different orientations.

Thank you a lot for this discussion on this!

You may be talking about the directions of the calculations. If so, then the following short thread may clear things up for you:

yes thanks! This is what I am now coming to understand. and it seems the larger the image, the more angles that measures explaining why there is around 12 outputs for a 3D image with 80 stacks. I take an average of these and use this value as my final result

The CP documentation is not clear about what it’s doing. I’ve checked the code and you do indeed get a value for each of 4 directions in 2D and 13 directions for 3D. I forgot about that because I am used to having them averaged by default.

Thanks! Appreciate the confirmation and also that it is okay to collect an average of all the outputs.

Iassume that the 4 outputs for 2D images correspond to 0, 45, 90, 135 degrees respectively, is there a standard 13 degree points then that are used for 3D images?

In 2D you’re looking at pixels to the east, south-east, south and south-west of the pixel of interest. In 3D, you in addition consider the 9 directions corresponding to the voxels below the voxel of interest. This is at least what CP is doing. There are other implementations that consider more directions (e.g. 8 in 2d).

Great! Thank you so much for your help!!