2014-10-01 56 views
2

我正在尝试阈值,并与Cinder OpenCV块反转图像。 在我了openFrameworks会使用类似的东西:openCV:阈值和反转图像

someImage.threshold(230, true); 

...这里真正是参数指定阈值和反转。

煤渣我想以下几点:

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

...不工作,或

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

...产生和错误,让卡住的程序。 有什么建议吗?

+1

cv :: invert是* Matrix *反转,而不是您可能想要的颜色反转。 – berak 2014-10-01 08:31:04

+0

也请为您的任何案件提供* exact *错误。 – berak 2014-10-01 08:32:07

+0

@berak感谢您对cv :: invert的评论 - 并且投票结果为down :)我已经发现CV_THRESH_BINARY_INV参数是要走的路,但结果是由于我使用的值而引起的误导(请参阅我自己的回答)。我将调查更多关于这个值的问题,不幸的是,在某些时候,cinder缺乏文档对我来说有点压倒性... – 2014-10-01 09:38:30

回答

2

好吧, 经过更多的测试,我意识到,实际上走的路是

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

与我在我的问题发布貌似与阈值我试图将相关的代码问题使用(255上的230)。如果我使用较低的值(例如255上的70),则颜色反转实际上会起作用。

+0

因为你基本上使用opencv:http://docs.opencv.org/modules/imgproc/doc/ miscellaneous_transformations.html#threshold – berak 2014-10-01 11:04:26

+3

哦,[binary_not](http://docs.opencv.org/modules/core/doc/operations_on_array.html#bitwise-not)可能就是你的'反转'应该做的。 – berak 2014-10-01 11:06:04