How to convert image pixels values to the temperature values?
Show older comments
Hello,
How to convert image pixels values to the temperature values?, in image I found pixel value, like 255, and I know that it match 37,4 C, how to export that value to the screen?
Answers (1)
Image Analyst
on 19 May 2014
You have to convert your entire image to a floating point image knowing at least two temperatures, not just one. Just because 255 = 37.4 does not tell us what what temperature zero gray levels is at.
After that
imshow(temperatureImage, []); % Use [] because it's floating point
impixelInfo('Position', [x,y,width,height]);
impixelinfo() will let you mouse around the image and it will report the temperature on your GUI.
14 Comments
Dovile
on 19 May 2014
Image Analyst
on 19 May 2014
So why don't you just scale it like you'd intuitively expect
temperatureImage = (grayImage / 255) * (37.4-23.1) + 23.1;
Makes sense to me. Isn't that what you thought of too?
Andy Smith
on 7 Jul 2015
Since I want to report this method in my thesis, kindly let me know the technical name of this method. Is it the Histogram Shrinking? Thanks in advance.
Guillaume
on 7 Jul 2015
Huh? It's one of the simplest mathematical operation: a linear transformation
y = a*x + b
Also known as scaling in this context.
Andy Smith
on 7 Jul 2015
Thanks for your reply, Guillaume.
Mateo Ramirez
on 22 Nov 2017
Dear Image Analyst,
I know two temperature for my image (highest and lowest) how can I convert my image to a floating point.
Best regards, MRa.
Image Analyst
on 22 Nov 2017
MRa:
temperatureImage = mat2gray(yourImage) * (highTemp - lowTemp) + lowTemp;
Mateo Ramirez
on 28 Nov 2017
Edited: Mateo Ramirez
on 28 Nov 2017
Thank you very much Image Analyst,
For some reason I didn't receive any notification on your reply.
MRa.
Mateo Ramirez
on 29 Nov 2017
Dear Image Analyst,
I might be missing one step, converting my image to a Matrix (mat). If this is correct can you explain me please why should i do that? Below the code piece of code i used and attached the picture I am trying to analyze:
image = imread('IR71.png');
[I2, rect] = imcrop(image);
temperatureImage = mat2gray(I2) * (36.9 - 23.2) + 23.69
gray = mat2gray(I2);
imshow(gray)

With your previous uploaded tutorials I was able to identify the hottest point in the "Photovoltaic Panel" I want now to print the temperature of this zone right next to the "Hot Point". With this first piece of code" [I2, rect] = imcrop(image)" I am making my life easier just before adding it to the full code.
Looking forward to receiving your comments, Best regards, MRa.
Image Analyst
on 29 Nov 2017
You need to convert the colors into a temperature. You can't do that just by your formula. It's not that easy. See my attached demo.
Alaa Eddin Ziadah
on 12 Dec 2020
Edited: Alaa Eddin Ziadah
on 12 Dec 2020
Dear Image Analyst,
i am trying to run your code withe my thermal image(see attach), but i become always an error:
>> rgbImage = originalRGBImage(imageRow1 : imageRow2, imageCol1 : imageCol2, :));
Index in position 1 exceeds array bounds (must not exceed 120).
can you please help me.

Image Analyst
on 12 Dec 2020
Sure. Start a new question and attach your image and code. You probably did not update the rows and columns to crop the proper part of the image.
Bipasha Kundu
on 17 Nov 2021
Hello Sir,
I am working on a project which is quite similar to this. I would like to know how to get the High and Low temperature. Thank you
Image Analyst
on 17 Nov 2021
@Bipasha Kundu to get the max and min temperature you can use max() and min() on your temperature image:
maxTemp = max(temperatureImage(:));
minTemp = min(temperatureImage(:));
Categories
Find more on Convert Image Type in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!