title: Edge detection on dim edges using Python
body: <p>I want to find dim edges using Python.</p>
  
  <p>Input images (100 X 100) : </p>
  
  <p><a href="https://i.stack.imgur.com/VTJE2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VTJE2.jpg" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/EupLv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EupLv.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/E1lQE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E1lQE.png" alt="enter image description here"></a></p>
  
  <p>It consists of several horizontal boards: top, middle, bottom.</p>
  
  <p>I want to find middle board bounding box like:</p>
  
  <p><a href="https://i.stack.imgur.com/ekISU.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ekISU.jpg" alt="enter image description here"></a></p>
  
  <p>I used several edge detection methods (prewitt_x, sobel_x, cv2.findContours) but cannot detect well.</p>
  
  <p>Because edge btw black region and board region is dim.</p>
  
  <p>How can I find bounding box like red box?</p>
  
  <p>Code below is example using prewitt_x and cv2.findContours:</p>
  
  <pre><code>import cv2
  import numpy as np
  
  img = cv2.imread('my_dir/my_img.bmp',0)
  
  # prewitts_x
  kernelx = np.array([[1,1,1],[0,0,0],[-1,-1,-1]])
  img_prewittx = cv2.filter2D(img, -1, kernelx)
  img_prewittx_gray = cv2.cvtColor(img_prewittx, cv2.COLOR_BGR2GRAY)
  cv2.imwrite('my_outdir/my_outimg.bmp',img_prewittx)
  
  # cv2.findContours
  image, contours, hierarchy = cv2.findContours(img_prewittx_gray, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
  rects = [cv2.boundingRect(cnt) for cnt in contours]
  print(rects)
  </code></pre>
  
  <p>In fact, I don't want to use slower one like Canny detector.</p>
  
  <p>Help me :)</p>