The 216MB Photoshop RAW/16 file had 27 MILLION unique colors out of 36M
This is a perl creating a hash with 27 million keys:
[0] Perl> $t = time; ++$h{$_} for 1 .. 27e6; print time() - $t;; 52.9575479030609
53 seconds!
76% of the pixels have unique colors! This makes your hashing algorithm rehash everything when it lands on a dup.
Sorry, but if you mean "rehash every preexisting key", you are wrong. Why do you believe that?
(If you mean something else by the highlighted phrase above, you're gonna have to explain yourself better.)
The beauty of hashing for this application is that it doesn't matter what the range is, only the actual total.
For each pixel in your image you either need to add a new key; or increment an existing value. Either takes approximately the same amount of time: circa: 0.000000457763671875 of a second on my rather ancient hardware.
Indexing your 48-bit values (as opposed to my 32-bit ones) will take ~50% longer; so perhaps 40 seconds to count the colours in my 125 mega-pixel image.
I have it down to < 46 seconds with 88.55% unique colors
If you've already trimmed your OP time of "2.17 hours" to 48 seconds, why have you wasted our time by asking this question?
Another monk that I won't waste my time reading and producing solutions for in future.
In reply to Re^3: Perl Hashes in C?
by BrowserUk
in thread Perl Hashes in C?
by BrianP
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |