MATLAB Answers

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

조회 수: 7(최근 30일)
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

표시 이전 댓글 수: 3
Florian Morsch
Florian Morsch 3 Aug 2018
Since i dont know the rest of your code i just make a assumption:
thermalImage = lowTemp + (highTemp - lowTemp) * mat2gray(indexedImage);
maxTemperature = max(thermalImage(:));
if your mat2gray(indexedImage) is 1 at any point, then your math will bring lowTemp + (highTemp - lowTemp)*1, which equals highTemp. So your max(thermalImage(:)); will always have highTemp and so it will be 84.02. Have you checked which value you get from mat2gray(indexedImage);?
Also it could be possible that you indeed have a maximum of 84.02 in every image, so the output of 84.02 for every image could be correct.
Antony Joseph
Antony Joseph 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 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(:));

로그인 to comment.

채택된 답변

Florian Morsch
Florian Morsch 3 Aug 2018
편집: Florian Morsch 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

Antony Joseph
Antony Joseph 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 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.

로그인 to comment.

추가 답변(0개)

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by