Lab-XYZ 색상 변환 구현

Lab-XYZ 색상 변환 구현

1 소스 코드[ | ]

<?php
function xmp_print($arr) { echo '<xmp>'; print_r($arr); echo '</xmp>'; }
function lab2xyz($lab) {
	list($l, $a, $b) = $lab;
	$y = $l/116 + 0.1379310344827586;
	$x = $a/500 + $y;
	$z = $y - $b/200;

	$x = $x > 0.2068965517241379 ? pow($x,3) : $x/7.787 - 0.0177129876053369;
	$y = $y > 0.2068965517241379 ? pow($y,3) : $y/7.787 - 0.0177129876053369;
	$z = $z > 0.2068965517241379 ? pow($z,3) : $z/7.787 - 0.0177129876053369;

	// Observer = 2°, Illuminant = D65
	$x *= 95.047;
	$y *= 100.000;
	$z *= 108.883;
	return array($x, $y, $z);
}

$white = array(100.000, 0.005, -0.010);
$yellow = array(97.138, -21.556, 94.482);
$red = array(53.233, 80.109, 67.220);
$black = array(0, 0, 0);

xmp_print( lab2xyz( $white ) );
xmp_print( lab2xyz( $yellow ) );
xmp_print( lab2xyz( $red ) );
xmp_print( lab2xyz( $black ) );

2 실행 결과[ | ]

Array
(
    [0] => 95.049851438514
    [1] => 100
    [2] => 108.89933326664
)
Array
(
    [0] => 76.999426977932
    [1] => 92.779392383866
    [2] => 13.850024627033
)
Array
(
    [0] => 41.240065373795
    [1] => 21.260108903626
    [2] => 1.9300302151415
)
Array
(
    [0] => 1.978563146654E-15
    [1] => 2.0816681711722E-15
    [2] => 2.2665827548174E-15
)

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}