Skip to content

Instantly share code, notes, and snippets.

@kiyotakagoto
Created February 10, 2012 01:58
Show Gist options
  • Save kiyotakagoto/1785448 to your computer and use it in GitHub Desktop.
Save kiyotakagoto/1785448 to your computer and use it in GitHub Desktop.
XYZ色空間からL*a*b*色空間へ
# 参考:http://www005.upp.so-net.ne.jp/fumoto/linkp25.htm
sub xyz_to_Lab {
my $xyz_href = shift;
my ($Xn, $Yn, $Zn) = ( 98.072, 100, 118.225);
#my ($Xn, $Yn, $Zn) = ( 95.045, 100, 108.892);
my $Lab = {
L => 116 * ( ($xyz_href->{X} / $Yn) ** (1/3) ) - 16,
a => 500 * ( ($xyz_href->{X} / $Xn) ** (1/3) - ($xyz_href->{Y} / $Yn) ** (1/3) ),
b => 200 * ( ($xyz_href->{Y} / $Yn) ** (1/3) - ($xyz_href->{Z} / $Zn) ** (1/3) ),
};
return $Lab;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment