Hi Bart,
I am a bit out of my league here thinking in the frequency domain, but it seems like a bit of a pity to choose a well-behaved-yet-weaker filter to perform the initial filtering because it's well behaved, and then apply a stronger poorly behaved one in the reconstruction phase to make up for it.
Hi Jack,
It isn't as grim as you may have been led to believe. With down-sampling we effectively discard a number of pixels, which is an unrecoverable in most situations. We will also introduce some blur, due to the weighted averaging of pixels before creating new ones. Some filters are used to control this weighted averaging. All of these filters have benefits and drawbacks, so we need to find a nice (fit for purpose) filter with the most pleasing properties. We can basically fit the trade-offs into the following diagram.
We want to strike some balance between blurring, aliasing, blocking and ringing. Optimizing for one (reducing its prominence), will create more of the other artifacts, so many solutions tend to be optimally balanced somewhere in the middle of all. One may prefer a certain trade-off for certain types of image content (e.g. line drawings versus real photographic images).
Based on Nicolas' particular disgust for dark halo overshoots (ringing), and the general consensus that if we were to tolerate some (to enhance the sensation of sharpness, actually similar to what our eyes do) it should be balanced between over- and undershoot amplitude.
I've been going through most of the available filters in ImageMagick, and looked specifically for those that had relatively symmetrical (low) halo behavior in linear light (because of color mixing/blending benefits), but at the same time exhibited little tendency to generate aliasing artifacts (very likely to occur in downsampling). That takes care of two of the four possible artifact quadrant choices, and leaves blur versus blocking to avoid.
Blur is beneficial in reducing blocking (and noise), but can also be restored to a certain degree with deconvolution. The more advanced the Deconvolution process is, the better the restoration of original detail will be. When noise is restored less than signal is, we get a better Signal-to-Noise ratio.
Does ImageMagick allow to perform some form of decent real deconvolution (such as LR) in-line? If so, wouldn't it be better to use a gaussian deconvolution operator in the -define line instead of DoG to undo the gaussian filtering? Or perhaps in addition to a weaker DoG?
ImageMagic does have a (de)convolution function, but it is (currently) not as advanced as a more involved programs can offer. The 'Lightroom/ACR' version of deconvolution is not all that spectacular (it generate lot of artifacts very quickly), but there are other solutions that can do a spectacular job (e.g. FocusMagic).
ImageMagick's Difference of Gaussians (DoG) function can be used to generate a high-pass filter, but it is used as a single pass deconvolution kernel in the spatial domain, the way I use it. In the way I implemented that line of code, the two Gaussians now become an 'Impulse function', from which a Gaussian is subtracted, effectively producing a High-Pass filtered (high-spatial frequency) version of the image, that is then added to the original image.
As you may have guessed I am allergic to artificially amplified acutance (and alliteration)
And so am I, but a High-Pass filtering can be a very intelligent enhancer of
actual detail,
provided that the correct dimensions are chosen (!!!). It's the latter that can be achieved with adding
a modest amount of the recovered High spatial frequency content, and using a
properly dimensioned Gaussian component in the High-pass filter. It can also be (ab)used to add more of the high spatial frequency detail back than is recoverable in a single convolution pass. That is where taste and viewing conditions come into play.
To allow to follow one's own preferences, and allow to do more for certain viewing conditions, or less for specific further processing requirements (e.g. more advanced Deconvolution), I've added a user definable 'Amount' setting in the next release version of the script, so one can pick one's own amount of poison.
I've also found a better (slightly sharper but with less aliasing) filter than Gaussian. It is ....., drum roll ..., an non-standard as yet filter coined
RobidouxSoft. It is soft, but not as soft as some others, it produces less aliasing artifacts than many others, has relatively symmetrical halo performance in linear light down-sampling, and as such is IMHO one of the best performers if one also allows for a sharpening step to follow its use. And even with sharpening, aliasing performance is not bad (of course depending on image source).
Cheers,
Bart