level 8
SeedRandom[2]
blot[smoothness_: 20, points_Integer: 10] :=
With[{fun = Exp[-smoothness #.#] &,
pts = RandomReal[1, {points, 2}]},
RegionPlot[
Total[fun[# - {x, y}] & /@ pts] > .5, {x, -.5, 1.5}, {y, -.5, 1.5},
Frame -> False, PlotStyle -> Black, BoundaryStyle -> Black]]
img = ImageAdjust@
DistanceTransform[
SelectComponents[
Binarize@ImagePad[ImageCrop@ColorNegate@Rasterize[blot[]], 10],
"Count", -1]];
pts = Catenate[
Select[Cases[
ListPointPlot3D[
13 ImageData@
ImageTake[
ColorConvert[Blur[img, 25], "Grayscale"], {1, -1,
10}, {1, -1, 10}]], {x_Real, y_, z_},
Infinity], #[[3]] > 2 &] /. {x_, y_,
z_} :> {{x, y, -z - 3}, {x, y, z}}];
ListPointPlot3D[pts, AspectRatio -> Automatic]
点集为pts,构成一个光滑闭合曲面,谢谢各位大佬了。
2020年02月19日 09点02分
1
blot[smoothness_: 20, points_Integer: 10] :=
With[{fun = Exp[-smoothness #.#] &,
pts = RandomReal[1, {points, 2}]},
RegionPlot[
Total[fun[# - {x, y}] & /@ pts] > .5, {x, -.5, 1.5}, {y, -.5, 1.5},
Frame -> False, PlotStyle -> Black, BoundaryStyle -> Black]]
img = ImageAdjust@
DistanceTransform[
SelectComponents[
Binarize@ImagePad[ImageCrop@ColorNegate@Rasterize[blot[]], 10],
"Count", -1]];
pts = Catenate[
Select[Cases[
ListPointPlot3D[
13 ImageData@
ImageTake[
ColorConvert[Blur[img, 25], "Grayscale"], {1, -1,
10}, {1, -1, 10}]], {x_Real, y_, z_},
Infinity], #[[3]] > 2 &] /. {x_, y_,
z_} :> {{x, y, -z - 3}, {x, y, z}}];
ListPointPlot3D[pts, AspectRatio -> Automatic]
点集为pts,构成一个光滑闭合曲面,谢谢各位大佬了。
