View Single Post
Old 29th September 2019, 15:13   #3  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
OK, here tis, seems working OK, and really quite nippy too.

Code:
Colorbars.Trim(0,-100).ConvertToY8.KillAudio
ORG=Last
H=Height
SeparateRows(H)
KR = Last.BlankClip(Length=1,Color_YUV=$008080)
WR = KR.Invert

LIMITHI = 100.0  # <= is Target (100.0 for test on Colorbars greyscale)
SHOW    = True
DEBUG   = False

CondS="""
        ave=AverageLuma                              # ave of current frame (row)
        ret = (ave<=LIMITHI) ? 1 : 0                 # 0 = Not detect Black(White Row return), 1=Detect Black(Black Row return)
        (DEBUG) ? RT_DebugF("%d] Ave=%f ret=%d",current_frame,ave,ret) : NOP
        return ret
"""

ConditionalSelect(Last,CondS,WR,KR)     # 0=WR : 1=KR
WeaveRows(H)

(SHOW) ? StackHorizontal(ORG,Last) : Last
Return Last


EDIT: You might need use latest test version Avs+, think there were possible problems specifying Color_YUV for Y8.

EDIT: I'm gettin' 22FPS on x86 and 27FPS on x64 Core Duo quad (using single core).

EDIT: Colorbars Greyscale, Ave of upper block is 110.298439, of middle block 74.504684, of bottom block 72.639061.

EDIT: Mod with 2 limits, gonna set black for middle bar

Code:
LIMITLO =  74.0  # >= is Target     # We're gonna Black middle block
LIMITHI =  75.0  # <= is Target     #    Ditto
SHOW    = True
DEBUG   = False
###############
Colorbars.Trim(0,-100).ConvertToY8.KillAudio        # Or your source filter
###############
ORG=Last
H=Height
SeparateRows(H)
KR = Last.BlankClip(Length=1,Color_YUV=$008080)
WR = KR.Invert

CondS="""
        ave=AverageLuma                              # ave of current frame (row)
        ret = (LIMITLO <= ave <= LIMITHI) ? 1 : 0    # 0 = Not detect Black(White Row return), 1=Detect Black(Black Row return)
        (DEBUG) ? RT_DebugF("%d] Ave=%f ret=%d",current_frame,ave,ret) : NOP
        return ret
"""

ConditionalSelect(Last,CondS,WR,KR)     # 0=WR : 1=KR
WeaveRows(H)

(SHOW) ? StackHorizontal(ORG,Last) : Last
Return Last
__________________
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; 5th December 2019 at 20:31.
StainlessS is offline   Reply With Quote