File: C:/xampp/htdocs/FograCT1/deltaE2000_graph.php
<table width="200" border="1" align="center">
<tr>
<td>
<div align="center">
<?php // content="text/plain; charset=utf-8"
unlink('scatter00.png');
require_once ('../jpgraph/jpgraph.php');
require_once ('../jpgraph/jpgraph_scatter.php');
// Function to calculate ΔE₀₀ (CIEDE2000)
include 'de00.php';
// Center color (L*, a*, b*)
$L_center=$_POST['L'];
$a_center=$_POST['a'];
$b_center=$_POST['b'];
//$L_center = 55;
//$a_center = -3;
//$b_center = -50;
// Generate points for 2 ΔE₀₀ ellipse/circle
$a_values = [];
$b_values = [];
for ($angle = 0; $angle <= 360; $angle += 5) { // Adjust step size for more/less precision
// Initial guess for a* and b* (using ΔE76 circle as a starting point)
$a_guess = $a_center + 2 * cos(deg2rad($angle));
$b_guess = $b_center + 2 * sin(deg2rad($angle));
// Refine the guess to achieve ΔE₀₀ ≈ 2
$tolerance = 0.01;
do {
$deltaE = de00($L_center, $a_center, $b_center, $L_center, $a_guess, $b_guess);
// Adjust a_guess and b_guess
$a_guess += 0.01 * (2 - $deltaE) * cos(deg2rad($angle));
$b_guess += 0.01 * (2 - $deltaE) * sin(deg2rad($angle));
} while (abs($deltaE - 2) > $tolerance);
// Save the point
$a_values[] = $a_guess;
$b_values[] = $b_guess;
}
$a_values_76 = [];
$b_values_76 = [];
for ($angle = 0; $angle <= 360; $angle += 5) { // Adjust step size for more/less precision
$a_values_76[] = $a_center + 2 * cos(deg2rad($angle));
$b_values_76[] = $b_center + 2 * sin(deg2rad($angle));
}
$min_a = min($a_values) - 2;
$max_a = max($a_values) + 2;
$min_b = min($b_values) - 2;
$max_b = max($b_values) + 2;
$range = max(($max_a - $min_a), ($max_b - $min_b));
//echo "range=".$range.",a range:".($max_a - $min_a).",b range:".($max_b - $min_b);
// Ensure the scale is square
$ratio=($max_a - $min_a)/($max_b - $min_b);
//echo "ratio=".$ratio;
// Create a square graph (1:1 aspect ratio)
$graphWidth = 385*$ratio;
$graphHeight = 600;
$graph = new Graph($graphWidth, $graphHeight);
//$graph->SetScale('linlin');
// Set the scale to ensure equal scaling for x and y axes
/* $min_a = min($a_values) - 5;
$max_a = max($a_values) + 5;
$min_b = min($b_values) - 5;
$max_b = max($b_values) + 5; */
$graph->SetScale('linlin', $min_b, $max_b, $min_a, $max_a);
//$graph->SetScale('linlin', $min_a, $max_a, $min_b, $max_b);
$graph->SetBox(true); // Add a box around the graph
$graph->SetFrame(true); // Add a frame around the graph
// Set titles
$graph->title->Set('2 ΔE00 Ellipse/Circle');
$graph->xaxis->title->Set('a*');
$graph->yaxis->title->Set('b*');
// Create a scatter plot
$scatter = new ScatterPlot($b_values, $a_values);
$scatter->mark->SetType(MARK_FILLEDCIRCLE);
$scatter->mark->SetWidth(3);
$scatter_76 = new ScatterPlot($b_values_76, $a_values_76);
$scatter_76->mark->SetType(MARK_FILLEDCIRCLE);
$scatter_76->mark->SetWidth(3);
$scatter_76->mark->SetColor('red');
$scatter_76->SetLegend('2 ΔE76');
// Add the plot to the graph
$graph->Add($scatter);
$graph->Add($scatter_76);
// Display the graph
$graph->Stroke('scatter00.png');
?>
<img src="scatter00.png">
</div>
</td>
</tr>
</table>