Ronak
Ronak

Reputation: 11

Return value of threshold function in opencv

I am applying Otsu threshold method using opencv 2.4.9 function 'threshold'

As per opencv documentation:

The special value THRESH_OTSU may be combined with one of the above values. In this case, the function determines the optimal threshold value using the Otsu’s algorithm and uses it instead of the specified thresh . The function returns the computed threshold value. Currently, the Otsu’s method is implemented only for 8-bit images.

For my test image function is returning value of 49.

  1. What does 49 signify?
  2. How can I use it for further thresholding operation like masking rows which are having no of white pixels less than threshold?

Upvotes: 1

Views: 3509

Answers (1)

Amen
Amen

Reputation: 1633

The value 49 means thresholding your image with the threshold 49 would give you the best result based on the otsu method.
If I've understood your second question correctly the way to applying this 49 value for threshold is to iterate through the grayscale image pixel by pixel and assigning 0 to pixels having intensity above 49 and assigning 255 to those having intensity below 49 or vice versa.

Upvotes: 0

Related Questions