OpenCV Automatic Thresholding values

asked 2015-02-10 12:24:43 -0500

Nemesis gravatar image

updated 2015-02-10 12:56:27 -0500

Hi all, I am trying to write a function for automatic threshold value but I don't know how to get them from histogram. For example the histogram of the H channel(blue one) of the original image says that the first maximum belongs to the background, the second to the skin and the last to the hematome. For example I have this input image:

I convert input img to other color space (HSV) then I split channels and then I print out on histogram all channels H-blue line, S-green line, V-red line. . How would I write a function to get automatic binarization (thresholding values)?

edit retag flag offensive close merge delete


So based on the maxima in those histograms, you want to define the correct values for thresholding? You are looking for regional thresholds or a single threshold for the complete image?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-11 04:12:18 -0500 )edit

Actualy I don't understand your question. :/ I have couple images of hematoma and for all of them I need different values for thresholding. I am trying to use some adaptive thresholding or a automatic one what can set values for thresholding by itself.

Nemesis gravatar imageNemesis ( 2015-02-11 11:46:57 -0500 )edit

Hmm if local or global thresholding is not a known concept I suggest googling for thresholding techniques and start reading. It are very basic concepts.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-11 12:24:38 -0500 )edit

Try using Otsu thresholding on any of the H,S,V/R,G,B and see if you get desired results.

Param-Uttarwar gravatar imageParam-Uttarwar ( 2015-02-13 23:22:59 -0500 )edit