Skip to content
Advertisement

How to remove all pixels that aren’t connected to at least 10 another pixels in python [closed]

Is there a way to remove all pixels that aren’t connected to at least 10 other pixels? I want this

image

to look something like

this.

Advertisement

Answer

Using erosion and dilation to remove the grain works very well for this particular image

JavaScript

This gives an array with every character’s island pixels labeled

JavaScript

Output

result

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement