View Single Post
Old 15th August 2013, 21:04   #22  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by MrJ View Post
No I'm not sure. I haven't read the documentation for on SmoothLevels for a long time so anything I did
know about it is half forgotten. I was finding that shooting light subjects like snow with the camera on automatic gave
really underexposed shots. I use virtualdub's levels to get numbers for the first and third settings but can't even
remember what the others do. If I don't know I tend to leave it at default. Were you going to suggest something else?
TV Levels would be more usual ie range 16 -> 235 rather than 0 -> 255
Code:
SmoothLevels(9,1,170,16,235,show=false,Lmode=3)
SmoothAdjust thread here:
http://forum.doom9.org/showthread.php?t=154971

Might also like to try Autogain by same author :
http://forum.doom9.org/showthread.php?t=167573


Or you might like to try this in future (rather than vdub). {requires recent RT_Stats and GScript}:

RoboLevels.avs
Code:
Function RoboLevels(clip c,float "Strength",int "Samples",float "Ignore",Bool "ALQBC",Bool "QBC",Float "QBC_Thresh",int "X",int "Y",int "W",int "H", \
    int "Matrix",bool "PC",bool "DEBUG",bool "Laced", Int "WMod",Int "HMod",bool "Show") {
# Samples a number of frames from source clip and using minimum and maximum luma levels from those samples, auto levels clip.
# Default temporarily auto crop borders and samples the area remaining, or if both ALQBC and QBC == false then samples X,Y,W,H coords instead.
# Can optionally return border cropped clip when QBC==true.
#
# Args:
#  Strength, default 0.95 (0.0 -> 1.0). Auto levelling strength.
#  Samples, default 32. Number of frames sampled from source clip c.
#  Ignore, default 0.2 (0.0 -> 100%). Percentage of dark pixels to ignore when ascertaining YPlaneMin, YPlaneMax (noise).
#  ALQBC, default=true. Use temp auto cropped clip coords for auto levels sampling.
#  QBC, default false. If true then returns border cropped clip else non cropped.
#  QBC_Thresh, default -32.0. Threshold used for border detection. See RT_QueryBorderCrop.
#     NOTE, RT_QueryBorderCrop 'massages' DEFAULT THRESH (exactly -32.0) if low samples count or if short clip. Reason being to avoid
#     overcropping when insufficient data available for reliable cropping. It is considered better to not crop enough or at all, than
#     to overcrop. You can override by simply setting an explicit threshold (+ve) of eg 40.0, or setting a NON-DEFAULT auto thresh (-ve)
#     eg -16.0 or -32.1, where YPlaneMin is established for the sampled frames and then abs(thresh) is added to that value which is
#     then used as an explicit thresh.
#  X,Y,W,H. All default 0, ie full frame. Coords for luma sampling, only used if both ALQBC and QBC are both false.
#  Matrix default= 2(PC601) if clip width<720 else 3(PC709).
#     Conversion matrix for conversion of RGB to YUV-Y Luma.  0=REC601 : 1=REC709 : 2 = PC601 : 3 = PC709:  YUV not used
#     DO NOT USE Matrix of 0 or 1.
#  PC default = false. If YUV and PC == true then auto level PC Levels 0->255 instead of TV levels 16->235. RGB always 0->255
#  Debug default false. If true then send info the DebugView.
#    Recommended, DebugView: http://technet.microsoft.com/en-gb/sysinternals/bb545027
#  Laced, default = true. Alters Interlaced default for HMod, HMod doubled if true.
#  WMod, default = the natural cropping WMod for clip c colorspace (eg 2 for YV12 and YUY2, 1 for RGB).
#  HMod, default = the natural cropping HMod for clip c colorspace (eg 2 for YV12 and 1 for YUY2 and RGB), but doubled if Laced==true.
#    NOTE, WMod, HMod, If overridden must all be multiples of natural cropping WMod and HMod for clip c colorspace.
#    NOTE, VirtualDubMod and some players, may not like any colorspace WMOD less than 4 (Vdub latest, OK).
#    NOTE, If eg VDMod show blank frame, OR eg player halts saying eg "No combination of filters cound be found to render frame"
#    then set WMod to a multiple of 4. We do not do this by default as Current VDub and some player/encoders may work just fine.
#    If you dont care about possibility of losing a couple of pixels then always supply WMod=4 to avoid display problems.
#  Show, default false. If true, shows Levels() used on frame.
#
    myName="RoboLevels: "
    c
    Frames=FrameCount
    Strength=Float(Default(Strength,0.95))
    Samples=(!Defined(Samples)) ? 32 : (Samples > Frames) ? Frames : (Samples < 1) ? 1 : Samples
    Ignore=Float(Default(Ignore,0.2))
    ALQBC=Default(ALQBC,True)
    QBC=Default(QBC,False)
    QBC_Thresh=Float(Default(QBC_Thresh,-32.0))
    Matrix = Default(Matrix,(width <= 720) ? 2 : 3)
    PC=Default(PC,False)
    DEBUG=Default(DEBUG,False)
    SHOW=Default(Show,false)
    QBCropXP = Default(X,0) QBCropYP = Default(Y,0) QBCropWP = Default(W,0) QBCropHP = Default(H,0) # prep
    Assert(Strength>0.0 && Strength <=1.0, myName + "0.0 < Strength <= 1.0")
    GScript("""
        if(ALQBC || QBC) {
            QBCS=RT_QueryBorderCrop(samples=Samples,thresh=QBC_Thresh,debug=DEBUG,ignore=Ignore,matrix=Matrix,laced=laced,wmod=WMod,hmod=HMod)
            Eval(QBCS)
        }
        QLMMS=RT_QueryLumaMinMax(c,samples=Samples,ignore=Ignore,x=QBCropXP,y=QBCropYP,W=QBCropWP,H=QBCropHP,debug=DEBUG,matrix=Matrix)
        Eval(QLMMS)
        if(IsRGB() || PC) {
            CSMin = 0
            CSMax = 255
        } else {
            CSMin = 16
            CSMax = 235
        }
        ALMin = Int(CSMin - ((CSMin - QLMMMin) * Strength) + 0.5)   # Round Up
        ALMax = Int(CSMax - ((CSMax - QLMMMax) * Strength))         # Round down
        if(QBC) {
            CropS="Crop("+String(QBCropXM)+","+String(QBCropYM)+","+String(QBCropWM)+","+String(QBCropHM)+")"
            (DEBUG)?RT_Debug(MyName,CropS,false):NOP
            Crop(QBCropXM,QBCropYM,QBCropWM,QBCropHM)
            (SHOW) ?RT_SubTitle(CropS,y=20):NOP                     # NOTE, After Cropping
        }
        LevelsS="Levels("+String(ALMin)+",1.0,"+String(AlMax)+","+String(CSMin)+","+String(CSMax)+",Coring=False)"
        (DEBUG)? RT_Debug(MyName,LevelsS,false):NOP
        (SHOW) ? RT_Subtitle(LevelsS,y=0):NOP
        Levels(ALMin,1.0,ALMax,CSMin,CSMax,Coring=False) # DO NOT use Coring
    """)
    return Last
}
With client script:
Code:
Import("RoboLevels.avs")
VideoFile = "D:\TESTVOBS\PAL_I_Top_169_P-JurassicPark.d2v"
Mpeg2Source(VideoFile)
##################
WMOD  = RT_Undefined()  # Use script Default
#WMOD = 4               # If player or eg VDubMod gives problem

QBC=false               # Dont border crop
SHOW=True               # Show Levels() used on frame

RoboLevels(qbc=QBC,WMod=WMOD,show=SHOW)
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 15th August 2013 at 21:30.
StainlessS is offline   Reply With Quote