Reputation: 25
I have a binary matrix containing several binary objects and I want to bridge between them. Actually I have the following picture:
And the result has to be like this:
Is there any function or a shortcut way, other than loops, for this problem?
Upvotes: 0
Views: 703
Reputation:
Morphological operations are suitable but i would suggest line structuring element as your arrangement is horizontal and you do not want overlaps between lines:
clear
clc
close all
BW = im2bw(imread('Silhouette.png'));
BW = imclearborder(BW);
se = strel('line',10,0);
dilateddBW = imdilate(BW,se);
img= imerode(BW,se);
figure;
imshow(img)
Upvotes: 2
Reputation: 3222
Use a morphological close for this purpose
http://www.mathworks.com/help/images/ref/imclose.html
Try using a square structuring element of various sizes until you get what you expect.
Upvotes: 0