Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Image Analyst
Image Analyst el 17 de Nov. de 2020
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);

Más respuestas (0)

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by