Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Tool that turns your images into plotter-like line drawings (javier.xyz)
405 points by javierbyte on May 20, 2021 | hide | past | favorite | 74 comments



Nice! I did something like this a long time ago: http://theartbot.com I wrote a couple algorithms but the best one basically treated the darkness of the image like the altitude in a map, then drew contour lines. I also physically built the plotter.


That's really neat! Is the source of the path generator available anywhere?


Oh that is a beautifully simple trick, I love it!


That's really cool!


Hint: generate 2 or 3 images from the same photo with different "Lines" settings, then stack them with "multiply" blend mode and some color overlays. Example: https://cdn.vlad.studio/d376f5d1f3e3142028e2bfb8da134346.png


There's a fun and vibrant plotter art community clustered around the AxiDraw and similar low cost at-home plotters. Lots of fun stuff, including several image converters like this.

Just yesterday I was playing with the Flow Imager plugin for VPype. Similar trick of using line density, but in this case it's using a randomized curved flowfield for texture. The fun thing is the experimental "flow along image edges" feature where you get some lines tracing edges in the original picture. https://github.com/serycjon/vpype-flow-imager


Just a warning. If you upload your own headshot in the standard light-on-light linkedin background style. You will come out looking like a horror film drawing. There isn't enough contrast so it makes your face very dark and jagged.

I love it.


But I thought of that as a feature: it's great to make cursed images!


For anyone on Brave or Firefox with protection enabled: you have to turn it off, because canvas randomisation will just result it in it permanently drawing a mess of lines covering the entire square forever.


I run brave and did not experience this issue.


Why does this feature exist?


webgl/canvas is used for abusive fingerprinting for tracking you through different brosers, checking what GPU you use, persistent cookieless re-association


I thought it was just taking a while lol


This is great! I just created a pen holding adapter for my 3d printer so I can do some plots. I still need to find a good way to efficiently convert SVG files to gcode, but this will be a good start.

Inkscape has a gcode generation tool, but it requires some tweaks to work on my prusa 3d printer. Still a work in progress!


It's just a list of X, Y coordinates...

An untested python one-liner:

    '\n'.join(["G0 X"+x+" Y"+y for x,y in coords])
Grab the code for homing and stuff from the start of another gcode file that works.


Svg is typically a lot more complicated than coordinate points... https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Pa...


If you can use an editor like Inkscape to flatten the image (by recursively ungrouping until every path is under the top-level <svg> tag), you should have a bunch of paths that share a coordinate space. There are pathological cases like images that use CSS for positioning, but for most cases this will work.

Then you can use something like svgpathtools (https://github.com/mathandy/svgpathtools) in Python to loop over the paths and get the coordinates.

In case it's useful, I have an example svg to gcode converter here: https://github.com/paulgb/penkit/blob/master/penkit/polargra...

It is for driving a polargraph-style plotter, so it includes a coordinate transform that GP does not need to do.


(In the context of this post, which is just straight lines)


Yes, in this case the SVG is a list of coordinate pairs, should be fairly easy to extract.

https://github.com/javierbyte/pintr/blob/master/lib/svg.js#L...

* Update to add a link to the code that generates the SVG.


Curves can be a bit more complicated, plus generating the tool lift and moves! I also need to factor in scaling the drawing as well, plus speeds.


I used to do kind of the opposite art/bored in class thing. Doodle a bunch of random loops and lines. Then see if I could see a graphic of something in there. Sort of my own rorschach test. Then try to bring out that image by going over those lines. I can't be the only one to do this.


There are at least 2 of us :-)


3.


Number 4 reporting in


Number 5 here


half a dozen!


That's Numberwang!


Number 6 here


WOW this is cool! Going to take these files and put them into my lasercutter to see what I get. Really really cool thing!


Author here, that sounds soo cool! If you decide to try please let me know if you need any support!


You can check this work, very beautiful

https://github.com/ColCarroll/imcmc


Along similar lines, does anyone know of any good way to turn images into 'hedcut' WSJ style art? I've seen a few attempts but they don't tend to be very good, but it feels like something that's solvable, even if with a GAN or something.


WSJ have a site for this at https://aiportrait.wsj.com/.


Ditherit.com might do a decent rough approximation



Many years ago I wrote a program to convert images into Python scripts containing "turtle" commands. It's mostly a "cheat" based on "penup" and "GOTO(x, y)", but it can certainly be extended with smarter routing and optimisation algorithms: http://chriswarbo.net/projects/turtleview


Cool concept. I was trying to develop something along those lines. I'd like to feed an image to an algorithm and have it draw it, like this: https://www.youtube.com/watch?v=b8mwFDJgWR0 (but better)


Nice. This reminds me a lot of the 'String Art Generator' https://github.com/halfmonty/StringArtGenerator to recreate 'Pin and Thread' art.

Also see a ' weaving algorithm' here : https://github.com/i-make-robots/weaving_algorithm


The drawing process looks similar to the Venom transformation!

https://youtu.be/ph26HHK9FZg?t=36


cool concept, struggling to get good facial definitions.

https://a.tmp.ninja/obxwcfzK.png


Also, you can try reducing the "contrast" and "definition" settings. I think in this case the hoodie is taking a lot of the lines, I'll take a look, thanks!


Left image looks... interesting. I wonder whether this kind of artwork style has a name.


Can you try again with "Single Line" on?


Last month there was a lovely PlutoCon talk by Paul Butler on turning a picture into a plot.

https://m.youtube.com/watch?v=L2KdOJRR3Vo

His notebook is at https://plutocon2021-demos.netlify.app/paulbutler_penplottin...


Hijacking this post a bit, but does anyone know of a library or API service to convert SVGs to PLT (AutoCad Plotter format, based on HPGL) files. I need them to feed to a laser engraver.

I found convertio[o], but it doesn't support SVG embedded fonts so the text defaults to Times.

[0] https://convertio.co/svg-plt/


You would probably have better luck with SVG -> DXF, then open in AutoCad and "plot to file"[1].

https://forums.autodesk.com/t5/image/serverpage/image-id/400...


Inkscape does it. Change the text to paths (Path -> Object to Path)


Using mobilenet to detect facial features. Smart! Would suggest to go one step further and remove background before processing the face.


I wonder if the number of lines can be a measure of Kolmogorov complexity for an image...

Neat idea regardless.


It can certainly be a Minimum Description Length (MDL), which is a more general measure based on an arbitrary language (like "lines on a canvas").

Kolmogorov Complexity is the MDL when the language is Turing-complete; in that case I think the number of lines would be less interesting than the patterns in their arrangement. For example, we can arrange millions of lines in a spiral with very low Kolmogorov Complexity; whilst a handful of "random" lines could have a much higher complexity (since, without a pattern, we have to specify them all individually).

I mentioned it in a sibling, but I've written a very simple Python script which can be used as a test-bed for finding the Kolmogorov complexity of plotter-based images (using turtle graphics) http://chriswarbo.net/projects/turtleview


I dabbled with making something similar (transparent colored triangles, instead of lines), and had a lot of trouble getting something good.

Are there any text describing theories for doing this, or does everybody just trial and error their way through?


Cool.

Shameless plug: public domain image vectorizer

https://github.com/jankovicsandras/imagetracerjs


Nice way to generate images as headshots for accounts.


Great work!

Does anyone have any plotter recommendations?



+1 for AxiDraw if you’re not into restoring a vintage machine. I’ve been impressed with the build quality of mine (it’s going on four years with no issues).

I’m also a fan of the Saxi driver software. Paired with a Raspberry Pi, it gives you a web-based interface to an AxiDraw so that you don’t have to physically connect your computer to the plotter.

https://github.com/nornagon/saxi


I bought an Ioline Smart Trac 24 in. x 16 ft. in ~1998 and still works perfectly.

Here's a video of my plotter with a Sharpie:

https://drive.google.com/drive/folders/1IbZ4IPUEkU28_KBybtFo...

The best pens are the cheap ballpoint ones, unless you already have rapidographers. I don't like using Sharpies because they fade out in the middle of the drawing and you have to plot at low speed.

For example, I ballpoint outlined the staircase piece (linked above) and then I manually filled it in with a Sharpie.


sixteen FEET?

unfortunately sharpies aren’t very good. i use paint pens but they require significant pressure to open the valve behind the nib.

i am currently working on making my own markers...


Yes, 16+ feet with a simple mechanism.

It works like old typewriters. You align the corners of the paper and then clamp it.

Compare that, at the time, to the top of line of a Gerber (or 3M) plotter that was the only one able to handle 12+ ft. It used an array of sensors that at runtime adjusted the clamping-wheels pressure to keep the paper/vinyl roll aligned.

It was around $15-18K, while my Ioline was ~$1,300.

====

Could you tell me more about your markers?


So I have a 5' x 5' router table that I've modified to hold pens. I was using paint pens that require the nibs to be indented to get more paint to flow. They run out every 2-4 feet of line. It doesn't make great lines. Here is the machine re-loading a pen: https://www.instagram.com/p/CAD-tR1FU8J/

The "pens" i've made are a piece of delrin, with a 1/4" hole drilled down the middle and a piece of 1/4" F1 felt stuffed in there.

Here's the pen, sorta working https://www.instagram.com/p/COE-5dSpPAm/ and here is a longer drawing. you can see that it does still go from "too much" to "too little" as the line draws. https://www.instagram.com/p/CO4xW6QJLf2/

There are many, many other drawings in that profile. The thin line ones were made on an HP DraftPro DXL.


This one and a few more are awesome:

https://www.instagram.com/p/Byl2M0oJnwJ/

How do you code that? I'm trying to guess who inspired you: Duncan Brinsmead, Keith Peters?

===

About the pens, what happened to this brush: https://www.instagram.com/p/CB9iYKiJQ_A/

I'm thinking of a stronger felt, if they exist, with that brush shape.

===

Sometimes I use vinyl instead of paper because it's "easy" to clean any drips with q-tips and 90%+ alcohol.


The first one is a perlin vector field plus a deformation. I haven't heard of those artists but I will look them up.

On the brush: That's a chinese calligraphy brush. I spent a bunch of time making a bearing holder to let the brush swivel freely. It didn't work. The brush is very, very hard to get to behave. A human will tilt it slightly in order to get the bristles to go in the right direction, but the CNC machine keeps everything completely orthogonal. Works for pens but not brushes.

Edit: Keith Peters' algorithmic stuff ( http://www.artfromcode.com/ ) does seem to share a lot of the same underlying techniques. Perlin flow fields and hex truchet tiles especially.


I snagged an HP7475a off a local buy and sell site recently for $60. Came with a serial-to-plotter cable (which I only realized after splicing that cable, working out the wiring, and finding it was already the cable I needed :( )

Then I bought a cheap 3d printer and made a few of these, which fit the "fat" sharpies: https://www.thingiverse.com/thing:1261805

I need to adjust that print for "ultra fine" sharpies in order to do prints like what this website is producing though.


on older plotters:

there were many manufacturers. the ones that seem to be higher quality were HP and Roland. alps made a tiny one that was repackaged for commodore, atari, etc. and there were a plethora of other manufacturers (graphtec, houston instruments, and so on)

check ebay for "pen plotter" but beware that many are quite large and shipping will be expensive.

i currently have a HP DXL 7575a (a large roller plotter) and a Roland DXY-1150 (small flatbed). the roland was shipped but the hp i had to pick up locally. roland still has the manual on the site for the 1150, but it required a wacky power supply that took some effort to find. for HP stuff make sure it has RS232 and not HP-IB interfaces or whatever wacky stuff. also, different plotters used different languages. Roland's RDGL and HP's HPGL were easy enough to implement directly from the documentation...

many of them don't work because various belts have died. my HP fired right up.

one ongoing concern is that pens are no longer made so you have to fight over scraps on ebay.

modern plotters:

get an axidraw. it is nice and lets you use standard pens.


In the commercial space, I think "wide format printers" have totally replaced plotters at this point. They're basically big ink jet printers, though usually a bit more sophisticated (often 6 or more inks, including variants like "matte black" and "photo black" and "gray"). The quality is very impressive, you can literally print posters or frameable photos on it if you have the right paper.

"XY plotters" are still around but seem to be very niche (emulating hand writing) or DIY/hobby stuff.

I remember being in an engineering office of some sort as a kid, fascinated by watching the multi-pen plotter [1] drawing some kind of technical drawing. It had a pen carousel to change colors, and a little robot gripper to hold it. Finding information on these (from the 2 minutes of searching I did) seems quite hard, so it seems like they probably went out of fashion before the internet was a thing.

[1] https://encyclopedia2.thefreedictionary.com/XY+plotter


there is a big plotter enthusiast community. i was able to find full documentation for my late 80's plotter online easily enough.

plotters are still made today, they're just called "vinyl cutters" and don't have the pen changers anymore.

perhaps let the people who actually know the answer to the given question do the writing?


Hang around the industrial auction sites like Bidspotter. I just scored a 1980s-era Draftmaster II for $60 and it came with a pile of pens.


Pretty cool! Nice work, dude.


Love it, that's ace, thanks for posting!


Love it! That’s really cool


Pretty cool! Too bad most of my photos are in HEIC format and the site won't load them.


Thanks! Author here, are you testing with the HEIC files from your computers? To me it seems that iOS does not have issues with HEIC but probably it is doing some conversion before.


That's right. It was from my computer


Impressive. Very artsy.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: