I wonder how I can remove single pixels (and double pixels) in a classification raster. I read in one thread that this might be done by moving windows of 3x3 or 5x5 pixels and i can filter out and delete the single (or double pixels). But this makes me think that the result is really dependent on the starting point of the moving window. If I would delete a classified single pixel at the rim o one window, it could still be attached to more pixels in the neighboring window. Is there a good algorithm or way to prevent that? Preferably in R?

Similar questions and discussions