For various reasons, certain images may have areas filled with dots instead of solid colors. This is most common when the number of colors is limited, as in scans of images printed by old printers, or dithered GIFs. The problem with these images is that they don't compress very well (PNG and JPEG work best with horizontal lines and smooth gradients, respectively) and scaling them can cause the dots to merge, resulting in strange patterns that aren't supposed to be in the image.
I want a method to automatically "de-dither" an image, replacing the dots in dotted areas with solid color. For example, it should make the right left side of this image look more like the left right side:
I especially want a solution that works in the GIMP or Imagemagick, but I am also willing to try other tools.