# Specifying different thickness for each graded contours of Mandelbrot Set so that I can export it as .STL file.

I am using Mandelbrot Set function in Mathematica to get the Mandelbrot plot. I want to 3d print this model, so want to specify thickness for each contour and then convert into .STL file. Is this possible?

• What Mathematica function are you using to create a Mandelbrot Set contour plot? ManderbrotPlot produces a raster plot, according to its documentation. Oct 31, 2018 at 22:27
• Can you provide some type of example of what you wish the output to be? In my experience the neat features of a M-Set are far too fine to be rendered with current 3D printers. Nov 1, 2018 at 15:28

## 2 Answers

Here's an approach based on converting the image to LAB and using the L channel

baseData = ImageData[
ColorConvert[
MandelbrotSetPlot[Frame -> None, PlotRangePadding -> None],
"LAB"
]
];

ListPlot3D[baseData[[;; , ;; , 1]], PlotRange -> All, Boxed -> False,
Axes -> False]


This won't print well at all because of the tiny spikes. You can also smooth some of that out if you want a somewhat more printable version

ListPlot3D[
BlockMap[
Mean@*Flatten,
Clip[baseData[[;; , ;; , 1]], {0.001, 1}, {1, 1}],
{3, 2}
], PlotRange -> All, Boxed -> False, Axes -> False]


Finally, if you are willing to figure out what L value each contour corresponds to, you can use Map to set things to that heigh

pts = ImageData[ColorNegate@Binarize@bild];
g = RegionPlot3D[
pts[[Sequence @@ Round@{i, j}]] == 1, {i, 1, #1}, {j, 1, #2}, {z,
0, 1}, PlotPoints -> 100, Mesh -> False, Axes -> False,
Boxed -> False] & @@ Dimensions[pts]
pts = Cases[g, x_GraphicsComplex :> First@x, Infinity]


This can be exported to STL via the built-in.

Modern alternatives are:

With[{h = 50},(*height*)
RegionProduct[ImageMesh[bild], MeshRegion[{{0}, {h}}, Line[{1, 2}]]]]


and

ImageMesh[Image3D[ConstantArray[bild, 50]]]


h is here pixel.

Export["Test.stl", pts, {"STL", "BinaryFormat" -> False}]

This example might not be complete on Import.

• OP wants to be able to specify a different thickness for each contour. This only provides a uniform thickness. Mar 11, 2021 at 17:46