Make photomosaics, GIFs, and murals from pictures in Python with ML/OpenCV
11–20 of 23 posts
Re: Make photomosaics, GIFs, and murals from pictures in Python with ML/OpenCV
#12I'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: htt…
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.
I've done some similar work[1], but issue with L*ab color is it's terrifically slow to calculate diff, at least in JS.
Re: Make photomosaics, GIFs, and murals from pictures in Python with ML/OpenCV
#13Re: Make photomosaics, GIFs, and murals from pictures in Python with ML/OpenCV
#14Earlier quoted context omitted.
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.
It is quite noticeable when you are using a limited selection of tiles or image has desaturated colors. I've done some similar work[1], but issue with L*ab color is it's terrifically slow to calculate diff, at least in JS. [1] https://imgur.com/a/g3EzcSV
L*b was very slow, yes. It’s all done offline but I tend to like quicker feedback...
Re: Make photomosaics, GIFs, and murals from pictures in Python with ML/OpenCV
#15Re: Make photomosaics, GIFs, and murals from pictures in Python with ML/OpenCV
#16Earlier quoted context omitted.
It's using the KMeans[1] library from sklearn.cluster. But this isn't really ML, is it? My ML knowledge is limited. Regardless, it's a cool project. OP might want to update the title to remove ML. [1] https://github.com/worldveil/photomosaic/blob/master/emosaic...
"[Kmeans] algorithm has a loose relationship to the k-nearest neighbor classifier, a popular machine learning technique for classification that is often confused with k-means due to the name." Maybe an ML expert could elaborate? I've been curious on my own projects when to actually mention when they use true ML or not. https://en.wikipedia.org/wiki/K-means_clustering
K-means, clusters on centroids that are means. After every interation new means are calculated and then reclustering occurs.
Re: Make photomosaics, GIFs, and murals from pictures in Python with ML/OpenCV
#17Re: Make photomosaics, GIFs, and murals from pictures in Python with ML/OpenCV
#18Is the example image ( https://github.com/worldveil/photomosaic/blob/master/media/r... ) with or without opacity cheat?
Re: Make photomosaics, GIFs, and murals from pictures in Python with ML/OpenCV
#19Is the example image ( https://github.com/worldveil/photomosaic/blob/master/media/r... ) with or without opacity cheat?
Both! You can experiment with —-best-k and —randomness 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.
Re: Make photomosaics, GIFs, and murals from pictures in Python with ML/OpenCV
#20Earlier quoted context omitted.
Both! You can experiment with —-best-k and —randomness 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.
I'm talking about `--opacity` - because to me the mosaic images used in the sky can't be that blue originally.
I’ve found that opacity if 0.7 is often a nice compromise.