Connect objects binary image
Show older comments
Hi
I have this binary image with 4 objects, and want to connect this 4 object into one object/blob (see image, with the approximate connection points marked with red).
I have tried: imclose, bwmorph(BW,'bridge'), bwmorph(BW,'endpoints'), imdilate, imerode and imfill.
Do you have solution for that, I have been struggling for weeks. 

Answers (1)
Subhadeep Koley
on 4 Feb 2020
Hi, try the code below and see if it gives the expected output. (Download the attached image)
a = rgb2gray(imread('BW_img_marked.jpeg'));
b = imbinarize(a);
se = strel('disk', 12, 4); % Structuring element for dilation
c = imdilate(b, se); % Dilating the image
d = imfill(c,'holes'); % Filling the holes
imshow(d);

3 Comments
Mithushan Soundaranathan
on 4 Feb 2020
Mithushan Soundaranathan
on 4 Feb 2020
Edited: Mithushan Soundaranathan
on 4 Feb 2020
Jonne
on 29 Apr 2021
Nice how did you do this? could you share the code
Categories
Find more on Image Processing Toolbox 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!
