Hello, I have a thermal video from a professional camera and how have to find the hottest point regarding temperature in this video. Would you please like to tell me how can I do this? I imported thermal image from this video and applied threshold it gives the values but after that it doesn't locate the hottest spot. Thanking you in anticipation.
MATLAB: How to Detect the hottest spot in a thermal video
computer visionImage Processing Toolboxthermal
Related Solutions
It's just 3 lines. Just mask the original image:
binaryImage = grayImage > 150;maskedImage = zeros(size(grayImage)); % Initialize.
maskedImage(binaryImage) = grayImage(binaryImage);
See the full demo below:
% Demo by ImageAnalyst
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 14;% Read in a standard MATLAB gray scale demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');baseFileName = 'coins.png';% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);% Check if file exists.
if ~exist(fullFileName, 'file') % File doesn't exist -- didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file') % Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName); uiwait(warndlg(errorMessage)); return; endendgrayImage = imread(fullFileName);% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[rows columns numberOfColorBands] = size(grayImage);% Display the original gray scale image.
subplot(2, 2, 1);imshow(grayImage, []);title('Original Grayscale Image', 'FontSize', fontSize);% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);% Give a name to the title bar.
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off') % Let's compute and display the histogram.
[pixelCount grayLevels] = imhist(grayImage);subplot(2, 2, 2); bar(pixelCount);grid on;title('Histogram of original image', 'FontSize', fontSize);xlim([0 grayLevels(end)]); % Scale x axis manually.
yl = ylim();line([150 150], [0 yl(2)], 'Color', 'r');% Threshold at 150
binaryImage = grayImage > 150;% Display the original gray scale image.subplot(2, 2, 3);imshow(binaryImage, []);title('Binary Image', 'FontSize', fontSize);% Mask the image
maskedImage = zeros(size(grayImage)); % Initialize.% Assign values from grayImage that are > 150.
maskedImage(binaryImage) = grayImage(binaryImage);% Display the original gray scale image.subplot(2, 2, 4);imshow(maskedImage, []);title('Masked Image', 'FontSize', fontSize);
See this demo:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
format longg;format compact;fontSize = 20;% Read in a standard MATLAB gray scale demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');baseFileName = 'moon.tif';% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);% Check if file exists.
if ~exist(fullFileName, 'file') % File doesn't exist -- didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file') % Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName); uiwait(warndlg(errorMessage)); return; endendgrayImage = imread(fullFileName);% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[rows columns numberOfColorBands] = size(grayImage);% Display the original gray scale image.
subplot(2, 2, 1);imshow(grayImage, []);title('Original Grayscale Image', 'FontSize', fontSize);% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);% Give a name to the title bar.
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off') uiwait(msgbox('Draw the ROI. Left click to anchor vertices, then right click inside to finish it up.'));binaryImage =roipolyold();subplot(2, 2, 2);imshow(binaryImage, []);title('Your ROI', 'FontSize', fontSize);% Find out where image is exactly 81 gray levels.
image81 = grayImage == 81;% Mask by ROI to get only 81 pixels inside the ROI.
binaryImage = binaryImage & image81subplot(2, 2, 3);imshow(binaryImage, []);title('Value = 81 AND inside Your ROI', 'FontSize', fontSize);% Construct the RGB image
redChannel = grayImage;greenChannel = grayImage;blueChannel = grayImage;redChannel(binaryImage) = 0;greenChannel(binaryImage) = 255;blueChannel(binaryImage) = 0;% Display it.
rgbImage = cat(3, redChannel, greenChannel, blueChannel);subplot(2, 2, 4);imshow(rgbImage, []);title('RGB image with green', 'FontSize', fontSize);
Best Answer