How to get only Otsu Threshold value using OpenCV like Matlab function graythresh.
For example, if I write this code I get binary image like using Matlab function im2bw:
Mat bw;
uint8_t data[14] = { 10, 10, 10, 10, 10, 10, 20, 20, 54, 54, 54, 54, 55, 55 };
Mat M(1, 14, CV_8UC1, &data);
threshold(M, bw, 0, 1, CV_THRESH_BINARY | CV_THRESH_OTSU);
The function cv::threshold() returns the computed threshold value if you set THRESH_OTSU flag.
double thres_val = cv::threshold(M, bw, 0, 255, CV_THRESH_BINARY | CV_THRESH_OTSU);
See cv::threshold() for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With