First time here? Check out the FAQ!
answered 2018-07-02 03:53:30 -0600
You can use opening with a rectangle kernel of size 3 and iterate (4 for posted image)
First image original
Second image result
third image difference between original and result : some pixels are lost