How to copy a a ROI created by roipoly ?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 ?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/243976/image.png)
0 Commenti
Risposte (1)
Subhadeep Koley
il 3 Nov 2019
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 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!