convolution of closed curve

1 回表示 (過去 30 日間)
Adrian Szatmari
Adrian Szatmari 2017 年 9 月 28 日
Hi Everyone!
I have this code that works, but is not very elegant. I was wondering if there was not a way to make it better, or a function option that does this for me. I have a sequence of 2D points that represents a closed curve in the plane. The points are ordered and the distance between two consecutive points is constant (unlike in the code snippet which is only MWC). I want to smooth the curve. I have defined a Gaussian filter of a certain window. I first pad the closed curve so that the beginning and end overlap with each other, the size of the overlap being half of the size of the filter window. Then I apply the Gaussian filter and I go back to the original sequence.
syms x s;
f = symfun((1/(sqrt(2*pi)*s))*exp(-x^2/(2*s^2)),[x s]);
s = 2;
L = floor(5*s)*2;
M = L*2+1;
support = linspace(-L,L,M);
G = double(f(support,s));
closed_curve = rand(100,2); %different in original code, points are really equally spaced
closed_curve_ext = [closed_curve(end-L+1:end,:); closed_curve; closed_curve(1:L,:)];
closed_curve_ext(:,1) = conv(closed_curve_ext(:,1), G, 'same');
closed_curve_ext(:,2) = conv(closed_curve_ext(:,2), G, 'same');
closed_curve = closed_curve_ext(L+1:end-L,:);
Any help is appreciated!

回答 (0 件)

カテゴリ

Help Center および File ExchangeSmoothing and Denoising についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by