Mapping of temperature values on ROI of image

I had to find the required temperature values from my ROI in a thermal video. I extracted some frames and extracted the region of interested that is still in the form of pixels. Now I want to map temperature values to that ROI from my excel file that is basically extracted from the same frame. After that I have to test whether the values are exactly from the region of interest or not? Any idea about that or any example. Waiting for you kind response. Thanks

 Accepted Answer

15 Comments

If you have values that I have sent you in excel the X and Y coordinates are X0=319 Y0=225 X1=44 Y1=3 X2=44 Y2=3 X3=319 Y3=235 X4=319 Y4=235 X5=319 Y5=235 Then is it possible to get extract the region of interest from these values according to the coordinates and then through heat map ploting the ROI w.r.t. time and make video? Thanks That is what I am interested to do now. This may b the last step. Thanks again
I did not know how to interpret the data. It's just a big 2D matrix and I don't know what the rows, columns, or any of the numbers represent. I didn't see any rows or columns labeled X or X0 or X1 or anything. Do you need me to do anything, or can you handle it now?
These 2D matrix values are the values of temperature imported with the help of camera software of a thermal frame. X0,X1,.... are the values of region of interest (represented in terms of pixels here). From 2D matrix values (Temp Values) I have to plot heat map. Then I have to extract ROI according to X and Y axis values. Then plotting heatmap w.r.t time will give a sequence of frames that is required. I am trying HeatMap, but still couldn't do much. If you got my point then it will be really appreciable if you could do it for me. Thanks
There is no X0,X1 in the workbook. There is only the 2D matrix of temperature values. How am I supposed to find the coordinates of the ROI when they're not in the workbook?
X0=319 Y0=225 X1=44 Y1=3 X2=44 Y2=3 X3=319 Y3=235 X4=319 Y4=235 X5=319 Y5=235 These are is an option in camera software to select ROI, So I selected my ROI along X-Axis and Y-Axis and then imported these values. Could we extract ROI using these coordinates from temperature values?
Yes. since it looks like a rectangle, just do
subImage = thermalImage(Y1:Y3, X1:X3);
% Get mean in that region
theMean = mean2(subImage);
Thank You SO much. I have learned a lot from you. I have now got image from the matrix values. Now I will work to extract ROI according to these Coordinates. but it seems it doesn't work. I try more to find the solution. Thanks again. I will definitely come back to you. You are amazing with your knowledge. Thanks Regards
What doesn't work? Are you sure you did thermalImage(Y1:Y3, X1:X3) like I said, and not thermalImage(X1:X3, Y1:Y3) like many/most other novices would? It should work as long as X3 and Y3 lie within the image. Please explain what "doesn't work" means to you.
Yes I did the same . But it didn't work. I gave the values as I sent It to you. Well I have done with the region of interest by applying mask. I have done it by first getting image from excel file via imagesc. Meanwhile I applied mask to get my region of interest. Then I applied colormap jet to get my colors back. But it seems it didn't work for the first frame. Actually I used axHd1=get(h,'Parent') get(axHd1,'Clim') to get the colors back. Is there any other way to get the same colors and also how can I get video from output of imagesc frames? Because I am not getting how can I save these frames and could get output. I have to plot these frames per unit time to get my video. I think you would have understand my question?
I don't know why you did that to get the colormap when you should have already had it. Maybe you should just attach your video and m-file.
Ok. Now please I do tell you from start. Consider I don't have video because I started new work. I was having excel sheet that I sent to you, I attach it again of 3-frames. I have written a code to get file and to extract region of interest. Now I have got it. I have to make video of it. Also have to plot w.r.t time. Could you please check and verify . I hope you could now understand. I need video for a lot of frame that I could again later. If it works for 3 frames it will definitely work for others as well. Thanks Regards
Why do you have this:
x_orig = 288;
y_orig = 384;
when the data is 864 ( = 288 * 3) and the x dimension length is 256?
If anything you should have this:
x_orig = 256;
y_orig = 288;
You made the common beginner mistake of thinking x and y are row and column. They are not. They are column and row respectively.
Start like this:
[rows, columns] = size(D);
xSize = columns;
numFrames = 3;
ySize = rows/numFrames;
I = zeros(ySize, xSize, numFrames);
figure;
for i = 1 : numFrames
row1 = (i-1)*ySize + 1;
row2 = row1 + ySize -1;
thisFrame = D(row1:row2, :);
r = im2double(mat2gray(thisFrame));
bw = im2bw(r);
maskedImage = bsxfun(@times, thisFrame, cast(bw, 'like', thisFrame));
subplot(numFrames, 3, 3*(i-1)+1);
imshow(r, []);
title('r');
subplot(numFrames, 3, 3*(i-1)+2);
imshow(bw, []);
title('bw');
subplot(numFrames, 3, 3*(i-1)+3);
imshow(maskedImage, []);
title('maskedImage');
But it doesn't effect my processing. I want ROI data with a video. If you have run this file, you would have noticed. Thanks
The file didn't run because you swapped x and y.
please tell me how can I make video as per time from these frames. Thanks

Sign in to comment.

More Answers (1)

Like I said in your duplicate post:
Not exactly sure what " Now I want to map temperature values to that ROI from my excel file that is basically extracted from the same frame" means but if your ROI is a binary image mask, you can do
thermalImage(mask) = someValue;
To see if some value is in your ROI, you can do this:
pixelsInROI = thermalImage(mask);
if max(pixelsInROI == someValue) == 1
% someValue is the value of at least one of the pixels.
else
% someValue is NOT the value of at least one of the pixels.
end

7 Comments

Thanks, Yes my ROI is a binary image mask. And I have to map excel file values to this image. These values are temperature values extracted from original frame with the help of camera software. (Exported)
This is direct for thermal Image? how can I map my temperature values and to get the output the same as it was the original frame?
Hello, @Image Analyst Sorry to ask you again. The above mentioned code didn't work for me. Then dimensions of my mask and the excel values are also not same. Actually there was an extra border when I exported frames, so the frames included both border(white) an RGB image from where I extracted ROI. But the resolution and Dimensions are so high. While we just have data (Temperature Values) just from RGB area. I need any solution if you people could help me. Is there any way to do this? Thanks Regards
Somehow you need to map your ROI values in your Excel file to pixels on the image. Now, I don't know if your ROI files are just a rectangle with a top row, bottom row, left column and right column (in which case you can use indexing), or if they are an irregularly-shaped region (in which case you'll need to use poly2mask). Perhaps if you attach one frame and the workbook (and tell me what cells in the workbook represent the ROI), I may be able to help.
Yes, Thanks, I am gonna attach the frame and the extracted Temperature values that I want to map to my Extracted ROI. Actually that is what I need to know through this process what are the temperature values of my ROI , I mean what cells in work book include ROI values. In this frame I have extracted the square region that is yellow and red, so can see, and I have to know the temperature values after masking this area. I don't need the data(Tem Values) outside this region. I hope you understand what I want to do. Thanks again.
Don't you have the original image? I don't want a screenshot with all that junk. Can't your camera save/export just the image only and not all that other unneeded stuff?
Thanks for code. My region of interest in this frame is a die. The Camera gives the .irdx video from which I exported .avi Video and then exported frames. I can extract a .bmp image that is the same that I sent you. There isn't any option to export certain region directly from camera software. But I have an option to select the region of Interest to see the temperature values and I can also see the pixel position from where I can get the X and Y coordinates. The temperature values in excel also exported from frame that I sent you, could also be used to find the region of Interest. Can I extract region of interest from the values in excel without any image? Is it possible to draw image from these values of region of interest and then plot w.r.t time to get video? Thanks again

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!