Using code lying around in gptoolbox it was easy to whip up a little function that converts a binary image into a 3d-printable stencil.
I've added a new function bwstencil.m
to gptoolbox. Here're the simple contents:
imh = imfill(im,'holes');
im = imresize(im,2,'nearest');
[V,F] = bwmesh(~im,varargin{:});
[V,F] = extrude(V,F);
[V,F] = remesh_planar_patches(V,F);
Notice that I'm removing "islands" (regions that would be part of the stencil but not connected to the boundary). You can see that the eye of Hans Hass above has been removed in the stencil.
For this example, I've 3D printed the result as a proof of concept:
In retrospect, for this example I should have created the opposite stencil if I'm painting black on white:
and the physical proof: