Heightmap extrusion/displacement for low-relief chocolate

Hello,
I am looking to find the proper G’MIC command to have an OBJ file of the heightmap below where exactly black pixels yield no polygon at all. This should yield a sort of low-relief chocolate bonbon or neapolitan with rounded borders.


I have tried extrude3d, isosurface3d, elevation3d but they either don’t care about the text background (extrude3d), do not seem to work or put polygons for black pixels. Material is not important in the OBJ output.

If the command fulfills the need and is fast enough with not too high resolution, it could be used within a Python Flask webservice for chocolate previsualization before order, and a gmic-py public tutorial. My idea is to avoid using Blender3D as a model generator behind a web API and avoid putting 3d model-generation computing onto the web browser. A webGL viewer would be used for display but not model-generation.

Expected result is like https://3dp.rocks/lithophane/ 's output models but instead with the model’s contour depending on the input picture, not just displaced and projected on top of a square or sphere etc… That online wizard is in full Angular 1 JavaScript, fully on the web browser’s end.

Example 3dp rocks lithophane configuration:


Example result model, but base corners are not rounded on the XY(ie. base) plane, which is not what I want:

Example gmic 3.x command:

~/Productions/pix2chocolate_gmiconly$ gmic elevate_linear_gradient.png elevation3d. 0.75 output_obj elevate_linear_gradient.obj
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input file 'elevate_linear_gradient.png' at position 0 (1 image 1735x3002x1x4).
[gmic]-1./elevation3d/ Generate 3D elevation of image [0], with z-factor 0.75.
[gmic]-1./ Output 3D object [0] as Wavefront 3D object file 'elevate_linear_gradient.obj' (with materials).
  > File 'elevate_linear_gradient.obj' (5208470 vertices, 5203734 primitives).
    - Export vertices: Done.  
    - Export materials: Done.  
    - Export primitives: Done.  
[gmic]-1./ Display 3D object [0] = 'elevate_linear_gradient.png' (5208470 vertices, 5203734 primitives).

[gmic]-1./ End G'MIC interpreter.


But… corners are not nice to see and the polygons count is extremely high… I have not found a resolution parameter for the elevate3d command.

Attached is the Inkscape SVG file for generating the heightmap:
chocolate_bonsoir_heightmap

Such SVG XML files are very easy to generate from open-source online vector wysiwig editors…
The pipeline would be: wysiwig in-browser svg-like editor > svg file with blurred elements to mimic height elevation gradients > REST API > gmic(-py) generation > 3d model response > in-browser webGL viewer.

To have fun, a test with G’MIC elevation 3D

3d

Edit : 20220814

Another test from the SVG > to PNG > G’MIC