Alright. What graphics software are you using? I’m going to assume Photoshop or Gimp, for others you’re on your own to adapt the instructions. None of the versions of Photoshop and Gimp I have come with a DC-preserving high-pass filter, but it can be replicated by hand with a bit of work. For Gimp I have also written a script that automates it:
highpassdc.py. It belongs in
~/.gimp-*/plugin-ins/ (no idea where that is on Windows, or if it works there at all) and then appears in the
Filters >
Generic menu as
High Pass with DC.
A
high-pass filter (the terminology here comes from signal processing) is a filter that preserves (lets pass) high-frequency components, i.e. fine details, but removes (filters out) low-frequency components, i.e. overall color and broad variations. This is the opposite of blurring, which removes details but preserves broad variations. Blurring is a low-pass filter.
The basic idea is that you first blur the image sufficiently that all the detail you want to preserve is gone, but the tiling repetition that you want to get rid of is still present. Then you subtract that blurred image from the original image. Because that also removes the overall color, you then have to add that back. Matters are complicated by the fact that color values are limited to 0..1 (or 0..255), but the subtraction can yield negative values in the intermediate result, so you have to jump through some hoops to represent those as well.
It’s also a bit more complicated in Photoshop because it doesn’t have clear names like “add” or “subtract” for its layer compositing modes, but vague terms like “linear dodge” that I assume come from photography jargon and I have to experiment every time again to find out what exactly they do… “linear dodge” is “add”, “linear burn” is “subtract the inverse” (there doesn’t seem to be a simple “subtract”, you have to invert the subtrahend manually before). So, in Photoshop, “subtract A from B” in the following instructions means “put A on top of B, invert it, set its compositing mode to ‘linear burn’, and merge down”. In Gimp, it means “put A on top of B, set its compositing mode to ‘subtract’, and merge down”.
- Start with your original picture in a layer called “original”. To preserve the seamless tiling, enlarge the canvas to 3 times the size and fill it with a 3x3 tiling of the original image.
- Duplicate layer “original” as “blurred” and blur it until all the detail you want to preserve is gone, but the tiling repetition that you want to get rid of is still present. You probably need to experiment to see what blur radius gives the best result.
- Duplicate both original and blurred and subtract blurred from original. Let the result be “pos”.
- Duplicate original and blurred again and subtract original from blurred. Let the result be “neg”.
- Duplicate original as “avg” and fill it with its average color (Photoshop has an “average” filter in the “blur” menu, in Gimp you can read the average from the histogram).
- Add pos to avg.
- Subtract neg from the result.
As an alternative to the blurring-and-subtracting, you can use the built-in “high-pass” filter, which results in the high-pass result added to 50% gray, but to get the average color back in, you still need to subtract that 50% gray and add the average color, which is about the same amount of work as the above.