I suggest you to use opencv library, which works well under C# also that you may be know already about. you find functions to - detect outer contours - detect inner contours, and make some morphological processes that help you in filling holes.
Filling Grayscal Image C#
-
09-10-2022 - |
Question
I'm designing an LPR application for academic purpose, and one of the steps in the detection step is to fill the holes in a dilated edge detected grayscale image, I would like to know if there's a C# code that could do that
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow