【发布时间】:2016-01-20 03:36:56
【问题描述】:
我有一张带有一些噪点的二值图像。我想通过使用沿图像滑动的矩形大小(10x10)来减少噪点。
如果矩形包含超过 20 个nonZero 像素,我会将 ROI 复制到目标图像。
for (int i = 0; i < binary.rows-10; i+=10){
for (int j = 0; j < binary.cols-10; j+=10)
{
cv::Rect Roi(i, j, 10, 10);
cv::Mat countImg = cv::Mat(10, 10, CV_8UC1);
countImg = cv::Mat(binary, Roi);
if (cv::countNonZero(countImg)>20)
{
countImg.copyTo(binary_filter.rowRange(i, i + 10).colRange(j, j + 10));
}
}
}
程序在函数countImg = cv::Mat(binary, Roi);遇到错误谁能解释一下?
【问题讨论】: