title: Undefined offset error in array php
body: <p>I got this messege when I run the code below<br>
  Notice: Undefined offset: 226 in C:\wamp\www\cbir\index.php on line 50</p>
  
  <p>I think that these lines of code cause the error
           $reds[$r]++;
           $greens[$g]++;
           $blues[$b]++;</p>
  
  <pre><code>    $reds = array();
  
      $blues = array();
      $greens = array();
  
      $freqr = array();
      $freqb = array();
      $freqg = array();
  
      $info = getimagesize($_FILES['image']['tmp_name']);
  
      $width = $info[0];
      $height = $info[1];
      $totalpixels = $width * $height;
  
      $img = imagecreatefromjpeg($_FILES['image']['tmp_name']);
      if ($img) {
           for ($i = 0; $i &lt; $height; $i++) {
          for ($j = 0; $j &lt; $width; $j++) {
              $rgb = imagecolorat($img, $j, $i);
              $r = ($rgb &gt;&gt; 16) &amp; 0xFF;
              $g = ($rgb &gt;&gt; 8) &amp; 0xFF;
              $b = $rgb &amp; 0xFF;
  
              // Add counts to our histogram arrays for each color.
              $reds[$r]++;
              $greens[$g]++;
              $blues[$b]++;
          }
      }
  </code></pre>