-distort Resize instead of -resize w/out HDRI esp. enlarging
Posted: 2012-06-07T07:24:47-07:00
http://entropymine.com/imageworsener/clamp-int/ suggests that IM resize, because it uses two-pass orthogonal resampling, which (allegedly) stores intermediate values in a clamped range when not in HDRI mode, leads to unexpected artifacts when enlarging a lot. This makes sense, and I would expect this to also happen when downsampling, but much much less, because haloing is not much of an issue when downsampling as a result of "averaging" over larger areas.
Does IM indeed store the result that sits between the two orthogonal passes in a format that forces clamping of the intermediate result?
When using a filter that does not over/undershoot, like Triangle (bilinear), Point (nearest), Cubic (cubic B-spline smoothing), Quadratic (quadratic B-spline smoothing), or Gaussian (Gaussian blur), it does not matter, because there are no over and undershoots to clamp. This is mostly an issue with the strongly sharpening filters, like Catrom or Lanczos, and to a lesser extent, with Mitchell.
I've not looked carefully enough at the code to see if this is really what's going on, or checked that I can see these artifacts, but one quick solution to this problem would be for a user to swith to -distort Resize (which of course brings other issues to the table), because it does not go through an intermediate storage. When running a Q8 version of IM, for example, this may be worth it. Q8 using -distort Resize may actually run faster than Q16 with -resize for a given result quality. It also suggests using less sharpening filters at low quantum.
This also could be resolved using an intermediate float or double image just to pass values from one orthogonal sweep to the other, not elsewhere.
A "deeper" but way way more complicated solution would be to use a rotating double precision array of image rows, never storing the entire intermediate image (at low or high quantum). Is this what IM does already? (If so, my hat is off to whoever programmed this, because doing this well has got to be painful given the various filter extents and the handling of up- and downsampling.)
Does IM indeed store the result that sits between the two orthogonal passes in a format that forces clamping of the intermediate result?
When using a filter that does not over/undershoot, like Triangle (bilinear), Point (nearest), Cubic (cubic B-spline smoothing), Quadratic (quadratic B-spline smoothing), or Gaussian (Gaussian blur), it does not matter, because there are no over and undershoots to clamp. This is mostly an issue with the strongly sharpening filters, like Catrom or Lanczos, and to a lesser extent, with Mitchell.
I've not looked carefully enough at the code to see if this is really what's going on, or checked that I can see these artifacts, but one quick solution to this problem would be for a user to swith to -distort Resize (which of course brings other issues to the table), because it does not go through an intermediate storage. When running a Q8 version of IM, for example, this may be worth it. Q8 using -distort Resize may actually run faster than Q16 with -resize for a given result quality. It also suggests using less sharpening filters at low quantum.
This also could be resolved using an intermediate float or double image just to pass values from one orthogonal sweep to the other, not elsewhere.
A "deeper" but way way more complicated solution would be to use a rotating double precision array of image rows, never storing the entire intermediate image (at low or high quantum). Is this what IM does already? (If so, my hat is off to whoever programmed this, because doing this well has got to be painful given the various filter extents and the handling of up- and downsampling.)