title: OpenCV-Python: How to detect a hotspot in thermal image?
body: <p>I am using openCV and Python to make a computer vision application that detects hotspots in an image from thermal cameras.  </p>
  
  <p>The image is basically of a big machinery and I want to get the hottest (in terms of temperature) part of the image.<br>
  What I thought of till now:</p>
  
  <ol>
  <li>Use color quantization (and K-means) to reduce the number of colors to 8.</li>
  <li>Use some sort of thresholding and get the cluster with most amount of red (since usually red=more heat).</li>
  </ol>
  
  <p>Now I've successfully done the first part. I have a quantized image which contains 8 colors only.<br>
  All the thresholding I've done till now needs me to put the color range myself (i.e using <code>cv2.inRange</code> function to create a mast and then using <code>cv2.bitwiseAND</code> to apply the mask to the image). But here I want it to be dynamic, so that it just gets the hottest part. i.e even if there is very little red, it should just get me the region with most red.</p>
  
  <p>So what is a way to do that? </p>
  
  <p>(Also, by "Hotspots", here I mean actual HOT spots. I.e spots which have the highest temparature.)</p>
  
  <p>Edit:
  As the comment from <a href="https://stackoverflow.com/users/1648011/photon">Photon</a> mentioned, currently I'm calculating the histogram of red and using that to set the threshold.<br>
  I'm looking to optimize this further, so let me know if any more efficient method exists. (The process should be fast. I can compromise on the accuracy to an extent)  </p>