0
$\begingroup$

I have a grayscale image,

the dominant colors in the background are shades of white and light gray, I have tried using otsu binarization but it gave no good results, so I decided according to the histogram below to write manually:

img_gray[img_gray > 130] = 255

so all white/gray shades have been converted to white. it worked impressively well, I was wondering is there an efficient way getting this threshold without re-inventing the wheel, I know I can apply: np.bincount(img_gray.ravel()) and try to find the beginning of the ramp before the peak.

enter image description here

Important fact to say is:

The images' characteristics are there will be always two peaks, the first will reside between 0 to 50 (it's the small one) and the other somewhere in the light white shades.

Is there an approach to find this threshold?

Thank you all

$\endgroup$
1
  • $\begingroup$ What can we say about the model of the histograms for your images? Are they always like the one you showed above (Very big sharp peak)? $\endgroup$
    – Royi
    May 30 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.