0

I am trying to write a function for automatic threshold value but I don't know how to get them from histogram. For example I have this input image:Input Image

I convert input image 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. Output image

How would I write a function to get automatic binarization (thresholding values)?

GPPK
  • 6,546
  • 4
  • 32
  • 57
User
  • 92
  • 2
  • 12
  • There are many ways to do automatic thresholding. One of the most common ways is using [Otu's method](http://docs.opencv.org/trunk/doc/py_tutorials/py_imgproc/py_thresholding/py_thresholding.html#otsus-binarization). There is adaptive thresholding as well. – scap3y Feb 10 '15 at 18:51
  • I have already tried them but the result was very noisy and not very accurate. I used it wrong perhaps. – User Feb 10 '15 at 18:54
  • Probably. Like I said, it is best if you write your own code which does the threshold. That way, you are sure of what you are thresholding. Also, might I ask why you are using HSV and not BGR? – scap3y Feb 10 '15 at 18:57
  • I am new in OpenCV and also in image processing. I am working on algorithm for detection hematoma from skin. From the beginning I detected hematoma by its color that's why I converted it in to HSV. As I said I am new in the area so I am trying many methods. – User Feb 10 '15 at 19:04
  • Ah okay. Then you should first try and understand how/why the HSV color space is used. Try going through a basic image processing book like the one by Gonalez and Woods. – scap3y Feb 10 '15 at 19:14
  • For me the best solution int this situation will not be thresholding, but using inRange function and extracting the dark area by colour. See my answer (and comments below) here http://stackoverflow.com/questions/28290508/detect-spots-empty-parking-opencv/28299102#28299102 – cyriel Feb 10 '15 at 23:50

0 Answers0