Skip to content

Commit

Permalink
Merge cd2153f into efb6677
Browse files Browse the repository at this point in the history
  • Loading branch information
iynehz committed Jan 6, 2023
2 parents efb6677 + cd2153f commit a342e17
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/PDL/Transform/Color.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,7 @@ sub f_lab {
my $delta = 6/29;
my $delta3 = $delta * $delta * $delta;
return (
($in > $delta3) * ( $in * (($in->abs+($in==0)) ** (0.333-1)) ) +
($in > $delta3) * ( $in * (($in->abs+($in==0)) ** (1/3-1)) ) +
($in <= $delta3) * ( $in / (3 * $delta * $delta) + 4/29 )
);
}
Expand Down
10 changes: 9 additions & 1 deletion t/color.t
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ 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.5859237, 5.5509345)), 't_xyz2lab right values' or diag "got=$b";
ok all(approx $b, pdl(100, 8.5945916, 5.5564131)), 't_xyz2lab right values' or diag "got=$b";


for my $rgb (pdl(255, 0, 0), pdl(0, 255, 0), pdl(0, 0, 255)) {
my $t = t_lab() x !t_srgb();
my $lab = $rgb->apply($t);
my $rgb2 = $lab->invert($t);
ok(all(approx $rgb2, $rgb), "t_lab loop $rgb") or diag "got=$b";
}

done_testing;

0 comments on commit a342e17

Please sign in to comment.