File: C:/Users/fred/AppData/Roaming/Code/User/History/51bd029e/bsJP.php
<table width="200" border="1" align="center">
<tr>
<td>
<div align="center">
<?php
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*)
// Center color (L*, a*, b*)
$L_center = 89;
$a_center = -5;
$b_center = 93;
// Generate points for 2 ΔE₀₀ ellipse/circle
$a_values_00 = [];
$b_values_00 = [];
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_00[] = $a_guess;
$b_values_00[] = $b_guess;
}
// Generate points for 2 ΔE₇₆ circle
$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(min($a_values_00), min($a_values_76)) - 0;
$max_a = max(max($a_values_00), max($a_values_76)) + 0;
$min_b = min(min($b_values_00), min($b_values_76)) - 0;
$max_b = max(max($b_values_00), max($b_values_76)) + 0;
$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 = 600*$ratio;
$graphHeight = 600;
$graph = new Graph($graphWidth, $graphHeight);
// Set the scale to ensure equal scaling for x and y axes
$graph->SetScale('linlin', $min_b, $max_b, $min_a, $max_a);
// Set equal tick intervals for both axes
/* $interval = $range / 10;
$graph->xaxis->SetTickPositions(range($min_a, $max_a, $interval));
$graph->yaxis->SetTickPositions(range($min_b, $max_b, $interval));
// Force equal scaling for X and Y axes
//$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 and 2 ΔE00 Circle');
$graph->xaxis->title->Set('a*');
$graph->yaxis->title->Set('b*');
// Create scatter plots
$scatter_00 = new ScatterPlot($b_values_00, $a_values_00);
$scatter_00->mark->SetType(MARK_FILLEDCIRCLE);
$scatter_00->mark->SetWidth(5);
$scatter_00->mark->SetColor('blue');
$scatter_00->SetLegend('2 ΔE00');
$scatter_76 = new ScatterPlot($b_values_76, $a_values_76);
$scatter_76->mark->SetType(MARK_FILLEDCIRCLE);
$scatter_76->mark->SetWidth(5);
$scatter_76->mark->SetColor('red');
$scatter_76->SetLegend('2 ΔE');
// Add the plots to the graph
$graph->Add($scatter_00);
$graph->Add($scatter_76);
// Display the graph
$graph->Stroke('scatter00.png');
?>
<img src="scatter00.png">
</div>
</td>
</tr>
</table>