Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can't easily do that. That's not how morphology works. However, if that is representative of all your images, you can pretty simply solve the problem without morphology. First use Flood Fill to set the white background to a different color. Then find all remaining white pixels. Replace them with the nearest color. Then use Flood Fill again to return the background to white.