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.
minimize resize halo by luminance-weighted gamma blending
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
minimize resize halo by luminance-weighted gamma blending
Last edited by NicolasRobidoux on 2014-08-12T23:42:34-07:00, edited 1 time in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: halo minimization by luminance-weighted gamma blending
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.
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):

sRGB:

RGB:

LAB:

Blended gamma=2 RGB:

Blended gamma=3 RGB:

Dual Blended gamma=3 RGB:

input (puzzle):

sRGB:

RGB:

LAB:

Blended gamma=2 RGB:

Blended gamma=3 RGB:

Dual Blended gamma=3 RGB:

input (valiant):

sRGB:

RGB:

LAB:

Blended gamma=2 RGB:

Blended gamma=3 RGB:

Dual Blended gamma=3 RGB:

input (chip):

sRGB:

RGB:

LAB:

Blended gamma=2 RGB:

Blended gamma=3 RGB:

Dual Blended gamma=3 RGB:

input (wizzard):

sRGB:

RGB:

LAB:

Blended gamma=2 RGB:

Blended gamma=3 RGB:

Dual Blended gamma=3 RGB:

input (person):

sRGB:

RGB:

LAB:

Blended gamma=2 RGB:

Blended gamma=3 RGB:

Dual Blended gamma=3 RGB:

All the images can be downloaded at http://www.fmwconcepts.com/misc_tests/R ... ests_8.zip
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
All the images can be downloaded at http://www.fmwconcepts.com/misc_tests/R ... ests_8.zip
input (checker):

sRGB:

RGB:

LAB:

Blended gamma=2 RGB:

Blended gamma=3 RGB:

Dual Blended gamma=3 RGB:

input (puzzle):

sRGB:

RGB:

LAB:

Blended gamma=2 RGB:

Blended gamma=3 RGB:

Dual Blended gamma=3 RGB:

input (valiant):

sRGB:

RGB:

LAB:

Blended gamma=2 RGB:

Blended gamma=3 RGB:

Dual Blended gamma=3 RGB:

input (chip):

sRGB:

RGB:

LAB:

Blended gamma=2 RGB:

Blended gamma=3 RGB:

Dual Blended gamma=3 RGB:

input (wizzard):

sRGB:

RGB:

LAB:

Blended gamma=2 RGB:

Blended gamma=3 RGB:

Dual Blended gamma=3 RGB:

input (person):

sRGB:

RGB:

LAB:

Blended gamma=2 RGB:

Blended gamma=3 RGB:

Dual Blended gamma=3 RGB:

All the images can be downloaded at http://www.fmwconcepts.com/misc_tests/R ... ests_8.zip
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: halo minimization by luminance-weighted gamma blending
This viewtopic.php?f=1&t=25945#p113621 and some of the preceding posts in the same thread are relevant to this subject.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: halo minimization by luminance-weighted gamma blending
Some progress has been made, e.g. http://www.luminous-landscape.com/forum ... #msg751649.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: minimize resize halo by luminance-weighted gamma blendin
There is yet another iteration of the script, which has three variants as explained in http://www.luminous-landscape.com/forum ... #msg763245
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: minimize resize halo by luminance-weighted gamma blendin
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".
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".
snibgo's IM pages: im.snibgo.com
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: minimize resize halo by luminance-weighted gamma blendin
Alan:
Suggestion:
For downsampling, tryor 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.
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
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.