title: finding largest connected component using opencv 2.4 in python 2.7
body: <p>I am writing code in python 2.7.12 using opencv '2.4.9.1'.<br>
  I have a 2d numpy array containing values in range [0,255].<br>
  My aim is to find largest region containing value in range[x,y]<br>
  I found 
  <a href="https://stackoverflow.com/questions/47520487/how-to-use-python-opencv-to-find-largest-connected-component-in-a-single-channel">How to use python OpenCV to find largest connected component in a single channel image that matches a specific value?</a> as pretty well-explained .
  Only, the catch is - it is meant for opencv 3 .</p>
  
  <p>I can try to write a function of this type<br>
  [pseudo code]<br></p>
  
  <pre><code>def get_component(x,y,list):
    append x,y to list
    visited[x][y]=1
   if(x+1&lt;m &amp;&amp; visited[x+1][y]==0)
    get_component(x+1,y,list)
   if(y+1&lt;n &amp;&amp; visited[x][y+1]==0)
    get_component(x,y+1,list)
   if(x+1&lt;m)&amp;&amp;(y+1&lt;n)&amp;&amp;visited[x+1][y+1]==0
    get_component(x+1,y+1,list)
   return
  
  MAIN
  biggest_component = NULL
  biggest_component_size = 0
  low = lowest_value_in_user_input_range
  high = highest_value_in_user_input_range
  matrix a = gray image of size mxn
  matrix visited = all value '0' of size mxn
  for x in range(m):
   for y in range(n):
    list=NULL
    if(a[x][y]&gt;=low) &amp;&amp; (a[x][y]&lt;=high) &amp;&amp; visited[x][y]==1:
     get_component(x,y,list)
     if (list.size&gt;biggest_component_size)
      biggest_component = list
  Get maximum x , maximum y , min x and min y from above list containing coordinates of every point of largest component to make rectangle R .
  Mission accomplished !
  </code></pre>
  
  <p>[/pseudo code]<br></p>
  
  <p>Such an approach will not be efficient, I think.<br>
  Can you suggest functions for doing the same with my setup ?<br>
  Thanks.<br></p>