How to copy a a ROI created by roipoly ?
조회 수: 8 (최근 30일)
이전 댓글 표시
Hi there
i created a ROI over a specific part of an image using roipoly (see image). i would like to copy this exact ROI shape (the blue mask only) to place it on another part of the same image. how can i copy the same ROI ?
댓글 수: 0
답변 (1개)
Subhadeep Koley
2019년 11월 3일
Ahmad, You can create the mask by double-clicking, or by right-clicking inside the region and selecting Create mask from the context menu. Once the generated binary mask is saved in your MATLAB workspace, you can apply that mask to to extract ROI from any image. Refer the code below.
[row, col] = size(originalImage);
maskedImage = zeros(size(originalImage)); % originalImage is the image you want to apply the mask on
for j = 1:row
for k = 1:col
if(yourBinaryMask(j,k) == 1) % yourBinaryMask is the mask you generated previously with roipoly
maskedImage(j,k) = originalImage(j,k); % maskedImage is the ROI masked image
end
end
end
Hope this helps!
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!