Page 10 of 16

Re: proper scaling of the Jinc filter for EWA use

Posted: 2012-04-19T21:59:15-07:00
by henrywho
My 99% use cases are to down-size the overly-MegaPixel-bloated JPG (and recently RAW) from my digital cameras to desktop, FB and web sizes, i.e. from ~16MP down to ~1MP, using distort resize under linear RGB. I want to balance between aliasing and sharpness (but less concern on haloing because I have little experience in detecting it).

1) Robidoux is not sharp enough, and Quadratic@blur=0.9428090415820634 is really blurry.
2) JincJinc4 is sharp but prone to aliasing in JPG.
3) RobidouxSharp is also sharp but prone to aliasing even in PNG.
4) To my surprise, Gaussian gives too much aliasing and produces artifacts (e.g. the eyes in fly_original.jpg).
5) Box produces artifacts too (again, the eyes in fly_original.jpg)
6) JincJinc3 and LanczosSharp are actually doing quite well for bigger-sized JPG (e.g. -quality 88% -sampling-factor 1:1:1)
7) JincJinc2 and Lanczos2Sharp are better for smaller-sized JPG

Re: proper scaling of the Jinc filter for EWA use

Posted: 2012-04-20T05:59:56-07:00
by NicolasRobidoux
@henriwho: Thank you very much for the report.

Suggestion: If Robidoux is too soft and RobidouxSharp too aliased, I suggest that you try Mitchell (with distort Resize), which is pretty much halfway.

Side note: Because JPEG involves a (Discrete) Cosine Transform, I am not surprised that the filters based on Fourier considerations (Lanczoses et al, whether resize with Sinc or distort with Jinc) generally do better than those based on "good local approximations of smooth functions" (those based on Keys cubics: Robidoux, Mitchell, RobidouxSharp, CatRom, whether with resize or distort), but that their advantage appears to be less with PNGs (which don't destroy information through the Fourier domain).

Re: proper scaling of the Jinc filter for EWA use

Posted: 2012-04-20T06:06:11-07:00
by NicolasRobidoux
W.r.t. Gaussian, increase sigma and the support. Anthony likes a pretty tight Gaussian default. E.g., multiply both by sqrt(2). Also note that Anthony has fined tuned Gaussian blur quite a bit. If you use an older IM, you may not get as good a default as with a more recent one.

P.S. http://www.imagemagick.org/Usage/resize/#filter_sigma viewtopic.php?f=1&t=19245

Re: proper scaling of the Jinc filter for EWA use

Posted: 2012-04-20T06:11:00-07:00
by NicolasRobidoux
@henriwho: Warning: Before IM 6.7.5, -colorspace sRGB meant that you were converting from sRGB. Now it means that you are converting to sRGB. This means that the "old" way of going through linear light now makes things worse. You need to swap RGB and sRGB for it to do what you want. And having it do the "wrong" things is likely (my student Adam Turcotte and I are doing quantitative comparisons to be done in a week or two, so I may be able to remove the "likely" from this sentence soon) to mess things up quite a bit. (But possibly not enough so that you go: "Something's wrong!")

Re: proper scaling of the Jinc filter for EWA use

Posted: 2012-04-20T06:28:58-07:00
by NicolasRobidoux
anthony wrote:...
But the no-op case is very important as many users (like me) are not dealing with real-world images (photos) but more commonly with cartoon like images (computer graphics, text, line drawing), so a good no-op default is vital.
If no-op is so important: RobidouxSharp.

However, this scheme is likely to elicit complaints from people who use IM to produce JPGs from digital photographs. Since a "cartoon" user is more likely to be willing to read documentation, maybe you'd want to put the "if you care about no-op sharpness, use RobidouxSharp" in the documentation instead, and stick to Robidoux as the general default since it is a good MOR scheme (the -resize Mitchell of the EWA world). Or else make LanczosSharp the default.

It was really interesting to read the results of henriwho's comparisons, B/C they pretty much match my gut feelings, but not necessarily the conclusions of a client who did a quick subjective comparison involving several people including web designers; they were split more or less 50/50 between Robidoux and LanczosSharp --- this was before RobidouxSharp, but I don't think it would have ranked --- when the matter at hand was fairly low quality reduced JPG images with sizes up to about 600x600 and the usual chroma subsampling (I don't have the details of how the comparison was done). This being said, as you decrease the JPEG quality, spectral accuracy slowly takes a back seat, and you'd rather kill small detail than having it come and go as triggered by quantization. It may be that their test was close to the JPEG quality threshold that marks the boundary between "Robidoux is better" and "LanczosSharp is better".

Warning: I wish I had had the time to do sweeping and careful visual comparisons... Everything I write is based as much on how I understand things than empirical evidence. Facts don't lie. Ideas do.

Re: proper scaling of the Jinc filter for EWA use

Posted: 2012-04-20T06:38:31-07:00
by NicolasRobidoux
@Anthony: If you set the -resize default to Mitchell, it would make sense to me that you set the -distort Resize default to Robidoux, UNLESS you want different flavors for the -resize and -distort defaults.

Re: proper scaling of the Jinc filter for EWA use

Posted: 2012-04-20T07:06:30-07:00
by NicolasRobidoux
@Anthony: Note that what henriwho apparently calls JincJinc2/3/4 are the "sharpened for horizontal/vertical preservation" Lanczos2Sharp/LanczosSharp/what should be Lanczos4Sharp using the NEW blur values.

(Totally unrelated: 10 cm of fresh snow in my backyard and it's still snowing hard. Can I move to Brisbane? It's "Spring", here.)

Re: proper scaling of the Jinc filter for EWA use

Posted: 2012-04-20T07:29:48-07:00
by NicolasRobidoux
@Anthony: When I have a minute, I'll custom design a filter specifically so that under EWA no-op be the identity. For things like rotations etc, that don't stretch or shrink things too much in any direction, I hope it's going to be OK.

EWA Triangle and Hermite do have the "no-op is the identity property" but they are not very good enlargement schemes.

I can promise you that it won't be a great all-around scheme. But I'll try to do better than what one gets with EWA Triangle and Hermite. (EWA Triangle is OK when downsampling, but it's dreadful when enlarging a lot. I've not experimented much with EWA Hermite, but I expect it to be worse, all around, than EWA Triangle.)

Re: proper scaling of the Jinc filter for EWA use

Posted: 2012-04-20T13:36:43-07:00
by NicolasRobidoux
henrywho wrote:...but less concern on haloing because I have little experience in detecting it...
Haloing is less of an issue when downsampling.

Question: Have you compared with "tensor" (orthogonal, that is, -resize instead of -distort Resize) filters?

I believe that the best EWA filters are better, when downsampling, than the best tensor filters, but this does not (necessarily) make it true.

Re: proper scaling of the Jinc filter for EWA use

Posted: 2012-04-20T16:37:15-07:00
by NicolasRobidoux
@Anthony: No time to experiment, but I would not be surprised if, for cartoons and good "near to no-op" behavior, some sharpened EWA Jinc Lancos 4-lobe would eventually be found to be a good sharp scheme.

But again, no time to double check this now.

Re: proper scaling of the Jinc filter for EWA use

Posted: 2012-04-21T03:26:39-07:00
by henrywho
NicolasRobidoux wrote:Haloing is less of an issue when downsampling.
Can we have/do we need separate default filters for upsampling and downsampling?

Re: proper scaling of the Jinc filter for EWA use

Posted: 2012-04-21T05:15:12-07:00
by NicolasRobidoux
henrywho wrote:
NicolasRobidoux wrote:Haloing is less of an issue when downsampling.
Can we have/do we need separate default filters for upsampling and downsampling?
Answer 1: In a nutshell, this is what I programmed for the GEGL library. The result of resampling with a scheme acceptable for downsampling (EWA Triangle) is blended with the result of a scheme acceptable for upsampling (the nonlinear LBB-Nohalo method), with the blending dependent on the EWA ellipse: http://git.gnome.org/browse/gegl/tree/g ... r-lohalo.c. This method replaces Lanczos in the bleeding edge goat-invasion branch of GIMP, meaning that if you click on Lanczos resizing, it silently swaps the lohalo method for it. I don't particularly like EWA Triangle, but gegl-sampler-lohalo.c (which I'll most likely rename gegl-sampler-nohalo.co at some point) is a method which is supposed not to add any haloing, ever. LBB-Nohalo is a halo free upsampler (LBB stands for "Locally Bounded Bicubic"; Nohalo is a subdivision method).

Answer 2: The complication is that some transformations both upsample and downsample: shrink in one direction, stretch in another. Actually, warping can go from one extreme to another within one single image, so you want to switch from one resampling scheme to the other smoothly. A complete implementation is expensive: You need to compute (a reasonable approximation of) the EWA ellipse on a pixel-per-pixel basis.

Answer 3: This being said, one could make a quick and dirty automated judgement call as to whether upsampling or downsampling dominates, and select a global default based on that. This should not be too hard to program.

Answer 4: However, what a good pair would be really depends on what you value most: sharpness? lack of jaggies? little moire? lack of haloing artifacts? few false colours?

It doubles the amount of discussion required to pick a default! (Although I agree that if there is a clear winner in one of the directions which does not do so well in the other, the "doubled discussion" could be shorter.)

Re: proper scaling of the Jinc filter for EWA use

Posted: 2012-04-21T05:28:19-07:00
by NicolasRobidoux
henrywho wrote:... Can we have/do we need separate default filters for upsampling and downsampling?
This being said, I generally advocate that you separately choose a downsampler, a "near no-op (rotations, sub-pixel translations, very mild distorsions)" resampler, and an upsampler, that suits your taste. If you have more than one user case for some of these broad categories (png VS heavy JPEG compression, largish images VS small thumbnails, ...), you may actually further refine your "catalog of favorites". ImageMagick's forest of methods to the rescue!

What bites you in each of these three broad situations is quite different.

Rules of thumb: Don't worry about haloing when downsampling. Don't worry about moire when upsampling. An interpolatory scheme when doing near no-op operations is a plus.

My next GEGL programming project probably will use EWA LanczosSharp (or something close) when downsampling or upsampling a lot in at least one direction, and classical tensor Lanczos when close to no-op. Even though EWA LanczosSharp is not particularly sharp, many people like the "look" of it when upsampling: Yes, it's a bit blurry, but it's not offensive in any way. And there is little question that it is a prime quality downsampler. However, it is not interpolatory, which means that resizing to the exact same size changes the image, which is not a good thing. Using tensor (Sinc-windowed Sinc) Lanczos 3 around no-op would seem to be a good match.

Re: proper scaling of the Jinc filter for EWA use

Posted: 2012-04-21T06:28:09-07:00
by NicolasRobidoux
@Anthony: It sounds to me that users like you and users like henrywho (with a quite different user case) would prefer Mitchell to be the EWA default, over Robidoux. I suspect that RobidouxSharp is going to be felt to be overboard for a number of users. Too aliased for a default. I suspect that many people would prefer Robidoux over Mitchell when enlarging a lot, but few people enlarge a lot these days.

Another reason: Although I am not particularly fond of Lanczos2Sharp for upsampling, henrywho, who seems to really know what he's doing, found that Lanczos2Sharp works well for small thumbnails. Now, there are weak theoretical and experimental reasons why Keys splines are good for upsampling (strong reasons with tensor, weaker with EWA: viewtopic.php?f=22&t=19823). Given that Mitchell is "miraculously" close to (the old) Lanczos2Sharp, it looks to me like it's a shoe-in: we get a Keys spline for upsampling, and we get a sharpened Jinc Jinc 2 "clone" for downsampling. Can't argue with that. Esp. since thumbnail production is a major "market" for ImageMagick.

Suggestion: Unless you fall in love with RobidouxSharp, why don't you switch the EWA default back to Mitchell?

Re: proper scaling of the Jinc filter for EWA use

Posted: 2012-04-21T10:54:05-07:00
by NicolasRobidoux
... which gives me an idea: I could find the Keys cubic which is closest in some sense to the (optimally sharpened?) Jinc Lanczos2. 'Likely not be very far from Mitchell.

Manana.