Results are too periodic
Nakilon opened this issue · comments
https://github.com/nothings/stb/blob/8e51be04dc7dcee462e1f09e410faceab52cc6d2/stb_image_write.h
https://github.com/nothings/stb/blob/8e51be04dc7dcee462e1f09e410faceab52cc6d2/stb_image.h
$ ./wfc -m overlapping -w 128 -h 128 input.png output.png
Apologies for a delayed response, I missed the issue.
The problem is that, although the pattern in the input image is simple (this is good), the colors are very varied. You can see this in the zoomed version of the first input image:
The 3x3 tiles extracted from this input image cannot be matched differently than what you see in the output image (that is, straight repetition of the input image). It's a bit like with puzzles, these tiles cannot be put together in a different way.
If I simplify the first input image and use only three colors we get something like this:
The 3x3 tiles extracted from this image will match each other more flexibly.
With this new input image if I run:
$ ./wfc -m overlapping -w 128 -h 128 input.png output.png
I get:
It's not periodic anymore. Hope this makes some sense.
Extra note: make
was set to build debug version by default. I pushed a change to build non-debug, optimized code by default which should give a significant speed up.
Thanks for the explanation. I ended up with implementing own algorithm, I'll try to find the screenshots from that time...
and a video https://i.imgur.com/kHnH9xJ.mp4
This looks interesting, although I suspect you used a different algorithm at the end?
The algorithm was something like: at first fill the image with learned pixels randomly, and then find random pairs of pixels that when you swap them they should match their neighbors more according to the training image and HSL bicone distance. Surprisingly if you learn not only direct 4 (or 8) neighbors but more distanced ones it does not work well.
My next idea was to apply the algorithm not only while cutting the image in 1x1 pixels but first 8x8, then 4x4, then 2x2, and only then 1x1. Not sure about the result but that would improve the speed.