halo minimization by local min/max smooth clamping
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: halo minimization by local min/max smooth clamping
Fred:
Unlike Ligthen/Darken which in and by themselves can be done with greyscale versions of the images (thanks Anthony!), I don't think that clamp-locally can. The problem is similar to what happens with transparency: Suppose that the negative lobes of the resampling filter cause a pixel values to be (0,0,0) (in RGB, say). How do you lighten that? You have no colour information!
So, if you want to use the intensity, you have no choice but to convert to an image format with an "intensity" channel. (And then, live with the side effects, which are mild, basically non-existent if you compute in floating point.)
Unlike Ligthen/Darken which in and by themselves can be done with greyscale versions of the images (thanks Anthony!), I don't think that clamp-locally can. The problem is similar to what happens with transparency: Suppose that the negative lobes of the resampling filter cause a pixel values to be (0,0,0) (in RGB, say). How do you lighten that? You have no colour information!
So, if you want to use the intensity, you have no choice but to convert to an image format with an "intensity" channel. (And then, live with the side effects, which are mild, basically non-existent if you compute in floating point.)
Last edited by NicolasRobidoux on 2011-04-09T07:37:37-07:00, edited 1 time in total.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: halo minimization by local min/max smooth clamping
I have looked some more and I am more opimistic RE: the usefulness of the channel by channel (and the luminance channel) version of clamp-locally.
As it turns out, the flat plateaus created by the clamping are a bit too obvious to my taste.
However, blending with the plain resampled image (by taking the average of the clamped enlargement (say) and the "plain" enlargement) makes these plateaus unobstrusive.
Of course, the clamping effect is lessened, but nonetheles the worst over/undershoots are dampened, and a feeling of slight sharpening is actually created (because, sometimes, the halos/ripples can be perceived as a kind of blur).
Certainly not a "jump in your face effect," at least with the rose test picture, but nonetheless an improvement.
It is just that you need to remember not to drink it straight.
-----
The other good news is that it does not appear that using something more sophisticated than linear to resample the min and max values is needed. LBB is likely to improve matters, but probably in an unnoticeable way. (I am not particularly fond of Hermite...)
As it turns out, the flat plateaus created by the clamping are a bit too obvious to my taste.
However, blending with the plain resampled image (by taking the average of the clamped enlargement (say) and the "plain" enlargement) makes these plateaus unobstrusive.
Of course, the clamping effect is lessened, but nonetheles the worst over/undershoots are dampened, and a feeling of slight sharpening is actually created (because, sometimes, the halos/ripples can be perceived as a kind of blur).
Certainly not a "jump in your face effect," at least with the rose test picture, but nonetheless an improvement.
It is just that you need to remember not to drink it straight.
-----
The other good news is that it does not appear that using something more sophisticated than linear to resample the min and max values is needed. LBB is likely to improve matters, but probably in an unnoticeable way. (I am not particularly fond of Hermite...)
Last edited by NicolasRobidoux on 2011-04-09T07:38:13-07:00, edited 2 times in total.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: halo minimization by local min/max smooth clamping
Fred:
Let's let go of using the intensity and stick to channel by channel.
Would you be able to take the min/max over a 3x3 cross (the center and the closest four pixels, for a total of five pixels) instead of a 3x3 square?
nicolas
Let's let go of using the intensity and stick to channel by channel.
Would you be able to take the min/max over a 3x3 cross (the center and the closest four pixels, for a total of five pixels) instead of a 3x3 square?
nicolas
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: halo minimization by local min/max smooth clamping
Right now, I like this. It is mild, but it takes the "edge" off the haloing.
I think that "pure" clamp-locally may be better if one is using JPEG compression, but this remains to be seen.
I think that "pure" clamp-locally may be better if one is using JPEG compression, but this remains to be seen.
Code: Select all
input="rose:"
filt="triangle"
convert $input \
\( -clone 0 -filter lanczos -resize 1600% \) \
\( -clone 0 -statistic minimum 3x3 -filter $filt -resize 1600% \) \
\( -clone 0 -statistic maximum 3x3 -filter $filt -resize 1600% \) \
\( -clone 1 -clone 2 -compose lighten -composite \
-clone 3 -compose darken -composite \) \
-delete 0-3 pureclamplocal.png
convert $input -filter lanczos -resize 1600% lanczos.png
composite -blend 66.66% lanczos.png pureclamplocal.png clamplocal.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: halo minimization by local min/max smooth clamping
this should do it in one command. check to be sure I don't have the percents reversed (as I sometimes get confused by Anthony's mixing of background/overlay vs dest/source)
see http://www.imagemagick.org/script/compose.php and http://www.imagemagick.org/Usage/compose/#blend
Code: Select all
input="rose:"
filt="triangle"
convert $input \
\( -clone 0 -filter lanczos -resize 1600% \) \
\( -clone 0 -statistic minimum 3x3 -filter $filt -resize 1600% \) \
\( -clone 0 -statistic maximum 3x3 -filter $filt -resize 1600% \) \
\( -clone 1 -clone 2 -compose lighten -composite \
-clone 3 -compose darken -composite \) \
\( -clone 0 -filter lanczos -resize 1600% \) \
-delete 0-3 -compose blend -define compose:args=66.67%,33.33% -composite \
clamplocal.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: halo minimization by local min/max smooth clamping
fmw42 wrote:Processing Luminance in Rec709YCbCr
Triangle/BilinearCode: Select all
infile="rose:" fact=1800 convert $infile -filter lanczos -resize ${fact}% rose_lanczos_${fact}.png
Code: Select all
infile="rose:" filt="triangle" fact=1800 convert $infile -colorspace Rec709YCbCr -separate \ \( -clone 0 -filter lanczos -resize $fact% \) \ \( -clone 0 -statistic minimum 3x3 -filter $filt -resize $fact% \) \ \( -clone 0 -statistic maximum 3x3 -filter $filt -resize $fact% \) \ \( -clone 3 -clone 4 -compose lighten -composite \ -clone 5 -compose darken -composite \) \ \( -clone 1 -filter lanczos -resize $fact% \) \ \( -clone 2 -filter lanczos -resize $fact% \) \ -delete 0-5 -set colorspace Rec709YCbCr -combine \ -colorspace RGB rose_${filt}_${fact}_clamplocal_ycbcr.png compare -metric rmse rose_lanczos_${fact}.png rose_${filt}_${fact}_clamplocal_ycbcr.png null: 150.326 (0.00229383)
Hermite:Code: Select all
infile="rose:" filt="hermite" fact=1800 convert $infile -colorspace Rec709YCbCr -separate \ \( -clone 0 -filter lanczos -resize $fact% \) \ \( -clone 0 -statistic minimum 3x3 -filter $filt -resize $fact% \) \ \( -clone 0 -statistic maximum 3x3 -filter $filt -resize $fact% \) \ \( -clone 3 -clone 4 -compose lighten -composite \ -clone 5 -compose darken -composite \) \ \( -clone 1 -filter lanczos -resize $fact% \) \ \( -clone 2 -filter lanczos -resize $fact% \) \ -delete 0-5 -set colorspace Rec709YCbCr -combine \ -colorspace RGB rose_${filt}_${fact}_clamplocal_ycbcr.png compare -metric rmse rose_lanczos_${fact}.png rose_${filt}_${fact}_clamplocal_ycbcr.png null: 151.032 (0.0023046)
Nicolas, you may want to change the colorspace to Rec601YCbCr and give that a try. See viewtopic.php?f=2&t=18485#p71136
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: halo minimization by local min/max smooth clamping
I think that the above is completely wrong.NicolasRobidoux wrote:Fred:
Unlike Ligthen/Darken which in and by themselves can be done with greyscale versions of the images (thanks Anthony!), I don't think that clamp-locally can. The problem is similar to what happens with transparency: Suppose that the negative lobes of the resampling filter cause a pixel values to be (0,0,0) (in RGB, say). How do you lighten that? You have no colour information!
So, if you want to use the intensity, you have no choice but to convert to an image format with an "intensity" channel. (And then, live with the side effects, which are mild.)
P.S.
Retraction of my retraction:
Actually, I am pretty sure that clamp-locally can't be done using a greyscale version of the image. You must either clamp-locally every single channel (with the possible exception of alpha, although I would not see why), or only clamp-locally the luminance channel (and possibly the alpha channel) of the image converted to a suitable image format (like YCbCr).
The reason is that otherwise you may introduce colour discontinuities. Yuck!
Last edited by NicolasRobidoux on 2011-04-09T07:57:24-07:00, edited 2 times in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: halo minimization by local min/max smooth clamping
Nicolas,
Did you see my code variant for you above at viewtopic.php?f=22&t=18458&start=45#p71128. Just want to be sure you did not skip over that. Hope it helps.
Fred
Did you see my code variant for you above at viewtopic.php?f=22&t=18458&start=45#p71128. Just want to be sure you did not skip over that. Hope it helps.
Fred
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: halo minimization by local min/max smooth clamping
I need to see how this works with line drawings and the like. No time now.