title: Scanning Image Pixels
body: <p>I want to detect a shape(blue area) in an image. How do I start reading the pixels from a user input coordinate(red dot), scan the pixels around the dot, and stop reading when it crosses the boundary of the shape, instead of scanning the whole image as following?</p>
  
  <pre><code>for (int y = 0 &lt; height; y++) {
      for (int x = 0; x &lt; width; x++) {
         // Read and store pixel value and location     
      }
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/gkRMx.png" alt="enter image description here"></p>