Google Earth Engine – How to Eliminate Isolated Pixels in Classified Images

google-earth-enginegoogle-earth-engine-javascript-apiland-classification

Is there a way to eliminate isolated pixels just like we can do with the classification sieve of the QGIS SCP plugin?

I've done a classification of an image that contains many isolated pixels which I want to remove.

enter image description here

Best Answer

Just use a focal operator or reduceNeighborhood with a mode reducer.

image.focalMode(3)

or

image.reduceNeighborhood(ee.Reducer.mode(), ee.Kernel.circle(1))
Related Question