PFree 0.2

A PhotoShop plugin, developed using FilterMeister, that reduces purple fringing on the Sony DSC-F828 and probably other digicams as well.

This is a work in progress, but already works extremely well on many landscape images, so I'm sharing it now. See also the companion plugin CAfree for reducing CA-like blue fringes in the corners of wide & tele images.

Background

There are a zillion theories about purple fringing in general, and particularly on the Sony 828. For my personal musings look here. But generally you don't need to have an opinion for this to work. It does help to have some understanding of the causes in order to avoid PF in the first place (avoid shooting wide open in high contrast scenes, and avoid overexposing highlights, particularly specular reflections and bright sky behind dark objects).

It seems to me that there are actually two causes of fringing, one caused by chromatic aberrations, and one by a sensor effect (scattering of light on the sensor surface plus electronic effects?). The CA type is geometrically predictable and as far as I can tell is mainly a problem in the blue channel at wide angle in the corners of the frame. The sensor type can happen anywhere in the frame around overexposed highlights, affects the red and blue channels (and to a lesser extent green) and is thus more troublesome. I set out to fix both, but this plugin only addresses the sensor type (though it has some impact on the CA type as well). More to come.

The basic approach is to find blown highlights, guess how blown they are from their size, then estimate a synthetic fringe from those highlights, and subtract it from the image. A few constraints are added, mainly to deal with the fact that in overexposed highlights we don't really know how bright the orignal source really was. In the worst case, the changes to the image are limited to desaturation, to avoid creating strange artifacts. The desaturation is better than global desaturation of magentas because it is selective (only around highlights) and simultaneously lowers luminance so you don't end up with a light gray fringe where there was a purple one.

Installation

Drop the filter (download below), which is an .8bf file, into your PhotoShop filters directory, usually something like c:\program files\Adobe\Photoshop\PlugIns\Filters. Then launch PhotoShop. I've tested this with Photoshop 5.0LE and CS, and PS Elements 2.0. It's not demanding and should work with other versions as well.

If you're using other software that accepts PhotoShop compatible plugins installation should be similar, but I don't have any examples to try. PFree might also run standalone with PluginCommander but I haven't tried that either.

Controls

PFree opens to a control dialog with a preview at left. You can drag on the preview to move around your image or selection. You can zoom using the +/- buttons below the image or the top slider. The preview is by default zoomed to 100%; you can vary the zoom for a general impression, but the controls aren't fully scale-aware, so you should fine tune your settings only at 100%.

This is not exactly commercial-grade software, so the controls are less than intuitive. Fortunately, the defaults work fairly well in many circumstances, and the preview is quick so it's easy to experiment. Generally I find it better to err on the side of undercorrection, removing just enough to eliminate the obvious impression of purple.

The filter generally doesn't touch areas without highlights, so it's generally possible to apply it to small selections without any annoying artifacts. This can be a good strategy if there are small and big fringes - treat the whole image once, then selectively hit any remaining spots again.

Running the filter on an 8mpix image takes about 30 seconds on a 2.4GHz P4. The code is incredibly inefficient so big improvements are possible in a future version. Pressing the Esc key during execution should abort the filter.

Preview Zoom
Controls the zoom level in the preview window, as above
Show Fringe/Highlight
Lets you see what's happening internally - set to 1 to see the estimated fringe to be removed (before intensity scaling) and 2 to see the highlights. See example below.
Range - R/G/B
Determines how fast the fringe decays as you move away from an overexposed source. The defaults work well for most 8mpix images from the 828, but can be changed if the image is downsampled etc. For example, for a 5mpix image, you'd set them to about 80% of the defaults. I doubt the difference would be noticeable. Generally the G value should be left alone.
Intensity - R/G/B
Determines how strongly the estimated fringe values are corrected. If you see a lot of purple remaining with the defaults, try increasing the value. You can also vary the color balance of fringes by adjusting the R and B values. The G value is currently not used.
Highlight Threshold
The threshold value that PFree will regard as an overexposed highlight producing fringe. Normally this would be 255, though I've observed a few cases where the maximum green value is 253, not 255 (JPEG or interpolation artifact?) so this is set to 252 for safety. I've observed fringing around normally exposed high contrast edges (200 or so), so you can try setting lower values to see what happens.
Highlight Scale
This represents the scale (in pixels) of "interesting" highlights producing fringe. Bright spots smaller than this value in diameter will be substantially attenuated to they don't produce much fringe. This can be helpful if you have a few tiny specular highlights you want to leave alone, and one big blown-out area to correct strongly. If you set this to 1, all highlights are treated as equally bright regardless of size.
Highlight Base
Like the rise rate above, this controls how severely small highlights are attenuated before estimating the fringe they produce. Setting this to 0 maximizes the attenuation of small sources. As with the Rise Rate above, it may be necessary to play with the intensities after changing this control.
Saturation
This is not saturation in the color sense. Rather it controls the dependence of the rate of decay of the fringe as you move away from a highlight on the ambient luminance level. It looks to me like fringes diffuse farther in areas of high illumination, becoming a general bluish fog in some cases (this would seem to indicate an opto-electronic origin, not a purely optical scattering effect). Setting this to 256 means the fringe decays equally fast regardless of illumination.

Examples

The following is a fairly bad picture (at 50%), with purple haloes on some Christmas lights and strong blue and purple fringes where the garland meets the sky: The result: all but the worst fringing on the garland is gone, and the color balance in the distant trees is free of bluish haze.


Here's what PFree is doing internally (the following are crops from the garland/distant trees/sky area of the image above):

Estimated highlights, adjusted for their spatial scale.

Estimated fringe generated by the highlights. There's a surprising amount of blue "pollution" in the tree area.



Another example: Glare off raindrops. I deliberately undercorrected a bit here (20% less than the default intensities) as the remaining color is completely imperceptible at reasonable sizes (these are 100% crops).


The dreaded sticks-against-sky fringe (actually sticks on snow here, 50% crops):


Here's the toughest case I've encountered - a foreground holly bush in deep shadow against a backdrop of bright fog (real fog, not lens flare). There's fringing on the leaves, but also a general bluish cast to the more distant trees in the fog:

The default correction works on the leaf fringes, but leaves uncorrected bluish fringes down the middle of the trees. The edges of the trees actually look green, but this is because they're neutral gray and their centers are bluish-purple:

A better correction can be achieved by increasing the Range of the blue correction (to 32 here) and setting the Saturation parameter to its lower extreme (1) so that the fringe correction persists across the fairly bright tree trunks. Still, there are some persistent bluish patches, and the desaturation of the holly bush edges is rather severe. Good thing I bracketed so I don't really need this one:

License

PFree is copyright 2004 Thomas Fiddaman. Use and distribute it freely. Other rights reserved. Not for resale or commercial distribution without prior written permission.

PFree includes absolutely no warranty express or implied - use at your own risk. Don't oversave your originals (duh).

Download

Sorry, there's only a Windows version: PFree 0.2

Feedback

I'm continuing to work on this out of my own curiousity. Rather than emailing me, please contribute to the Sony forum discussion at DPreview - otherwise I'll get too distracted from real work. I'm particularly interested in pathological images that resist fixing but are somehow "worth saving". I find that most images with a lot of fringing are also bad in other ways; why waste time on those?