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

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
Post Reply
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

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

Post 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
Last edited by NicolasRobidoux on 2014-07-06T01:13:06-07:00, edited 6 times in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

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

Post 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/.)
Last edited by NicolasRobidoux on 2012-09-06T04:46:52-07:00, edited 3 times in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

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

Post 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.)
Last edited by NicolasRobidoux on 2012-10-07T09:01:02-07:00, edited 2 times in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

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

Post 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.)
Last edited by NicolasRobidoux on 2012-09-06T04:47:41-07:00, edited 1 time in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

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

Post 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.
Last edited by NicolasRobidoux on 2012-09-06T04:37:00-07:00, edited 2 times in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

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

Post 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
Last edited by NicolasRobidoux on 2014-06-29T23:49:15-07:00, edited 9 times in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
Last edited by fmw42 on 2012-09-05T18:14:12-07:00, edited 1 time in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

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

Post by NicolasRobidoux »

@Fred: Thank you for having a look and commenting.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

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

Post by NicolasRobidoux »

@Fred: High contrast diagonals are what LanczosSharp and LanczosRadius3 are for. But this is another topic.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

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

Post 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.)
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

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

Post 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
Last edited by NicolasRobidoux on 2014-06-29T09:28:45-07:00, edited 5 times in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

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

Post 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/.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

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

Post 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.)
Last edited by NicolasRobidoux on 2014-07-04T08:20:26-07:00, edited 15 times in total.
Post Reply