title: OpenCV: Choosing HSV thresholds for color filtering
body: <p>In order to filter a color out of an image, it's necessary to set boundaries as to which color needs to be detected. I have a feeling this is mostly a trial-and-error process. Are there any ways to quickly find the correct thresholds for a particular color? In this specific case I'm trying to detect the gray area of the graph in the picture below. This without detecting the dotted lines of course. For this example I need very specific boundaries. The question is, how can I find them easily?</p>
  
  <pre><code>hsv = cv2.cvtColor(im, cv2.COLOR_BGR2HSV)
  
  lower = np.array([0, 0, 0], np.uint8)
  upper = np.array([180, 255, 200], np.uint8)
  
  mask = cv2.inRange(hsv, lower, upper)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/SuGwH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SuGwH.png" alt="enter image description here"></a></p>