Log in

View Full Version : Limiting autogain contrast


LigH
1st August 2024, 18:54
Sometimes I use ColorYUV to automatically "fix and enhance" some amateur videos in a dumb but convenient no-brainer solution:
#half power
Merge(ColorYUV(autogain=true), ColorYUV(autowhite=true))

#quarter power
Merge(Merge(ColorYUV(autogain=true), ColorYUV(autowhite=true)))

There is just one exception when it fails: when the material has a fade to black, the contrast is enhanced to the whole target brightness range which makes block artifacts and noise pop out.

I wish there was a way to limit the contrast factor of the autogain to a maximum value so that no-contrast scenes keep a still narrow range of brightness. Or there may be another, smarter filter.

DTL
5th August 2024, 13:32
Some ways with current AVS scripting may be like calculate difference of input and processed frame (Subtract()) and create mask using limiting functions (starting from simple ColorYUV or other Levels() or Expr()). In the way that low difference creates 'pass' mask and after some changes - mask reach 'no pass' level and set output mixer (Overlay or Layer filters) with this mask.

The mask of single polarity need to use 'absolute difference' so may be Expr() can be used. Single Subtract() creates 1/2 full scale zero level so to get all black mask - the 1/2 full-scale subtract required (using same Expr() or Levels and other levels shift).

For single polarity absolute difference from black to white you can test
Expr(c1, c2, "x y - abs")
where c1 is input clip and c2 - auto-corrected. And play with gain of the resulted mask to control limiting of changes. To make it less area-dependand the large radius blur is required or simple downsize and upsize (may be faster in comparizon with large radius blurs).

While there is no good methods of detecting real scene changes over fades in/out it is simple intra-frame solution. Even mvtools without 'lighting' estimation and compensation can not detect scene change over simple fades correctly because it causes progressive SAD increasing and finally triggers thSCD1 threshold. Only new versions without constant level calculation in dissimilarity metric may be tested (like Structure only from full SSIM calculation) but not yet tested as scene change detector over fades in/out.

LigH
5th August 2024, 14:22
:thanks:

Nice ideas to think about and tinker...

dracore
6th August 2024, 22:23
Sometimes I use ColorYUV to automatically "fix and enhance" some amateur videos in a dumb but convenient no-brainer solution:
#half power
Merge(ColorYUV(autogain=true), ColorYUV(autowhite=true))

#quarter power
Merge(Merge(ColorYUV(autogain=true), ColorYUV(autowhite=true)))

There is just one exception when it fails: when the material has a fade to black, the contrast is enhanced to the whole target brightness range which makes block artifacts and noise pop out.

I wish there was a way to limit the contrast factor of the autogain to a maximum value so that no-contrast scenes keep a still narrow range of brightness. Or there may be another, smarter filter.

Yeah, ColorYUV's autogain can be handy, but it's not perfect. That fade-to-black issue is a bummer.

You might want to try Curve() or Histogram() to get more control over the brightness and contrast. Or, use MaskedMerge() to detect those fade-to-black scenes and apply a different set of adjustments.

If you're feeling adventurous, you could even explore DaVinci Resolve or Premiere Pro's Lumetri Color Panel for more advanced color grading tools.