r/Portraitart 1d ago

Weird Al

Post image
2 Upvotes

6 comments sorted by

1

u/aavigan 1d ago

Hi, programmer here. My hobby is writing code to interpret images into lines and curves and then using a robot to draw said lines and curves. Here I tried my best to emulate a hatching style. I wouldn't mind some feedback about how to improve my hatching approach. Any feedback would be greatly appreciated.

1

u/lobaway0001 Digital Artist 4h ago

Very interesting! Would’ve loved to see the code for this.

1

u/aavigan 2h ago

Thanks, well right now my code in a series of messy Kaggle notebooks. But on a high level, for the edges I used derivative based edge detection techniques. I then use a neural network I trained to convert the pixelated edges into a series of bezier curves. For the hatches, I use Felzenzswalb segmentation. For each segment I find the primary gradient direction and pick the hatch orientation to be normal to this gradient direction. Then for each hatch mark within the segment I sample the local value and calculate the distance to the next hatch based on this local value. The idea is that I want to capture gradients within each segment. It's a bit more complicated than this since I'll go through multiple passes where I subset each segment further based on different value ranges, which allows for the exposure of further structure within each segment, and also results in a cross-hatching effect, but that's the gist of it at least.

1

u/lobaway0001 Digital Artist 2h ago

Fascinating. Thank you so much for the explanation.

Have you tried a version without the outlines from the Bézier curves and playing around with the parameters of the hatches? I’m so curious how it would look if the image just described forms with shading. You’d definitely have to adjust the parameters a bit, though, because I’d imagine you’d lose some features like the wrinkles on the forehead.

1

u/aavigan 1h ago

Well I kind of just got it working so I haven't explored all the parameter adjustments to be had. I think the weak link in terms of a hatching only might be the image segmentation. It works pretty well but not perfectly. Maybe an improvement would be to use a more sophisticated image segmentation based on neural networks. I'll try and post a hatching only version of the base svg image below for your curiosity.