Is it possible to erode only the outermost layer of a circle?
11 ビュー (過去 30 日間)
古いコメントを表示
Hi folks,
I am looking to erode a circle from the outside in, layer by layer. So far, I have tried to use the following:
x = imerode(x, strel('disk', 1));
but in the case of an image with a higher Euler number than 1, this erodes the holes within the image as well...Is there a way around this please?
2 件のコメント
採用された回答
その他の回答 (2 件)
Image Analyst
2022 年 5 月 31 日
Here are the steps I'd try, assuming you're starting with a binary image
Call bwboundaries to get the outer layer. Of course, tell it to ignore interior holes - there's an option for that.
Have a for loop where you visit every (x,y) location and set it's value to false.
Something like (untested)
boundaries = bwboundaries(mask, 4, 'noholes');
bxy = boundaries{1};
rows = bxy(:, 1);
cols = bxy(:, 2);
for k = 1 : length(rows)
mask(row, col) = false;
end
0 件のコメント
Walter Roberson
2022 年 5 月 31 日
negate the image so the holes and background are true and the white is false. bwareafilt requesting the largest. That will be the background. negate the background to get the filled foreground. Subtract the original image from the filled one to get the location of the holes. Erode the filled image. Subtract the holes.
You might have to filter differently if you have multiple disconnected objects.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!