Can I look at label intensity histograms with SimpleITK?

I have a label map and and corresponding image and would like to look at the intensity histograms for each or each label, I know that there is an intensity histogram being calculated behind the scenes, for example in sitk.LabelIntensityImageFilter() but I don’t know how to to access the underlying itk.Histogram object, so I can get the corresponding counts, and limits on the bins.

I would prefer to develop in SimpleITK, but am happy to use the python wrappers for itk if that is the best way to do this.

I realise that I could do this with numpy but if possible it would be nice to stay with SimpleITK.

Hello @Toby-Jackson,

Unfortunately, this cannot be done in SimpleITK. This is a “feature”. Part of the simplification design includes hiding underlying complexity from the user.

In this case, you will need to use ITK or numpy. If working with numpy, use GetArrayViewFromImage to avoid the memory copy done in GetArrayFromImage.

1 Like