title: Parallel Algorithm: Checking if a pixel is covered by one of the shapes
body: <p>There is a map in 2-d space coordinates are from leftPos to rightPos in x axis, and from bottomPos to topPos in y axis. </p>
  
  <p>There are shapes in this map: triangles, circles, squares. There are total of N shapes. I am trying to count to pixels if its inside any shapes. Shapes can overlap, and thus may have intersection areas.</p>
  
  <p>My code is:</p>
  
  <pre><code>% paintedPixel is initialized to all zeroes
  
  for i=1:1:N
      for j=leftPosition:1:rightPosition
         for k=bottomPos:1:topPos
             if (isInside(point(j,k), shape(i)) ) 
                  paintedPixel[j,k] = 1;
  
         done
      done
   done
  </code></pre>
  
  <p>so I am trying to parallelize this code but only I can change the last <em>for</em> to <em>parfor</em>. 
   For the outher <em>for</em> s, MATLAB complains that k is not fixed. I understand that there might be race condition in general, but this particular case, I am just trying to assign if any of the shapes cover the given pixel.</p>
  
  <p>So my question how to paralelize this ? I tried to put shape for to innermost, but MATLAB gives error saying that <strong>paintexPixel in parfor cannot be classified</strong></p>