Thermal Image analysis on legs
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’);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’); 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’); thermal image MATLAB Answers — New Questions