$im = Image::Magick->new(size=>$xyr, type=>'TrueColor', depth=>16); $err=$im->Read(filename=>"RGB:$raw"); warn "$err" if $err; # Read RAW ($blob) = $im->ImageToBlob(); $bl=length $blob; @ushort=unpack("S*", $blob); $blen=length $blob; $ulen=scalar @ushort; printf("CR: $lbl Blob len $blen unpacks to $ulen uint16s -> %d pix -> %4.6f B/us\n", $blen / 6, $blen/$ulen); for($ii=0; $ii < scalar @ushort; $ii+=3) { ($rr, $gg, $bb) = @ushort[$ii .. $ii+2]; # Array slice # Show full integers in 4Gig range for Yellow, purple, cyan $yy=sprintf("%10d", $rr*$gg); # White=4294967296 (4,294,967,296) 10 dig $pp=sprintf("%10d", $rr*$bb); $cc=sprintf("%10d", $gg*$bb); # (2^16)^3 = 2^48 = 2.815E14, 15 sig figs MAX. # Doubles have 52/53 bits of Significand $tt=sprintf("%15d", $rr*$gg*$bb); # TRUE color, R*G*B??? $c2v2c{r}{$rr}++; # Count Red channel points with this value $c2v2c{g}{$gg}++; # Count Gre channel points with this value $c2v2c{b}{$bb}++; # Count Blu channel points with this value $c2v2c{y}{$yy}++; # Count Blu channel points with this value $c2v2c{p}{$pp}++; # Count Blu channel points with this value $c2v2c{c}{$cc}++; # Count Blu channel points with this value $c2v2c{t}{$tt}++; # Count Blu channel points with this value } $vt=0; # Values Total; sum of all values foreach $chan (@leg) { # sort keys %c2v2c $clr = $leg{$chan}; # y -> Yellow %v2c = %{$c2v2c{$chan}}; # Values -> Count_of_this_value hash $vc = scalar keys %v2c; # Distinct values for this channel $vt += $vc; # Value Count accumulator push @vc, "$clr $vc"; } printf("CR: $lbl Chan Value Counts: %s, tot=$vt\n", join(", ", @vc)); return $vc; # Last ValueCount should be for T, TrueRGB } # End Count_Rgb().