How to manually complete lines with gaps (binary image)

How can I manually connect the edges in a binary image (se example done in Paint picture 2)?
The "gaps" as you see are not always small (and therefore the closes edges are not always the once that should be connected). It would be preferable if the image would be shown to the user when running the script and letting the user click/select/indicate two edges at a time that should be connected (and therefore a line created between them) as many times as needed.
Thank you very much for your time and help,
Rebecka

 Akzeptierte Antwort

darova
darova am 11 Apr. 2019
clc, clear
choice = questdlg('Want to draw?', ...
'Connect lines', ...
'Yes','No','Yes');
I = false(500,500);
imshow(I)
% press anything after drawing to end editing
while strcmp(choice,'Yes')
h = imline;
mask = createMask(h);
I = I | mask;
imshow(I)
if waitforbuttonpress, break; end
end
Look also HERE

1 Kommentar

Thank you very much! This was extremly helpful!
Took me a minute or two to understand how the drawing tool worked (that you had to click inbetween every line you draw to draw another one), but it worked perfectly!
/Becka

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Gefragt:

am 11 Apr. 2019

Kommentiert:

am 13 Apr. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by