How to generate random smooth 2D closed curves/shapes

36 ビュー (過去 30 日間)
Roy Velich
Roy Velich 2020 年 8 月 11 日
回答済み: Moreno, M. 2022 年 4 月 15 日
Hi,
I would like to know how can I generate a collection of random 2D closed smooth curves. I thought about generating a random 3D surface with random peaks, and then intersecting the Z=0 plane with it, and extract the largest contour, for example. I just not sure how to do it practically... it is the correct way? I would love to get some guidance.
I am look for a result in this fashion:
Thanks
  3 件のコメント
Roy Velich
Roy Velich 2021 年 2 月 4 日
Yes, I endded up downloading thousands of random images from the web, applying Guassian blur on each of them (with a collection of kernels) and extracting closed level curves from the blurred images. I can give you my code if you want.

サインインしてコメントする。

回答 (2 件)

hosein Javan
hosein Javan 2020 年 8 月 12 日
If you are familiar with bezier curve, you can do it easily by setting random values for points coordinates.

Moreno, M.
Moreno, M. 2022 年 4 月 15 日
The function bspl is creation of my own and is available in these 2 links:
Given a closed Bézier polygon at which the initial and final points are coincident, and the adjacent points to the ends of the curve are colinear, the generated Bézier curve is closed and smooth. If you want your curve not to self-intersect, then your initial set of data points should be the bounding points of a point cloud. If the adjacent points to the end of the curve are equidistant, then your curve has C3 continuity:
tiledlayout(2, 2)
for i = 1 : 4
X = rand(10, 2);
X = X(boundary(X), :);
X(length(X) - 1, :) = 2 * X(1, :) - X(2, :);
X = bspl(X, 1e3);
nexttile
plot(X(:, 1), X(:, 2))
axis equal
end

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by