How to delete one of the two outlines of an image

2 ビュー (過去 30 日間)
Jórdan Venâncio Leite
Jórdan Venâncio Leite 2020 年 4 月 5 日
コメント済み: Rena Berman 2020 年 10 月 12 日
I have a binary image with two outlines (attachment). One larger and one smaller. I used the bwconncomp and regionprops function to identify such outlines and their respective areas. I would like to get another image, similar to the image i attached, but without the smaller outline. The regionprops function returns a struct with a field and two values where it is possible to identify the area of the smallest contour in which I want to remove it from my initial image. Do you have any idea how to solve this?
Thanks in advance
Contour = bwconncomp(image, 8);
area = regionprops(Contour, 'Area');
  1 件のコメント
Rena Berman
Rena Berman 2020 年 10 月 12 日
(Answers Dev) Restored edit

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

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 5 日
Following code will select the smallest region and remove it from the image
load('Image.mat');
image = preenc;
Contour = bwconncomp(image, 8);
area = regionprops(Contour, 'Area');
[~, idx] = min([area.Area]);
mask = Contour.PixelIdxList{idx};
image(mask) = 0;
imshow(image);
  2 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 4 月 5 日
preenc is the name of the variable in your Image.mat file. Just set it to whatever is the name of your image variable.
Ameer Hamza
Ameer Hamza 2020 年 4 月 5 日
Like this
load('Image.mat');
image = preenc;
Contour = bwconncomp(image, 8);
area = regionprops(Contour, 'Area');
idx = find([area.Area] < 50000);
for i=1:numel(idx)
mask = Contour.PixelIdxList{idx(i)};
image(mask) = 0;
imshow(image);
end

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by