필터 지우기
필터 지우기

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);

추가 답변 (0개)

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by