title: How to draw contour of the heatmap and superimpose on original image using opencv python?
body: <p><a href="https://i.stack.imgur.com/5LhGh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5LhGh.png" alt="enter image description here" /></a><a href="https://i.stack.imgur.com/fixg3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fixg3.png" alt="heatmap" /></a></p>
  <p>I have measured the class activation maps and superimposed on the original image. Rather, I would like to include only the contour (in blue) of the heatmap and superimpose on the original image, so that the original image details are not obstructed. The code for creating the heatmap and superimposing on the original image is shown:</p>
  <pre><code>img = cv2.imread(img_path)    
  #Resizes the heatmap to be the same size as the original image
  heatmap = cv2.resize(heatmap, (img.shape[1], img.shape[0]))    
  #Converts the heatmap to RGB 
  heatmap = np.uint8(255 * heatmap)    
  heatmap = cv2.applyColorMap(heatmap, cv2.COLORMAP_JET)
  heatmap1 = cv2.cvtColor(heatmap, cv2.COLOR_BGR2GRAY)
  thresh = cv2.threshold(heatmap1, 0, 255, cv2.THRESH_BINARY_INV 
  |cv2.THRESH_OTSU)[1]
  contours = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, 
  cv2.CHAIN_APPROX_NONE)[0]
  cnt1 = contours[1] #vary the contour number and see the performance
  img1 = cv2.drawContours(img, [cnt1], -1, (255, 255, 255), 3)
  </code></pre>