title: Crop just the white pixels
body: <p>I wrote the following code using OpenCV and Python:</p>
  
  <pre><code>import cv2    
  
  cap = cv2.VideoCapture(1)
  
  cv2.namedWindow('Original')
  cv2.namedWindow('Captured')
  cv2.namedWindow('Deffects')
  
  while True:
  
      ret, frame = cap.read()
      gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
      cv2.imshow('frame', frame)
  
      if cv2.waitKey(1) == ord('c'):
          cv2.imshow('Captured', gray)
          cv2.imwrite('tswira.jpg', frame)
  
      if cv2.waitKey(1) == ord('s'):
          img1 = cv2.imread('carte1.jpg', 0)
          img2 = cv2.imread('tswira.JPG', 0)
  
          img1 = cv2.resize(img1, (250, 250))
          img2 = cv2.resize(img2, (250, 250))
  
          sub = img1 - img2
  
          cv2.imshow('Original', img1)
          cv2.imshow('Captured', img2)
          cv2.imshow('Deffects', sub)
  
      if cv2.waitKey(1) == ord('q'):
          break
  
  cap.release()
  cv2.destroyAllWindows()
  </code></pre>
  
  <p>This is the image I'm getting as output:</p>
  
  <p><a href="https://i.stack.imgur.com/lQfCi.jpg%20%3E" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lQfCi.jpg%20%3E" alt="![enter image description here"></a></p>
  
  <p>However, my question is this: how can I crop just the white area?</p>