Given a binary image such as the attached figure, how can I split the white pixels into 2 subsets, the inner and the outer ones? In other words, how do I determine if a white pixel is entirely surrounded by red pixels?

Name:  binary image.png
Views: 352
Size:  2.1 KB

Rather than code what I need is the guidelines, a method or algorithm.