Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 30th, 2012  |  syntax: None  |  size: 0.43 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Can PHP process images as matrices like MATLAB?
  2. $width = 1024;
  3. $length = 768;
  4. $myImage = array();
  5. for($i = 0; $i < $width; $i++){
  6.         for($i2 = 0; $i2 < $width; $i2++){
  7.             //        X   Y
  8.             $myImage[$i][$ii] = array(
  9.                 'red'   => 0,
  10.                 'green' => 0,
  11.                 'blue'  => 0,
  12.                 'alpha' => 0);
  13.         }
  14. }
  15.        
  16. foreach($myImage[500] as &$pixel){
  17.     $pixel['red'] = 255;
  18. }