I'm new to image processing, but I have good knowledge of general data processing.

Could you please suggest an approach which can be used to segment images like this? I suppose it is some kind of local basin and the segment should stop a larger gradients. However, some outside region may also become dark as seen in the top right corner.

enter image description here

Here the result should be the two dark blobs. Ideally I'd like to use existing packages in Python.

UPDATE: Here is another example showing the more difficult parts: enter image description here The ideal result would be only those two elliptical blobs. Not all blobs are perfectly elliptical though as seen in the first image. You also see that there is a surrounding which in the end should not confuse the algorithm. Especially the small circle in the last image seems pretty tough to get.

  • $\begingroup$ Based on that one image, edge detection may work better. $\endgroup$ Oct 1, 2018 at 14:19
  • $\begingroup$ In this part of the images it may work. But I'm afraid there are many blobs which do not have a closed contour and many spurious contours. Meanwhile I had good success with a method from Felsenszwalb! Only, there are a few blobs whose boundary is too weak. But it's a pretty good starting point. I wonder what else could work. $\endgroup$
    – Gere
    Oct 1, 2018 at 18:10
  • $\begingroup$ Can you post some representative examples? $\endgroup$ Oct 3, 2018 at 8:05
  • $\begingroup$ @ziggyjones I added another example explaining the challenge better. $\endgroup$
    – Gere
    Oct 4, 2018 at 9:03
  • $\begingroup$ That second image is quite hard. Is that cropped from a larger frame? Is there some logic to the higher contrast features? Knowing how the images were acquired and what things are constant would be most helpful to find a good solution to this problem. On the other hand, if some small amount of manual interaction is possible, then the problem likely becomes trivial. $\endgroup$ Sep 24, 2023 at 15:02

1 Answer 1


I'd choose a method which takes into consideration both edge detection and binary segmentation (Binarization).
One easy way to do so is using the Markov Random Field approach which is solved using some Graph Theory algorithms (The Minimum Cut Algorithm).

A method like Howe's method might be a great start: A Laplacian Energy for Document Binarization.
There is a reference implementation.

You'd probably need to tweak the hyper parameters based on a data set of images like you have.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.