Thermal camera image processing - (https://w​ww.mathwor​ks.com/mat​labcentral​/answers/3​84579-ther​mal-camera​-image-pro​cessing)

3 views (last 30 days)
Hello all,
I have used Image Analyst's Demo to obtain temperature information from pixels (https://www.mathworks.com/matlabcentral/answers/384579-thermal-camera-image-processing)
I would like to understand the theory or the logic behind how the conversion of a rgb image into indexed (indexedImage = rgb2ind(rgbImage, storedColorMap);) and then converting (thermalImage = lowTemp + (highTemp - lowTemp) * mat2gray(indexedImage);) is giving the temperature information of every pixel. I used the same script with modification as per my requirement and i do get the temperature values (not may be 100% accurate , but close enough)... so i would like to understand the logic used or theroy behind how the pixel intensity is converted into temperature in the demo given in the link (see the title)
Looking forward to any responses.
Thank you in advance.

Answers (1)

Nipun Katyal
Nipun Katyal on 3 Mar 2020
An indexed image is basically a gray scale image along with a color map where the pixel values are the indices in the color map and each row in the color map corresponds to an RGB value.
We want to scale the pixel values in the thermal image according to the color bar in the image, so as to establish a linear relationship between the temperature and the pixel internsity.
% Crop off the surrounding clutter to get the colorbar.
colorBarImage = imcrop(originalRGBImage, [1, 20, 17, rows]);
b = colorBarImage(:,:,3);
After we have the color bar we have extracted the range of all possible values that a thermal image can have and used this to generate the indexed image.
% 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);
The reason why we are using an indexed image is to scale the maximum temperature with the highest pixel intensity in the color bar(which might not be white) and the likewise with the minimum, as well as maintaining the trend in the color bar. Therefore the pixel values in the gray scale indexed image, which map on to the colormap are used to retain the trend as well as give a relative scale on the image.
The difficulty in using an RGB image would be deciding how to choose the maximum and the minimum pixel values for the corresponding temperature as well as choosing the trend in which the temperature varies according to the pixel values, which makes it less feasible as compared to using an indexed image.

Community Treasure Hunt

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

Start Hunting!