The amazing adventures of Doug Hughes

I received an email today from an Image Component user. This person works for a museum in New York and was working on a project apparently related to making archived digital pictures available online. Many of their pictures were scanned from printed materials and, unfortunately, had a very strong moir pattern. When the image was scaled down using the Image Component the pattern became very apparent.

For those of you that don’t know what a moir pattern is, it’s a funny, repeating pattern you get when you scan printed images. This comes from the fact that printed images are made up of tiny little dots, similar to pixels, but a different pattern.

When you scan these images, the translation from the offset dot pattern to a computer pixel system creates a very obvious pattern in the image. When you scale the image down this pattern usually becomes even more apparent.

Most scanners have a setting called “descreen” which applies an algorithm which removes this pattern when you’re doing the scan. This is the best time to fix these types of problems. Unfortunately, the images the museum was working with had no been descreened and the resulting scaled images were not pretty.

Here’s an example with the moir pattern. The image is obviously of very poor quality.

If you’re working in some software like Photoshop, there are techniques you can apply to reduce this effect. Generally, this is to have an image two to three times the size you need the image to be. You then apply a median filter of two or three pixels, scale the image to the target size, then apply an unsharp mask.

The Image Component isn’t exactly as powerful as photoshop. However, the purpose really is to average a set of 4 or 6 pixels so they are roughly the same color. Then, scale them down and their resampled pixels should end up the correct color. So, before rescaling the image I applied a 3-pixel blur. (The AIC has an annoying feature where blurred images get a black border around them. To prevent that I increased the image canvas size before burring then cropped it back out.) I then re-read the unaltered image and drew it back over the blurred version at 30% transparency. The purpose of this was to bring some sharpness back into the image.

Finally, I resized the image to the target size. This process did a pretty good job of lessening the moir effect. It’s not gone, but it’s a lot better than it was. Here’s the result with this technique applied:

The code I wrote is as follows. (You’ll need the Image Component to do this. Download it here .)