0

I have an image which I want to turn into a binary one(only black and white) I want to determine the threshold based on the histogram of the image, so in the min point in the hist the thresholding will begin.

for example I have attached a photo of a histogram which I made from some image. how can I access into the histogram in python and set it to choose the min point from the histogram as it thresholding point( in this histogram there are few min points as you can see - one around 210 for example). histogram of an image
I have several images that I want to do this for them so I dont want to determine the threshold by myself every time. Is there a way in python for doing this ?

Hodaya
  • 1
  • 1
  • the histogram will be created form some array, find out the minimum x value from that array. if you want to binarize from the min value, then there is no need to get the histogram. In the given hist, min value is ~50, so values above 50 (all the pixels) will become 1 and values below 50 (no values) will be 0. In that case, you will get same results with a threshold pt of 1, which is a white image. (If by min point you mean a minima then that makes sense, in which case you can use derivatives of the array used to plot the hist) – SajanGohil Dec 08 '20 at 08:07
  • try looking at https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_histograms/py_histogram_begins/py_histogram_begins.html and if you have a problem - post your code – skibee Dec 08 '20 at 08:19
  • Can you specifiy your question? What do you mean by "min point in the hist the thresholding will begin"? Can you provide the sample code you are using so far? – angelogro Dec 08 '20 at 08:21

0 Answers0