In traditional photography and film, a diffusion filter is used to soften light from a flash or stationary lamp. Specialized lenses are available for this purpose (see the image above), but the effect can be cheaply replicated by smearing petroleum jelly over the light (seriously) or by shooting through a sheet of nylon.
In image processing, a diffusion filter often means something else entirely. Photoshop’s “Diffuse” filter randomly rearranges pixels within a set radius. (GIMP can do the same thing, but their effect is more accurately titled “Spread.”) This effect can be animated for a cheap explosion effect - something a number of SNES, Genesis, and DOS games used to great effect.
This project demonstrates a simple, real-time method for replicating such an effect. All code is commented and reasonably optimized, and an animated “special effect” version is provided for those interested. Unlike Photoshop, this routine allows you to specify separate horizontal and vertical max random distances, as well as the ability to wrap pixels around image edges.
Here’s the original image (a poster for the Playstation 3 game “LittleBigPlanet”).
Here is the same image with a diffuse filter applied (max distance = 5).
…and here is the image again, but with max distance = 50.
…and one more example. This time, edge wrapping has been enabled. Note the bleed of planet pixels at the top and black pixels at the bottom.