Borrar filtros
Borrar filtros

Thermal Image analysis on legs

9 visualizaciones (últimos 30 días)
Tasneem
Tasneem el 2 de Jun. de 2023
Respondida: Rahul el 26 de Ag. de 2024 a las 8:27
I am trying to edit the below code so that it gives me an image of the area selected that is above the average temperature of the lower limb.
I would be grateful for any tips
clc;
close all;
clear;
workspace;
format long g;
format compact;
% Read the thermal image
thermalImage = imread('thermal_image_side_leg_2 .jpeg'); % Replace 'thermal_image.jpg' with the filename of your thermal image
% Display the thermal image
figure;
imshow(thermalImage);
title('Original Thermal Image');
% Convert the thermal image to grayscale
thermalImageGray = rgb2gray(thermalImage);
% Display the grayscale thermal image
figure;
imshow(thermalImageGray);
title('Grayscale Thermal Image');
% Select the area of interest using the imfreehand function
figure;
imshow(thermalImageGray);
title('Select Area of Interest');
roi = imfreehand; % This allows you to draw a freehand region of interest (ROI) on the grayscale thermal image
binaryMask = createMask(roi);
% Apply the binary mask to the grayscale image
maskedGrayImage = thermalImageGray .* uint8(binaryMask);
% Display the masked grayscale image
figure;
imshow(maskedGrayImage);
title('Masked Grayscale Image');
% Define the temperature scale using the color bar
colorBarImage = imread('Color_bar_side_leg_2.png'); % Replace 'colorbar_image.jpg' with the filename of your color bar image
temperatureRange = [26, 38]; % Replace with the temperature range provided by the color bar
% Calibrate the masked grayscale image using the temperature range
calibratedImage = (double(maskedGrayImage) - double(min(thermalImageGray(:)))) * (temperatureRange(2) - temperatureRange(1)) / (double(max(thermalImageGray(:))) - double(min(thermalImageGray(:)))) + temperatureRange(1);
% Display the calibrated image
figure;
imshow(calibratedImage);
title('Calibrated Image');
% Calculate the average temperature of the ROI
averageTemperature = mean(calibratedImage(binaryMask));
% Display the average temperature
disp(['The average temperature of the selected area is: ', num2str(averageTemperature), ' °C']);
% Calculate the average temperature of the ROI
averageTemperature = mean(calibratedImage(binaryMask));
% Display the average temperature
disp(['The average temperature of the selected area is: ', num2str(averageTemperature), ' °C']);
% Threshold the calibrated image to create a binary mask for temperatures above the average
binaryAboveAverage = calibratedImage > averageTemperature;
% Display the binary mask
figure;
imshow(binaryAboveAverage);
title('Areas above Average Temperature');
% Apply the binary mask to the original image
thresholdedImage = thermalImage;
thresholdedImage(repmat(~binaryAboveAverage, [1, 1, 3])) = 0;
% Display the thresholded image
figure;
imshow(thresholdedImage);
title('Thresholded Image');
  2 comentarios
Pratham Shah
Pratham Shah el 6 de Jun. de 2023
Hi!
Please provide the image which you are using. Also mention the problem that you are facing.
Image Analyst
Image Analyst el 6 de Jun. de 2023
If you have any more questions, then attach your data ('thermal_image_side_leg_2 .jpeg') and code to read it in with the paperclip icon after you read this:
Also see my demo that converts a pseudocolored image into a temperature image:

Iniciar sesión para comentar.

Respuestas (1)

Rahul
Rahul el 26 de Ag. de 2024 a las 8:27
I understand that you are trying to obtain a thermal image of those areas which have a higher temperature than that of the selected area.
After debugging the code provided by you, I found that a minor change in the code can help you achieve the desired result.
You can change the code for calculating the 'calibratedImage' as follows:
calibratedImage = (double(thermalImageGray) - double(min(thermalImageGray(:)))) * (temperatureRange(2) - temperatureRange(1)) / (double(max(thermalImageGray(:))) - double(min(thermalImageGray(:)))) + temperatureRange(1);
% Here I have replaced 'double(maskedGrayImage)' with 'double(thermalImageGray)'
% This allows for a correct calculation of the 'callibratedImage'.
Once we get the 'callibratedImage' correctly, then we the subsequent calculations of 'averageTemperature', 'binaryAboveAverage' and 'thresholdedImage' are also evaluated correctly resulting in the desired result of providing the Thermal Image of those areas which have a temperature greater than of the selected area.
You can also consider using 'drawfreehand' function instead of 'imfreehand' as 'drawfreehand' offers a better way to select a part of an image.
You can refer to the following documentations for your reference:
Hope this helps! Thanks.

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by