Page 1 of 8

Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal,... gamma?

Posted: 2012-09-05T07:48:31-07:00
by NicolasRobidoux
Following up on viewtopic.php?f=22&t=21415&start=90#p89702, I will show enlargements of sRGB images, straight through sRGB, but also through linear RGB, LAB, LUV, XYZ, and both the "safe" sigmoidal (with contrast = 9.520945) and the less safe, but "tighter" one (with contrast = 11.6933).
In all cases, I'll use the Ginseng filter (tensor Jinc-windowed Sinc 3-lobe) viewtopic.php?f=1&t=21703, for no other reason that it is my favorite interpolatory scheme. Results with plain Lanczos (tensor Sinc-windowed Sinc 3-lobe) are usually very similar.
Everything done with a bleeding edge IM7 compiled in HDRI mode.
First, a tiny 8x8 image of two 4x4 black squares laid diagonally on a white background: Image. Below, I show the results of enlarging it 32x.
Nearest neighbour enlargement, for reference (note that which colourspace is used does not matter with nearest neighbour):
Image
All the other enlargements are done with tensor Jinc-windowed Sinc 3-lobe (a.k.a. Ginseng):
Straight sRGB:
Image
Linear RGB:
Image
LAB:
Image
LUV:
Image
XYZ:
Image
"Safer" sigmoidal:
Image
"Less safe" sigmoidal:
Image

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-05T10:31:14-07:00
by NicolasRobidoux
Now, a light (but not white) on dark (but not black) antialiased jigsaw piece image: Image. Below, I show the results of enlarging it 10x.
Nearest neighbour:
Image
Straight sRGB:
Image
Linear RGB:
Image
LAB:
Image
LUV:
Image
XYZ:
Image
"Safer" sigmoidal:
Image
"Less safe" sigmoidal:
Image
P.S. Sigmoidization is motivated by a desire to minimize over- and undershoots without adding blur or jaggies. This test image has a global min of 75 and global max of 227.
First, let's rank the above methods in increasing other of global max:
"unsafe" sigmoidal (12 overshoot) = "safe" sigmoidal (12), XYZ (16) = RGB (16), sRGB (25), LAB (27) = LUV (27).
Now, let's rank them in decreasing order of global min:
"unsafe" sigmoidal (17 undershoot), "safe" sigmoidal (18), LAB (19) = LUV (19), sRGB (22), XYZ (75) = RGB (75).
Given that all the enlargements were produced with the exact same resampling filter (tensor Jinc-windowed Sinc 3-lobe) except, of course, the first one, done with nearest neighbour, I find it pretty convincing that sigmoidization is doing what it's supposed to do.
(This test image is a cropped and modified version of the jigsaw_tmpl test image from http://www.imagemagick.org/Usage/images/.)

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-05T16:03:03-07:00
by NicolasRobidoux
Not sure this is the best small test image, but it's done:
A close up of push pins (thumb tacks), mechanical watch parts, a small screw, and a sieve used to make single cups of loose tea: Image. Below, I show the results of enlarging it 10x.
Nearest neighbour:
Image
Straight sRGB:
Image
Linear RGB:
Image
LAB:
Image
LUV:
Image
XYZ:
Image
"Safer" sigmoidal:
Image
"Less safe" sigmoidal:
Image
(This test image is a crop of an 8-bit version of the curios test image from http://www.imagemagick.org/download/ima ... x840images. Photo credit: Jean-Francois Avon.)

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-05T17:06:43-07:00
by NicolasRobidoux
A close up of of a sign on a beach hut in England: Image. Below, I show the results of enlarging it 7x. This is a better test image than the previous one: If you flicker between the various results, the differences are really clear.
Nearest neighbour:
Image
Straight sRGB:
Image
Linear RGB:
Image
LAB:
Image
LUV:
Image
XYZ:
Image
"Safer" sigmoidal:
Image
"Less safe" sigmoidal:
Image
(This test image is a crop of an 8-bit version of the cabins test image from http://www.imagemagick.org/download/ima ... x840images. Photo credit: Anthony Barnett.)

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-05T17:55:21-07:00
by NicolasRobidoux
With images that are mostly mid-tones without sharp features, it's quite hard to see the difference, hence the choice of test images.

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-05T18:06:18-07:00
by NicolasRobidoux
A close up of The Wizard: Image. Below, I show the results of enlarging it 8x.
Nearest neighbour:
Image
Straight sRGB:
Image
Linear RGB:
Image
LAB:
Image
LUV:
Image
XYZ:
Image
"Safer" sigmoidal:
Image
"Less safe" sigmoidal:
Image
P.S. This is cheating, because I am using EWA Lanczos instead of (tensor) Ginseng, but here is the result going of through a synthetic "gamma 4 colorspace" (see the "chip" post below):
Image

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-05T18:07:49-07:00
by fmw42
For me the RGB and XYZ seem better due to the smoothness of the diagonal in the N character on the sign image.

But for the wizard, sigmoidal is the best, then the group of( sRGB, LAB, LUV ) which are better than ( RGB, XYZ ).

P.S. This topic is a very good set of test -- very informative -- by comparing all the different colorspaces.

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-05T18:13:31-07:00
by NicolasRobidoux
@Fred: Thank you for having a look and commenting.

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-05T18:17:07-07:00
by fmw42
You welcome. On the checkerboard, I agree that the sigmoidal seems best. Same for the puzzle.

It seems that very high contrast diagonals are hard. Strange that RGB and XYZ do better there, but everywhere else the sigmoidal appears to win, even the diagonals in the wizards hat, but I guess they are not that high contrast.

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-05T18:25:47-07:00
by NicolasRobidoux
@Fred: High contrast diagonals are what LanczosSharp and LanczosRadius3 are for. But this is another topic.

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-05T18:33:43-07:00
by fmw42
NicolasRobidoux wrote:@Fred: High contrast diagonals are what LanczosSharp and LanczosRadius3 are for. But this is another topic.
OK. Thanks for the clarification. Under the current conditions, then sigmoidal wins.

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-06T04:05:33-07:00
by NicolasRobidoux
@Fred: I was a bit terse: Generally, EWA methods deal more elegantly with sharp diagonal features than tensor methods. But there is a price to pay: The best EWA methods are not interpolatory. (This being said: Neither is Mitchell-Netravali, the default IM filter for -resize enlargement.) This does not mean that some of them are not as perceptually sharp (actually, sharpness could be estimated with the frequency response): LanczosRadius3 is pretty much as sharp as regular tensor Lanczos. But EWA methods (and the default mitchell -resize filter) change images under "no-op".

Tensor "Ginseng" (which is almost the same as tensor Lanczos) is interpolatory. So, this thread is about comparing interpolatory methods that differ only in what type of pixel values---as defined by a colourspace---are used to do the weighted averaging. (Sigmoidization implicitly defines a colourspace transformation. The others---sRGB, RGB, LAB...---are standard colourspaces.)

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-06T06:03:41-07:00
by NicolasRobidoux
A close up of yours truly: Image taken at a New Year celebration, hence the "party" light. Below, I show the results of enlarging it 8x.
Nearest neighbour:
Image
Straight sRGB:
Image
Linear RGB:
Image
LAB:
Image
LUV:
Image
XYZ:
Image
"Safer" sigmoidal:
Image
"Less safe" sigmoidal:
Image
Most obvious differences are near the collar and the white and pupil of the eye which is to your right.
P.S. Another cheat: Result of EWA LanczosSharpest 4 through the "gamma 4 colorspace":
Image
IM 7 (HDRI mode) command

Code: Select all

magick input_small.png -set colorspace sRGB -colorspace RGB -gamma 4 -filter Lanczos -define filter:lobes=4 -define filter:blur=0.88451002338585141 -distort Resize 800% -gamma .25 -colorspace sRGB ewalanczossharpest4.gamma4.png

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-06T06:06:15-07:00
by NicolasRobidoux
If you want to download the images directly from the source, they are here in folders inside http://web.cs.laurentian.ca/nrobidoux/misc/sigmoidal/.

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-06T06:31:29-07:00
by NicolasRobidoux
A crop of the chip: Image. Below, I show the results of enlarging it 8x.
Nearest neighbour:
Image
Straight sRGB:
Image
Linear RGB:
Image
LAB:
Image
LUV:
Image
XYZ:
Image
"Safer" sigmoidal:
Image
"Less safe" sigmoidal:
Image
The uncropped test image was taken from http://www.wisdom.weizmann.ac.il/~visio ... ageSR.html.
If you flicker, you'll see small differences all over the place.
P.S. This is an example in which LAB gives a noticeably different result than sRGB.
P.S. Here is an example of what happens if you go through a rather extreme "gamma space", namely gamma=64, with the following command (as discussed in viewtopic.php?f=1&t=25736&p=112685#p112673):

Code: Select all

magick input_small.png -set colorspace sRGB -colorspace RGB -gamma 64 -define filter:filter=sinc -define filter:window=jinc -define filter:lobes=3 -resize 800% -gamma .015625 -colorspace sRGB ginseng.gamma64.png
Image
Despite having chosen "gamma 64 color space" rather randomly, I must say that I'm impressed. This being said, such heavy handed color space manipulation has to wreak havoc on some types of images. Don't try this at home!
WARNING I would not be surprised if you need an HDRI (floating point, not 8 or 16 bit) version of ImageMagick to perform such extreme gamma manipulation without artefacts being introduced by rounding error. I've not checked. (I almost always use HDRI.)