use warnings;
use List::Util qw( min max );
-our $VERSION = '1.04';
+our $VERSION = '1.05';
# ITU-R recommendation 601 luma co-efficients
our $kr = .299;
}
sub newyuv {
- # convert from YPbPr values 0..255 (or hex string)
+ # convert from YPbPr values -1..1
my $class = shift;
- my ($y, $cb, $cr) = @_ >= 3 ? @_ : (map {hex} $_[0] =~ /(..)/g);
-
- $_ -= 128 for $cb, $cr;
- $_ /= 255 for $y, $cb, $cr;
+ my ($y, $cb, $cr) = @_;
my @rgb = map { max(0, min(255, $_ * 255)) } (
$y + $cr,
bless \@rgb, $class;
}
+sub newyuv8 {
+ # convert from YPbPr values 0..255 (or hex string)
+ my $class = shift;
+ my ($y, $cb, $cr) = @_ >= 3 ? @_ : (map {hex} $_[0] =~ /(..)/g);
+
+ $_ -= 128 for $cb, $cr;
+ $_ /= 255 for $y, $cb, $cr;
+
+ $class->newyuv($y, $cb, $cr);
+}
+
sub luminance {
# perceived brightness
my ($r, $g, $b) = @{ $_[0] };