Maybe some pros can comment - if I made something wrong or if Lanczos / the windowed resize filters have a special weakness here (besides the 'normal' ringing).
Example: test.png
(It looks 'ugly' at original size, as it's an output from Ghostscript at 4x size - to compensate the non-working antialiasing there. I have to downsize this supersampled image to 25% in order to get a normal, antialiased image.)
First, a 'normal' resize:
Code: Select all
convert test.png -resize 25% result1.png
Looks fine.
The normal Lanczos resize with more lobes:
Code: Select all
convert test.png -set option:filter:lobes 8 -resize 25% result2.png
Still fine. If I magnify that, I of course see that there's some ringing. But it's ok.
Code: Select all
convert result2.png -crop 79x93+4+9 +repage -scale 400% result2s.png
The above commands show no severe artifacts yet, but in general, the results will be wrong (even if it's not noticable in THIS example). The reason is that my input image is a sRGB image. (I stripped the metadata to keep the filesizes low, but I can assure you that the image had been converted with the "sRGB IEC61966-2.1" profile.)
One solution is to make gamma corrections in order to do the resizing in linear space. So, I modify my 'normal' resize:
Code: Select all
convert test.png -gamma 0.45455 -resize 25% -gamma 2.2 result3.png
And with more lobes:
Code: Select all
convert test.png -gamma 0.45455 -set option:filter:lobes 8 -resize 25% -gamma 2.2 result4.png
A non-acceptable result, if you ask me. I don't even need to zoom in that image to see that the last result has three halos/ghosts around these letters. Well, doing a gamma correction after resize probably accentuates the artifacts from Lanczos. But is it really supposed to be that bad?
For comparison - again a magnified image of the letter 'A' here:
Code: Select all
convert result4.png -crop 79x93+4+9 +repage -scale 400% result4s.png
I can avoid some of the severe artifacts by just using the default Lanczos settings (not using more lobes). But even with the default of 3 lobes, I still see one distinct halo around the letters. I don't see that halo on the first result images - without the gamma corrections. But again: Without the gamma corrections, IM apparently assumes that the input is already in linear space, and that's just wrong with most images. (Yes, I have read that thread.)
One problem could be that such a manual gamma correction is not totally correct yet. But even if I could convert my sRGB images to a 100% correct linear space (and I don't know how to do that with ImageMagick) - I'm not sure if the accentuated resize artifacts would be gone.
Has anyone some hints here (besides using a more blurry resizing filter)?
(Edit: Corrected one typo in the 'result4' command.)