필터 지우기
필터 지우기

Thermal camera image processing

조회 수: 191 (최근 30일)
Nasser Jarrar
Nasser Jarrar 2018년 2월 24일
편집: DGM 2024년 1월 10일
I'm working on thermal camera image processing and I would like to create an equation to show what every pixel means in temperature. How can I create such equation and how can I put it in the code so it can give me temperatures for certain colors?
  댓글 수: 5
Kiran Kintali
Kiran Kintali 2019년 12월 30일
Please see mlhdlc_heq.m and mlhdlc_heq_tb.m demo files on how to do this. Thanks.
Shiwani Dhamodaran
Shiwani Dhamodaran 2020년 1월 2일
thanks i will try and tell u if i have any problem

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2018년 2월 24일
편집: Image Analyst 2022년 8월 4일
OK, try this demo I made up specially for your attached image.
[EDIT 8-4-2022, see improved, updated demos attached where you can drag boxes over the image and colorbar in your specific image]
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 15;
%===============================================================================
% Get the name of the image the user wants to use.
baseFileName = '11.png'; % Assign the one on the button that they clicked on.
% Get the full filename, with path prepended.
folder = pwd
fullFileName = fullfile(folder, baseFileName);
%===============================================================================
% Read in a demo image.
originalRGBImage = imread(fullFileName);
% Display the image.
subplot(2, 3, 1);
imshow(originalRGBImage, []);
axis on;
caption = sprintf('Original Pseudocolor Image, %s', baseFileName);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Column', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Row', 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
grayImage = min(originalRGBImage, [], 3); % Useful for finding image and color map regions of image.
% Get the dimensions of the image. numberOfColorChannels should be = 3.
[rows, columns, numberOfColorChannels] = size(originalRGBImage);
% Crop off the surrounding clutter to get the colorbar.
colorBarImage = imcrop(originalRGBImage, [1, 20, 17, rows]);
b = colorBarImage(:,:,3);
% Crop off the surrounding clutter to get the RGB image.
rgbImage = imcrop(originalRGBImage, [81, 1, columns-20, rows]);
% Get the dimensions of the image.
% numberOfColorBands should be = 3.
[rows, columns, numberOfColorChannels] = size(rgbImage);
% Display the image.
subplot(2, 3, 2);
imshow(rgbImage, []);
axis on;
caption = sprintf('Cropped Pseudocolor Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Column', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Row', 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
hp = impixelinfo();
% Display the colorbar image.
subplot(2, 3, 3);
imshow(colorBarImage, []);
axis on;
caption = sprintf('Cropped Colorbar Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Column', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Row', 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0.05 1 0.95]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
% Get the color map.
storedColorMap = colorBarImage(:,1,:);
% Need to call squeeze to get it from a 3D matrix to a 2-D matrix.
% Also need to divide by 255 since colormap values must be between 0 and 1.
storedColorMap = double(squeeze(storedColorMap)) / 255
% Need to flip up/down because the low rows are the high temperatures, not the low temperatures.
storedColorMap = flipud(storedColorMap);
% Convert from an RGB image to a grayscale, indexed, thermal image.
indexedImage = rgb2ind(rgbImage, storedColorMap);
% Display the thermal image.
subplot(2, 3, 4);
imshow(indexedImage, []);
axis on;
caption = sprintf('Indexed Image (Gray Scale Image)');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
% Define the temperature at the top end of the scale
% This will probably be the high temperature.
highTemp = 28.9;
% Define the temperature at the dark end of the scale
% This will probably be the low temperature.
lowTemp = 0.9;
% Scale the image so that it's actual temperatures
thermalImage = lowTemp + (highTemp - lowTemp) * mat2gray(indexedImage);
subplot(2, 3, 5);
imshow(thermalImage, []);
axis on;
colorbar;
title('Floating Point Thermal (Temperature) Image', 'FontSize', fontSize, 'Interpreter', 'None');
hp = impixelinfo(); % Let user mouse around and see temperatures.
hp.Units = 'normalized';
hp.Position = [0.45, 0.03, 0.25, 0.05];
% Get the histogram of the indexed image
subplot(2, 3, 6);
histogram(thermalImage, 'Normalization', 'probability');
axis on;
grid on;
caption = sprintf('Histogram of Thermal Temperature Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Temperature', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Frequency', 'FontSize', fontSize, 'Interpreter', 'None');
  댓글 수: 42
Image Analyst
Image Analyst 2022년 8월 4일
@Ali Raza I don't see any colorbar in that image, so what did you do about that? My program expects to extract the colorbar from the image.
I'm attaching the latest version and this one lets you draw a box over the thermal image and over the colorbar. Both are needed to convert a pseudocolored image into temperature. Otherwise how would I know that yellow in your image is 40 degrees or 300 degrees? There would be no way to tell.
Subasri Raaja Anjana
Subasri Raaja Anjana 2022년 10월 11일
Can I know how to draw a box over the thermal image to crop it ? I am not getting any option available to do that.

댓글을 달려면 로그인하십시오.

추가 답변 (6개)

Image Analyst
Image Analyst 2018년 2월 24일
  댓글 수: 10
Image Analyst
Image Analyst 2021년 6월 17일
@RICHA SINGH, look at your color bar! You did not modify the code to crop YOUR color bar out. You simply used the code I gave, which was for a different image, so your color bar is not the full, actual color bar used in your image. Make that adjustment and it should work.
RICHA SINGH
RICHA SINGH 2021년 6월 17일
ok sir thank you

댓글을 달려면 로그인하십시오.


mr.hien tran
mr.hien tran 2018년 10월 5일
excuse me sir. can you help me ? I'm working on thermal image processing How can i find the highest temperature in infrared image?? please!!!

monika  SINGH
monika SINGH 2019년 5월 16일
편집: Image Analyst 2022년 4월 8일
Image Analyst, with your code below:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 15;
%===============================================================================
% Get the name of the image the user wants to use.
baseFileName = '11.png'; % Assign the one on the button that they clicked on.
% Get the full filename, with path prepended.
folder = pwd
fullFileName = fullfile(folder, baseFileName);
%===============================================================================
% Read in a demo image.
originalRGBImage = imread(fullFileName);
% Display the image.
subplot(2, 3, 1);
imshow(originalRGBImage, []);
axis on;
caption = sprintf('Original Pseudocolor Image, %s', baseFileName);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Column', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Row', 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
grayImage = min(originalRGBImage, [], 3); % Useful for finding image and color map regions of image.
% Get the dimensions of the image. numberOfColorChannels should be = 3.
[rows, columns, numberOfColorChannels] = size(originalRGBImage);
% Crop off the surrounding clutter to get the colorbar.
colorBarImage = imcrop(originalRGBImage, [1, 20, 17, rows]);
b = colorBarImage(:,:,3);
% Crop off the surrounding clutter to get the RGB image.
rgbImage = imcrop(originalRGBImage, [81, 1, columns-20, rows]);
% Get the dimensions of the image.
% numberOfColorBands should be = 3.
[rows, columns, numberOfColorChannels] = size(rgbImage);
% Display the image.
subplot(2, 3, 2);
imshow(rgbImage, []);
axis on;
caption = sprintf('Cropped Pseudocolor Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Column', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Row', 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
hp = impixelinfo();
% Display the colorbar image.
subplot(2, 3, 3);
imshow(colorBarImage, []);
axis on;
caption = sprintf('Cropped Colorbar Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Column', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Row', 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0.05 1 0.95]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
% Get the color map.
storedColorMap = colorBarImage(:,1,:);
% Need to call squeeze to get it from a 3D matrix to a 2-D matrix.
% Also need to divide by 255 since colormap values must be between 0 and 1.
storedColorMap = double(squeeze(storedColorMap)) / 255
% Need to flip up/down because the low rows are the high temperatures, not the low temperatures.
storedColorMap = flipud(storedColorMap);
% Convert from an RGB image to a grayscale, indexed, thermal image.
indexedImage = rgb2ind(rgbImage, storedColorMap);
% Display the thermal image.
subplot(2, 3, 4);
imshow(indexedImage, []);
axis on;
caption = sprintf('Indexed Image (Gray Scale Image)');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
% Define the temperature at the top end of the scale
% This will probably be the high temperature.
highTemp = 28.9;
% Define the temperature at the dark end of the scale
% This will probably be the low temperature.
lowTemp = 0.9;
% Scale the image so that it's actual temperatures
thermalImage = lowTemp + (highTemp - lowTemp) * mat2gray(indexedImage);
subplot(2, 3, 5);
imshow(thermalImage, []);
axis on;
colorbar;
title('Floating Point Thermal (Temperature) Image', 'FontSize', fontSize, 'Interpreter', 'None');
hp = impixelinfo(); % Let user mouse around and see temperatures.
hp.Units = 'normalized';
hp.Position = [0.45, 0.03, 0.25, 0.05];
% Get the histogram of the indexed image
subplot(2, 3, 6);
histogram(thermalImage, 'Normalization', 'probability');
axis on;
grid on;
caption = sprintf('Histogram of Thermal Temperature Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Temperature', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Frequency', 'FontSize', fontSize, 'Interpreter', 'None');
IN THE ABOVE CODE, ARE YOU SURE IT GIVES ACCURATE TEMPERATURE W.R.T TEMPERATURE??
AND WHAT IS SIGNIFICANCE OF COLORBAR
  댓글 수: 4
Apra Gupta
Apra Gupta 2021년 6월 30일
Ok Sir, Right now I m converting my images to JPEG and then working on it, bt in its JPEG format the information related to temperature gets lost.
Image Analyst
Image Analyst 2022년 4월 8일
편집: Image Analyst 2022년 4월 8일
@monika SINGH, with my code above that you posted, it's as accurate as your color bar is. I'm sure it's not as accurate as if you could just get the temperature image directly from your camera but as far as how many degrees off it is, I can't say. It depends on the range of temperatures in the colorbar and how bad the JPG artifacts in the image are, and how accurately you specify the color bar coordinates.
The colorbar tells you how to convert an RGB value into a temperature.

댓글을 달려면 로그인하십시오.


Andrew Oliver
Andrew Oliver 2022년 4월 8일
@Image Analyst I would like to use and reference your code in an undergrad project that I am currently doing which deals with a basic thermal imaging analysis system using MATLAB, would you be able to share with me the appropriate way to cite this? Many thanks

Jacob Kalmanovich
Jacob Kalmanovich 2022년 6월 14일
Hello, my apologies to ask another question. I am fairly new to matlab and am have a similar problem.
I used a similar code for my image which I attached. I understand that my issue is because I did not properly crop the colorbar, however I am not completely aware on how to do that. Would you please offer me your assistance in this matter? Thank you.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 15;
%===============================================================================
% Get the name of the image the user wants to use.
baseFileName = '11.png'; % Assign the one on the button that they clicked on.
% Get the full filename, with path prepended.
folder = pwd
fullFileName = fullfile(folder, baseFileName);
%===============================================================================
% Read in a demo image.
originalRGBImage = imread(fullFileName);
% Display the image.
subplot(2, 3, 1);
imshow(originalRGBImage, []);
axis on;
caption = sprintf('Original Pseudocolor Image, %s', baseFileName);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Column', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Row', 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
grayImage = min(originalRGBImage, [], 3); % Useful for finding image and color map regions of image.
% Get the dimensions of the image. numberOfColorChannels should be = 3.
[rows, columns, numberOfColorChannels] = size(originalRGBImage);
% Crop off the surrounding clutter to get the colorbar.
colorBarImage = imcrop(originalRGBImage, [1, 20, 17, rows]);
b = colorBarImage(:,:,3);
% Crop off the surrounding clutter to get the RGB image.
rgbImage = imcrop(originalRGBImage, [81, 1, columns-20, rows]);
% Get the dimensions of the image.
% numberOfColorBands should be = 3.
[rows, columns, numberOfColorChannels] = size(rgbImage);
% Display the image.
subplot(2, 3, 2);
imshow(rgbImage, []);
axis on;
caption = sprintf('Cropped Pseudocolor Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Column', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Row', 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
hp = impixelinfo();
% Display the colorbar image.
subplot(2, 3, 3);
imshow(colorBarImage, []);
axis on;
caption = sprintf('Cropped Colorbar Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Column', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Row', 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0.05 1 0.95]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
% Get the color map.
storedColorMap = colorBarImage(:,1,:);
% Need to call squeeze to get it from a 3D matrix to a 2-D matrix.
% Also need to divide by 255 since colormap values must be between 0 and 1.
storedColorMap = double(squeeze(storedColorMap)) / 255
% Need to flip up/down because the low rows are the high temperatures, not the low temperatures.
storedColorMap = flipud(storedColorMap);
% Convert from an RGB image to a grayscale, indexed, thermal image.
indexedImage = rgb2ind(rgbImage, storedColorMap);
% Display the thermal image.
subplot(2, 3, 4);
imshow(indexedImage, []);
axis on;
caption = sprintf('Indexed Image (Gray Scale Image)');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
% Define the temperature at the top end of the scale
% This will probably be the high temperature.
highTemp = 28.9;
% Define the temperature at the dark end of the scale
% This will probably be the low temperature.
lowTemp = 0.9;
% Scale the image so that it's actual temperatures
thermalImage = lowTemp + (highTemp - lowTemp) * mat2gray(indexedImage);
subplot(2, 3, 5);
imshow(thermalImage, []);
axis on;
colorbar;
title('Floating Point Thermal (Temperature) Image', 'FontSize', fontSize, 'Interpreter', 'None');
hp = impixelinfo(); % Let user mouse around and see temperatures.
hp.Units = 'normalized';
hp.Position = [0.45, 0.03, 0.25, 0.05];
% Get the histogram of the indexed image
subplot(2, 3, 6);
histogram(thermalImage, 'Normalization', 'probability');
axis on;
grid on;
caption = sprintf('Histogram of Thermal Temperature Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Temperature', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Frequency', 'FontSize', fontSize, 'Interpreter', 'None');
  댓글 수: 5
Image Analyst
Image Analyst 2023년 5월 31일
@Tasneem you can define isotherms using contour or simply by testing for equality
oneTemperature = temperatureImage == desiredTemperature; % Makes a binary image.
To specify an ROI, you can do it in several ways, such as by thresholding.
hotPixels = temperatureImage > someTemperature;
It's a generic, general purpose demo of how to threshold an image to find blobs, and then measure things about the blobs, and extract certain blobs based on their areas or diameters.
If you have more questions, start a new discussion thread of your own and attach your image(s).
Tasneem
Tasneem 2023년 5월 31일
Dear @Image Analyst thank you !
I will have a look and try get my head around it.
I will start my own thread as well
thank you for your help and time!

댓글을 달려면 로그인하십시오.


Güney Can Gürbüz
Güney Can Gürbüz 2023년 6월 5일
Dear @Image Analyst , I have a task which is related image processing. I need to see temperatures along a horizontal line where is center of the circles. Could you help me about this problem? How can I see temperature vs position graph? Thank you in advance.
  댓글 수: 8
DGM
DGM 2024년 1월 10일
편집: DGM 2024년 1월 10일
It's not clear what your task is, whether you're talking about trying to use improfile(), or what to part of the task the colormap is relevant.
There are a handful of "iron" colormaps that are all very similar but not identical, and I don't know of any which I would consider to be canonical. For example, the map used above is what many sources would refer to as "iron", even though it's significantly different to both the FLIR and Chauvin-Arnoux maps. Some of the maps you might find online that are claimed specifically to be a duplicate of the FLIR map are even less accurate. As far as I know, there are at least two distinct "iron" map variants used by FLIR.
Here is a handful of maps which are either explicitly called "iron" or are claimed specifically to be the FLIR map, or are recommended as being a substitute:
If the goal is to estimate temperature from pseudocolor images, then getting an accurate estimate of the applied colormap is essential. Given the above sample, "iron" is not specific enough to be useful.
Click the Ask button at the top of the page and write a question describing your task. If there are relevant images, include them. If it's not apparent from the images, mention the camera brand.
Image Analyst
Image Analyst 2024년 1월 10일
@NUZUL, colormaps are not used for image segmentation.
If you're talking about my thermal image demo above, it does not matter what colorbar/colormap is embedded in the thermal image. It will work with any colormap.
If you're wanting to create an "iron" colormap, then you'll have to define it because it's not one of the built-in colormaps of MATLAB.
To define your own:
>> colormapeditor

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by