View Full Version : Spatial Filtering - Demystified (well, slightly...)

07-15-2008, 10:15 AM
Following a request from this thread

where I tried to fix up some issues with some terrain noise using a spatial filter, I have been asked to explain a bit more about the process. Its not an easy process to understand but I have uploaded my old help file and clipped some app specific bits out of it.

It seems that Gimp at least has an FFT plugin which does exactly the same thing though the screen images might be slightly different, the principle is the same.

Maybe RobA can do some screenies of the images posted from this next link using Gimp and we can see the same process being done.

Spatial Imaging Help (http://www.viewing.ltd.uk/Temp/CG/SpatialFiltering/Help/cut_down_help.htm)

07-15-2008, 01:19 PM

The FFT stuff in gimp seems a bit different. Principally, when you run an FFT on an image, it uses 50% grey as the 0 point.

For example, your image:

has a spectrum of this:

Whereas the result of a FFT in gimp is this:

The same manipulation can be done, but to zero out a portion of the specrum, instead of black, I paint with 50% grey. (Actually, I create a layer that is 50% grey and use a layer masks). For the provided image, I did the same thing as you, decomposing the image to RGB, then masking each depending on the "hotspots", replacing those areas with 50% grey in each channel. Here is the result:

This seems a pain in the butt (all that manual painting) so I tried another experiment... After decomposing, I ran a sobel edge detection on each channel, applied a 10px gaussian blur, thresholded it, followed by a 5px gaussian blur, then normalized each channel. Blending down each of these masks and recompositing gave me:

I think it is a pretty impressive results for something that I could automate...(hmmm)

Also, for reference, here is the FFT the procedure resulted in:

I have been able to create gimp equivalents for the first 12 of the filters you show, but have not worked out the last three... how do you prevent image blowout?

-Rob A>

07-15-2008, 01:50 PM
I have been able to create gimp equivalents for the first 12 of the filters you show, but have not worked out the last three... how do you prevent image blowout?

Think I might have have it now... I am using a 50% layer set to divide mode (i.e. x 2) on to with a mask... Here are some results on a photo I took... do these make sense, Redrobes?


HF enhance:

HF and MF enhance:

HF, MF, and some LF enhance:

-Rob A>

07-15-2008, 03:55 PM
Yeah I think thats doing the trick. One thing I wanted to try for a while and which you might want to expand or script up is a way of creating wave outlines for a coast using the effects of deliberate ringing. Some pics show what I mean but I haven't faffed about much to distill the idea down to something usable yet.

07-15-2008, 04:32 PM
That is pretty clever! Try reflecting the image x&y to make it symmetrical before applying the fft. That way when you reverse it it wont ring around the lower RH corner.

Also, as an update, here is that second snippet from the other thread, processed (now that I think I have this figured out) using the edge detect/blur/mask method:

Not too bad, still a bit of playing with parameters required, however.

-Rob A>

07-15-2008, 05:44 PM
You guys are teh rock.