In order to make the mask expansion a bit more "intelligent" and to avoid that it includes complete tables, I have implemented a very straightforward algorithm:
1) Detect vertical and horizontal lines, that have a length of >= 20% of the image height/width in the dilated image and create a binary mask ("exclusion mask") to label the pixels that belong to these lines.
2) During the mask expansion: Whenever a pixel is in question to be treated as a new seed pixel: Check if it is labelled in the exclusion mask.
2a) If labelled in the exclusion mask, do not consider it a new seed pixel.
2b) If not labelled in the exclusion mask: Proceed as usual (add it to the seed pixel list)
This is simple, fast and effective to avoid whole tables being included in the masks because they touch a chemical structure depiction in the dilated image.
In order to make the mask expansion a bit more "intelligent" and to avoid that it includes complete tables, I have implemented a very straightforward algorithm: 1) Detect vertical and horizontal lines, that have a length of >= 20% of the image height/width in the dilated image and create a binary mask ("exclusion mask") to label the pixels that belong to these lines. 2) During the mask expansion: Whenever a pixel is in question to be treated as a new seed pixel: Check if it is labelled in the exclusion mask. 2a) If labelled in the exclusion mask, do not consider it a new seed pixel. 2b) If not labelled in the exclusion mask: Proceed as usual (add it to the seed pixel list)
This is simple, fast and effective to avoid whole tables being included in the masks because they touch a chemical structure depiction in the dilated image.