How to generate a ROI matrix in Workspace after copying and pasting an existing ROI on an image (Copy an ROI to another image)

2 views (last 30 days)
Hi, Guys,
I have 2 images with the same size. An ROI was drawn on 1st image. Then I copy this ROI on the 1st image, and then paste it on the 2nd image. How to generate a ROI matrix for the 2nd image in Workspace? Thanks.
% Read 1st image and display it
i1 = imread('cameraman.tif'); figure(1)
imshow(i1);
h=imellipse; % Draw ROI on 1st image
ROI_1st = createMask(h);
% In Workspace, there is a variable "ROI_1st" as "256x256 logical".
% Copy the ROI in 1st image
% Read 2nd image and display it
i2 = imread('cameraman.tif');
figure(2)
imshow(i2);
% Paste the ROI on 2nd images
% Paste result and I can also move the ROI to the desired the position
After copying the ROI from the 1st image to the 2nd image, how to generate a variable in Workspace as a matrix to represent the 2nd ROI? Thank you very much.

Answers (0)

Community Treasure Hunt

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

Start Hunting!