How do I map grayscale values to get temperature?

In the attached file I have shown the thermal image clicked during live preview from my camera.
I am able to fetch the Minimum, Maximum, and Mean Grayscale Level values along with GL value at Center (Blue Circle) at backend continuously in live video.
I want to know if I can use these GL values to get corresponding temperature with any equation or any function.
Also can you suggest anything else that I can use for this purpose?

2 Comments

I would be very thankful if you guys can provide some insight and guide me.
@PRAVEEN KUMAR Look to my answer and comments below.

Sign in to comment.

Answers (2)

"I want to know if i can use these GL values to get corresponding temperature with any equation or any function."
No, there is way to do that based on the grayscale level. That colormap is not linear in grayscale brightness.

6 Comments

Look at the colorbar. Dark at the bottom, dark at the top. Notice the bright green in the middle. The eye is most sensitive to green, so bright green contributes a lot to grayscale intensity. The brightest grayscale is in the middle of the color bar. Any given lower brightness probably occurs at least twice, once in each direction away from the middle.
You have two possible solutions:
  • find some way to get temperature data from the camera (such as using FLIR research software); or
  • extract all of the colors from the colorbar, and for each pixel of data find the smallest distance to an entry in the colorbar in order to determine relative position, which you can then map to temperature. See rgb2ind()
I'm fairly certain that the attached screenshot shows an RGB image displayed with an unrelated colorbar. If there is a grayscale image, it's not the one shown, because the one that's shown isn't using the axes colormap.
So at this point, we don't even have a colorbar to pull a roughly calibrated relationship from.
Yes, the displayed colormap is jet, but that's not what the image is using. There is no purple in jet, as you can see from the colorbar, but there are huge areas of purple in the image.
How are you getting min, max, and mean on the live image?
You can get the RGB or grayscale value for one single pixel if you called impixelinfo but that is just the gray level for one pixel only, not for a region of multiple pixels.
Thank you for your response @Walter Roberson & @Image Analyst
Here is the piece of code i am running.
clear cam;
cam= webcam('PureThermal (fw:v1.3.0)');
preview(cam);
global take_photo;
take_photo=1;
while(take_photo == 1)
data = snapshot(cam);
gray=rgb2gray(data);
minGL=min(gray(:));
maxGL=max(gray(:));
meanGL=mean2(gray(:));
minGLValue=int2str(minGL);
maxGLValue=int2str(maxGL);
meanGLValue=int2str(meanGL);
app.MinGLEditField.Value= minGLValue;
app.MaxGLEditField.Value= maxGLValue;
app.MeanEditField.Value=meanGLValue;
x= str2double(minGLValue);
y= str2double(maxGLValue);
c=x*2.083;
d=y*0.1286;
a=app.ToneImageSlider.Value;
bw=gray>a;
imshow(data)
%imshow(data,'parent',app.UIAxes);
title('Structural Fault Detection',"FontSize",14);
colorbar;
caxis([x y]);
axis on;
colormap("jet");
[L n]=bwlabel(bw);
stats = regionprops(L, 'BoundingBox','Centroid');
row=80;
column=60;
center=[row column];
Inttensity=gray(column,row);
intt=int2str(Inttensity);
app.CenterEditField.Value= intt;
viscircles(center,5,'color','b');
hold on
for object = 1:length(stats)
bb = stats(object).BoundingBox;
bc = stats(object).Centroid;
rectangle('Position',bb,'EdgeColor','r','Linewidth',2)
plot(bc(1),bc(2), '-m+');
if length(stats) <=5
a=text(bc(1)+15,bc(2),strcat('X: ', num2str(round(bc(1))),' Y: ',num2str(round(bc(2)))));
end
end
hold off
end
Please see and suggest me what to do next.
PureThermal is a FLIR camera.
There is no possibility that converting a color FLIR image to grayscale will work properly for your purposes. FLIR does not use a linear colormap.
If I understand correctly, PureThermal (without the 2 of PureThermal2) is a board with a sensor and a FLIR Lepton socket. In particular, as far as I can see, it is not one of FLIR's cameras that has WiFi.
If my understanding is correct, then you have three choices:
  1. calibrate your equipment in order to determine the color to temperature mapping. I am not confident this will work: based on my past reading about FLIR, the lower-end devices appear to automatically determine temperature range to use. However, you might succeed in determining the colormap, and then for any given image if you have two calibrated spots you could determine the rest of the temperatures; OR
  2. You can purchase the FLIR research software;
  3. You might be able to take the sensor and Lepton module and put it into a development board that provides better software
If using the FLIR research software is not an option, then adding another development board is probably not an option; then your only option might be calibration overall, together with having two points of known temperature in each image.
FLIR sells at different price-points, and it is deliberate that their less-expensive equipment makes it difficult to get actual temperature data out.

Sign in to comment.

Products

Release

R2020a

Asked:

on 20 May 2022

Commented:

on 22 May 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!