3

我正在尝试使用 Cinder OpenCV 块对图像进行阈值化和反转。在 openFrameworks 我会使用类似的东西:

someImage.threshold(230, true);

...其中 true 是指定阈值和反转的参数。

在 Cinder 中,我正在尝试以下操作:

cv::threshold (input, threshNear, 230, 255, CV_THRESH_BINARY_INV);     

...这不起作用,或者

cv::threshold (input, threshNear, 100, 255, CV_8U);
cv::invert ( threshNear,  threshNearInverted);

...产生错误并让程序卡住。

有什么建议吗?

4

1 回答 1

7

Ok, after more testing I've realized that actually the way to go is

 cv::threshold (input, threshNear, 70, 255, CV_THRESH_BINARY_INV);

the problem with the code I posted in my question looks like to be related with the threshold value I was trying to use (230 on 255). If I use a lower value (like for example 70 on 255) the color inversion actually works.

于 2014-10-01T09:35:03.347 回答