Skip to main content
GameDev.net gamedev.net
🔒 Locked

Painting with Boids (new video/engine, Jan 25)

Started by djz Jan 5, 2010 at 9:03 PM 34 replies 7.6k views
Original Post
djz
djz
Videos Here These images were created with a variation on Craig Reynolds's Boids algorithm. I have occasionally taken on work from some independent film-makers, mostly working with Photoshop on image-retouching & rotoscoping which has spurred on my interest of unusual/experimental animation techniques. What the pictures above relate to is my ongoing experimentation with using AI algorithms to "creatively" recreate images, with the ultimate goal of creating an automated computer-animator that will process and rerender video files with guided recreations. My previous thread dealt with "Evolved" images, ala Roger Alsing's method. I created a parallel implementation of it that relied on tree structures (essentially genetic programming with trees and terminals, but instead of performing computations, each tree would evaluate to a series of drawing commands that would ultimately recreate the image given your specifications..number of polygons, desired tints, etc.) While this created some striking effects, getting it to animate was another story. My approach was to take a base image, and then continually mutate the frame until, based on the summed distance in colourspace between each pixel of generated and source was reduced by a certain amount per-frame. Here's some still images, using this method: Since this method wasn't proving viable for actual animation, I decided to look at other ways of creating interesting images based on pre-existing images; algorithmically that still ahd the appearance of creativity. Obviously, these renders are still very infant; and the concept is mere prototype at this stage; but what I am doing is using a Boids agent with many more parameters and influences. The individual agents (I call them Fish, with the analogy being, as I explained to my girlfriend, that the resulting effect should in theory be like fish in an aquarium schooling together and changing colour to reproduce an image; although they look more like worms than fish, with their long trails) can be attracted to certain colours, and will change their shape and behaviour based on their 'environment' - essentially the underlying image. If you review the canonical Boids implementation you will see that the new headings and speed for each boid is calculated mathematically. What I have done instead, due to the number of parameters that must be considered, and desired behaviours that you would want to 'blend together', is that each "Fish", during any simulation step, it may consider any action that is in its 'Action List' i.e. Turn Left, Turn Right, Speed Up, Speed Down, etc. It evaluates a score for all immediately available actions, assigning scores for categories like "Colour" (how far away is this Fish from its "Home Colour") "Heading" (how aligned is this Fish with its local neighbor?) "Clustering" (how many neighbors? if it's too many, it gets a penalty. Too few gets a penalty as well), and many other factors. Once it determines the total "penalty" (there is no move without cost!) it adds a wee bit of noise (0.01%) to the score, and picks the action with the best score. We'll see if it holds up for processing video. I have many more prototypes to make before determining if it is worth the effort; but for still images, the results are all ready pretty cool. I have some ideas on how to make it work for video clips, but that's for another day.... The goal is to eventually integrate several of these ideas into an application that could be used to produce some shots for a film-project I have been involved with off-and-on. If anyone is interested, I may upload a video of what this looks like running in real-time on a still image. The effect is quite neat. Edit: Here's another Lena, with different parameters. It looks a bit more painterly than the others. [Edited by - djz on January 26, 2010 12:00:25 AM]
LockePick
LockePick
By any chance are you working at SFU with Steve DiPaola?

It's a really solid and interesting approach. I hope you can translate it into video well. I am noticing, particular on that last Lena, that when each path is thicker it looks like somebody dragging around the smudge tool in Photoshop rather than 'painting'. The first Lena you posted is pretty fantastic, because the streaking effect is less prominent.
choffstein
choffstein
I've bookmarked both this thread and your Genetic Artwork thread to remind myself why I program.
Ravuya
Ravuya
This is really cool. I'd love to see a video - I bet it looks crazy.
taby
taby
Stunning! This is really fantastic stuff you've done.

Here's a couple of outstanding journals that you might want to write about this in:
Computers & Graphics

The Visual Computer

If you've never done up a journal paper before, I'll gladly send you some template LaTeX files to give you an idea of how it's done.
ChaosEngine
ChaosEngine
Damnit, that is really cool. I would love to see that in action.
if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight
djz
djz
@LockePicke: No, unfortunately! I am planning, once my existing student loans have been dealt with, to go to school for CS, but I still have to pay off my music education.

@taby: I have an academic background in music, but not in CS; However, I would definitely be interested in seeing the template just to get a feel for how a proper journal article is done; even if I am not able to produce something that stands up to academic rigor at this point in my career.

I have a few videos rendered, but I'd rather not host them on YouTube; does anybody have a suggestion for where to host, or would be willing to host a couple video files?

Thanks to all for the feedback, it is very encouraging!!
owl
owl
This is really cool! You know what's cooler? That if you half-close your eyes and look at the drawings, you can see the original picture with great detail.

Isn't there some AI to add (deduce) detail of a picture from one with low resolution? Like in the movies, when they zoom a picture to no-end.
[size="2"]I like the Walrus best.
superpig
superpig
Quote:
Original post by owl
Isn't there some AI to add (deduce) detail of a picture from one with low resolution? Like in the movies, when they zoom a picture to no-end.


No, you can't add information that isn't there; think of a low-res picture like a high-res one that's been subjected to lossy compression. The best we can do, really, is to try and generate vectors from the bitmap, and then either generate higher-resolution (but no more detailed) images from the vector art, or try matching the vector shapes against an image library to figure out what an object in the image is and filling in its higher-resolution info from the library.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
Sneftel
Sneftel
Quote:
does anybody have a suggestion for where to host, or would be willing to host a couple video files?

I personally like Vimeo for video sharing. Good quality compression, and it's not full of, well, YouTubers.
owl
owl
Quote:
Original post by superpig
Quote:
Original post by owl
Isn't there some AI to add (deduce) detail of a picture from one with low resolution? Like in the movies, when they zoom a picture to no-end.


No, you can't add information that isn't there; think of a low-res picture like a high-res one that's been subjected to lossy compression. The best we can do, really, is to try and generate vectors from the bitmap, and then either generate higher-resolution (but no more detailed) images from the vector art, or try matching the vector shapes against an image library to figure out what an object in the image is and filling in its higher-resolution info from the library.


The brain is an amazing piece of hardware...
[size="2"]I like the Walrus best.
djz
djz
Video :)
LockePick
LockePick
Quote:
Original post by djz
@LockePicke: No, unfortunately! I am planning, once my existing student loans have been dealt with, to go to school for CS, but I still have to pay off my music education.

Ah, I saw 'Vancouver' and this type of research and immediately thought of this guy. TBH I never looked into his research much so I don't know how much it overlaps but I always thought it was a very cool premise. I remember him covering boids at some point too (not in a context related to painting though).

I don't know if he (DiPaolo) is still doing those projects or what his focus is on specifically right now but if you ever want to get in contact I've taken his courses before and could try to get you an introduction.

Video is gorgeous, btw, keep going!
djz
djz
Quote:
Original post by LockePick
Quote:
Original post by djz
@LockePicke: No, unfortunately! I am planning, once my existing student loans have been dealt with, to go to school for CS, but I still have to pay off my music education.

Ah, I saw 'Vancouver' and this type of research and immediately thought of this guy. TBH I never looked into his research much so I don't know how much it overlaps but I always thought it was a very cool premise. I remember him covering boids at some point too (not in a context related to painting though).

I don't know if he (DiPaolo) is still doing those projects or what his focus is on specifically right now but if you ever want to get in contact I've taken his courses before and could try to get you an introduction.

Video is gorgeous, btw, keep going!


Thanks so much for the wonderful link, I have grabbed a few bits of goodness from there and put them in my reference folder. I would definitely be interested in an introduction - It's good to know that there is someone teaching around these parts who is doing research on this type of thing. It's not looking like I'll be going back to school anytime before Fall 2011, but knowing that there is a prof doing such nifty research at SFU is a definite influencing factor when it comes to choice of institution.

(I'm not sure if this applies to CompSci as much as music or art, but when I was choosing which music school to go to, my criterion was the profs I wanted to study with rather than the institution itself; I'm assuming this is logical for other disciplines as well...)
Extrarius
Extrarius
You pictures look really cools, but the videos made me wonder about the drawing algorithms you're using.

You might want to contact smart_idiot about the algorithms he used in polypaint (original polypaint thread). Humans could produce some pretty awesome pictures with it, but, at the same time, I think whatever algorithms he used might be well-suited to your boid-driven drawing. See many example pictures in this archive(from this post).

In several ways, your boid system is a kind of anisotropic diffusion algorithm. Maybe you could take some ideas from that kind of algorithm and include edge detection, gradient values, and other values commonly used in image processing to improve the boid's decision weighting algorithm.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
djz
djz
Quote:
Original post by Extrarius
In several ways, your boid system is a kind of anisotropic diffusion algorithm. Maybe you could take some ideas from that kind of algorithm and include edge detection, gradient values, and other values commonly used in image processing to improve the boid's decision weighting algorithm.


This is the direction I was planning on going :) I'm pretty comfortable with image filtering and was planning on using that to derive currents and influences from the picture later on. Right now I'm mostly working on getting the Boids engine itself working and flexible - I want to have the human artist using it to animate over top of video to be able to customize it thoroughly; so the simulation has to be controllable, and the main feature I've been working on this evening is giving the AI a nice interface for editing. There's no GUI yet, but when I get around to that it will be pretty straightforward to let the user create their own scoring algorithms. Through mussing about with it myself, creating scoring objects in code, I was able to get all kinds of interesting behaviour, like single file line following - which could look spectacular for tracing over the edges of an image!

Regarding the drawing of the individual Boids, I'll get around to fixing that. I know it's not so good right now :(

New Video Here

I apologize for the poor quality of the stream. If you want to see it a bit nicer, download the avi version. I've also done some tests of using videos as source instead of still images, that don't look bad at all. I'll upload later on, when I get some time.

I improved the physics model quite a bit. Hopefully I can get the engine working at fast enough speeds that an artist could manipulate gravity objects and the like without too much difficulty, since the effects are pretty cool. Almost looks like fluid simulation.
irreversible
irreversible
Did you think of this approach, djz? Because this is frickin' awesome.
djz
djz
Quote:
Original post by irreversible
Did you think of this approach, djz? Because this is frickin' awesome.


If somebody else has tried this, I am unaware. I'm sure I'm not the first person to contemplate it though!!

Just posting to say that I found this excellent paper on stroke based rendering from SIGGRAPH02. I updated the scoring algorithm to take image-gradients into account and I'll post some pictures of that later. :) Been very busy with work & programming so haven't had time to upload my latest demo shots and images.

As a side question, perhaps somebody knows the smartest way to get work with video in C#/.NET? Currently I can only stream in image-sequences; which works fine, but it would be nice to just load up an AVI. If it's going to require a lot of code I have other priorities at the moment, if there's an easy way to do it with .NET or an easy to use library out there I'd add video support in right away.
djz
djz


This is a new render showing off two rendering modules rendering different clouds on different layers. It took 12 minutes to generate this image. Still missing out on some areas of details, but definitely getting closer to my envisioned effect. Also demos a new Colour model (scoring framework relating to underlying pixel values) extended with some pre-filtering.



Same parameters, much longer simulation time; and after the image was generated I applied a couple filters. Didn't test well for animation though...far too noisy. I downsampled it to get rid of some fairly annoying artifacts.



restricting allowed hues & colour moves...

[Edited by - djz on January 12, 2010 2:02:03 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.