Filling the region within objects with white

4 ビュー (過去 30 日間)
jeffin
jeffin 2017 年 7 月 7 日
コメント済み: jeffin 2017 年 7 月 10 日
I am trying to do background subtraction and the result of one image is displayed here. There are lot of unfilled region in the region of interest.I have used Imfill command in my code. Can someone suggest me how to fill the black region in the region of Interests.
Kindly suggest me some solutions. Thanks in advance.

採用された回答

Image Analyst
Image Analyst 2017 年 7 月 8 日
編集済み: Image Analyst 2017 年 7 月 8 日
I don't know exactly what "fill the black region in the region of Interests" means. If you want to fill the black regions with black, thus making the white "islands" or "holes" black also (essentially making them disappear), then use bwareafilt() and specify the smallest white blob that you're willing to accept. For example, if you want to remove all blobs smaller than 1000 pixels, do this:
binaryImage = bwareafilt(binaryImage, [1000, inf]);
You could also use bwareaopen().
binaryImage = bwareaopen(binaryImage, 1000);
On the other hand, if you want to remove black holes in white regions, simply use imfill:
binaryImage = imfill(binaryImage, 'holes');
I also don't know what the "region of interest" is in that image. Can you indicate it, perhaps by outlining it in red? If the ROI is only part of the whole image, then you'll need to make a mask somehow, perhaps with poly2mask() or some other method depending on how ROI is defined, then use the mask to erase the non-ROI parts of the image.
binaryImage(~ROIMask) = false; % Erase outside of ROI region(s)
  1 件のコメント
jeffin
jeffin 2017 年 7 月 10 日
The Small white regions present at the top should be eliminated, while the large region present at the bottom should be filled.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by