title: Finding complete rectangles enclosing 0
body: <p>There are diverse rectangles in given 1000 x 1000 arrays.  in <code>&lt;Figure 1&gt;</code>, the serial “1” displayed as yellow cell is the pattern of rectangle. The minimum size of rectangle in <code>&lt;Figure 1&gt;</code> is 3 x 3 displayed as green cell.</p>
  
  <p>There should be at least one of ‘0’ inside the rectangle.</p>
  
  <p>But, in this array, there exists unclosed shape or straight line pattern also.</p>
  
  <p><img src="https://i.stack.imgur.com/HZF2M.png" alt="enter image description here"></p>
  
  <p>(The initial value of array is ‘0’, and the patterns are represented a series of ‘1’. They are not overlapped or included each other.)</p>
  
  <p>What could be an efficient algorithm to find the complete regtangles in the array except unclosed shape or straight line? For example in the figure above the number of complete rectangles is 3</p>