0

I'm currently overlaying a thermal camera on a normal rgb camera, the thermal camera outputs an image in grey scale.

I'm converting to rgb using a colormap to add colour to the image, then overlaying it to the normal rgb camera. This is working fine

thermal = cv2.applyColorMap(thermal, cv2.COLORMAP_HOT)
alpha =0.5
blended_portion = cv.addWeighted(foreground, alpha, background[:foreground_height,:foreground_width,:], 1 - alpha, 0, background)
background[:foreground_height,:foreground_width,:] = blended_portion
cv.imshow('composited image', background)

However this code applies that 0.5 opacity to the entire image, is there any way possible where i only decrease the opacity at a certain threshold? so for example if its cold then its just 0 opacity but when its hot the opacity is 100?

so kind of like this: enter image description here

yoyo
  • 59
  • 1
  • 7
  • Does `background[thermal > 50] = blended_portion` work? There is some trick in numpy that lets you set certain pixels. Refer to `numpy.where()` also – Sparkofska Aug 26 '21 at 08:42

1 Answers1

0

Sorry for not providing code, but with these resources you should be able to figure it out:

  1. See the thresholding tutorial to create a binarized version of your thermal image.

  2. Then apply this binary image as a mask to your thermal image so that only the 'hot parts' remain (see this answer)

  3. Now, in your call to cv.addWeighted() use the masked thermal image.

Sparkofska
  • 1,280
  • 2
  • 11
  • 34
  • can i get a bit more details on this? im not sure how to implement this method because im already overlaying the images and as i mentioned when i overlay the images and use the threshold it effects the entire photo. i want only the hotspots in the image i want everything else to be transparent – yoyo Aug 29 '21 at 23:22
  • Can you add picture of what you have right now, and an example picture of what you want? I don't really know how you define "hot" spot. Red is hot I assume, but what about yellow and all these shades of orange – Sparkofska Aug 30 '21 at 10:42