View Full Version : Autolevels and full black frames
frubsen
2nd April 2020, 14:55
Hi all,
I'm trying to use autolevels() and I'm running into an issue where it's causing pure black frames that exist in my video to go all funky colored.
(see attachment)
Is there a parameter I'm missing that can act as a threshold so it's doesn't try to do it's magic on pure black frames?
videoh
2nd April 2020, 15:24
Maybe the coring option can be useful here.
StainlessS
2nd April 2020, 17:18
What version AutoLevels ?
frubsen
2nd April 2020, 18:19
using 0.10
frubsen
2nd April 2020, 18:56
ahhh, think i figured it out. I needed to have ConvertToRGB24() before autolevels. That seemed to fix the issue.
edit-hmm but then that seems to cause some issues in other places with blacks getting crushed....weird
I'm using
autolevels(output_low=6, output_high=235)
frubsen
2nd April 2020, 19:18
This is my script
SetMemoryMax(800)
LSMASHVideoSource("X:\Reels_10-18.mov")
converttoyv12()
Crop(146, 2, -146, -2)
removedirtmc(50)
converttorgb24()
autolevels(output_low=6, output_high=235)
converttoyv12()
ColorYUV(autowhite=true)
LanczosResize(662, 480)
Sharpen(0.3)
You can see the difference when I use ConverttoRGB24() and without it in this scene. It's a very underexposed clip to begin with, I just find it odd how changing the colorspace really affects how autolevels works.
StainlessS
2nd April 2020, 23:51
autolevels(output_low=6, output_high=235)
Maybe should be 16 NOT 6. # 16 and 235 are defaults for YUV.
Try this one here:- http://www.mediafire.com/file/8k2vubr57yw1yp3/AutoLevels_25%252626_x86_x64_dll_v0.12Beta3_20190711.zip/file
Maybe use something like this
AL_IGNORE_LO = 1.0/4096
AL_IGNORE_HI = AL_IGNORE_LO
AL_RADIUS = 12
AL_SC2TH = 8
AL_SC2PERC = 100.0/3
AL_MINRNG = 100
SetMemoryMax(800)
LSMASHVideoSource("X:\Reels_10-18.mov")
converttoyv12()
Crop(146, 2, -146, -2)
removedirtmc(50)
AutoLevels(FilterRadius=AL_RADIUS,ignore_low=AL_IGNORE_LO,ignore_high=AL_IGNORE_HI,
\ sc2Th=AL_SC2TH,sc2Perc=AL_SC2PERC,MinRng=AL_MINRNG)
ColorYUV(autowhite=true)
LanczosResize(662, 480)
Sharpen(0.3)
StainlessS
3rd April 2020, 16:27
Now I've seen your frame (well modified frames)
Maybe start with something like this, but I dont really have any idea what you are expecting to get out of it.
Using the previously linked dll
/*
Autolevels(clip c,
int "filterRadius" = 7, [* Original plugin = 5 *]
int "sceneChgThresh" = 20,
string "frameOverrides" = "",
float "gamma" = 1.0, [* Auto if autogamma *]
bool "autogamma" = false,
float "midpoint" = 0.5,
bool "autolevel" = true,
int "input_low" = undefined, [* measured by statistics *]
int "input_high" = undefined, [* measured by statistics *]
int "output_low" = (c.IsYUV)?16 :0, [* 16 for yuv, 0 for rgb *]
int "output_high", = (c.IsYUV)?235:255 [* 235 for yuv, 255 for rgb *]
bool "coring" = false,
float "ignore" = 1.0/256.0,
float "ignore_low" = ignore,
float "ignore_high" = ignore,
int "border" = 0,
int "border_l" = border,
int "border_r" = border,
int "border_t" = border,
int "border_b" = border,
bool "debug" = false
[* Additional to original args *]
int "sc2th" = 12
Float "sc2Perc" = 33.33 [* Where scene change via sceneChgThresh, and % of pixels different by at least sc2th is less than sc2Perc, then Override to NOT scene change *]
Float "GamMax" = 1.5 [* Max limit on Gamma correct *]
Float "GamMin" = 1.0/GamMax [* Min limit on Gamma correct *]
int "minRng" = 100 [* If dynamic range of luma is less than minRng then corrections are reduced *]
)
*/
LoadPlugin(".\ImageSeq.dll")
AUTOGAMMA = True
MIDPOINT = 0.45
IGNORE_LO = 1.0/512
IGNORE_HI = IGNORE_LO
###
SC2TH = 12
SC2PERC = 100.0/3
GAMMAX = 2.0 # Limit gamma correction
GAMMIN = 1.0/GAMMAX # Ditto
MINRNG = 110
Imagesource(".\without rgb24.jpg")
Crop(0,0,Width/4*4,height/4*4) # Mod 4
converttoyv12()
ORG=Last
AutoLevels(autogamma=AUTOGAMMA,MidPoint=MIDPOINT,ignore_low=IGNORE_LO,ignore_high=IGNORE_HI,
\ sc2Th=SC2TH,sc2Perc=SC2PERC,gammax=GAMMAX,gammin=GAMMIN,MinRng=MINRNG)
#ColorYUV(autowhite=true)
Stackhorizontal(ORG,Last)
https://i.postimg.cc/4dcyKnSP/z-00.jpg (https://postimg.cc/bDzpWY8S)
It dont look too good (but you got the source frame, I dont, also v0.10 is I think original AutoLevels just recompiled).
EDIT: Above using just gamma, plenty of both black and white already in your modded frames.
Above image, gamma is almost certainly being limited by GamMax as MidPoint would make way too bright.
frubsen
4th April 2020, 17:41
Thanks StainlessS, ended up using your first script and it worked out pretty well.
StainlessS
4th April 2020, 19:42
Good.
I'm kinda curious, can you post same frame again, before and after.
You can also turn off AUTOGAMMA in 2nd script and also play with other args.
Maybe make IGNORE_LO = 1.0/4096 # 1.0/512
EDIT: You can upload images on PostImage.org without an account, and post links here.
(Use hotlink for forum, or thumbnail for forum.)
scharfis_brain
5th April 2020, 13:03
when converting YUV -> RGB -> YUV don't forget to set the correct matrix:
converttorgb24(matrix="PC.601") Y=0 becomes R=G=B=0
yourfiltershere()
converttoyv12(matrix="PC.601") R=G=B=0 becomes Y=0
converttorgb24(matrix="PC.601") Y=0 becomes R=G=B=0
yourfiltershere()
converttoyv12() R=G=B=0 becomes Y=16
converttorgb24() Y=16 becomes R=G=B=0 (everything below Y=16 and above Y=235 will be clipped!)
yourfiltershere()
converttoyv12() R=G=B=0 becomes Y=16
frubsen
5th April 2020, 18:45
before
https://i.postimg.cc/21s0fjG6/before.png (https://postimg.cc/21s0fjG6)
after
https://i.postimg.cc/Hrc6K8QR/after.png (https://postimg.cc/Hrc6K8QR)
StainlessS
5th April 2020, 18:51
Thanks very much, I'm quite amazed that it does as well as that.
frubsen
5th April 2020, 18:56
Yeah it worked really well, very happy with it, thanks!
StainlessS
5th April 2020, 19:03
Did you try AutoGain ?
EDIT: I meant AutoAdjust.
AutoAdjust is a bit darker.
frubsen
7th April 2020, 14:58
I did not try autoadjust on that clip
I have some new under exposed clips I'm going to play around with soon and will give both a shot.
frubsen
12th April 2020, 19:08
So I'm running into another issue with flickering brightness levels using autolevels 0.12.
Here is the script I'm using
AL_IGNORE_LO = 1/4096
AL_IGNORE_HI = AL_IGNORE_LO
AL_RADIUS = 12
AL_SC2TH = 4
AL_SC2PERC = 100.0/3
AL_MINRNG = 100
SetMemoryMax(800)
ImageSource("Reel_4.720p_%05d.png", start =4,end=3592,fps=18)
audiodub(BlankClip(audio_rate=48000, stereo = true, length = 3589, fps=18))
converttoyv12()
Crop(140, 4, -140, -4)
removedirtmc(40)
AutoLevels(FilterRadius=AL_RADIUS,ignore_low=AL_IGNORE_LO,ignore_high=AL_IGNORE_HI, sc2Th=AL_SC2TH,sc2Perc=AL_SC2PERC,MinRng=AL_MINRNG)
Tweak(sat=1.1)
LanczosResize(676, 480)
sharpen(0.2)
And here the sample of what it's doing
https://www.mediafire.com/file/weku81fueml29lh/flicker.mp4/file
edit: looks like it's the AL_IGNORE_HIGH value which is causing the differing levels...now what to set it to...
StainlessS
12th April 2020, 20:13
Ignore by default in original was 1.0/256.0, I changed to 1.0/512.0,
1.0/4096 was intended specific for your dark clip [I did not want it to ignore too much, 0.0 would have been a good choice too maybe].
I want to get back to this plug, wanna add DC detect clip, where can denoise/blur DC, and stats taken from that instead of source.
Try above two mentioned Ignore settings, see what happens.
frubsen
13th April 2020, 00:14
I ended up just going back to autolevels(output_low=16, output_high=235) and it fixed the issue.
StainlessS
13th April 2020, 11:36
You could try this (req RT_Stats)
https://forum.doom9.org/showthread.php?p=1757661#post1757661
Does a scan of SAMPLES Frames of a clip detecting min and max luma for those samples (default 40 samples),
then stretches luma range using Levels() for entire clip.
There should be no flickering at all, unless already in source clip.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.