如何平滑循环列向量 [英] How to smooth a cyclic column vector

查看:95
本文介绍了如何平滑循环列向量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个OpenCV2问题.

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).

我尝试使用:

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

但是我得到了错误:

断言失败(columnBorderType!= BORDER_WRAP)

Assertion failed (columnBorderType != BORDER_WRAP)

在OpenCV中卷积循环向量的最佳方法是什么? (最佳"应考虑到空间和时间要求.)

What is the best way to convolve a cyclic vector in 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?).

编辑:现在,我通过复制(包装)手动扩展points,因为内核需要许多点.然后,我将多余的部分裁剪掉.这与上面类似,但是浪费的空间和时间更少.

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.

这篇关于如何平滑循环列向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆