Clear Filters
Clear Filters

HOW TO FIND OUT MAXIMUM TEMPERATURE FROM EACH FRAME(My video has 225 frames) USING MATLAB ?

1 view (last 30 days)
This Image frame I just took from my thermal simulation video.
Here temperature range: 20-degree Celcius to 84.02 degrees Celcius.
This video has 225 frames. I have to find the maximum temperature in each frame. Then I can plot Maximum temperature vs frames graph.
script:
% This will probably be the high temperature.
highTemp = 84.02;
% This will probably be the low temperature.
lowTemp = 20.05;
thermalImage = lowTemp + (highTemp - lowTemp) * mat2gray(indexedImage);
maxTemperature = max(thermalImage(:));
I was following this code but I am getting the same maximum temperature in each frame.
That is my problem.
I should get the actual maximum temperature in each frame. Then I can plot Maximum temperature vs frames graph.
could you please check this one?
  6 Comments
Antony Joseph
Antony Joseph on 3 Aug 2018
@Florian Yes, you are correct, mat2gray(indexedImage) is 1 at some point. why should that come like that?
Antony Joseph
Antony Joseph on 3 Aug 2018
Edited: Antony Joseph on 3 Aug 2018
CrackImage is my above-cropped Image. Just check this code. mat2gray(indexedImage) is 1 at some point. why should that come like that?
ColorMap = CrackImage(:,1,:);
ColorMap = double(squeeze(ColorMap)) / 255;
ColorMap = flipud(ColorMap);
indexedImage = rgb2ind(CrackImage,ColorMap);
thermalImage = lowTemp + (highTemp - lowTemp) * mat2gray(indexedImage);
maxTemperature = max(thermalImage(:));

Sign in to comment.

Accepted Answer

Florian Morsch
Florian Morsch on 3 Aug 2018
Edited: Florian Morsch on 3 Aug 2018
mat2gray() converts a matrix to a grayscale image. If you have a white pixel in your image thats a 1. Now what you are doing is multiplying every value of your grayed "indexedImage" with "(highTemp-lowTemp)".
After that you search for the maximum value of "thermalImage", which of course can only be maxTemp as soon as you have a white pixel.
Since you have a white pixel in every image, you also get highTemp as output on every image. So your code works perfectly fine since it gives the output it should give according to the mathematics you implemented. Unfortunatly thats not the output you are expecting, but your implemented math wont have any chance to give another output except if you would have a gray image without white pixels. Correct your math and your code and you might get what you are expecting.
As a hint, if you convert you image to a gray image your red area should be one of the darker areas, so it might be more interesting to look at the min(thermalImage(:)); with the corrected maths. But be careful with the edges of the image, the blue will be also be a low gray value.
  2 Comments
Antony Joseph
Antony Joseph on 3 Aug 2018
but when my math change to min(thermalImage(:)); the output result coming as my lowTemp = 20.05; because mat2gray(indexedImage) is 0 at some point.
any other Math correction I have to do? what you think?
Florian Morsch
Florian Morsch on 3 Aug 2018
Edited: Florian Morsch on 3 Aug 2018
You should understand how a mat2gray() works first. It converts the pixels to gray values between 0 and 1, with 0 is black and 1 is white.
In your gray image the brighter spots like white, light blue and so on will be closer to 1, which is white. The darker a area the closer it is to 0, so your edges with the dark blue and the red in the center will go to a lower value. Just because you want your red to be the highest value your computer will not interpret it like that.
Thats why i said you have to correct your math and/or code. Right now you are checking for the highest value while searching in the wrong spot. In your code right now you detect a spot probably somewhere between the green and light blue color, which is 1 and convert that to maxTemp. You dont even check the correct place of temperature. On the other hand, if you check for the darkes value you get your very edges of the image, which are of course in your gray image the one coming closest to 0. So for the low temperature right now that might be correct. But since your blue color near the edges is lets say 0.3 and your red color also might have the gray value 0.3, how can you tell which of the both values is the correct one?
You see this? The center of the red area has nearly the same index value as the some pixel in the blue area.
With your math
lowTemp +(highTemp-lowTemp)*mat2gray(indexedImage);
both of those pixels have nearly the same value at end. For your blue pixel you get a temperature of 35,438, for the red pixel 37,016.
Right now you never will be able to seperate between those two. If you use your code right now, both of the pixels will have nearly the same value, but the "hottest" point will be somewhere in the white area around the red pixel in the middle, and the "cooles" point will be the edges of the image.

Sign in to comment.

More Answers (0)

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!