HOW TO FIND OUT MAXIMUM TEMPERATURE FROM EACH FRAME(My video has 225 frames) USING MATLAB ?
2 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/193073/image.png)
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 个评论
采纳的回答
Florian Morsch
2018-8-3
编辑:Florian Morsch
2018-8-3
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 个评论
Florian Morsch
2018-8-3
编辑:Florian Morsch
2018-8-3
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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/193455/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/193457/image.png)
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Orange 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!