Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Results are too periodic #2

Closed
Nakilon opened this issue Jul 4, 2021 · 4 comments
Closed

Results are too periodic #2

Nakilon opened this issue Jul 4, 2021 · 4 comments

Comments

@Nakilon
Copy link

Nakilon commented Jul 4, 2021

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

input

output

input

output

@krychu
Copy link
Owner

krychu commented Jan 8, 2022

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:
issue11

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:

issue11_out

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.

@krychu krychu closed this as completed Jan 21, 2022
@Nakilon
Copy link
Author

Nakilon commented Jan 21, 2022

Thanks for the explanation. I ended up with implementing own algorithm, I'll try to find the screenshots from that time...

image
image
image
image
image

and a video https://i.imgur.com/kHnH9xJ.mp4

@krychu
Copy link
Owner

krychu commented Jan 30, 2022

This looks interesting, although I suspect you used a different algorithm at the end?

@Nakilon
Copy link
Author

Nakilon commented Jan 30, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants