Commons:Cleaning up interference with Fourier analysis

From Wikimedia Commons, the free media repository
Revision as of 07:24, 10 April 2006 by Dcoetzee (talk | contribs) (Write intro and initial Photoshop tutorial)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Interference or other regular patterns overlaid on an image can be introduced by a variety of sources, including:

  • Electromagnetic interference in the environment of the device collecting the image;
  • Noise in a transmitted image such as a television still due to analog transmission interference or degradation of media;
  • The texture of the paper that the image was printed on, particularly if it was printed in a cheap magazine or newspaper.

Attempting to remove these by ordinary image space techniques such as replicating the pattern and subtracting it would be extremely difficult and unlikely to be completely successful.

A simple and effective technique for dealing with these problems is to identify the interfering feature in the power spectrum image produced by Fourier analysis, eliminate them, and convert back to the original image. This tutorial shows how to do this using some widely available tools. I currently only discuss how to do it with Photoshop because that's what I use, but I'm sure it's also possible with free tools.

Tutorial (Photoshop)

First, go to Alex V. Chirokov's Archive page and click the link labelled "Download new version of FFT/IFFT Photoshop plugin". Copy the files from the archive into your Photoshop plug-in directory. Start Photoshop.

The initial image, containing clearly visible diagonal bar interference

For our sample image, we'll be using this lovely photo of a rose which mysteriously became striped with an interfering pattern of diagonal lines (actually, I took Image:Rosa_Gold_Glow_2.jpg and added the interference myself).

File:Cleaning up Fourier screenshot 1.png
The three images right after performing the FFT conversion

First, we'll need to edit each channel separately. Click the "Channels" tab, and for each of the Red, Green, and Blue channels, select the channel, select all, copy its contents, and paste into a new image. Convert all three new images to RGB mode using Image->Mode->RGB color.

On all three images, select Filter->Fourier Transform->FFT. Next, select one of the images and zoom it (it doesn't matter which one). You should see an image full of colourful noise, with a few bright spots. We need to figure out exactly where all the bright spots are. Select Layer->Duplicate Layer to duplicate the layer containing the FFT image, and click OK. Next, with the new layer selected, go to Image->Adjustments->Brightness/Contrast, turn contrast to 100%, and turn brightness down until each of the bright spots in the image is clearly visible. If you can see them all the spots fine in the original FFT image, you can skip this step. (If you're curious about why the FFT images are so colourful, it's because it's encoding the phase shift, needed to later reverse the transformation, in the hue of each pixel.)

File:Cleaning up Fourier screenshot 2.png
The three images after erasing the bright spots with a black brush

Now, create one more layer on top of the others. On this layer, use a round, pure black brush of appropriate size to erase all of the bright spots except the one in the middle. Don't be afraid to erase too much of the area around a spot - it usually doesn't hurt anything as long as you're not too close to the center. In this sample image I spotted 8 bright spots, but there can be as few as 2. Copy this layer to a new channel on top of each of the other two images, making sure that it's lined up over the bright spots in all the images.

Finally, hide the middle layer (the one with brightness/contrast adjusted) from view, choose Layer->Flatten Image, and say "OK" to the dialog telling you that hidden layers will be discarded. Make sure no bright spots are left other than the one in the middle. Flatten the other two images as well. Then, choose Filter->Fourier Transform->IFFT. You should observe greatly reduced interference in all three channels.

The final image, with the interference mostly gone

To recombine the channels, simply select the correct channel in the original image and copy the contents of the edited image over it using Select All, Copy, switch images, Paste. It may be necessary to adjust brightness/contrast. We now have a much nicer looking rose. It's not quite perfect though, being slightly blurrier than the original and having some subtler artifacts left over — it's always best to find a clean copy of the original image if possible.