How to fill the space in between the irregular lines?
2 views (last 30 days)
Show older comments
I have two line (like a curve) with some gap in it and running parallel in a binary image. I need to fill the gaps without disturbing the original structure, so at the end I get two lines running parallel without any gaps(One long and one short). Also this principle should apply if the number of lines increases(eg: 4 lines in an image). My lines never intersect each others, always I have them running parallel. Its not a homework, its part of my project I'm working. I'm in middle of something and I cant think some algorithm to work in a generic way(If number of lines increases). Any idea guys?
0 Comments
Answers (1)
Image Analyst
on 2 Feb 2015
Did you ever think of an algorithm that goes across the image filling in the space between the first line and the last line as you stated? Something like this
[rows, columns] = size(binaryImage);
for col = 1 : columns
thisColumn = binaryImage(:, col);
topRow = find(thisColumn, 1, 'first');
bottomRow = find(thisColumn, 1, 'last');
binaryImage(topRow : bottomRow, col) = true;
end
It should work for the image you showed but I can't know whether it will work for images you did not show me, like images with tons of lines all over the place at weird angles and spacings, like you dropped a box of toothpicks on the ground.
See Also
Categories
Find more on Image and Video Ground Truth Labeling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!