What does HackerNews think of primitive?

Reproducing images with geometric primitives.

Language: Go

#20 in Go
If you are not in for the maths, you might also like this: https://github.com/fogleman/primitive

It redraws images with shape primitives and allows verctorization with a cool art style.

I think the “smallest” is the interesting part of this exercise. I think it needs to aim for lossless, with a sliding scale of quality that loses detail to the point where a human would notice. Consider an SVG from [Primitive](https://github.com/fogleman/primitive) and a mostly-transparent overlay containing the diff against the original image. Tuning Primitive is not entirely deterministic (like your algorithm) and I think a human interface for the front-end would allow a few knobs to erase parts of the diff in order to shrink the detail imperceptively. Seems like a good opportunity for a contest :)
This looks cool. It reminds me a lot of Primitive Pictures[0], coincidentally also written in Go, which supports other shapes besides triangles as well.

[0]: https://github.com/fogleman/primitive

I've started work down this path for a project I am working on. I downloaded some footage of satellites flying over the earth from NASA, used FFMPEG to extract each frame of the video, wrote a ruby script which runs over every image in a folder and calls primitive (https://github.com/fogleman/primitive) on each image.

The final step is to recombine it into a single video, which I haven't done yet because I haven't yet implemented video playback in the program I'm writing. In the meantime I'm just loading each image on the fly and playing it as a sprite animation. This results in low FPS but it gets the gist across.

https://www.youtube.com/watch?v=SBFGqxWYyvI&feature=youtu.be

I'm thinking it'd still look pretty choppy even if it was a 60 FPS video though. I'm not yet sure how I'm going to smooth it out. I can share the FFMPEG command I used / script I made with you if you want, but I'd have to find it first (this was maybe a year ago). I'm sure the script is garbage.

I do not believe the go program that I am using is deterministic. You can run the same command on an image twice and it will produce a different result. It might be possible to make it deterministic, but it's not something I've wanted so I haven't looked into it.

Shoutout to Michael Fogleman's primitive[1] for likely inspiring this work.

[1]: https://github.com/fogleman/primitive

The core of Primitive is open source, written in Go.

https://github.com/fogleman/primitive

Only the UI is closed source. It's written in Objective-C and basically shells out to the Go code.

Apparently, he published all of his code (I didn't see any mention of where). Regarding the color -- he mentions being careful with the palette, but I wonder how he gets it to turn out correctly (assuming it's RNG). It seems like you would have to keep generating new instances until you find one that looks pleasing.

One algorithm that comes to mind:

  1. Choose a color palette and initial resolution.
  2. Implement generative features at current resolution.
  3. Generate the output and until it "looks right".
  4. Increase feature resolution.
  5. Go to step 2.
In other words, one could keep generating prints until the locations and extents of the sampled colors "looks right", then keep the random seed and continue implementing finer details until they "look right", etc.

This will be the second time I drop this on HN this week, but check out Primitive Pictures[0] if you are interested in this kind of stuff. Also, I highly recommend Schiffman's YouTube channel[1] which goes into depth on how to get started with processing (and p5.js, the browser/canvas version). Note that the artist in the article learned how to do this by reading Schiffman's book, which is covered in a series of tutorials in the linked YouTube channel.

[0] https://github.com/fogleman/primitive

[1] https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1_aw