File: C:/xampp/htdocs/FograCT1/ParseCRIx.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Gray finder Check</title>
<style type="text/css">
<!--
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #ffffff;
margin: 0; /* 比較好的做法是將 Body 元素的邊界與欄位間隔調整為零,以處理不同的瀏覽器預設值 */
padding: 0;
text-align: center; /* 這樣會讓容器在 IE 5* 瀏覽器內置中對齊。然後,文字會在 #container 選取器中設定為靠左對齊預設值 */
color: #000000;
}
.oneColElsCtr #container {
width: 46em;
background: #FFFFFF;
margin: 0 auto; /* 自動邊界 (搭配寬度) 會讓頁面置中對齊 */
border: 0px solid #000000;
text-align: left; /* 這樣做會覆寫 Body 元素上的 text-align: center。 */
}
.oneColElsCtr #mainContent {
padding: 0 20px; /* 請記住,欄位間隔就是 Div 方塊內部的空間,而邊界就是 Div 方塊外部的空間 */
}
-->
</style></head>
<body class="oneColElsCtr">
<?php
include 'sp38XYZ.php';
include 'xyz2lab01.php';
include 'xyz2lab.php';
//error_reporting(0);
$company=$_GET['company'];
$light=$_GET["fileLT"];
echo "Light:".$light;
$contents = file("upload/".$light);
$stringC = implode($contents);
$string = implode($contents);
$dot = explode("_", $string);
print_r($dot);
$snstring=$dot[0];
echo "sn:".$snstring;
$old_name = "upload/".$light;
$new_name = "upload/criTT.txt";
// Renaming the file
if (copy($old_name, $new_name)) {
echo "File renamed successfully.";
} else {
echo "Error renaming the file.";
}
$LightX=sp38XYZ("X",($dot[3+1]*1),($dot[3+2]*1),($dot[3+3]*1),($dot[3+4]*1),($dot[3+5]*1),($dot[3+6]*1),($dot[3+7]*1),($dot[3+8]*1),($dot[3+9]*1),($dot[3+10]*1),($dot[3+11]*1),($dot[3+12]*1),($dot[3+13]*1),($dot[3+14]*1),($dot[3+15]*1),($dot[3+16]*1),($dot[3+17]*1),($dot[3+18]*1),($dot[3+19]*1),($dot[3+20]*1),($dot[3+21]*1),($dot[3+22]*1),($dot[3+23]*1),($dot[3+24]*1),($dot[3+25]*1),($dot[3+26]*1),($dot[3+27]*1),($dot[3+28]*1),($dot[3+29]*1),($dot[3+30]*1),($dot[3+31]*1),($dot[3+32]*1),($dot[3+33]*1),($dot[3+34]*1),($dot[3+35]*1),($dot[3+36]*1));
$LightY=sp38XYZ("Y",($dot[3+1]*1),($dot[3+2]*1),($dot[3+3]*1),($dot[3+4]*1),($dot[3+5]*1),($dot[3+6]*1),($dot[3+7]*1),($dot[3+8]*1),($dot[3+9]*1),($dot[3+10]*1),($dot[3+11]*1),($dot[3+12]*1),($dot[3+13]*1),($dot[3+14]*1),($dot[3+15]*1),($dot[3+16]*1),($dot[3+17]*1),($dot[3+18]*1),($dot[3+19]*1),($dot[3+20]*1),($dot[3+21]*1),($dot[3+22]*1),($dot[3+23]*1),($dot[3+24]*1),($dot[3+25]*1),($dot[3+26]*1),($dot[3+27]*1),($dot[3+28]*1),($dot[3+29]*1),($dot[3+30]*1),($dot[3+31]*1),($dot[3+32]*1),($dot[3+33]*1),($dot[3+34]*1),($dot[3+35]*1),($dot[3+36]*1));
$LightZ=sp38XYZ("Z",($dot[3+1]*1),($dot[3+2]*1),($dot[3+3]*1),($dot[3+4]*1),($dot[3+5]*1),($dot[3+6]*1),($dot[3+7]*1),($dot[3+8]*1),($dot[3+9]*1),($dot[3+10]*1),($dot[3+11]*1),($dot[3+12]*1),($dot[3+13]*1),($dot[3+14]*1),($dot[3+15]*1),($dot[3+16]*1),($dot[3+17]*1),($dot[3+18]*1),($dot[3+19]*1),($dot[3+20]*1),($dot[3+21]*1),($dot[3+22]*1),($dot[3+23]*1),($dot[3+24]*1),($dot[3+25]*1),($dot[3+26]*1),($dot[3+27]*1),($dot[3+28]*1),($dot[3+29]*1),($dot[3+30]*1),($dot[3+31]*1),($dot[3+32]*1),($dot[3+33]*1),($dot[3+34]*1),($dot[3+35]*1),($dot[3+36]*1));
echo "XYZ:".$LightX.",".$LightY.",".$LightZ;
$Xn=$LightX/($LightX+$LightY+$LightZ);
$Yn=$LightY/($LightX+$LightY+$LightZ);
$Zn=$LightZ/($LightX+$LightY+$LightZ);
echo "XnYnZn:".$Xn.",".$Yn.",".$Zn;
$Lxn=($LightX*100)/$LightY;
$Lzn=($LightZ*100)/$LightY;
$Lyn=($LightY*100)/$LightY;
echo "<br>xyY:".$Lxn.",".$Lyn.",".$Lzn;
$Lx=$Lxn/($Lxn+$Lyn+$Lzn);
$Ly=$Lyn/($Lxn+$Lyn+$Lzn);
echo "<br>xy:".$Lx.",".$Ly;
$x=$Xn/($Xn+$Yn+$Zn);
$y=$Yn/($Xn+$Yn+$Zn);
echo "<br>nxy:".$x.",".$y;
//echo "<br>xy:".$dot[1].",".$dot[2];
$n=($dot[1]-0.332)/($dot[2]-0.1858);
$n2=($Lx-0.332)/($Ly-0.1858);
$Lux=$dot[3];
$cct= (-449*pow($n,3)) + (3525*pow($n,2)) - 6823.3*$n + 5520.33;
$cct2=(-449*pow($n2,3)) + (3525*pow($n2,2)) - 6823.3*$n2 + 5520.33;
$cct=round($cct,0);
$cct2=round($cct2,0);
echo "<br>CCT:".$cct."cct2:".$cct2.",__Lux=".$Lux;
$dtime=time();
$dStr=substr($dtime,7,9);
$myFile ="data.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
//fwrite($fh, $p);
$viHead=$dot[4]." ".$dot[5]." ".$dot[6]." ".$dot[7]." ".$dot[8]." ".$dot[9]." ".$dot[10]." ".$dot[11]." ".$dot[12]." ".$dot[13]." ".$dot[14]." ".$dot[15]." ".$dot[16]." ".$dot[17]." ".$dot[18]." ".$dot[19]." ".$dot[20]." ".$dot[21]." ".$dot[22]." ".$dot[23]." ".$dot[24]." ".$dot[25]." ".$dot[26]." ".$dot[27]." ".$dot[28]." ".$dot[29]." ".$dot[30]." ".$dot[31]." ".$dot[32]." ".$dot[33]." ".$dot[34]." ".$dot[35]." ".$dot[36]." ".$dot[37]." ".$dot[38]." ".$dot[39];
fwrite($fh, $viHead);
fclose($fh);
//sleep(1);
//exec('echo . | "C:\Program Files\R\R-4.4.0\bin\Rscript" appi1MxNoUi.R');
//sleep(1);
exec('echo . | "C:\Users\fred\AppData\Local\Programs\Python\Python37-32\python.exe" C:\xampp\htdocs\FograCT1\CRItest.py');
sleep(1);
$cctFile = file("critest.txt");
$stringCCT = implode($cctFile);
echo $stringCCT;
$trimmed_string = substr($stringCCT, 18);
echo $trimmed_string;
$stringCCT=round($trimmed_string,0);
?>
<table width="300" border="1" align="center">
<tr>
<td bgcolor="#cccccc"> CCT:</td><td><?php echo $cct;?></td><td bgcolor="#cccccc">Lux</td><td><?php echo $Lux;?></td></td></td>
</tr>
<tr>
<td bgcolor="#cccccc"> CRI:</td><td><?php echo $stringCCT;?></td>
</tr>
</table>
<?php
$contentD = file("D50data.txt");
$stringD = implode($contentD);
$dotT = explode("\t", $stringD);
//print_r($dot);
unlink('splineC.png');
require_once ('../jpgraph/jpgraph.php');
require_once ('../jpgraph/jpgraph_line.php');
require_once ('../jpgraph/jpgraph_scatter.php');
require_once ('../jpgraph/jpgraph_mgraph.php');
require_once ('../jpgraph/jpgraph_regstat.php');
//echo "dot39:". floatval($dot[39]);
//print_r($dotT);
$xdata = array(380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550,560,570,580,590,600,610,620,630,640,650,660,670,680,690,700,710,720,730);
$ydata = array($dot[4]/$dot[22],$dot[5]/$dot[22],$dot[6]/$dot[22],$dot[7]/$dot[22],$dot[8]/$dot[22],$dot[9]/$dot[22],$dot[10]/$dot[22],$dot[11]/$dot[22],$dot[12]/$dot[22],$dot[13]/$dot[22],$dot[14]/$dot[22],$dot[15]/$dot[22],$dot[16]/$dot[22],$dot[17]/$dot[22],$dot[18]/$dot[22],$dot[19]/$dot[22],$dot[20]/$dot[22],$dot[21]/$dot[22],$dot[22]/$dot[22],$dot[23]/$dot[22],$dot[24]/$dot[22],$dot[25]/$dot[22],$dot[26]/$dot[22],$dot[27]/$dot[22],$dot[28]/$dot[22],$dot[29]/$dot[22],$dot[30]/$dot[22],$dot[31]/$dot[22],$dot[32]/$dot[22],$dot[33]/$dot[22],$dot[34]/$dot[22],$dot[35]/$dot[22],$dot[36]/$dot[22],$dot[37]/$dot[22],$dot[38]/$dot[22], floatval($dot[39])/$dot[22]);
$xdata2 = array(380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550,560,570,580,590,600,610,620,630,640,650,660,670,680,690,700,710,720,730);
$ydata2 = array($dotT[0],$dotT[1],$dotT[2], floatval($dotT[3]),$dotT[4],$dotT[5],$dotT[6],$dotT[7],$dotT[8],$dotT[9],$dotT[10],$dotT[11],$dotT[12],$dotT[13],$dotT[14],$dotT[15],$dotT[16],$dotT[17],$dotT[18],$dotT[19],$dotT[20],$dotT[21],$dotT[22],$dotT[23],$dotT[24],$dotT[25],$dotT[26],$dotT[27],$dotT[28],$dotT[29],$dotT[30],$dotT[31],$dotT[32],$dotT[33],$dotT[34],floatval($dotT[35]));
// Get the interpolated values by creating
// a new Spline object.
$spline = new Spline($xdata,$ydata);
$spline2 = new Spline($xdata2,$ydata2);
// For the new data set we want 40 points to
// get a smooth curve.
list($newx,$newy) = $spline->Get(50);
list($newx2,$newy2) = $spline2->Get(50);
//echo "<br>nex2:".$newx2;
//print_r($newx2);
// Create the graph
$g = new Graph(380,250);
$g->SetMargin(30,20,40,30);
//$g->title->Set("Curve C");
$g->title->SetFont(FF_ARIAL,FS_NORMAL,12);
$g->subtitle->Set('Test in Green (D50 in Blue)');
//$g->subtitle->SetColor('darkred');
$g->SetMarginColor('lightgreen');
//$g->img->SetAntiAliasing();
// We need a linlin scale since we provide both
// x and y coordinates for the data points.
$g->SetScale('linlin');
// We want 1 decimal for the X-label
$g->xaxis->SetLabelFormat('%1.1f');
// We use a scatterplot to illustrate the original
// contro points.
$splot = new ScatterPlot($ydata,$xdata);
$splot2 = new ScatterPlot($ydata2,$xdata2);
//
$splot->mark->SetFillColor('[email protected]');
$splot->mark->SetColor('[email protected]');
$splot2->mark->SetFillColor('[email protected]');
$splot2->mark->SetColor('[email protected]');
// And a line plot to stroke the smooth curve we got
// from the original control points
$lplot = new LinePlot($newy,$newx);
$g->Add($lplot);
$lplot->SetColor('darkgreen');
$lplot2 = new LinePlot($newy2,$newx2);
$g->Add($lplot2);
$lplot2->SetColor('[email protected]');
//$g->Add($splot);
//$g->Add($splot2);
$g->Stroke('splineC.png');
?>
<table border="1" align='center'>
<tr>
<td><img src="splineC.png?nocache=<?php echo time(); ?>"></td>
</tr>
</table>
<br><br>
<tr>
<td align="center"><font size="-2"> © <a href="mailto:[email protected]">Fred Kuo</a>, 2024. All rights reserved.<br><a href="http://www.pbn.com.tw/wordpress">Read more.</a><br>
</td>
</tr>
</body>
</html>