Prepare for reuse in other YUVish conversions.
our $VERSION = '1.00';
+# ITU-R recommendation 601 luma co-efficients
+our $kr = .299;
+our $kb = .114;
+our $kg = 1 - $kb - $kr;
+
sub new {
my $class = shift;
my @rgb = @_ >= 3 ? @_ : (map {hex} $_[0] =~ /(..)/g);
}
sub luminance {
- # perceived brightness (using ITU-R recommendation 601 luma co-efficients)
+ # perceived brightness
my ($r, $g, $b) = @{ $_[0] };
- return $r*.299 + $g*.587 + $b*.114;
+ return $r*$kr + $g*$kg + $b*$kb;
}
sub rgb24 {