Bas Relief Creation

Definition:

Bas relief is needed to CNC carve most 3D scenes, as the available (Z) depth of the CNC process is much less than the depth used in most 3D models. Coins are a good example of bas relief images.

A simple, ie proportional, scaling does not work well; most of the detail is lost.

Instead, a non-linear projection should be used. Typically these projections emphasize changes-in-depth, rather than absolute depth. Emphasizing this part of the depth data appears to trick, or allow, the human brain to infer the original depth information, making bas reliefs look more recognizable and “realistic”.

There are commercial programs that will do these projections, for example ArtCam and Vectric Aspire. They are costly.

BlenderCAM, free, has the ability to generate bas reliefs. The process is not straight forward.

There are several research papers and a few scripts out there as well.

In most cases the process steps are:

  1. Generate a depth map of the 3D scene. This is usually a grey-scale image where the shade of grey represents the depth or height. They are also called height maps, and Z buffers. Blender can be used to generate these.

  2. Apply a non-linear scaling to the image. “Height map” aware algorithms look at the 2 dimensional first and second order differentials- the 3D slope, and rate of change in slope, and adjust the heights based on this information. People have also had success with applying typical 2D image adjustments, such as gamma correction (so-so results) and unsharp mask (better) to the height map data.

  3. Use the adjusted height map to generate a CNC routing path. Vectric VCarve and CamBam can do this. Tests need to be done; I suspect both packages will generate “scanning” paths (across X, move down Y, continuously vary Z), which may not be good paths for milling. There may be a need to convert the adjusted height map back into a 3D model (STL) so that the CNC tools will generate smart milling paths- eg use adaptive clearing.

This projects goals are:

  • document how to create and save a height map (Z-buffer image) from blender
  • create/adjust/find software that will do the non proportional height scaling
  • document how to covert the adjusted height map into “safe” milling G-Code

References

BlenderCAM is alive and well!

It has been updated to work with the new Blender 2.8, which is a lot easier to use than previous versions.

The bas relief plugin hadn’t been updated, but I managed to tweak it so that it appears to be working.

I have an upcoming project to create a commemorative medal, and a bas relief carving will be a good fix.

So after several days of experimenting I’ve got a process that generates meshes from regular images:

Although the bas relief add-on is designed to work with depth maps generated from 3D geometry, as it is doing an analysis that highlights the changes (differentials) between heights, but maintain “plains”, it also works surprisingly well on standard pictures!

The image on the left is the raw JPEG (after background removal) applied as a depth map on a plane. Looks great as a lithophane, but the elevations are ragged, disconnected, and not at all pleasing as a carving.

A smoothed version, with the colour range crushed to a small range is better, but also has some unacceptable ridges and valleys (not easy to see in the rendering above.)

The two images that were filtered, feed to the bas relief add-on, and then given some more basic editing, really look like an engraving you’d find on a coin!

Aside: Some hints on how to generate depth maps from 3D geometry- https://blender.stackexchange.com/questions/56172/bas-relief-model-from-a-3d-model-scene/56224.

NOTE: in the process below, do each step as a duplicated new layer in Gimp!

The process I came up with was:

  • load image into Gimp
  • downsize to a reasonable size
  • remove background (wand select, mask editing, G’MIC interactive foreground selection)
  • set to 32 bit float, gray scale; you may need to tweak the display processing to give more gamma.
  • save removed background shape into a channel so it can be used for removing artifacts in the background later
  • Run the following in G’Mic. Set output to new active layer, and use current active layer as the input: then you can do several steps without re-starting G’Mic
    • sharp abstract
    • tone map (fast)
    • anisotropic smooth
  • export as EXR (PNG is 8-bit!)
  • import into Blender
  • run the bas relief add-on (set blendercam as renderer to see it!) Default settings work quite well
  • generated image will be saved as an EXR
  • import the bas relief generated EXR info Gimp
  • apply levels/curves to crush the range. There’ll be some very dark and very light areas. Need to clamp these to the “most common” heights for the highest and lowest points (based on your knowledge of the missing depth info that’s not in the image.)
  • heal/dodge/burn/blur
  • use the channel saved above to select the background; remove it and fill it with the “lowest” gray found in the rest of the image
  • channel -> selection, add border
  • blur the edges so there’s no a vertical cliff at the edge of the carving. Curvature blur worked very well for this

You can export to EXR and update in Blender to see the effects.

When you’re close, bake the displacement map into the geometry (‘apply’ the mesh displacement modifier.)

Final tweaks are quicker/easier to do with Blender’s sculpting tools.

Also tried this amazing AI: 3D Face Reconstruction from a Single Image. The generated mesh doesn’t have enough points to be used as input to the bas relief. With smoothing/tweaking it works, but is to indistinct to easily identify the person- which makes sense give how it works!