Page 1 of 1

minimize resize halo by luminance-weighted gamma blending

Posted: 2014-07-18T01:29:02-07:00
by NicolasRobidoux
As discussed initially in
viewtopic.php?f=1&t=25736 and
viewtopic.php?f=22&t=21804#p89728
and further developed in
http://www.luminous-landscape.com/forum ... #msg745796 and
http://www.luminous-landscape.com/forum ... #msg746273,
I have proposed a new approach to the minimization of haloing when using resampling filters that introduce it (filters "with negative lobes").
I suggest that, within the ImageMagick forums, we centralize the discussion here.
Thanks to Bart van der Wolf and Fred Weinhaus who have been really helpful.

Re: halo minimization by luminance-weighted gamma blending

Posted: 2014-07-19T16:05:06-07:00
by fmw42
Nicolas came up with a new method of blending gamma adjusted linear RGB magnification with the negated same so as to reduce both bright and dark halos.

see http://www.luminous-landscape.com/forum ... #msg746689

Here is the (unix syntax) command lines that I used for testing (in IM 6.8.9.5 Q16 Mac OSX). All tests were 800% magnification, except for the first example with the checker pattern, which is 3200% magnification.

Code: Select all

sRGB:
convert input_small.png -set colorspace sRGB \
-filter LanczosRadius -distort Resize 800% \
-depth 8 input_small_LanczosRadius_s800_sRGB.png

RGB:
convert input_small.png -depth 16 -set colorspace sRGB -colorspace RGB \
-filter LanczosRadius -distort Resize 800% \
-set colorspace RGB -colorspace sRGB \
-depth 8 input_small_LanczosRadius_s800_RGB.png

LAB:
convert input_small.png -depth 16 -set colorspace sRGB -colorspace LAB \
-filter LanczosRadius -distort Resize 800% \
-set colorspace LAB -colorspace sRGB \
-depth 8 input_small_LanczosRadius_s800_LAB.png

Blended (gamma 2 adjusted with no gamma) RGB:
convert \( input_small.png -depth 16 -set colorspace sRGB -colorspace RGB \) \
\( -clone 0 -gamma 2 -filter LanczosRadius -distort Resize 800% -gamma 0.5 \) \
\( -clone 0 -filter LanczosRadius -distort Resize 800% \) \
\( -clone 2 -colorspace gray -auto-level \) \
-delete 0 -compose over -composite \
-set colorspace RGB -colorspace sRGB \
-depth 8 input_small_LanczosRadius_blended_s800_g2_RGB.png

Blended (gamma 3 adjusted with no gamma) RGB:
convert \( input_small.png -depth 16 -set colorspace sRGB -colorspace RGB \) \
\( -clone 0 -gamma 3 -filter LanczosRadius -distort Resize 800% -gamma 0.333333333333333 \) \
\( -clone 0 -filter LanczosRadius -distort Resize 800% \) \
\( -clone 2 -colorspace gray -auto-level \) \
-delete 0 -compose over -composite \
-set colorspace RGB -colorspace sRGB \
-depth 8 input_small_LanczosRadius_blended_s800_g3_RGB.png

Dual Blending (gamma 3 and negated image with gamma 3), RGB:
convert \( input_small.png -depth 16 -set colorspace sRGB -colorspace RGB \) \
\( -clone 0 -gamma 3 -filter LanczosRadius -distort Resize 800% -gamma 0.333333333333333 \) \
\( -clone 0 -negate -gamma 3 -filter LanczosRadius -distort Resize 800% -gamma 0.333333333333333 -negate \) \
\( -clone 1 -clone 2 -evaluate-sequence mean -colorspace gray -auto-level \) \
-delete 0 -compose over -composite \
-set colorspace RGB -colorspace sRGB \
-depth 8 input_small_LanczosRadius_dualblended_s800_g3_RGB.png
Here are results for various images. The mitigation of haloing is most evident on the puzzle and valiant images.

All the images can be downloaded at http://www.fmwconcepts.com/misc_tests/R ... ests_8.zip

input (checker):
Image

sRGB:
Image

RGB:
Image

LAB:
Image

Blended gamma=2 RGB:
Image

Blended gamma=3 RGB:
Image

Dual Blended gamma=3 RGB:
Image



input (puzzle):
Image

sRGB:
Image

RGB:
Image

LAB:
Image

Blended gamma=2 RGB:
Image

Blended gamma=3 RGB:
Image

Dual Blended gamma=3 RGB:
Image



input (valiant):
Image

sRGB:
Image

RGB:
Image

LAB:
Image

Blended gamma=2 RGB:
Image

Blended gamma=3 RGB:
Image

Dual Blended gamma=3 RGB:
Image



input (chip):
Image

sRGB:
Image

RGB:
Image

LAB:
Image

Blended gamma=2 RGB:
Image

Blended gamma=3 RGB:
Image

Dual Blended gamma=3 RGB:
Image



input (wizzard):
Image

sRGB:
Image

RGB:
Image

LAB:
Image

Blended gamma=2 RGB:
Image

Blended gamma=3 RGB:
Image

Dual Blended gamma=3 RGB:
Image



input (person):
Image

sRGB:
Image

RGB:
Image

LAB:
Image

Blended gamma=2 RGB:
Image

Blended gamma=3 RGB:
Image

Dual Blended gamma=3 RGB:
Image


All the images can be downloaded at http://www.fmwconcepts.com/misc_tests/R ... ests_8.zip

Re: halo minimization by luminance-weighted gamma blending

Posted: 2014-07-23T02:43:53-07:00
by NicolasRobidoux
This viewtopic.php?f=1&t=25945#p113621 and some of the preceding posts in the same thread are relevant to this subject.

Re: halo minimization by luminance-weighted gamma blending

Posted: 2014-08-10T01:29:35-07:00
by NicolasRobidoux

Re: minimize resize halo by luminance-weighted gamma blendin

Posted: 2014-09-20T09:26:25-07:00
by NicolasRobidoux
There is yet another iteration of the script, which has three variants as explained in http://www.luminous-landscape.com/forum ... #msg763245

Re: minimize resize halo by luminance-weighted gamma blendin

Posted: 2014-09-25T07:31:59-07:00
by snibgo
I'll mention here that I've written my own version of the script, and done some trials with it: http://im.snibgo.com/resamphm.htm

I shouldn't judge the results from a single image, but I gotta say: I love the downsampling with sharpen. It's much better than I get with "-resize -unsharp".

Re: minimize resize halo by luminance-weighted gamma blendin

Posted: 2014-10-05T01:34:24-07:00
by NicolasRobidoux
Alan:
Suggestion:
For downsampling, try

Code: Select all

convert input.jpg -set colorspace sRGB -colorspace RGB -define filter:c=SHARPENINGAMOUNT -filter cubic -distort Resize SIZESPECIFICATION -set colorspace RGB -colorspace sRGB output.png
or something like that, where SHARPENINGAMOUNT is between 0 and .6666666666666, with the C values between the Robidoux and Catmull-Rom being most interesting. (Unless your image is really blurry or you like out of this world sharpness, I'd stick to value strictly less than C=.5, and I would not go below the RobidouxSoft value, value used by Bart's script, unless blur is what you consider the least offensive artifact.)
I am not sure that Bart's script's complications are responsible for what you like in the downsampling results. EWA with a Keys cubic through linear light may give something you like just as much.
It just may. And if so, I'd love to know.