Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //The purpose of this script is to help me figure out if I am averaging and translating colors correctly for the ring spectrometer
- $fiel = "1.png";
- list($width, $height, $type, $attr) = getimagesize($fiel);
- echo "<img src=\"". $fiel."\" $attr alt=\"getimagesize() example\" />";
- $im = imagecreatefrompng("1.png");
- $Pi = pi();
- $centerX = $width / 2;
- $centerY = $height / 2;
- echo "<br>The picture here is " . $width . " wide, and " . $height . " tall. <br>";
- echo "<br>The center of the image is at " .$centerX . ", " . $centerY ;
- echo '<br>Test Trig Fucntions php <br> Get all cordinates for a circle<br>';
- //$r = 1 ;
- $sum = 0;
- //echo 'Radiuz == ' . $r . '<br> X, Y, PixelColour at that point.<br><br>';
- //Max radius
- if ($centerX < $centerY){
- $maxRad = $centerX - 1;
- }
- elseif
- ($centerY <= $centerX){
- $maxRad = $centerY -1;
- }
- echo "Maximumux Radius is: " . $maxRad . "<br><br>Ring Number, Average Value:<br>";
- for($r=1; $r<=$maxRad; $r++ ){
- for ($a=0; $a<=360; $a++) {
- $ax = $r*cos($a*$Pi/180) + $centerX ; //x
- $ay = $r*sin($a*$Pi/180) + $centerY ; //y
- $PXCol = imagecolorat($im, $ax, $ay); //outputs a decimal number for color
- // echo $ax . ", " . $ay . ", " . $PXCol . "<br>";
- $sum = $sum + $PXCol;
- $avg = $sum / 360;
- $trunc = round($avg);
- }
- echo $r . ", " . dechex($trunc) . "<br>";
- }
- // choose a color for the ellipse
- $ellipseColor = imagecolorallocate($im, 0, 0, 255);
- // draw the white ellipse
- imagefilledellipse($im, $centerX, $centerY, 300, 300, $ellipseColor);
- // Output the image.
- //header("Content-type: image/png");
- //imagepng($im);
- //echo "<br>Trucated Average: ".$trunc."<br>";
- //echo "<br>Average in Hex: ". dechex($trunc) ."<br>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement