开发者

How to smooth a cyclic column vector

This is an OpenCV2 question.

I have a matrix representing a closed space curve.

cv::Mat_<Point3f> points;

I want to smooth it (using, for example a Gaussian kernel).

I have tried using:

cv::Mat_<Point3f> result;
cv::GaussianBlur(points, result, cv::Size(4 * sigma, 1), sigma, sigma, cv::BORDER_WRAP);

But I get the error:

Assertion failed (columnBorderType != BORDER_WRAP)

What is the best way to convolve a cyclic vector in开发者_JAVA百科 OpenCV? ("Best" should take into account space and time requirements.)


I found a way. I repeat the matrix, then blur, then extract a range.

GaussianBlur(repeat(points, 3, 1), ret, cv::Size(0,0), sigma); 
int rows = points.rows;
result = Mat(result, Range(rows, 2 * rows - 1), Range::all());

This requires extra work (and extra space?).

Edit: I now manually expand points by copying (wrapping) as many points are required by the kernel. I then crop off the extra points. This is similar to the above, but wastes less space and time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜