Fun with image filters in Go

646 views
Skip to first unread message

Job van der Zwan

unread,
Jun 3, 2012, 3:20:16 PM6/3/12
to golan...@googlegroups.com
Hello all,

I've been playing with Go for the last month, and I thought I'd share the stuff I've been making with the gonuts group. Not something serious or particularly useful (yet), but I thought it would be a nice change from all the projects (indirectly) related to webservers. Basically, I take this input:



... and turn it into this:

Here's a more colourful variant:




For comparison: the equivalent amount of pixels:

I'm exploring Go as an alternative to ProcessingOpenFrameworks and Cinder. As a programming language I already prefer Go over these Java and C++ based frameworks. I do miss the extras provided by them, like the capability to start a webcam and grab frames from it, but I am sure this is a temporary problem that will disappear as more third-party libraries will show up.

Yes, AJStarks, I have your SVGo library, and it's very useful when I need to render vector graphics ;-). Which will be soonish, when I finally manage to create that weighted voronoi stippling algorithm (the images above are basically the result of me being sidetracked while trying to implement the ideas of that paper in Go).

No, I won't share the code yet - it needs some improvements before I dare to show it to the public.

ajstarks

unread,
Jun 3, 2012, 8:14:48 PM6/3/12
to golan...@googlegroups.com
When you want to try vectors, see [1] for an explanation of using goplay and SVGo for code+picture "sketching", a mode inspired by Processing.

Kyle Lemons

unread,
Jun 4, 2012, 12:10:13 AM6/4/12
to Job van der Zwan, golan...@googlegroups.com
Cool!  My image processing fu is old and cursory, but it looks like a fun project.

Job van der Zwan

unread,
Jun 4, 2012, 9:44:46 AM6/4/12
to golan...@googlegroups.com
Hey, nice! I somehow missed that. That will certainly be useful.

ajstarks

unread,
Jun 4, 2012, 12:18:25 PM6/4/12
to golan...@googlegroups.com
Note that the SVG standard supports raster operations as well, for example via filter effects [1].  SVGo does not support these yet, but say tuned.

Job van der Zwan

unread,
Feb 23, 2013, 9:17:05 PM2/23/13
to golan...@googlegroups.com
So I've been working on this little hobby project again. The code is finally reaching the point where I'm not completely embarrassed by the thought of anyone taking a look at it:That said, I'm in the middle of a large rewrite, and anything can break at any time. It will probably stabilise soon though. For now I suggest sticking to playing with the examples. Just go to the example you want to try out (wsdipole, quartered, rectdipole don't work at the moment - I did say anything can break), "go build", run with --help for instructions on parameters to pass. The fun part is that some of the examples (split, cubesplit, wdipole) now accept paths to directories with pictures as input[1]! What's the use of that? Well, you can use something like ffmpeg to split a movie into frames[2], filter all of them in one go, and stitch it back together again. Here are of some movies to show of some experiments with that:


I'm uploading movies with variant parameters as I type this, so expect to find about a dozen different variants by next morning (sadly I'm limited to a 3G dongle at the moment). The scene from the Matrix was chosen because of the sweeping slow-motion (and a little bit because it fits thematically). The White Stripes video was chosen because the input was "low-res" to begin with, so it was interesting to see what would happen if this was filtered.

The file names represent the parameters given to the example program I filtered it through. So "g8" means eight generations, or 256 cells per frame. So that's the equivalent of 32 by 32 pixels - don't expect to see any useful details in that one.  "matrix-gr8-gg10-gb8-x2-y7.mpg" and "matrix-gr8-gg10-gb8-x7-y2.mpg" are examples of advanced usage of the split example. The different channels have a different number of cells (256 for red and blue, 1024 for green) and the relative weight of the x and y axis is different, resulting in taller or wider pixels on average.

I'll write a blog post detailing what the examples actually do after finishing the rewrite, but for now I just wanted to share some results. And I still haven't started on implementing those weighted Voronoi maps, which is what started this whole thing...

If you *do* want to look at the code: the density package is pretty fleshed out except for the SumMasks, and of the examples split and cubesplit are pretty much fully rewritten (the rest will soon follow).

[1] Warning: it will also walk through all subdirectories looking for pictures.
[2] Because of how the "path" package sorts files, it is important the input files are listed as example-000001.jpg, example-000002.jpg, ... example-001000.jpg to keep the order of the output correct.
Reply all
Reply to author
Forward
0 new messages