1 | initial version |
I think, that an erosion and dilatation will do the job. And, as I see, you are using binary image, so you can just check if there is a white/black pixel in the window. BUT I'm not sure that will preserve the edges clear and sharp...