How to display an existing ROI on an image (Copy an ROI to another image)

조회 수: 7 (최근 30일)
Hi, Guys,
I have 2 images with the same size. An ROI was drawn on 1st image. I want to display this ROI on 2nd image. The key is to display this ROI at the same location on 2nd image. Please see the following example.
% Read 1st image and display it
i1 = imread('cameraman.tif');
figure(1)
imshow(i1);
h=imellipse; % Draw ROI on 1st image
% Read 2nd image and display it
i2 = imread('cameraman.tif');
figure(2)
imshow(i2);
How to copy the ROI generated on 1st image (h) to Figure (2) and display it? Thank you!

채택된 답변

Joseph Cheng
Joseph Cheng 2014년 3월 27일
with the h = imellipse; you can get the points by doing
vert = getVertices(h)
figure(2),imshow(i2),hold on;
plot(vert(:,1),vert(:,2))
  댓글 수: 3
Joseph Cheng
Joseph Cheng 2014년 3월 28일
That shows most parameters you can change for your plot. Additionally you can look at the plot documentation in the link below.
plot(x,y,'--gs',...
'LineWidth',2,...
'MarkerSize',10,...
'MarkerEdgeColor','b',...
'MarkerFaceColor',[0.5,0.5,0.5])
Surya Gnyawali
Surya Gnyawali 2017년 7월 10일
It doesnt work with imrect. Can you please explain me why?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by