Deform a 2D mesh based on a contrast image

This seems simple, but I cannot figure out a simple solution. I want to get a flat mesh to expand and “compress” in 2D (not height field), based on black and white values.
Similar to this image … Any hints?

did you try this ?

Can’t you use point fields to move the vertices?

Deconstruct Mesh to get vertices.
Move them according to the field vectors in XY only.
Construct Mesh from new points.

Thanks Laurent! I’m looking at your shrinkbycolour3 script, what I need goes in that direction. I have never used Kangaroo, but I give it a try.

Looking into it @martynjhogg, thanks … I’m new to this approach so looking for similar answers in the forum. Do you have any pointers on examples/tutorials for doing something like this.

Looking again at this, the shrinkbycolour example that @laurent_delrieu has suggested by @DanielPiker is probably better.

The way I suggested can pull mesh vertices towards points but it’s hard to control and stop points overlapping etc.

ShrinkByColour outputs lines though, not a mesh, but if you want to end up with lines for a CNC process like laser etching or CNC router then this method is excellent.

Set the IMG component to point at the image you want to use. Set the BooleanToggle to TRUE and the lines are tensioned according to the lightness of the input image.

I don’t think you can get a mesh out of this as it stands because the ShrinkByColour component outputs lines. (12.9 KB)

1 Like

Getting a mesh out is just a matter of connecting the mesh to the Show component. I’ll upload a file later.

Here a version that outputs a mesh.

There is a slider which gives you the option of using a less dense mesh for the output than the one actually used to calculate the shapes (which can give a smoother result). (57.5 KB)
and the image input used


Thanks @martynjhogg, @DanielPiker this all works too nicely. I am tweaking and testing. Thanks again.

Just out of interest, what is your project?

I am designing custom lattice structures that adjust to b/w or color saturation images that result from a pressure sensor. With the adjusted mesh (expanded and compressed areas), I am creating a twisted box array and from there a gyroid structure. But I am new to many of these concepts, especially kangaroo. So, I am trying to learn and understand … see what results are achievable. The final structure is then 3D printed. At the moment looking into getting more differentiation between the expanded parts and the compressed parts, without generating overlaps.

1 Like

MeshOutput (64.2 KB)

Hi, thank you for sharing the wonderful goal!
It shows the error in R8.
I actually collected the same goal from your other post. That one works fine most of the time, but occasionally it will show the exact same error message.
I wonder if there is a remedy for this error.
The K2 goal in the above definition is from your other post.
Thank you very much!

not sure if it would yield desired result, but the weighted voronoi by Super Delaunay | Food4Rhino could maybe be used as well. extract brightness values from the image and with some remapping apply them as weights for each point to the voronoi. It if works, i think its fast :slight_smile: And from there you can build you mesh