Creating depth map images using google

here a new list of bullet points to try using meta , what ive found is it is easily confused ,once thread gets to long, it makes mistakes even for the most simple question download the best image you have so far , open new meta ai page ask a question it does it in like 10 seconds correctly

Generic True Depth Map Process - Any Image • Step 1 - Lock reference: Use only the single image user provides in current turn as ground truth. Do not pull elements from chat history • Step 2 - Define depth rule: True depth map = grayscale only, WHITE = closest to camera, BLACK = farthest, no lighting or shadows • Step 3 - Identify depth layers for ANY image: foreground subject = white to light gray, midground subject = mid gray, background = dark gray to black • Step 4 - Map forward areas correctly: jeans, boots, hands, closest object edges, nose, front legs must be lightest - check user example • Step 5 - Preserve ALL fine detail: straps, reins, bridle, buckles, hair, fabric folds, small props - do not simplify or erase • Step 6 - Preserve environmental effects: dust, smoke, crowd, flags, banners, barrels, fences - assign correct depth value based on distance • Step 7 - Dust / smoke / fog near subject = same light depth as subject legs/feet causing it, not dark • Step 8 - Crowd / stands / walls / distant objects = dark gray to black because far • Step 9 - Keep solid objects fully light top to bottom if they are close - no dark bottom gradient on close barrel • Step 10 - Grayscale only: remove all color, smooth gradients, no texture shading • Step 11 - Soft-roll top edges only when requested: add 2-5px gentle bevel/gradient to outermost white contour where it meets black to avoid sharp 90-degree cliff for 3D relief / CNC • Step 12 - When rolling: keep internal details crisp - only soften absolute outer top edge, not reins, straps, or internal lines • Step 13 - Do NOT add or remove objects unless user explicitly asks - if user says put dust/crowd/flag back, restore at correct depth • Step 14 - Final check before output: closest = white? farthest = black? all details present? no history bleed? top edges rolled only as requested? • Step 15 - Export: Provide depth map as high-res grayscale, keep original aspect, ready for lithophane / STL / displacement

I find this pretty interesting…I’ve yet to try carving but am itching to (and my wife wants some custom shelves which are probably going to be my excuse to start experimenting.)

But I’ve also been doing quite a bit of work at work lately making a custom agent for our team to use with various image/video models for generating images. So I thought it might be fun to do some experimenting. I the agent I built uses fal.ai for the models since they have a bunch of different models for different types of media so it’s really easy to switch between them. I basically started with this project: GitHub - AgriciDaniel/banana-claude: AI image generation skill for Claude Code - Creative Director powered by Gemini · GitHub but worked with claude to change it to use fal.ai instead of googles models directly.

Basically it lets me give claude a very simple request and it will expand it into a far more detailed/structured prompt and let me test it across multiple models or work with a model of my choice to get the results I’m looking for.

So I asked it if there were any models that were particularly well suited to this task. And it identified a few with Hi3D Image to Relief (Image to Image) API on fal as the most likely to be a good choice.

I gave it a try and it didn’t do horrible:

But it did seem a little soft and lacking in detail compared to the google attempts from @Terry_O_Sullivan’s prompt.

But for no prompting just using a specialized model It doesn’t seem that bad. You can try it direclty through the fal.ai website - you don’t have to use the full API to use their models.

But since it seemed softer and less detailed than the other versions in this thread I gave it that prompt and asked if it could suggest any improvements which it then ran with a few models to compare:

That’s @Britt 's version first which I gave it as a baseline though with a request to minimze the “glow” that got worse in his 2nd test. (which it said was due to the request for an “ultra soft rollover” and “Broad, smooth, sweeping gradient”)

The second is the modified prompt claude suggested with NanoBanana2. Third is with Nano Banana Pro, and the last was with the hitem3d image-to-relief

The NB2 version looks crispest to me - but it suggested that the NBPro version is most suitable for engraving.

Here’s the full versions of those:

NB2:

And NBPro:

The modified prompt it used was:

Convert this engraving into a grayscale depth map of a sculpted bas-relief carving, the kind a CNC router reads as a Z-height map for a carved wooden panel.

Height encoding: pure white is the highest point closest to the viewer, pure black is the lowest, furthest plane. Use smooth, continuous tonal gradients. Render as a depth map only: no lighting, no shading, no cast shadows, no ink lines or
hatching; the engraving strokes should become physical form, not surface pattern.

Layering: the stag and the rock outcrop it stands on are the highest layer, bright values. The pine trees and the near hillside sit one clearly distinct step lower in mid-grays. The distant mountains and lake are low and dark. The sky is the
base plane: a single flat, even, very dark gray.

Interior detail: inside the stag and the rock faces, keep crisp volumetric form: muscle structure of the shoulders and legs, the layered ruff of neck fur, facial planes, eye socket and muzzle, rounded antler beams and tines, and the faceted,
stepped rock blocks.

Edges: the edge of each form rolls over like a carved surface: the stag body and antlers curve down smoothly toward the background, the way a rounded carving meets its base. That rolloff happens inside the silhouette. Outside the silhouette, the
background begins immediately at its own flat value. There is absolutely no glow, halo, aura, bloom, light haze or bright rim around the stag, antlers or any object; the sky right next to the antlers is the same dark tone as the sky everywhere
else.

It’s interesting that the NB2 version kind of wound up with an anti-halo where it’s a black glow instead of a white glow. (Though I wonder if that would help give good separation in a carving…guess I may have to start figuring out mill mage next to preview :smiley: )

With the suggestion to rewrite the Layering and Interior detail paragraphs to suit other images. Which is one of the nice things about this agent/harness approach - I could extend it to customize those parts per image itself.

It could easily as for them to be less detailed. I’m just not sure where the happy point is since I haven’t actually tried carving yet.

The other nice thing about the harness I’m using is it can route between multiple models. So I can have it use one that’s good at background removal remove a background, one that’s good at editing images make any changes, and finally have it use a final one for the actual height map generation. It also gave me a python script to convert them to STL (since I’ve only used Estlcam for cam so far and as far as I know it can take STL’s but nto greyscale)

Preview in Estlcam looks decent enough … though I don’t have any proper engraving bits setup yet so this is just a 1/4" roughing end mill and 3mm finishing end mill:

And now I want to go deeper with this and get my harness to a point where it’s clean enough and usable enough I can share it. It has a few half finished features to make things like nice organizing work into projects and a start at a web based interface for previewing output and giving feedback between revisions. (those really help when you start doing multiple step processes. For example I did some silly fake commercials by having it generate a script, then generating stills for each shot so I could pick from 3-4 options before using them as a seed to generate video and then having some voice/music models generate audio and finally had it use remotion to script it all together into a finished video.)

I was going to try this on the latest picture that I used Gemini on. Unfortunately, it wants me to pay to render a depth map.

Here is what Gemini came up with:

Original image

Cropped image with background removed

Gemini depth map

MillMage 3D Relief preview.

Here is what I asked Gemini to do, and the responses from Gemini after each prompt. I didn’t use Terry’s script on this.

Me: Create a 3d depth map from this image for cnc carving.

Gemini: To optimize this map for your carving software, please let me know:

  • What CNC software are you using? (e.g., Vectric Aspire, Carveco, Fusion 360)
  • Do you want the orange collar completely flattened/removed from the carving, or should it remain a distinct physical layer?

Me: Millmage, remove collar

Gemini: To ensure the relief carving processes perfectly in MillMage, would you like to:

  • Adjust the overall depth contrast? (e.g., make the snout and tongue pop out further forward)
  • Add a raised or recessed border (oval or rectangular) around the dog profile to act as a frame for the carve?
  • Leave the file exactly as it is for immediate toolpath generation?

Me: Make the snout and tongue pop out further forward, add a raised oval border

Gemini:To ensure this finishes exactly to your specifications in MillMage, let me know if you would like to:

  • Adjust the thickness or profile of the oval border (e.g., make it wider, half-round, or sharp-edged)
  • Invert the map into a negative mold cavity instead of a positive relief
  • Add custom text along the top or bottom arc of the oval border

Me: Enlarge the border 15%, add custom text at bottom “Aya”

This depth map came out really well with very little prompting from me compared to the previous 2 I had done.

I do like theses prompts, blunt and to the point, maybe that’s what im missing in some of my commands NO

that definitely looks quick & painless, will have to try gemini. when you zoom in on preview , does it look fairly smooth or grainy , like it has picked up every hair of dog , was finding with meta would be to fine detail so carve would be say 18 hrs , if you asked to smooth it a bit would go to other scale , it couldn’t determine the happy medium

this is what i get trying gemini

fal.ai isn’t free - but the rates are pretty low. That Hi3D model is $0.2 per generation. The google models are actually some of the most expensive when you use them directly instead of through a gemini plan…but they are some of my favorites. The “free” gemini is very powerful by itself no doubt.

One thing my harness pointed out about the Hi3D model compared to the google model was that it does 16bit output while google was only doing 8bit. So there was more definition in the height map - probably not important for most uses and I’m sure that level of difference would get lost in the actual carving. Though - Playing with gemini directly I do see it offered me a 16 bit PNG so it probably can do it when specifically asked to.

I did a little bit of experimenting with trying to generate something for my wife’s shelf. But even gemini was having a hard time doing the initial design:

No matter what I tried it kept getting smudges and mistakes in the bitmap. I had slightly better results with a model designed for SVG work to create an initial design but didn’t have time to refine it to what I wanted and the model didn’t like the really wide aspect ratio.

I just gave Gemini a try and had honestly frustrating but kind of humerous results :rofl:

Original image:

I tried an all in one “Can we issolate the dog in this image and remove the background then prepare a height map suitable for 3d engraving with millmage and add an oval around him with his paw hanging over the edge of the oval.” and got disappointing results:

Yikes disembodied paw! And textured oval, and not sure why it added that text in the lower left at all.

So - stepped back and asked it to just remove background and isolate dog:

Side note - I didn’t notice it left part of the couch as the preview gemini showed was apprently cropped:

Then asked for just a height map and got something decent looking:

So asked for the oval and…things went south again:

Holy modified paw batman! Let’s try and change that…

Yeah…I made some typos but that’s still way off from my request.

I tried a few more times and just kept getting the same stretched out paw even after telling it not to modify the dog.

I may try with my harness later…but need to focus on actual work right now :smiley:

I did mine on my laptop. Gemini uses Nano-Banana2 using Chrome on the laptop.

Flash-Lite is for a phone I believe.

I cut out the 3D image of Aya today. It turned out pretty good.

I should have posted this a couple of days ago but didn’t… because I’m lazy and a true procrastinator. And I needed a break from MPR&P… so took some time to play.

I messed with this depth map stuff a little more than a year ago… and have forgotten almost all that I ever knew. And it’s maybe not even relevant since it’s really not about generating depth maps so much… but about the way I went about “carving” them. And since you guys have provided a few depth maps to play with… I played with them and thought you might find it interesting as well. :wink:

These first few you’ll recognize from this thread… and a distinguishing feature is how the strong grain of the little yellow pine planks lend quite a bit more texture to the “carving”. Wood with less prominent grain would be better for this – maybe basswood, poplar, etc. – but I used what I had already planked out and had on hand.

Britt’s Aya…

and Jason’s NB2 and NBPro stags…

I thought the Terry’s hand pump and basin had some neat detail to try…

The rustic cabin and old man with dog is from grayscale bas relief prompts I supplied to SculptOK…



This bird on a dripping faucet is from an image posted by Marion Ferguson over on the Lightburn forum… and processed with Gemini or ChatGTP using Terry’s script IIRC.


I recognize these are not true “carvings” but still thought they are neat and are about as close to carving as I want to get. These are all about 80-80mm tall and take about 20 minutes to laser with my ~30W Roly LaserMatic engraver… using grayscale and running at 2000 - 3000 mm/min to get 3 - 4 mm max depth. I then scrub them under cold running water with a scrub brush and leave them on a sunny window sill to dry.

I’ll shut up now… but this has gotta be good for something?

:wink:

Thanks for sharing them David. They turned out really well. Do you think the banding in Aya’s pic is due to the wood grain or the depth map?

Thanks, Britt.

It’s not the depth map… it’s fine. It’s just a poor choice of wood for this kind of project. And recognize that the “depth” for a laser is really just a power level somewhere between min and max that will be affected by the varying texture and hardness of the wood at different points across the surface. You’re not planing off material at a given depth… instead you are burning way material that burns in an inconsistent manner. Better would be basswood, poplar, maple, elm, cherry, etc… woods that have little or no grain would be best.

The detail that can be had with the laser is what always amazes me… and I guess that is what I was really trying to demo. Not trying to get people to stop v-carving… just thought it might be of interest to see what a laser does with “depth”.

:wink:

Thanks for clarifying that the depth map is Ok. I think I will try it on my 20W laser and see how it goes at some point. It’s back up to 100 again here. I’ll wait until it cools down since I use my garage for the laser and cnc.