MATLAB: (Japanese)​複数のROI指定後,​一括して画像抜き出し​表示

roi createmask日本語

1つの画像内に複数の選択領域をROIとして設定し,そのすべてを画像から一括して抜き出して表示することは可能でしょうか? 例えば 直径10ピクセルの円領域が 中心間隔30ピクセルで等間隔にマトリクス配置されている 「マスクアレイ」によって元画像を切り抜いた画像を表示したいのですが・・・ 具体的には, https://jp.mathworks.com/matlabcentral/answers/99873-roi の回答 にあるような処理を多数の領域で一括して行いたいです.

Best Answer

If you have several roi objects, you can use the createMask on each of them, and you can or them together by using any() . You would then extract the original image at the collective mask.
For example,
masks(:,:,1) = createMask(roi_object1);
masks(:,:,2) = createMask(roi_object2);
composite_mask = repmat( any(masks, 3), size(YourImage, 3)); %expand to number of color planes
masked_image = 0 * YourImage; %black but same size and same data type
masked_image(composite_mask) = YourImage(composite_mask);