Page 1 of 1

Downsampling through XYZ better than through linear RGB?

Posted: 2014-06-03T06:07:51-07:00
by NicolasRobidoux
Anthony, many places, has stated that one good thing about resampling through Lab is that it has a luma/luminance channel. This, actually, makes a lot of sense.

Now, it is fairly well established that downsampling (reducing the pixel size of an image, that is, "shrinking it" as in producing thumbnails) should be done through linear light. For sRGB images, the obvious candidate is linear RGB.

However, XYZ is a linear light space with a good luminance channel (Y). This suggests that

Code: Select all

convert (input image) -colorspace XYZ (resize command) -colorspace sRGB (output image)
may give better results than similar commands that use -colorspace RGB instead of -colorspace XYZ.

Has anyone compared?

Re: Downsampling through XYZ better than through linear RGB?

Posted: 2014-06-04T20:01:15-07:00
by anthony
My findings is that linear light scaling while mathematically more sound does not seem to generate better images.
But that was probably more due to extremes as was discussed in the resize in other colorspace examples.

Now I agree that seperating color from brightness would be a good idea as it would prevent color skew when resizing,
I am not certain on how much better using XYZ colorspace would be.

XYZ is a international colorspace designed to actually measure and identify exact colors regardless of the source. Yes it is linear, but I don't believe it actually seperates color channels from lumance. More like a 'RGB' colorspace. with more range to cover all prosible human visible colors (and then some).

But then I am a programmer, not a photographer. I don't really have a great critical eye for determining just how good a photo is. I acknowlege that fact. My monitor is also a typical computer monitor (Work provided Dell monitor that came with the computer). In fact the monitor has a completely different gamma value at the top of the screen to that at the bottom, which can make it even harder to judge what is a good or bad result!

So I would suggest... Try it. IM is a great tool to just try things.

Bring up a array of test images vs downsampling methods, and see how each 'thumbnail' looks for each downsampling method and image type (landscapes, sea scapes, cartoon, animations, graphs and line drawings, dithered images, etc etc etc)
That last is what generally makes 'linear light' transformations appear most logical, even though it does not seem to work as well for high contrast images.

Who know what method will throw up a exceptional result for the various image types. Such a chart would likely make a great resource in and of itself!

Re: Downsampling through XYZ better than through linear RGB?

Posted: 2014-06-04T20:36:00-07:00
by snibgo
I have documented some experiments at http://im.snibgo.com/graygam.htm

My general conclusion is that, for my photographic work, resizing up or down in sRGB or RGB is neither better nor worse. Unsharpening is better done in Lab than either sRGB or RGB. Blurring is better done in sRGB or RGB rather than Lab.

My experiments are not scientific, and I wouldn't prescribe my results as general rules.

(EDIT: I should also qualify this by saying I was using Q16 integer, not HDRI.)

Re: Downsampling through XYZ better than through linear RGB?

Posted: 2014-06-05T12:02:09-07:00
by NicolasRobidoux
I just remembered that because linear light spaces are, at least in principle, mapped to one another through an affine transformation, provided there is no clamping or other nonlinearity in the intermediate steps it should make no difference which one is used when using linear resampling. (Note that this basically requires HDRI mode.)
In other words, if the results obtained through XYZ are significantly different from those obtained through linear RGB, something worth investigating is happening, because generally they should not (unless does different things to different channels, of course).
-----
In summary:
The answer to my own question should be "Neither better nor worse".
-----
P.S. I did a quick check, and indeed the difference can be attributed to insignificant approximation errors (LUTs etc).

Re: Downsampling through XYZ better than through linear RGB?

Posted: 2014-06-05T12:08:48-07:00
by NicolasRobidoux
Thank you for your answers Anthony and Alan.

Note: All the evidence I've seen points to downsampling through linear light being generally better when using a linear resampling method (like most of IM's are).

I have not tested this enough to be 100% sure, but close. (Unfortunately, I have little time for testing these days.)

If you downsample enough (reduce by much more than a factor of 2) and use a sharpening filter (like orthogonal or EWA Lanczos) the differences are often noticeable.

Upsampling with a sharpening or resampling with a nonlinear filter is another story.