Advertisement
j0h

Color Is off.

j0h
Sep 18th, 2014
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.19 KB | None | 0 0
  1. <?php
  2. //The purpose of this script is to help me figure out if I am averaging and translating colors correctly for the ring spectrometer
  3.  
  4. $fiel = "red.jpg";
  5. list($width, $height, $type, $attr) = getimagesize($fiel);
  6. echo "<img src=\"". $fiel."\" $attr alt=\"getimagesize() example\" />";
  7.  
  8. $centerX = $width / 2;
  9. $centerY = $height / 2;
  10. echo "<br>The center of the image is at " .$centerX . ", " . $centerY ;
  11. echo '<br>Test Trig Fucntions php <br> Get all cordinates for a circle<br>';
  12. $r = 1 ;
  13. $sum = 0;
  14. echo 'Radiuz == ' . $r . '<br> X, Y, PixelColour at that point.<br><br>';
  15.  
  16. $im = imagecreatefromjpeg($fiel);
  17. $Pi = pi();
  18. for ($a=0; $a<=1; $a++) {
  19.  
  20.    $ax =  $r*cos($a*$Pi/180) + $centerX ; //x
  21.    $ay =  $r*sin($a*$Pi/180) + $centerY ; //y
  22.    $PXCol = imagecolorat($im, $ax, $ay);
  23.    echo $ax . ", " . $ay . ", " . $PXCol . "<br>";
  24. //$sum = $sum + $PXCol;
  25. //$avg = $sum / 360;
  26.  
  27.  
  28. }
  29. //Says red ff0000 is 16646144
  30.  
  31.  
  32. //echo "<br>Average Pixel Value in ring is: ". $avg . "<br>";
  33. //$trunc = round($avg);
  34. //echo "<br>Trucated Average:  ".$trunc."<br>";
  35. echo "<br>Average in Hex:  ". dechex(16646144) ."<br>";
  36. echo "<br>The value FF0000 should be:  ". hexdec("#FF0000") ."<br>";
  37.  
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement