我想获得3个通道的垫子,这样的东西的偶数行/的cols:的OpenCV获得垫
A = 1 0 1 0 1 0
1 0 1 0 1 0
1 0 1 0 1 0
result = 1 1 1
1 1 1
如何我能做到这一点使用OpenCV的?
在此先感谢。
编辑:
这里是我使用的代码:
Mat img_object = imread(patternImageName);
Mat a;
for (int index = 0,j = 0; index < img_object.rows; index = index + 2, j++)
{
a.row(j) = img_object.row(index);
}
但它抛出以下异常:
OpenCV Error: Assertion failed (m.dims >= 2) in Mat, file /build/buildd/opencv-2.4.8+dfsg1/modules/core/src/matrix.cpp, line 269
terminate called after throwing an instance of 'cv::Exception'
j的效用是什么?以及为什么我们将0添加到A.row(i)? – Maystro
不知道+0,我把它从别的东西上扯下来。 J在代码更新中反映出来。这是为索引destMat的行,因为你不想增加2 – GPPK
编辑的问题 – Maystro