Skip to content

Commit

Permalink
fix t_xyz2lab
Browse files Browse the repository at this point in the history
  • Loading branch information
vadim-160102 authored and mohawk2 committed Jan 23, 2022
1 parent 4bafe6b commit 9b55b2a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- fix t_xyz2lab - thanks @vadim-160102

1.005 2020-09-17
- eliminate // to keep 5.006 compat

Expand Down
4 changes: 1 addition & 3 deletions lib/PDL/Transform/Color.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1539,9 +1539,7 @@ sub t_xyz2lab {
my $wp_xyy = xyy_from_illuminant($me->{params}->{white});
$me->{params}->{wp_xyz} = $wp_xyy->copy;
$me->{params}->{wp_xyz}->slice('2') .= 1 - $wp_xyy->slice('0') - $wp_xyy->slice('1');
$me->{params}->{wp_xyz} *= $wp_xyy->slice('2');


$me->{params}->{wp_xyz} *= $wp_xyy->slice('2') / $wp_xyy->slice('1');
# input is XYZ by the time it gets here
$me->{func} = sub {
my($in,$opt) = @_;
Expand Down
8 changes: 7 additions & 1 deletion t/color.t
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,17 @@ ok(all( ($aa > $a -1e-10) & ($aa < $a + 1e-10) ),"decoding undoes coding");
# (minimal testing)
$a = xvals(101)/100;
eval {$t = t_pc();};
ok(($@ && $@=~m/^Usage\:/), "t_pc with no arguments died and threw out an info message");
like $@, qr/^Usage\:/, "t_pc with no arguments died and threw out an info message";
eval {$t = t_pc('sepia');};
is $@, '', "t_pc('sepia') ran OK";
eval {$b=$a->apply($t);};
is $@, '', "t_pc applied OK";
ok($b->ndims==2 && $b->dim(0)==3, "t_pc created an RGB output");

eval {$t = t_xyz2lab();};
is $@, '', "t_xyz2lab ran OK";
eval {$b=pdl(1,1,1)->apply($t);};
is $@, '', "t_xyz2lab applied OK";
ok all(approx $b, pdl(100, 8.5841461, 5.5183538)), 't_xyz2lab right values' or diag "got=$b";

done_testing;

0 comments on commit 9b55b2a

Please sign in to comment.