Filter löschen
Filter löschen

Thermal Image analysis on legs

2 Ansichten (letzte 30 Tage)
Tasneem
Tasneem am 2 Jun. 2023
Kommentiert: Image Analyst am 6 Jun. 2023
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 Kommentare
Pratham Shah
Pratham Shah am 6 Jun. 2023
Hi!
Please provide the image which you are using. Also mention the problem that you are facing.
Image Analyst
Image Analyst am 6 Jun. 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:

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by