フィルターのクリア

How do I make all pixels under an assisted line boundary = 1?

2 ビュー (過去 30 日間)
Lydia Bradley
Lydia Bradley 2020 年 11 月 17 日
コメント済み: Lydia Bradley 2020 年 11 月 17 日
I have manually segmented an image into two halves using:
roi = drawassisted('Closed',false);
Im = createMask(roi);
The generated mask (Im) is attached as an image
I want to make all pixels below that line = 1
The problem I am having is that the boundary sometimes loops back on itself, so x values are not unique, meaning I can't write a simple if statement using the pixel co-ordinates.
I'm sure the solution is quite easy, but I am really struggling to find it.
Any help much appreciated,
Thank you

採用された回答

Image Analyst
Image Analyst 2020 年 11 月 17 日
Try this (untested) with your mask to create a mask where the lower portion is true and the upper portion is false.:
[rows, columns] = size(mask); % Get size of your binary image with the line in it.
lastRow = ones(1, columns); % Initialize to top of image.
% Initialize a lower mask
lowerMask = false(rows, columns);
% Scan columns finding the last
for col = 1 : columns
thisColumn = mask(:, col);
t = find(thisColumn, 1, 'last');
if ~isempty(t)
lastRow(col) = t;
end
lowerMask(lastRow(col) : end, col) = true;
end
imshow(lowerMask);
  1 件のコメント
Lydia Bradley
Lydia Bradley 2020 年 11 月 17 日
This worked perfectly, thank you so much!

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

その他の回答 (0 件)

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by