3 ms·
So the basic idea is that a BF interpreter will ignore any non-BF characters? How about, if you'd take an 8 bit grayscale image, and allow each pixel a margin
by tripzilch 15y ago
So the basic idea is that a BF interpreter will ignore any non-BF characters?
How about, if you'd take an 8 bit grayscale image, and allow each pixel a margin of error, say 2 values up or down. Then you could process the pixels sequentially while looking for the next value that is within the range of +/- 2 of your next BF token and adjust it to the correct value. If instead you happen upon an incorrect BF token, you can also adjust it so that it either turns into the correct one or a non-BF instruction byte.
Of course there's no guarantee that you'll be able to fit the whole program since you'll be skipping a lot of pixels. But an image is big and the message is short, so there's a good chance. Especially if you retry with different BF encodings of the same message, and failing that upping the error margin to +/- 3, then +/- 4, etc.
- Two9A 15y agoMm, sounds like a plan. In taking the 8-bit greyscale image down to 4-bit, I've essentially introduced a margin of error of +/- 8, which explains why the message was able to fit into just the first ten or so rows of a 128-row image. A higher palette resolution would, as you say, increase the amount of space taken by the message, but would result in a higher fidelity of the image.
- tripzilch 15y agoAnother idea is to substitute the eight BF instructions to different bytes. Right now the byte-values for most instructions are within 1 or 2 values from eachother. You'd need a modified interpreter, though, but by picking different values for the BF instructions, spaced further apart in the 0-255 range, you'd get less collisions (incorrect BF tokens appearing at the wrong spot in your stream). Another possibility would be to pick different code points for each image/message encoded. Though you'd need another channel to specify which 8 bytes encode for which BF tokens. You could even not specify it, but limit the choices for the 8 byte values and try all combinations, then see which ones decode to a string that comes closest to character distribution in English language (this is the same method used by online translators to determine source language, character distribution is highly distinctive).