Segmentation based on the histogram slope: porosity


I would like to obtain the porosity of a sample from this type of image:

They are images obtained using the BSE detector of a scanning electron microscope, on flat polished section of a cement paste sample.
As you can see, the resolution of the porosity is similar to the resolution of the image, so it’s a very difficult task (if you think it is impossible, the point of this analysis is to show that it can’t be done reliably… so bear with me). In this image the porosity is in black. The greys are all types of hydrated phases, while in white you have the original phases of the cement paste.

This is the histogram of the image:

It’s quite impossible to see anything, so my first step is to apply a filter. I chose a median filter (radius of 5). I obtain this histogram, which seems easier to work with.

Choosing the segmentation on the flat region (threshold at ~25) misses a bunch of pores. Instead, the “common” method is to choose the threshold point as follow:


The threshold is the intersection between the pore mode slope, and the hydrate mode slope, around ~50. This visual method is “acceptable” for one image. But I would like to automate the process on a set of images, to obtain a better statistic.

I didn’t find any algorithm that would allow me to do that. The very manual way would be to fit the histogram with a bunch of Gaussians, and after identification, found the intersection I’m looking for, but that seems overkill.

So my question: do you know an algorithm emulating the manual approach ? (or do you have an even better idea ?)

I’m currently using scikit-image, but I’m willing to try other toolkits if they are more adapted.