Home | Space gifs

Removing noise bands from Rosetta's photos of Phobos

Originally written May 2013.

Phobos setting behind Mars, photographed by Rosetta, 25 February 2007.  The thick band running diagonally is Martian twilight; most of Mars from this angle was in darkness.  Phobos is lit both by the sun (making its relatively bright lower crescent here) and by light reflected from Mars.

These images underwent a bit of processing before getting to this stage.  Emily Lakdawalla wrote last year on her blog that she'd "love to see someone else give these images a shot, because they're lovelier in concept than in reality."  Well, I only learned how to use Fourier transforms in image processing yesterday, so I'm far from the best person to try to tidy up the shots.  But a quick Google didn't turn up much else, so here goes.

The problem is that there's a lot of noise in the originals.  Here is one example:

There are very noticeable bands running across the image.  Less noticeable (I only saw them after taking the average value across each band and subtracting it off the image) are bands running in other directions.  In any case, the regularity of the noise bands suggests the use of a Fourier transform.  The transformed image is the same size as the original but the pixels now have complex values.  Rather than splitting them into real and imaginary components, it is more useful to separate into magnitude and phase (z = magnitude * exp(i*phase)).  Here is the magnitude of the FFT (two F's, for "fast Fourier transform", the algorithm used to compute it):

That doesn't look like much.  Let's scale it up and take logs:

The dot in the middle is the constant term, reflecting (equal to?  I should actually work through the maths one day...) the average pixel value.  The transform exists in frequency space, and points near the middle of the picture reflect low-frequency components (i.e., slowly varying), and points further away reflect high-frequency components (rapidly varying). A perfect sine wave would result in a dot at the pixel corresponding to its frequency and direction (as well as another dot symmetrically opposite); periodic noise bands look a bit like sine waves, and show up as slightly smeared bright spots.

The basic procedure now is to say, "There's stuff in the middle there that I want to keep, but I want every other bright spot to disappear."  My code to do this in Octave doesn't always give great results, but it beats doing it by hand for 20 different pictures:

(An alternative is to create a mask using one of the images and use the same mask for all of them.  The bright patches move around a little, but as long as you mask off enough pixels, it works pretty well.)

Now we take this modified magnitude of the Fourier transform, combine it with the phase calculated earlier, and do an inverse transform.  The periodic components have disappeared in the filtered image:

It's still noisy, but Phobos seems a bit brighter than the background.  Re-scaling the brightness ought to bring out the contrast a little.  Suppose the pixel values are on a scale from zero to one.  Pick a value, say 0.4 (the actual value I used depended on the median pixel value in the filtered image), that we hope Phobos's brightness is greater than.  Then squish any pixels in the 0 to 0.4 range down to 0 to 0.1, and spread out pixels from 0.4 to 1 across 0.1 to 1.  Here is the result:

There's a bit of a trade-off here, since there's a dark band running through Mars's atmosphere in the later shots, and that gets exaggerated a lot if we try to make too much of the background noise disappear.  So I wouldn't be surprised if my effort can be improved upon.  (It's also likely that I'm losing a little bit of definition because of a bug in my Octave/GraphicsMagick libraries, but I'm not sure if it's easily visible to a human eye, and I don't have a working library to compare it to.)

Home | Space gifs