I’m writing an android application in OpenCV, and have been spending a few hours looking into a few functions used in a C example http://www.shervinemami.info/blobs.html
The cvThreshold function is used in the example program like so –
cvThreshold(planeH, planeH, 18, UCHAR_MAX, CV_THRESH_BINARY_INV);
cvThreshold(planeS, planeS, 50, UCHAR_MAX, CV_THRESH_BINARY);
cvThreshold(planeV, planeV, 80, UCHAR_MAX, CV_THRESH_BINARY);
with 5 parameters. Documentation I’ve found for the function shows the same parameters, however the function seems to return a double rather than a void.
The parameters are –
cvThreshold(sourceImage, destinationImage, minThreshold, maxThreshold,
thresholdType);
As far as I can tell (and is documented), the function checks the source image to see which elements fall within the specified range (between min and max threshold) based on the thresholdType selected, and outputs the result to the destination image. But I have no idea why a double is returned…
The documentation provided with the Android version is included below.
/**
* Applies a fixed-level threshold to each array element.
*
* The function applies fixed-level thresholding to a single-channel array. The
* function is typically used to get a bi-level (binary) image out of a
* grayscale image ("compare" could be also used for this purpose) or for
* removing a noise, that is, filtering out pixels with too small or too large
* values. There are several types of thresholding supported by the function.
* They are determined by "thresholdType" :
* * THRESH_BINARY
*
* dst(x,y) = maxVal if src(x,y) > thresh; 0 otherwise
*
* * THRESH_BINARY_INV
*
* dst(x,y) = 0 if src(x,y) > thresh; maxVal otherwise
*
* * THRESH_TRUNC
*
* dst(x,y) = threshold if src(x,y) > thresh; src(x,y) otherwise
*
* * THRESH_TOZERO
*
* dst(x,y) = src(x,y) if src(x,y) > thresh; 0 otherwise
*
* * THRESH_TOZERO_INV
*
* dst(x,y) = 0 if src(x,y) > thresh; src(x,y) otherwise
*
* Also, 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.
*
* @param src Source array (single-channel, 8-bit of 32-bit floating point).
* @param dst Destination array of the same size and type as "src".
* @param thresh Threshold value.
* @param maxval a maxval
* @param type a type
*
* @see <a href="http://opencv.itseez.com/modules/imgproc/doc/miscellaneous_transformations.html#threshold">org.opencv.imgproc.Imgproc.threshold</a>
* @see org.opencv.imgproc.Imgproc.findContours
* @see org.opencv.core.Core.max
* @see org.opencv.imgproc.Imgproc.adaptiveThreshold
* @see org.opencv.core.Core.compare
* @see org.opencv.core.Core.min
*/
It’s only really meaningful for the automatic threshold mode THRESH_OTSU using Otsu’s method