How to do Thermal image Normalization with range 0 to 40

Hi all I'm doing research about using thermal image for temperature measurement for medical purposes, I try to repeat methodology of paper "Face and eyes localization algorithm in thermal images for temperature measurement of the inner canthus of the eyes". They used Normalization of thermal image with range 0 to 40, and they got these results.
I tried the code below:
tt = imread('test.jpg');
figure, imshow(tt)
tt = double(tt);
normimg = uint8(zeros(size(tt)));
for idx = 1 : 3
chan = tt(:,:,idx);
minvalue = min(chan(:));
maxvalue = max(chan(:));
normimg(:,:,idx) = uint8((chan-minvalue)*40/(maxvalue-minvalue));
end
figure, imshow(normimg)
and I got different results so what I should do to get same results Thank you in advance

 Accepted Answer

You're not doing what they did. You're doing something completely different. All they did was to change the colormap, not change the matrix or get a new matrix scaled to a different range. So all you have to do is to display your thermal image and apply a colormap and use caxis() to set the range to 30-40
imshow(thermalImage, []);
colormap(hot(256)); % Whatever map you want.
caxis([30, 40]);
colorbar;
Now a value of 30 in your image will be mapped to the lowest color in the colorbar, and a value of 40 will be mapped to the highest color. Values outside those limits 30-40 will take on the value of the color at the limit.

6 Comments

I run your code but I did not get same paper results
You didn't apply it to your thermal image. You applied it to an pseudocolor RGB image generated by applying a colormap to the ACTUAL thermal image. Please attach your actual thermal image. Not your jpg pseudocolored RGB image test2.jpg, but your true thermal image with values in units of temperature degrees, not gray levels. I don't want the RGB JPG image. The thermal image will probably be a .mat file or some proprietary format file from the manufacturer.
thank you very much for reply, How I can get mate file or RAW Data from thermal...please I need your help
Basically: Do not do that, if you can avoid that. Instead, get the original data, which will probably be a grayscale image.
Hi I got mat file of thermal image for animal so how to make it in temperature range
Why isn't the thermal image already in units of temperature? Did you make a mistake and take the pseudocolored RGB image instead of the actual thermal image? Doesn't your camera output the thermal image? Are you sure? Is all you can get a grayscale or colored image? What model of camera are you using?

Sign in to comment.

More Answers (1)

You might be implementing the algorithm given in the publication incorrectly. The code that you mentioned seems to be correct in normalizing the RGB values of the image from 0 to 40, however there must have been something else that you might be missing from the publication.
This is because 'tt=imread('Test.jpg')' stores the RGB values of the image in the 'tt' matrix. The remainder of your script loops through the entire 'tt' matrix and normalizes the values between 0 and 40. So, the RGB values are between 0 and 40.
If you look at the colors corresponding to the RGB values in this website, http://www.w3schools.com/colors/colors_rgb.asp , you can observe that it is not possible to output the red or orange shades without going beyond RGB value 40. So, the dark image that you are observing seems to be the expected behavior.

Community Treasure Hunt

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

Start Hunting!