pixeltweek, modified mode filter

Pixeltweek is a very simple image filter which can be used as a surprisingly effective despeckler or as a pre-processor for images to remove noise and allow for more effective compression. It is only properly effective on images with areas of uniform color, which limits it's use to artwork and animation.

In more technical terms, it is similar in concept to a mode filter with a few alterations that greatly improve conservation of detail. Most importantly, it will only alter pixels in which the modal value is a majority - a condition that is typical of noise, or perhaps single-pixel boundries on complex shapes, but nowhere else. Imposing this condition diminishes noise removal significently, but diminishes degredation of signal component of an image to nearly nothing. Dithered colors excluded. It also has the option of looking for correlation in color channels - if a pixel is determined to be noise in two channels, it'll be assumed to be noise in the third as well. This can be disabled when all channels are truely independant, such as when removing CCD sensor noise.



As a denoiser, pixeltweek is really of little use. Even on animation, it shows no ability at all to handle edges. Animation is ideal for this type of filter: If it performs so poorly on this, it's not even worth trying on a photo.

Pixeltweek compared to the commonly used median filter. While the median filter removes all noise, it does so at the expense of significent edge bluring. Pixeltweek removes much less noise, but causes no noticeable degredation at all.

The same algorithm used for this denoising also has another interesting property. When given a noise-free image, it will make subtle changes in the borders between colors or color bands. These are too small to be noticed, even by a viewer flicking back and forth between the before and after image, but do make the image more easily compressed. In testing I found a 10% reduction in the size of a PNG.

PNG optimisation example
Size Link
397926 Before
348436 After

This benefit in compression comes from a combination of the removal of very fine noise (On the order of one quantitisation level) and a 'tightening' of the boundries between quantisation bands, as can be seen in a highly chroma-enhanced enlargement.

An attempt at using this technique on video proved partially successful, but the benefits were too small to be of much practical use.

Using bitrate=600:ssim:tune=ssim on a ten-minute animation test file.
Before pixeltweek:
x264 [info]: SSIM Mean Y:0.9885697 (19.419db)
x264 [info]: kb/s:605.02
After pixeltweek:
x264 [info]: SSIM Mean Y:0.9891523 (19.647db)
x264 [info]: kb/s:605.09

Even much of that slight gain is likely an illusion of the measuring process: The type of single-pixel feature that pixeltweek would detect as noise would have been removed during quantitisation anyway.

As a noise removal filter, pixeltweek was a failure: It works, but not well enough to be of practical use for that purpose. Other means just serve the purpose far better - in particular, I found that the use of a median filter followed by a threshhold limiter, both iterated, does the job very well indeed. I keep it only as a curiosity - it's ability to improve PNG compression may me of some utility.

For noise removal, I found that the 'limited mode' approach of pixeltweek was inferior to other approaches using a threshhold to apply either a median filter or other filters of similar properties. This


The noisy image approached with another method: Median filter, but changing only those pixels with a filtered value more than 28 away (RGB euclidian) away from the initial value. Repeat the process a second time. All the noise is gone, and the impact on details is not too severe. There is some bluring of fine details.

My eventual best result: For each pixel calculate the per-channel average of the eight neighbouring pixels. If the pixel is more than a distance of 64 away (RGB), replace with the color of the adjacent pixel for which the color distance to the average is least. Repeat a second time. A few more noisy pixels sneak through, but there is no bluring of edges at all.

I'm perfectly aware that it's 'tweak' not 'tweek.' It just makes the project easier to find on google if it doesn't have a name used by quite so many art forum posters.