Stop Using RemoveGrain

RemoveGrain is kind of an abomination as a filter. Mostly because it has over 20 different modes that effectively are different filters. These are probably just numbered in the order the author came up with them and this can be very confusing. Having that many modes also leads to the big question of what these modes actually do and which ones are actually used. A quick check showed that modes 2, 4, 11, 12, 19 and 20 are the most common (most other modes are useless and/or pointless in case you’re wondering).

Mode 2: 3×3 clipping operation with no nice name

Mode 4: 3×3 median

Mode 11&12: 3×3 convolution using [1 2 1, 2 4 2, 1 2 1]

Mode 19: 3×3 convolution using [1 1 1, 1 0 1, 1 1 1]

Mode 20: 3×3 convolution using [1 1 1, 1 1 1, 1 1 1]

If you’re paying attention you can easily see that all except mode 2 are easily replaceable by easier to read functions that support more input formats. Go do that!