Discuss Scratch

quadruple_door
Scratcher
90 posts

Rudimentary Wave Function Collapse Image generation

What i want i'm making is rudimentary image generation, using 8 colours red green blue yellow cyan magenta black white(white would be hidden against the forum background so i cant do fancy colours ), this will probably be my most complicated project yet haha

this is already shared although not finished

(if you were wondering why some of the posts have help info on them, its because this was originally in the help with scripts forum, but i moved it to advanced topics.)

Last edited by quadruple_door (Aug. 28, 2024 18:56:02)


Jareddddddd
Scratcher
1000+ posts

Rudimentary Wave Function Collapse Image generation

hi, could we potentially have for details? I have a few questions myself
1 - What type of wave? Line a sin/cos one? Or like noise
2 - Image generation like many corporate AIs?
3 - What does this array function do?

Edit to my post: no, this is essentially not possible to do. wfc image generation is based off of immense datasets and extensive programming. Essentially a wfcig (wfc image generation) will predict the pixels next to it based off of all other pixels. Many other projects found here on scratch do not use this method of wfc, rather relying on similarity between presets rather than similarity between pre-existing maps.

Last edited by Jareddddddd (Aug. 26, 2024 19:12:13)

quadruple_door
Scratcher
90 posts

Rudimentary Wave Function Collapse Image generation

Jareddddddd wrote:

-snip-
1: Not like an actual wave, a figurative quantum one that represents the superpositions of a vector, tbh, nobody really knows, just how quantum mechanics work
2:kind of, using drawn images to generate similar images using weird math and physics, although, now you mention it, it could be used for that with images with tags in data. (nice!)
3: a simple 2d “array” that has some repeating digits (eg 0000000000 ect) that can be read and edited but is inefficient and a prototype (also the variables are one time use, but i can fix that with a storage list now that i think about it.)

Jareddddddd
Scratcher
1000+ posts

Rudimentary Wave Function Collapse Image generation

quadruple_door wrote:

stuff
hello, wfc image generation is based on the principle of quantum mechanics “observation” in which once something is observed, it much become something of a definite state, and from that state, you can reasonably say what other things around it are. (think like the quantumly entangled particles from many videos). image generation does not actually do this.

While technically possible, the data used by larger companys are much larger than any one person can make.

Last edited by Jareddddddd (Aug. 26, 2024 19:16:33)

quadruple_door
Scratcher
90 posts

Rudimentary Wave Function Collapse Image generation

there are many examples of image generation using wfc to generate images, in fact its mainly used for map generation in games, but anyways let me explain how it could work for idk, road generation or something.

at first, everything is in a superposition but when a tile is observed, “rules” get applied to it, a vertical road cant feed into a horizontal road, forks must lead into more road, dead ends aren't allowed ect and then before you know it you've got roads!

get it to find rules for basic drawn bitmaps and viola! mediocre image that look kind of like the og!

i'm going for an hour, work something out maybe?

edit: im back, also i found practially exactly what im aiming for

Last edited by quadruple_door (Aug. 26, 2024 20:17:24)


quadruple_door
Scratcher
90 posts

Rudimentary Wave Function Collapse Image generation

bump

quadruple_door
Scratcher
90 posts

Rudimentary Wave Function Collapse Image generation

i'm gonna sleep on this, literally.
also, bump

quadruple_door
Scratcher
90 posts

Rudimentary Wave Function Collapse Image generation

awake, bump, i wanna make this.

awesome-llama
Scratcher
1000+ posts

Rudimentary Wave Function Collapse Image generation

Fortunately for you, the example you linked is open source and has been extensively implemented and has some documentation of its own: https://github.com/mxgmn/WaveFunctionCollapse

Let me pick out the important bits:

The output should contain only those NxN patterns of pixels that are present in the input.
In the examples a typical value of N is 3.
Read the input bitmap and count NxN patterns.

You loop over the entire input bitmap and count each pattern you find. You will want the number of each so that you can ensure:
Distribution of NxN patterns in the input should be similar to the distribution of NxN patterns over a sufficiently large number of outputs. In other words, probability to meet a particular pattern in the output should be close to the density of such patterns in the input.

Last edited by awesome-llama (Aug. 27, 2024 10:56:33)



quadruple_door
Scratcher
90 posts

Rudimentary Wave Function Collapse Image generation

nice! funny thing is, i was just reading the readme on that same repo just before seeing the message lol.

69th post haha

Last edited by quadruple_door (Aug. 27, 2024 11:01:55)


quadruple_door
Scratcher
90 posts

Rudimentary Wave Function Collapse Image generation

UPDATE!

I've been working on it for a while with significant improvement! image can be scanned for patterns, presets are being made and WFC Is next on my list after UI and preset making!

Project linky if you're interested! (in active development as of now so may not be entirely usable.)
edit: typo

Last edited by quadruple_door (Aug. 27, 2024 17:10:49)


SpyCoderX
Scratcher
1000+ posts

Rudimentary Wave Function Collapse Image generation

quadruple_door wrote:

UPDATE!

I've been working on it for a while with significant improvement! image can be scanned for patterns, presets are being made and WFC Is next on my list after UI and preset making!

Project linky if you're interested! (in active developent as of now so may not be entirely usable.)
It’s unshared lol


Very cool tho! I haven’t seen something interestingly complicated in a while (at least in this forum).

I think the forum “Advanced topics” would be either more helpful or more interested in your project.

Have a good day!

Last edited by SpyCoderX (Aug. 27, 2024 16:49:15)


^ Below this line is my signature ^

New to the forums? Click here!
Want help with your project? Click here!

<Coder | Forum Helper (about)>
You can call me Spy or Spycoder :)

What we need may not be what we want.


Banner by Scratchboxes
quadruple_door
Scratcher
90 posts

Rudimentary Wave Function Collapse Image generation

SpyCoderX wrote:

quadruple_door wrote:

blah blah quote chain prevention
It’s unshared lol


Very cool tho! I haven’t seen something interestingly complicated in a while (at least in this forum).

I think the forum “Advanced topics” would be either more helpful or more interested in your project.

Have a good day!
ive shared it now, idk how to move topics though, ah well.
(wait i think you report it)

Last edited by quadruple_door (Aug. 27, 2024 17:00:11)


rdococ
Scratcher
1000+ posts

Rudimentary Wave Function Collapse Image generation

Just a note, the wave function collapse algorithm isn't much like the quantum mechanical phenomenon besides the name and presence of randomness.
quadruple_door
Scratcher
90 posts

Rudimentary Wave Function Collapse Image generation

closing this topic (inactive and project is dead), well you get a nice pixelart editor anyways, might make a new forum if i pick it up, thanks you guys!

Powered by DjangoBB