What I did here is just that I took all the frames from that horse
running gif which I used in one of my previous posts, ran each frame
through Google's Deep Dream code and then stitched them back together to
create a new gif.
The result is very nice and you can see it below:
Fun, fun, fun!!
I might try to make some more of these in the next couple of days. :)
This is also an old, but fun project I did 8 months ago, inspired by the
video that József Fejes posted on his blog in March: All RGB colors in
one image. It was part of the challenge posted here, where people
had to write code that makes colorful images. Fun, fun, fun!
The challenge has already finished when I saw it, but anyway, it sounded
interesting and I wanted to see what I can come up with.
A bit about colours
There's a lot of colours out there! If you look into one pixel on your
screen and concentrate really really hard, you will notice that it can
(probably) display $16777216$ different colours! Here we are talking
about $24$-bit colours, where each one is represented as a combination of
red ($8$ bits), green ($8$ bits) and blue ($8$ bits) colours. $8$ bits can take
$256$ different values, so $256 \times 256 \times 256 = 16777216$. And that's a lot!
If you wore a different coloured shirt every minute, it would take you
almost $32$ years to wear all of the possible $24$-bit RGB colours. I know
you wanted to know that.
The result was colorful!
Below you can see what I got in the end.
In this case the image was $640\times480px$, which means it only contained
$307200$ different colours, that is, only around $1.831054687\%$ of all
possible $24$-bit RGB colours. OHNOES!
Make it bigger!
The next generated image was a bit bigger. It was $1088\times1920px$ big,
containing $2088960$ different colours, which is around $12.451171875\%$
of all the colours we wanted to use.
Click to see it bigger!
That's better. Why $1088$ you ask? Because the implementation was a quick
hack and required the dimensions to be divisible by $16$. That's what you
get when you want to see the results as quickly as possible. But you
know what's cool? Each colour in that image is used only once and it
would take you almost $4$ years to wear shirts in all of those colours if
you wore each one only for a minute!
A video would be even more colorful!
The next obvious thing that needed to be done was a video of how this
image was generated. Here are four frames from the first image shown in
this post being generated:
Having limited time, I decided that $12.451171875$ is roughly equal to
$100$ and that a HD video will be enough to call this project done. So,
a frame was saved after generating every so many pixels of the
$1088\times1090px$ image, the frames were turned into a video and it was
uploaded to YouTube to live there happily ever after.
The end?
Enter savfk!
It wasn't the end! After uploading
the video
on YouTube, my colleague
Saverio
messaged me and said:
I did a 2:30 thingy on purpose for your colour stuff!
Turns out he makes music (which I didn't know) and he made real
music for the crazy colour snake video!! The music fit perfectly and the
result can be seen below.
Yes, it will work with all of the colours if you have the time to
generate the frames. That's why I'm providing the code below!
Code
It's written in python and is again not cleaned up because I'm too lazy
to do that. If you want to use it to generate an image really using all
of the colours, the dimensions of it should be for example
$4096\times4096px$. Just set the height and width variables to $256$, and
that should work. It could also not work, I don't know, this was written
a long time ago. :P
And I forgot to mention how it actually works! For the traversing part,
it is just a randomized DFS algorithm. Every time when a pixel get
visited, a colour is chosen randomly and it is used if it is less than a
certain distance (Euclidean distance in RGB space) from the
previously used colour. If it isn't, another colour gets chosen
randomly. If after a number of random choices the colour still isn't
less than the threshold distance from the previous colour, then the
threshold gets increased. And that's it! Magic!
Oh, and BTW, you should have a folder called generated where all the
images will get saved to.