Export 3D objects to Wavefront .obj format

Is it possible to turn a 3d image into a 3D object via threshold? I feel like I can finally open up to creating 3D fractal.

EDIT: To expand, each pixels are boxes. And I would like the united boxes in 3D. Then export.

Could you provide a visual example?

That’s a example if I were to create a 3d sphere model using threshold. Each boxes are pixel.

There is something more advanced in G’MIC, to convert volumetric images with dimensions w\times h\times d to a 3D mesh : command isosurface3d.
Example for a 3D sphere:

$ gmic 100,100,100 set 1,50%,50%,50% distance 1 lt 50% isosurface3d 0.5

gives:

isosurface3d uses the well-known Marching Cubes method to extract a 3D surface from an isovalue in a volumetric image.

And if you blur the volumetric image a bit, you’ll get more smooth surfaces:

$ gmic 100,100,100 set 1,50%,50%,50% distance 1 lt 50% b 3 isosurface3d 0.5

2 Likes

Another example:

metaballs3d :
  100,100,100,1,"
    const s = 10;
    pot(cx,cy,cz) = gauss(x - cx,s,0)*gauss(y - cy,s,0)*gauss(z - cz,s,0);
    pot(30,30,50) + pot(50,50,30) + pot(60,30,70)"
  isosurface3d 30%

1 Like

Now, I got another idea. rep_dla+skeleton+distance=fractal landscape. Brilliant idea and good for this, right? I should try multithreading rep_dla first though.

@myselfhimself, in current developpement branch of G’MIC 2.9.5, command elevation3d has been re-implemented as a custom command (rather than a native one as before).
It has a new option (second argument) to allow the generated 3D elevation to have a solid base , which is something you were looking for.

In your case, I guess that your elevation factor should be negative. Example:

$ gmic 0 text Chocolate,0,0,48,1,1 b 1 n 0,255 elevation3d -0.02,10 o output.obj

generates the following 3D mesh:

If you want to test it, let me know if you get into troubles (or not :slight_smile: ).

1 Like

This is beautiful for adding floor thickness !!! Thank you for fiddling!!!
For my target application (mold negatives or positives for chocolate and pastry 3d printing or CNC machining) colors are not very important but it can be for other people. In such an application, the simplest similar tool name is lithophane http://3dp.rocks/lithophane/ , targetted at showing a picture trough light sub surface scattering, and is a technique fancied by many makers and DIYers.
Feel free to upload or send me a .obj of your mesh somewhere so that I can check its mesh for 3d printing.
I can also send your proper heightmaps with or without vacuum forming vents and various levels of “complexity” for my target application… I feel like you are doing free development for me… :slight_smile: My apologies for being so specific in the use case I describe…

Sorry just missed that message!! Let me try that out this week thanks!!!

Hello,
check done with the 3d printing toolbox shipped by default with Blender (File > User preferences > Addon > type “print” in the search field, check the 3d printing toolbox addon, then select your object, left side open the 3d printing toolbox tag, hit “Check all” button), here on blender 2.79 (because I do not need to run the software GL variant on this old computer):

Generation was done with a locally built 2.9.5 prelease gmic-py

I can rotate the mesh 180 degrees on the x axis, the that the relief looks up on Blender’s z axis, and scale it 10x or 100x smaller so that it fits better on the scene workplane.

There is nothing non manifold, no double vertices, no holes, the non-flat face is here (enter edit mode (tab), face mode (ctrl+tab), click “Non flat face button” in the left pane to have it selected, then the “.” numpad key to focus on it) and nobody cares about it:

The overhang faces statistic is not important, when clicking the related button in Edit mode > Face mode, one sees they correspond to the bottom surface’s faces.

Despite applying a Shade smooth:
image
The mesh looks very non-smooth… because there are hundreds of materials assigned to it:


And also many textures:
image

For video games (I worked on Half-Life mods when I was teenager), we would have 1 material per separatable 3d object and 1 or more textures per material. In the case of this low-relief, there could have been just 1 material and 1 UV mapped texture only.

Here is the mesh with a default smooth look after all materials removed:
image

The fact that the mesh with duplicated faces/vertices is closed and looks good when smoothed just brings me to thank you very much David!!! This is enough for 3d print and CNC-ing makes want to write a Python example for gmic-py + flask for building up a custom online chocolate previewer before delivery some day !!

Thanks!!

1 Like

@myselfhimself, you can disable the automatic generation of materials by specifying 0 as an output option, when saving the .obj file :

$ gmic ... -o output.obj,0

This also generates smaller files, so useful if you don’t want to export G’MIC materials at all.

1 Like

Super thank you!

G’MIC for chocolatiers.

1 Like

This is a question in the back of mind:

Is there a tutorial that introduce coding 3d objects in gmic? Vertices, faces, etc. All I know is isosurface3d which is useful for 3d fractal creation.

Maybe this helps

2 Likes

There is also this tutorial :
https://gmic.eu/bouncing_balls3d/

I want to try out this elevation 3d with vents generated by Inkscape dotted-line text outset … (dots which allow vacuum-air to pass through and increase chocolate mold precision:).
image

Example from industrial design course slides:

The big block disc at the top left corner is also a way to ensure that a hole is created… assuming that possibly black = no volume (or … my question is how to control elevation3d so that a color provides no volume == is a hole).
svg and png counterparts below
lithophane_with_vents

I have got a crash with the latter png:
image

Python 3.7.5 (default, Apr 19 2020, 20:18:17) 
[GCC 9.2.1 20191008] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gmic
gmic-py: If you do not see any text for G'MIC 'print' or 'display' commands, you could '!pip install wurlitzer' and if under an IPython environment, run the '%load_ext wurlitzer' macro. See https://github.com/myselfhimself/gmic-py/issues/64
>>> gmic.run("/home/jd/Productions/GMIC/lithophane/lithophane_with_vents.png elevation3d -0.02,10 display")
[gmic]-1./ Display image [0] = '('CImg3d':y)', from point (0,266742244,0).
[0] = '('CImg3d':y)':
  size = (1,533484488,1,1) [2035 Mio of floats].
  data = (67.5;73.5;109.5;103.5;51.5;100.5;-83.1803;-83.1803;0;0;-0;1;(...),1;1;1;1;1;1;1;1;1;1;1;1).
  min = -83.1803, max = 524287, mean = 1478.6, std = 18961.3, coords_min = (0,6,0,0), coords_max = (0,135959176,0,0).
Killed

(the Killed is not my killing, but G’MIC + Python crashing altogether)

Trying at 500dpi instead of 1000dpi, and using display3d instead of display, I see nothing:



My computer is very slow at displaying something.

Is there a color for 0 elevation or hole?.. I would like the black color to be boolean substracted somehow…

Hello Jonathan,

Note that elevation3d always produces a 3d object that has at least W\times H vertices and as many quadrangles (and the double if you activate the base feature).
So, for an image 6595\times 3370 , it means at least 22,225,150 vertices which is actually a quite big object (particularly if you want to output this as an .obj file, which is ascii-encoded by nature). This would lead to a huge output file
(I don’t even think Blender could reasonnably re-import it, considering that its Wavefront import module is not really optimized).

1 Like

For stuff like that, CAD is often more reasonable than using gmic. I’m sure basic CAD is enough.

1 Like

I will publish something this year on filament 3d printing slicing parameters which makes a 3d print porous and spares oneself to do any vents on the CAD side. This is an intrinsic property of filament 3d prints, which can be exaggerated in the perspective of thermoforming for chocolate molds-making etc…