問題は、ノイズに特定の特性を持たせたいということです。曲線に沿って多くのサンプルがあり、それらを「接続」したままにしたいとします。かなり滑らかな結果が必要で、曲線を閉じたままにしたい。したがって、順番に:ランダムウォークノイズはポイントを接続したままにします。ローパス フィルター処理されたノイズは、曲線を滑らかに保ちます。そして、ノイズ エンドポイントを (スムーズに) ゼロに修正して、閉じた結果を確保します。以下は、16 種類のノイズ (4x4) を生成し、全体的なスケールとフィルター処理の全体量を変化させるコードです。データの「サンプル レート」と形状の全体的なスケールに基づいて、これらの選択の両方を調整する必要があります。
% Generate sample data
[x,y] = pol2cart(0:0.01:2*pi, 1);
% Pick a set of 4 noise scale, and noise filter values
scales = [.01 .05 .1 .5];
filterstrength = [.1 .5 .9 .98];
% Plot a 4x4 grid, picking a different type of noise for each one
for i=1:4
for j=1:4
scale = scales(i);
f = filterstrength(j);
% Generate noise for x and y, by filtering a std 1 gaussian random
% walk
nx = filter(scale*(1-f), [1 -f], cumsum(randn(size(x))));
ny = filter(scale*(1-f), [1 -f], cumsum(randn(size(y))));
% We want a closed polygon, so "detrend" the result so that
% the last point is the same as the first point
nx = nx - linspace(0,1,length(nx)).*(nx(end)-nx(1));
ny = ny - linspace(0,1,length(ny)).*(ny(end)-ny(1));
subplot(4,4,4*(i-1)+j);
% Add the noise
plot(x+nx,y+ny);
end
end
その他の変更可能な点: 変形のスタイルに影響を与えるフィルター シェイプにはほぼ無限の選択肢があります。