tags:

views:

45

answers:

1

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 OpenCV? ("Best" should take into account space and time requirements.)

A: 

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.

Geoff