top | item 18674832

Make photomosaics, GIFs, and murals from pictures in Python with ML/OpenCV

126 points| muzakthings | 7 years ago |github.com | reply

21 comments

order
[+] dfbrown|7 years ago|reply
I'm not an expert in the topic, but my understanding is RGB is a poor color space for computing color difference. This could be why your mosaics end up so washed out. [1] suggests using a CIELAB color space [2].

Edit: Looking at the code more closely it looks like you were using Lab at one point but commented it out[3], so I'm guessing you're already aware of this.

1: https://stackoverflow.com/a/9019461/185171

2: https://en.wikipedia.org/wiki/CIELAB_color_space#CIELAB

3: https://github.com/worldveil/photomosaic/blob/bb720efda11383...

[+] muzakthings|7 years ago|reply
It didn’t make a ton of difference empirically when I tried it.

But you’re correct, generally that’s the space you want to be in.

[+] fireattack|7 years ago|reply
Is the example image (https://github.com/worldveil/photomosaic/blob/master/media/r...) with or without opacity cheat?
[+] muzakthings|7 years ago|reply
Both! You can experiment with —-best-k and —randomness <1.0 and sort of get things in the middle.

Basically what this will do is assign each tile less than 100% of the time randomly and then for each that isn’t, you choose among the top best K matches on L2 distance with equal probability. Gives it a little bit of both.

[+] PavlovsCat|7 years ago|reply
Yeah that's using opacity, e.g. there's an image of a blue horizon that gets tinted red.
[+] rmonroe|7 years ago|reply
Way better implementation of the face alignment than what I did for our peru trip. Good going ;-)
[+] androidgirl|7 years ago|reply
The gif with facial recognition is actually really really cool. Awesome work
[+] aaaaaaaaaab|7 years ago|reply
Ok, but where is the ML part?

We’ve been creating these mosaics for decades...

[+] muzakthings|7 years ago|reply
The face montage building trains a linear classifier on top of the pretrained embedding network - it’s the portion that talks about creating a training folder of your face.

But yes the photomosiacs strictly don’t use ML, unless you count the internal fun stuff Faiss (the similarity search lib) does to construct fast indexes.

[+] itronitron|7 years ago|reply
like others here, i really like the aligned face montage gif and it seems like it would be a great product for people to package up their selfies over a timeline
[+] giladoved|7 years ago|reply
This is fantastic, great project!