Obtain intensity values within the ROIs drawn on image in this script. Then, write and display intensity values within the ROIs on the image.
clear all
close all
% UUT image input
I = imread(‘UUT33.bmp’);
R = imresize(I, [800 1000]); % Resize image to full res
% Define ROI size
ROIWidth = 100;
ROIHeight = 100;
% Number of ROIs in X and Y directions
numROIsX = 3;
numROIsY = 3;
% Calculate the step size for placing ROIs
stepX = floor(size(R, 2) / (numROIsX + 1));
stepY = floor(size(R, 1) / (numROIsY + 1));
% Initialize ROI positions
ROIPositionsX = zeros(numROIsX, 1);
ROIPositionsY = zeros(numROIsY, 1);
% Calculate ROI positions based on the step size
for i = 1:numROIsX
ROIPositionsX(i) = i * stepX – floor(ROIWidth / 2);
end
for j = 1:numROIsY
ROIPositionsY(j) = j * stepY – floor(ROIHeight / 2);
end
% Create ROIs and visualize
figure;
imshow(R); % Display the original image
hold on; % Hold the current plot
% Loop through each ROI position and draw rectangles on image
for i = 1:numROIsX
for j = 1:numROIsY
x = ROIPositionsX(i);
y = ROIPositionsY(j);
rectangle(‘Position’, [x, y, ROIWidth, ROIHeight], ‘EdgeColor’, ‘r’, ‘LineWidth’, 2);
end
end
hold off; % Release hold on current plot
title(‘ROIs on image in exact positions’);
This scirpt inputs an image and draws rectangle ROIs in specific positions on the image. I need to obtain the intensity values within all of the ROIs, and then write in /display the intensity values wihin all of the drawn ROIs on the image. Any ideas?clear all
close all
% UUT image input
I = imread(‘UUT33.bmp’);
R = imresize(I, [800 1000]); % Resize image to full res
% Define ROI size
ROIWidth = 100;
ROIHeight = 100;
% Number of ROIs in X and Y directions
numROIsX = 3;
numROIsY = 3;
% Calculate the step size for placing ROIs
stepX = floor(size(R, 2) / (numROIsX + 1));
stepY = floor(size(R, 1) / (numROIsY + 1));
% Initialize ROI positions
ROIPositionsX = zeros(numROIsX, 1);
ROIPositionsY = zeros(numROIsY, 1);
% Calculate ROI positions based on the step size
for i = 1:numROIsX
ROIPositionsX(i) = i * stepX – floor(ROIWidth / 2);
end
for j = 1:numROIsY
ROIPositionsY(j) = j * stepY – floor(ROIHeight / 2);
end
% Create ROIs and visualize
figure;
imshow(R); % Display the original image
hold on; % Hold the current plot
% Loop through each ROI position and draw rectangles on image
for i = 1:numROIsX
for j = 1:numROIsY
x = ROIPositionsX(i);
y = ROIPositionsY(j);
rectangle(‘Position’, [x, y, ROIWidth, ROIHeight], ‘EdgeColor’, ‘r’, ‘LineWidth’, 2);
end
end
hold off; % Release hold on current plot
title(‘ROIs on image in exact positions’);
This scirpt inputs an image and draws rectangle ROIs in specific positions on the image. I need to obtain the intensity values within all of the ROIs, and then write in /display the intensity values wihin all of the drawn ROIs on the image. Any ideas? clear all
close all
% UUT image input
I = imread(‘UUT33.bmp’);
R = imresize(I, [800 1000]); % Resize image to full res
% Define ROI size
ROIWidth = 100;
ROIHeight = 100;
% Number of ROIs in X and Y directions
numROIsX = 3;
numROIsY = 3;
% Calculate the step size for placing ROIs
stepX = floor(size(R, 2) / (numROIsX + 1));
stepY = floor(size(R, 1) / (numROIsY + 1));
% Initialize ROI positions
ROIPositionsX = zeros(numROIsX, 1);
ROIPositionsY = zeros(numROIsY, 1);
% Calculate ROI positions based on the step size
for i = 1:numROIsX
ROIPositionsX(i) = i * stepX – floor(ROIWidth / 2);
end
for j = 1:numROIsY
ROIPositionsY(j) = j * stepY – floor(ROIHeight / 2);
end
% Create ROIs and visualize
figure;
imshow(R); % Display the original image
hold on; % Hold the current plot
% Loop through each ROI position and draw rectangles on image
for i = 1:numROIsX
for j = 1:numROIsY
x = ROIPositionsX(i);
y = ROIPositionsY(j);
rectangle(‘Position’, [x, y, ROIWidth, ROIHeight], ‘EdgeColor’, ‘r’, ‘LineWidth’, 2);
end
end
hold off; % Release hold on current plot
title(‘ROIs on image in exact positions’);
This scirpt inputs an image and draws rectangle ROIs in specific positions on the image. I need to obtain the intensity values within all of the ROIs, and then write in /display the intensity values wihin all of the drawn ROIs on the image. Any ideas? intensity values in rois in image MATLAB Answers — New Questions