Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV-Python: How to detect a hotspot in thermal image?

I am using openCV and Python to make a computer vision application that detects hotspots in an image from thermal cameras.

The image is basically of a big machinery and I want to get the hottest (in terms of temperature) part of the image.
What I thought of till now:

  1. Use color quantization (and K-means) to reduce the number of colors to 8.
  2. Use some sort of thresholding and get the cluster with most amount of red (since usually red=more heat).

Now I've successfully done the first part. I have a quantized image which contains 8 colors only.
All the thresholding I've done till now needs me to put the color range myself (i.e using cv2.inRange function to create a mast and then using cv2.bitwiseAND 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.

So what is a way to do that?

(Also, by "Hotspots", here I mean actual HOT spots. I.e spots which have the highest temparature.)

Edit: As the comment from Photon mentioned, currently I'm calculating the histogram of red and using that to set the threshold.
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)

like image 408
ChaoticTwist Avatar asked Jul 12 '16 05:07

ChaoticTwist


1 Answers

In order to estimate a threshold dynamically, you need to look at the distribution of the data. For this purpose, you need to calculate the histogram of the red. Then, find a threshold such that a certain percentage of the pixels are below it. For example 90%.

like image 124
Photon Avatar answered Oct 15 '22 21:10

Photon