Hi,
Trying to get the max RGB levels of a clip.
I have this after splitting the clip into RGB:
Somehow the conditional will not work. What I'm doing wrong?Code:Scriptclip(clip," r = YplaneMax(RE) g = YplaneMax(GR) b = YplaneMax(BL) max = (r >= g && r >= b) ? r : (g >= b) ? g : b) ")
+ Reply to Thread
Results 1 to 8 of 8
-
-
ScriptClip allows calling one function. One function. Your example might work if you declare this whole snippet as a function to call it.
But wait ... what does it do? The function YPlaneMax() returns the maximum of the Y plane. Are the clips RE, GR, and BL calculated before? Is the value in max used in further calculations?Last edited by LigH.de; 6th May 2017 at 13:38.
-
It works if you make the following changes:
Code:clip=clip.ConvertToRGB32 RE=clip.ShowRed ("YV12") GR=clip.ShowGreen("YV12") BL=clip.ShowBlue ("YV12") Scriptclip(clip,""" r = YplaneMax(RE) g = YplaneMax(GR) b = YplaneMax(BL) max = (r >= g && r >= b) ? r : (g >= b) ? g : b #) ## extra closing paren omitted """)
Code:max=Max(r, g, b)
Code:Subtitle("max="+String(max))
Last edited by raffriff42; 6th May 2017 at 21:20.
-
And keep in mind that the scope of the variable max is only within ScriptClip.
-
I use it for sort of autochroma leveling. The clip is splitted in RGB parts first (RE,GR,BL). Then I need to know which of the three has the highest level R, G or B.
After that I use autolevels to adjust all three with a same amount so the relation between R,G and B stays the same but optimized.
Say the clip has a RGB of 220,230,240. After leveling it will be 235,245,255 (I use full range).
So, I need to find which channel (R,G,or B) has the highest value.
Here's the complete script:
Code:LoadPlugin("plugins/Autolevels_06.dll") #clip=Avisource("D:/temp/test.avi") clip=Avisource("F:/Videos/Bronmateriaal/amerika 1983/amerika_origineel.avi") clip=clip.ConvertToRGB24() #source=source.ConverttoYV12() RE = clip.ShowRed().converttoYV24() GR = clip.ShowGreen().converttoYV24() BL = clip.ShowBlue().converttoYV24() Scriptclip(clip," r = YplaneMax(RE) g = YplaneMax(GR) b = YplaneMax(BL) r >= g && r >= b ? max=r : g >= b ? max=g : max=b) # find greatest channel subtitle(string(max),size=48) #test diff = 255 - max RE = RE.Autolevels(coring=true,sceneChgThresh=100,filterRadius=5,output_low=0,output_high=r+diff,ignore_low=0.005,ignore_high=0.0001) GR = GR.Autolevels(coring=true,sceneChgThresh=100,filterRadius=5,output_low=0,output_high=g+diff,ignore_low=0.005,ignore_high=0.0001) BL = BL.Autolevels(coring=true,sceneChgThresh=100,filterRadius=5,output_low=0,output_high=b+diff,ignore_low=0.005,ignore_high=0.0001) MergeRGB(RE,GR,BL) ")
-
-
-
Code:
RE = clip.ShowRed().converttoYV24() GR = clip.ShowGreen().converttoYV24() BL = clip.ShowBlue().converttoYV24() Scriptclip(clip," r = YplaneMax(RE) g = YplaneMax(GR) b = YplaneMax(BL) /* r >= g && r >= b ? max=r : g >= b ? max=g : max=b) # find greatest channel # ^ ^ ^ ^ ## (4 syntax errors) */ ## REWRITTEN max = (r>=g && r>=b) ? r : (g>=b) ? g : b # find greatest channel ## REWRITTEN AGAIN max = Max(r, g, b) # find greatest channel subtitle(string(max),size=48) #test ## ABOVE HAS NO EFFECT (OVERRIDDEN BY MergeRGB BELOW) diff = 255 - max RE = RE.Autolevels(coring=true,sceneChgThresh=100,filterRadius=5,output_low=0,output_high=r+diff,ignore_low=0.005,ignore_high=0.0001) GR = GR.Autolevels(coring=true,sceneChgThresh=100,filterRadius=5,output_low=0,output_high=g+diff,ignore_low=0.005,ignore_high=0.0001) BL = BL.Autolevels(coring=true,sceneChgThresh=100,filterRadius=5,output_low=0,output_high=b+diff,ignore_low=0.005,ignore_high=0.0001) MergeRGB(RE,GR,BL) subtitle(string(max),size=48) #test (MOVED DOWN) ")
It is a per-frame variable, therefore it must be used in a run-time filter like ScriptClip.
EDIT by the way, it sounds like you might want to try ColorYUV(autowhite=true, autogain=true) or, for nicer results, GamMac ["Gamma Machine"].Last edited by raffriff42; 7th May 2017 at 08:39.
Similar Threads
-
Avisynth FFmpegSource2 wrong color space
By Veggav in forum EditingReplies: 3Last Post: 10th Apr 2016, 09:47 -
Avisynth - What's Wrong with this Script. (FPS Convert/Motion Estimation)
By RAB78 in forum Video ConversionReplies: 41Last Post: 25th May 2015, 13:06 -
AVISynth TRIM results in wrong frame number in VirtualDub
By Budman1 in forum Video ConversionReplies: 33Last Post: 15th Jun 2014, 15:24 -
Is this deinterlace avisynth script wrong?
By brassplyer in forum EditingReplies: 4Last Post: 27th Apr 2014, 03:40 -
Why is this Avisynth script giving me wrong ordered fields?
By brassplyer in forum EditingReplies: 7Last Post: 3rd Jul 2013, 09:25