View Single Post
Old 17th July 2013, 14:13   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Below few posts moved from another thread.

Forensic, how bout this as template

Code:
Function RgbAmplifier (clip clip, int "Radius", float "Multiplier") {
    # Radius==1, switches OFF, Radius==2 = Diameter of 3 frames
    Radius=Default(Radius,1)
    Multiplier=Float(Default(Multiplier,2.0))
    Assert(Radius>=1 && Radius <= 99,"RgbAmplifier: Radius range 1->99 ("+String(Radius)+")")
    Assert(Multiplier>0.0 && Multiplier<10.0,"RgbAmplifier: 0.0 < Multiplier < 10.0  ("+String(Multiplier)+")")
    GScript("""
        WW=clip.Width() HH=clip.Height() FC=clip.Framecount()
        clipfinal=0
        for(i=0,FC-1) {
            RT_Debug("Frame="+String(i))
            clip2=clip.trim(i,-1)
            rangemin = Max(i-(Radius-1),0)
            rangemax = Min(i+(Radius-1),FC-1)
            diameter = rangemax - rangemin + 1
            for(y=0,HH-1) {
                for(x=0,WW-1) {
                    red=0       green=0     blue=0
                    redavg=0    greenavg=0  blueavg=0
                    for(j=rangemin,rangemax){
                        col = clip.RT_RGB32AsInt(n=j, x=x, y=y)
                        b=RT_BitAND(col,$FF)    col=RT_BitLSR(col,8)
                        g=RT_BitAND(col,$FF)    col=RT_BitLSR(col,8)
                        r=RT_BitAND(col,$FF)
                        redavg      = redavg    + r
                        greenavg    = greenavg  + g
                        blueavg     = blueavg   + b
                        if(j==i) {
                            red     =   r
                            green   =   g
                            blue    =   b
                        }
                    }
                    redavg = Float(redavg) / diameter
                    newred = Round(red + (Multiplier * ( red - redavg)))
                    newred = Max(Min(newred,255),0)
                    ###
                    greenavg = Float(greenavg) / diameter
                    newgreen = Round(green + (Multiplier * ( green - greenavg)))
                    newgreen = Max(Min(newgreen,255),0)
                    ###
                    blueavg = Float(blueavg) / diameter
                    newblue = Round(blue + (Multiplier * ( blue - blueavg)))
                    newblue = Max(Min(newblue,255),0)
                    ###
                    clip2=clip2.Overlay(clip2.BlankClip(pixel_type="RGB32", color=((newred*256+newgreen)*256)+newblue).crop(0,0,1,1),
						\ x=x, y=y, opacity=1.0)
                }
            }
            clipfinal=(clipfinal.IsClip()) ? clipfinal++clip2 : clip2
        }
        return clipfinal
    """)
}

Avisource("D:\avs\test.avi").ConvertToRGB32()
trim(1000,-200)
crop(32,32,32,32)
RgbAmplifier(2,1.1)
EDIT: Fixed color shifts.
__________________
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; 3rd June 2014 at 16:30.
StainlessS is offline   Reply With Quote