Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^4: Very Large Hex Combinations

by danambroseUK (Beadle)
on Aug 04, 2005 at 15:41 UTC ( #480882=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Very Large Hex Combinations
in thread Very Large Hex Combinations

Its a crazy idea but what I am trying to do is create every combination possible of a 640x480 bitmap file.

Yes this would take forever to do - but just imagine if every photo was created - we would have every photo of everything. Every photo ever taken and every photo to be taken- Effectivly a time machine!!

Jokes aside, how would this be achieved?


Thanks,
Dan


Comment on Re^4: Very Large Hex Combinations
Re^5: Very Large Hex Combinations
by abell (Chaplain) on Aug 04, 2005 at 15:54 UTC
    Its a crazy idea but what I am trying to do is create every combination possible of a 640x480 bitmap file.
    After that you could also generate all possible novels up to 500 pages, so I will finally get rid of the monkeys in my basement ;-)

    Seriously, the number of all possible images is *real* huge, and even if you managed to save them somewhere, indexing them would be as difficult as generating them. In order to retrieve a specific image, you would somehow be able to indicate "I want the image whose first pixel is 0xa, whose second pixel is 0x0 ..." and so on with all the pixels. It is more reasonable to just generate it on the fly (and it allows you to save a few gazillion bytes).

    Cheers

    Antonio



    The stupider the astronaut, the easier it is to win the trip to Vega - A. Tucket
Re^5: Very Large Hex Combinations
by ikegami (Pope) on Aug 04, 2005 at 16:17 UTC

    There are 5,153,960,755,200 (640*480*(2^24)) true colour 640x480 images.

    The file size of each image would be 921,654 (54 + 640*480*3) bytes.

    The disk space used by each image (on NTFS) would be 925,696 (ceil(921,654/4,096)*4,096) bytes (plus space used by the directory).

    The disk space used by all images (on NTFS) would be 4,771,000,855,245,619,200 (925,696 * 5,153,960,755,200) bytes (slightly under 5 billion Gigabytes).

     

    What if you generated 128x128 images using 16 colours?

    Num images = 160,000 File size = 8,310 bytes Disk space per images = 12,288 bytes Total disk space = 1,966,080,000 bytes =~ 2GB

    That's attainable, but it's only thumbnail size.

      There are a whole lot more than 640*480*2^24 true colour images. There are 307200 pixels (640*480), each of which can take 2^24 different colours. That leads to 2^(24*640*480) different images, that is 2^7372800. That's a number that takes more than 2 million digits to write down.

        Arg! You're right! That's how I did it originally, but I thought I had it wrong.

        There are 2^(24*640*480) true colour 640x480 images. That's a number with over 2211840 digits. Considering a googol has only 101 digits and "a googol is much larger than the number of atoms in the Universe", your goal is unfeasable.

        Even if we used 128x128x16 thumbnails, it's still unfeasable at 2^(4*128*128), a number with over 19660 digits.

        There is over a googol of 20x20 monochrome images. (Over 2.58 * 10^120, to be more precise.)

Re^5: Very Large Hex Combinations
by Anonymous Monk on Aug 04, 2005 at 16:23 UTC
    Eh, may I suggest starting with smaller sized pictures? Say, 8x8 bitmaps? Of which there are 18446744073709551616, each taking 8 bytes of storage. You only need 137438953472 disks of 1 Tb each to store them. Suppose you can install one such disk each second, and you never tire, you don't need sleep, you don't need to eat, and don't go to the bathroom. Furthermore, disk companies manage to supply you with enough disks. Then you only need 4355 years to install the disks to store your all your 8x8 bitmaps.

    After doing the 8x8 bitmaps, you might want to tackle the 12x12 bitmaps. If you can install 1Tb of storage each second, you only need 9 * 10^35 years to install your storage.

      8x8 bitmaps have file sizes of 246 bytes.
      8x8 bitmaps take 4096 bytes of disk space (under NTFS).
      Thus, all 8x8 bitmaps would take over 75,557,863,725,914 GB of disk space.

      I suppose you could invent your own archival format and image format where it would take the miminum 147,573,952,590 GB

        8x8 bitmaps contain 64 bits of data. You can store that in 8 bytes. I don't know where you get your 246 bytes from, GIF? JPG? If you want to store them in a format known by image viewers, I'd go for PBM, which, for 8x8 bitmaps, needs 7 additionaly bytes of overhead: the magic number (P4), and the width and height of the image, each encoded in ASCII. And each of the three pieces of data is followed by whitespace.

        But you don't have to store them in a file system (many file systems will use 8k blocks, where each block can be used by at most two files, hence the 4096 bytes you mention. But some file system can subdivide blocks into smaller fragments, and allow you to use smaller blocks as well, but I disgress) - you can store them on a raw disk as well. Using a format (such as P4) that has a fixed size, finding them on a raw disk would be easy.

        Of course, even if it was feasable, there's no point in generating and storing each possible image. You might as well generate the images when you need them.

Re^5: Very Large Hex Combinations
by BrowserUk (Pope) on Aug 04, 2005 at 16:27 UTC

    Update: Minor brainfart there. The point of the post still holds, but you'll need to multiply all the numbers by 2**( 640 * 480 ):

    142427923839648881629184805134324652164093716404030097299710376120451 134154787190076398812090414510556300740006550934739747222066752231099 294344002591005120626800863471535551485395485528316242619445670424359 449935350841325881969413228910724065033772133523230370773849709948530 89450777507879083442634420291861180736024127002634265953304576

    Assuming 24-bit color, there are 640 * 480 * 2**24 possible bit maps. That's 5.15e12.

    To put that number in perspective, if you could generate 1/second, it would take you 163,319 years.

    Now let's say you secured the services of 163,319 computers for 1 year and generated them all. It would require ~5 million million million million GB of storage to hold. So, let's say that the disks/tapes were available.

    Now to find that perfect picture that you are going to take of your great Aunt 5 years from now, all you've got to do is wade through all the mostly black and mostly white and mostly blue and mostly grey, and all those where you chopped off her head.

    If you can reject 1 per second that's gonna take you...


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
      Assuming 24-bit color, there are 640 * 480 * 2**24 possible bit maps.
      Wrong. There are 2 ** (24 * 640 * 480) possible bitmaps.
Re^5: Very Large Hex Combinations
by polettix (Vicar) on Aug 04, 2005 at 16:42 UTC
    One of those photos would reveal that you killed JFK!!! Do you think that the world is prepared for this truth?

    Flavio
    perl -ple'$_=reverse' <<<ti.xittelop@oivalf

    Don't fool yourself.
      Yes I am aware that there is going to be *minor* storage issues - what I am after is proof of concept a script that could produce, well start producing every combination possible.

      How might this be coded?

      Just imagine this could a project like seti whereby using idle computer time do the calculations, they have logged years of computing time in this way.


      Dan
        You're not crazy, you're in denial. You can't have more data than there are atoms in the universe. What would you store it on?

        Proof of concept? For a script to "start" the process? Why? We've already (pretty much) proven that such a script would never even make it to generating a single interesting picture in the sun's life time; unless you think all black is interesting.

        You'd be better off trying to create interesting randomly generated images than heading down this road.

        -Scott

        The program below will get you started. It generates all 8x8 images using just black and white pixels, storing them in PBM format, requiring only 15 bytes per file.

        Without counting overhead of inodes and directories, you only need to solve the *minor* *minor* *minor* storage issue of 257,698,037,760 Tb.

        On my computer, it took more than an hour to generate all 3x8 bitmaps. Rounding that down to an hour, an estimate to do all 8x8 bitmaps is 125 million years.

        That's 125 million years for an image consisting of a mere 64 bits. A 480x640 bitmap contains 307200 bits, the full colour version 7372800 bits. Realizing that a single bit more means doubling of your computer time you must come to the conclusion your quest is unfeasable.

        Really, it's cheaper to just subscribe to the porn sites instead of generating your smut images this way.

        Here's the code:

        #!/usr/bin/perl use strict; use warnings; my $dir = "/tmp"; foreach my $r1 (0x00 .. 0xFF) { my $d1 = sprintf "$dir/%02X", $r1; mkdir $d1 or die "mkdir $d1: $!\n"; foreach my $r2 (0x00 .. 0xFF) { my $d2 = sprintf "$d1/%02X", $r2; mkdir $d2 or die "mkdir $d2: $!\n"; foreach my $r3 (0x00 .. 0xFF) { my $d3 = sprintf "$d2/%02X", $r3; mkdir $d3 or die "mkdir $d3: $!\n"; foreach my $r4 (0x00 .. 0xFF) { my $d4 = sprintf "$d3/%02X", $r4; mkdir $d4 or die "mkdir $d4: $!\n"; foreach my $r5 (0x00 .. 0xFF) { my $d5 = sprintf "$d4/%02X", $r5; mkdir $d5 or die "mkdir $d5: $!\n"; foreach my $r6 (0x00 .. 0xFF) { my $d6 = sprintf "$d5/%02X", $r6; mkdir $d6 or die "mkdir $d6: $!\n"; foreach my $r7 (0x00 .. 0xFF) { my $d7 = sprintf "$d6/%02X", $r7; mkdir $d7 or die "mkdir $d7: $!\n"; foreach my $r8 (0x00 .. 0xFF) { my $f8 = sprintf "$d7/%02X", $r8; open my $fh, ">", $f8 or die "open $f8: $!\n"; printf $fh "%s\n%d %d\n", "P4", 8, 8; print $fh pack "C8", $r1, $r2, $r3, $r4, $r5, $r6, $r +7, $r8; close $fh or die "close $f8: $!\n"; } } } } } } } } __END__
Re^5: Very Large Hex Combinations
by tall_man (Parson) on Aug 04, 2005 at 21:20 UTC
    Check out the story The Library of Babel for a fictional universe in which such an experiment has been carried out with text.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://480882]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2014-07-13 06:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (247 votes), past polls