如何在OpenCV中生成前景轮廓图像



我为我的前景提取任务做了背景减去部分。现在,我有一个轮廓代表白色的前景和黑色的背景,我不知道如何使前景图像只包含像素值(从原始帧)。我使用Opencv 2.3,我使用Mat存储图像。什么好主意吗?

您可以这样做:

Mat image; // the original image
Mat foreground_bw; // the foreground in black and white
background_subtractor ( image, foreground_bw, -1.0 );
// getting the corresponding pixel values for the foreground.
Mat foreground = Mat::zeros ( image.rows, image.cols, image.type() );
image.copyTo ( foreground, foreground_bw );

用原始图像的尺寸制作新图像,循环遍历背景/前景图像(背景为黑色,前景为白色)中的所有像素,对于每个像素,要么从当前/原始图像(来自相机等)复制,要么从您的背景估计中复制。做。

最新更新