简体   繁体   English

如何在OpenCV Java中将二进制图像转换为灰度

[英]How to convert binary image to grey scale in opencv java

I have a binary image as output from background subtractor method and i want to convert it to grey scale image to apply cascade classifier in it. 我有一个二进制图像作为背景减法方法的输出,我想将其转换为灰度图像以在其中应用级联分类器。 How can i convert binary image to grey scale? 如何将二进制图像转换为灰度?

unfortunately, you can't do that (as turbo said before, the information is lost forever). 不幸的是,您无法做到这一点(正如Turbo之前所说,信息将永远丢失)。

but you had an image before, that you fed into the background subtractor , didn't you ? 但是您之前有一张图像,您已将其输入到背景减法器中,不是吗? use that instead. 用它代替。

also, the CascadeClassifier does not support masks (like you got from the background subtractor) directly. 同样,CascadeClassifier不直接支持蒙版(就像从背景减法器中获取的那样)。

if you want to use background subtractor to restrict the search to certain rois, you'll probably need to call findContours() on the mask, get the bounding rects for the contours, filter a bit for size, and apply the CascadeClassifier on the remaining rois. 如果要使用背景减法器将搜索范围限制在某些rois,则可能需要在蒙版上调用findContours(),获取轮廓的边界矩形,对大小进行过滤,然后将CascadeClassifier应用于其余部分投资回报率。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM