0

How can I fill the gaps that occurred as a result of thinning? The first image is the image before thinning, the second one is the image after thinning and the third one is an example of the pixels that I need to connect. I'm using MATLAB R2013a.

I used this code in thinning:

bw_clean = imopen(binary_image, strel('rectangle',[3 3]));
bw_clean = bwareaopen(bw_clean, 15);
thin_image = ~bwmorph(imcomplement(bw_clean), 'thin', Inf);

Image before thinning:

Image before thinning

Image after thinning:

Image after thinning

Example of what I need to connect:

Example of what I need to connect

When I used BW2 = imfill(A,'holes'); the output was:

Output using imfill

And when I used

se = strel('disk',10);
closeBW = imclose(A,se);

the output was:

Output usimg imclose

H. Nagaty
  • 13
  • 1
  • 5
  • 1
    How did you perform the thinning? Did you use morphological operators? Perhaps the thinning process can be configured in a way that would create continuous lines. It would help if you could [edit] your question and add this information. – Dev-iL Feb 10 '19 at 12:04
  • If you compute the skeleton operation in the first image you will directly get what you want – Ander Biguri Feb 10 '19 at 12:18
  • @Dev-iL I edited the question and wrote the code I used in thinning. – H. Nagaty Feb 10 '19 at 13:19
  • @AnderBiguri Is that what you mean? thin_image = ~bwmorph(imcomplement(bw_clean), 'skel', Inf); – H. Nagaty Feb 10 '19 at 13:21
  • This is not a thinning. Thinning respects the connectivity. –  Feb 10 '19 at 14:02
  • 2
    What you are seeing is caused by the image display. It is not showing all pixels in the image because it scaled it down to fit the image in the display area. Try zooming in on those regions you marked, you’ll see the missing pixels reappear. – Cris Luengo Feb 10 '19 at 15:11
  • @CrisLuengo: you are right, otherwise filling would have failed. –  Feb 10 '19 at 16:48
  • Thank you all for your help. – H. Nagaty Feb 10 '19 at 22:07

0 Answers0