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 = "red.jpg";
- list($width, $height, $type, $attr) = getimagesize($fiel);
- echo "<img src=\"". $fiel."\" $attr alt=\"getimagesize() example\" />";
- $centerX = $width / 2;
- $centerY = $height / 2;
- 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>';
- $im = imagecreatefromjpeg($fiel);
- $Pi = pi();
- for ($a=0; $a<=1; $a++) {
- $ax = $r*cos($a*$Pi/180) + $centerX ; //x
- $ay = $r*sin($a*$Pi/180) + $centerY ; //y
- $PXCol = imagecolorat($im, $ax, $ay);
- echo $ax . ", " . $ay . ", " . $PXCol . "<br>";
- //$sum = $sum + $PXCol;
- //$avg = $sum / 360;
- }
- //Says red ff0000 is 16646144
- //echo "<br>Average Pixel Value in ring is: ". $avg . "<br>";
- //$trunc = round($avg);
- //echo "<br>Trucated Average: ".$trunc."<br>";
- echo "<br>Average in Hex: ". dechex(16646144) ."<br>";
- echo "<br>The value FF0000 should be: ". hexdec("#FF0000") ."<br>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement