Detect the boundary in a 2 clustered colored image

1 回表示 (過去 30 日間)
oscillator
oscillator 2023 年 4 月 10 日
編集済み: Image Analyst 2023 年 4 月 10 日
I have this image. It has 2 clustered areas, a yellow and a blue one. I also drew 2 centrized points. I want to to find out which point is closer to the boundary which is why I want the boundary in the first place. I have to note that I am aware of the coordinates of the points but I can't use a specific starting point (for example in order to use the command bwboundary, because I have about 5000 images and don't know which one the function rand() will choose each time). All of them share the same philosophy.

採用された回答

Image Analyst
Image Analyst 2023 年 4 月 10 日
編集済み: Image Analyst 2023 年 4 月 10 日
You get a mask for the yellow, then call bwboundaries and then use sqrt (optional) and min:
boundaries = bwboundaries(yellowMask);
b = boundaries{1};
xb = b(:, 2);
yb = b(:, 1);
% Determine distances from point 1.
distances1 = sqrt((x1 - xb) .^ 2 + (y1 - yb) .^ 2);
minDistance1 = min(distances1)
% Determine distances from point 2.
distances2 = sqrt((x2 - xb) .^ 2 + (y2 - yb) .^ 2);
minDistance2 = min(distances2)
Knowing that you can find out if point 1 or point 2 is closer to a boundary point.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by