【发布时间】:2017-04-12 05:57:01
【问题描述】:
我想将 matlab 代码翻译成 c++ opencv,它对 RGB 图像进行阈值处理:red value>threshold1 AND red/green>threshold2 AND red/blue>threshold3
matlab代码为:
bw=(im(:,:,1)>=red_th&(im(:,:,1)./im(:,:,2))>=red_green_th&(im(:,:,1)./im(:,:,3))>=red_blue_th);
其中im(:,:,1), im(:,:,2)和im(:,:,3)分别是r、g、b值。
与使用“for cols and for rows”循环所有像素相比,我发现 matlab 代码非常有效。因此,我想在 opencv 中找到类似的有效方法,而不是循环 cols 和 rows。
我阅读了一些关于cv::threshold and inRange 的信息,但是,它们似乎无法满足我的要求。
【问题讨论】:
标签: c++ matlab opencv image-processing