我正在OpenCV中编写一个android应用程序,并且已经花费了几个小时来研究C示例http://www.shervinemami.info/blobs.html中使用的一些函数。

在示例程序中使用cvThreshold函数,如下所示:

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);

具有5个参数。我为该函数找到的文档显示了相同的参数,但是该函数似乎返回一个double而不是一个void。

参数是-
cvThreshold(sourceImage, destinationImage, minThreshold, maxThreshold,
            thresholdType);

据我所知(已记录),该函数检查源图像以根据所选的thresholdType查看哪些元素落入指定范围内(最小和最大阈值之间),并将结果输出到目标图像。但是我不知道为什么要返回 double ...

Android版本随附的文档如下。
/**
 * 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
 */

最佳答案

这对于使用Otsu's method的自动阈值模式THRESH_OTSU才有意义

关于opencv - OpenCV中cvThreshold/threshold返回的double到底是什么?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9588987/

10-11 22:44
查看更多