News for hackers. Stuff that matters.

kundor

Re:Finding Waldo in π on Sunday April 03, 2022 @12:14PM (#30897995)
Re:Finding Waldo in π on Friday April 01, 2022 @07:35PM (#30884419)
I added a reduced preview of this to my blog post. I really like how it gives an impression of finding Waldo in a haystack of noise, just like in the picture books.

The preview is not as pretty as the real thing, but I thought embedding a 27MB video in the page might be a bit much.

Re:Finding Waldo in π on Friday April 01, 2022 @01:31PM (#30880867)
That's awesome!
Re:Finding Waldo in π on Friday April 01, 2022 @12:23PM (#30879938)
PS. The fact that any image can be encoded in 32 bytes this way implies that there are only 2^256 possible images — about one hundred and sixteen quattuorvigintillion. That's obviously not literally true, but we are searching for a subsequence of π which is "close enough"; the number of possible images which humans would consider distinct is probably well less than that.

(That is, the vast majority of possible images are "color noise" which all look more or less the same.)

Re:Finding Waldo in π on Friday April 01, 2022 @11:53AM (#30879517)
You can have infinite and nonrepeating sequences which don't contain every possible subsequence. For instance, 1010010001000... (where there is one more zero each time) never repeats itself, but it never even has the digit 2 in it.
Re:Finding Waldo in π on Friday April 01, 2022 @10:20AM (#30878318)
You're right, that's a mistake! It should be the 92,296,989th through 92,300,940th bits.

Yes, I did only search at 4-bit aligned bytes. Doing otherwise would be more complicated, much harder for others to easily verify from the downloadable hex digit data file, and not really more likely to succeed. Looking further out is just as beneficial as looking at more offsets.

Re:Finding Waldo in π on Friday April 01, 2022 @10:09AM (#30878214)
That's a cool egg!

It's been a long time since I read Contact. Are the aliens supposed to have hacked the geometry of the universe to make the pattern show up in π?

Re:Finding Waldo in π on Friday April 01, 2022 @10:00AM (#30878141)
Yes, to an extent that would work.

1) Take target image

2) Find the index in π (say) where a matchable sequence of bytes occur, like for Waldo. (If your image is big, this could take several years of computation time.)

3) Transmit the palette, width, height, and index: about 800 bytes.

4) Probably the index is too far out for everyone to have a copy of the data already (it would be beyond terabytes). So the recipient then spends several years computing the number out far enough.

5) Profit!

Note: the palette is optional; you could leave it out and only transmit about 32 bytes. Using a palette also means lossiness, because you're reducing to 256 colors and making compromises between pixels. But using one saves you several orders of magnitude of computation time.

Re:Finding Waldo in π on Friday April 01, 2022 @09:51AM (#30878049)
But the probability of you actually finding where that string occurs before the sun goes nova is much, much smaller.
Re:Finding Waldo in π on Friday April 01, 2022 @09:43AM (#30877979)
Yes, it helps to have more unique values. We want each repeated byte to occur in part of the pattern where a color also repeats.

What I do is search for substrings with the fewest repeated bytes that don't match the target pattern. I prioritize first minimizing conflicts between light (white and tan) vs. dark (black and red). Reducing other conflicts is a tie-breaker.

The featured gif has 79 "mismatched" pixels out of 494, by the black/white metric. I've found candidates with as few as 75, but subjectively I didn't think they looked as good.

Re:Finding Waldo in π on Thursday March 31, 2022 @11:28PM (#30874890)
The part that's from π is the actual pixel data, which is extracted in the Python snippet "waldo.tobytes()". More-or-less equivalently, you could use "list(waldo.getdata())".

The GIF file as stored on disk has extra headers, and the pixel data's been compressed. So the whole file isn't found in the digits of π, just the pixel data itself.

I'd guess the chance of actually finding a correctly formatted full GIF file in contiguous bytes of π is effectively nil.

Re:Finding Waldo in π on Thursday March 31, 2022 @09:22PM (#30874196)
That's still a choice of palette; you'll find it listed on Wikipedia [1] under "Regular RGB palettes".

There's no doubt it's a much more objective choice than the one I used! I did say I was cheating.

Going to 4-bit color won't make it feasible. Even with 1-bit black/white pixels on about the minimum possible 18x24 Waldo face, you have 432 bits to look for, and you're not going to find them without cheating somehow. This guy on Twitter tried pretty thoroughly: https://twitter.com/gsuberland/status/1508697913177915393

For the palette hack, you want to go the other way; it's easier with bigger pixels. I was able to create a perfect Waldo face from the first 988 bytes of π as a TIFF, where the standard supports 16-bit palette indices for the pixel data. Unfortunately nothing except imagemagick seems to support actually viewing these TIFFs.

[1] https://en.wikipedia.org/wiki/List_of_monochrome_and_RGB_col...