我正在尝试使用 Cinder OpenCV 块阈值和反转图像。在 openFrameworks 中,我会使用类似的东西:
someImage.threshold(230, true);
Run Code Online (Sandbox Code Playgroud)
...其中 true 是指定阈值和反转的参数。
在 Cinder 中,我正在尝试以下操作:
cv::threshold (input, threshNear, 230, 255, CV_THRESH_BINARY_INV);
Run Code Online (Sandbox Code Playgroud)
...这不起作用,或者
cv::threshold (input, threshNear, 100, 255, CV_8U);
cv::invert ( threshNear, threshNearInverted);
Run Code Online (Sandbox Code Playgroud)
...产生错误并让程序卡住。
有什么建议吗?
好的,经过更多测试后,我意识到实际上要走的路是
cv::threshold (input, threshNear, 70, 255, CV_THRESH_BINARY_INV);
Run Code Online (Sandbox Code Playgroud)
我在问题中发布的代码问题似乎与我尝试使用的阈值(255 上的 230)有关。如果我使用较低的值(例如 255 上的 70),颜色反转实际上有效。
| 归档时间: |
|
| 查看次数: |
32972 次 |
| 最近记录: |