Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 22nd October 2018, 11:43   #1  |  Link
color
Registered User
 
color's Avatar
 
Join Date: May 2016
Posts: 235
Film Tint - help

I have tried the Tint plugin, but I want it to be a little bit easier and modified for my needs. So I would be happy If someone could write a new plugin or help me modify it. I have scanned frames from old movies and tried to get the perfect tint color to make it realistic.

I want to be able to do different colors on different parts of the movie on what frame, like
Quote:
KinoTint(color=lemon_yellow, 113, 454).KinoTint(color=fire_red, 455, 887)
so its lemon_yellow on frame 113 to 454 and fire_red on frame 455 to 887.

What I mean with "darker" belos is that I want two colors in the "gradient", When trying out the palett, the darker parts are more lighter and does not look like the original frames, so it needs to be a bit more darker.

light_amber: $FFD700
lemon_yellow: $dacca5
Canary_Yellow: $ffde00
light_orange: $f9f0af
pink: $79122c - darker $732928
purple: $d229fe - darker $3c303c
violet: $8437ff - darker $51135e
dark_Orange: $ffa027
orange_red: $cf7f7e
fire_red: $ff6240 - darker $a73f3e
blue: $28dcfd
marine_blue: $02feff
blue_green: $53ffff - darker $7de3b1
crimson: $fe0000
carmine: $ff4eae
magenta: $f468ef
emerald: $e0f6c1
grass_green: $7de3b1 - darker $195d20
sap_green: $7ddd8a
rose: $f08188
copper: $b69574
inferno: $f5a120 - darker $fe0000




Blue_Green: $53ffff - darker $7de3b1
I did try this one with green as chroma and used the darker color as "light color" or "soft color" in a photo editing program. Is it possible to do the same in avisynth?
__________________
Automatic Colorization

Last edited by color; 22nd October 2018 at 15:19. Reason: fixed some spellings
color is offline   Reply With Quote
Old 22nd October 2018, 16:35   #2  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
Perhaps Colormill (a VD plugin).
johnmeyer is offline   Reply With Quote
Old 22nd October 2018, 16:44   #3  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
Quote:
Originally Posted by color View Post
I did try this one with green as chroma and used the darker color as "light color" or "soft color" in a photo editing program. Is it possible to do the same in avisynth?
Are you asking about blend modes, similar to photoshop ?

Overlay has a few and rr42 has a uu_mt_blend
http://forum.doom9.org/showthread.php?t=170490

Alternatively, you can use the overlay mask itself , as a luma mask, to affect brighter and darker areas differently, using the greyscale image itself as the mask
poisondeathray is offline   Reply With Quote
Old 22nd October 2018, 16:47   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
I think that MSU did a VDub Plugin for the sepia colorizing type stuff, also did something (might be the same plug) called 'MSU Old Cinema',
which added snap crackle and pop (crud) to the video, to simulate aged film.

EDIT: Be warned, MSU has a nasty habit of not saving all settings to a settings file, which results in some settings
being impossible to set in Avisynth (only set when entering the VDub plug config dialog box).
https://forum.doom9.org/showthread.php?p=1371376

EDIT: Incidentally and JFYI, the word 'set' is supposed to have the most different meanings of all words in the English language.
(somewhere around 50).
__________________
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; 22nd October 2018 at 18:04.
StainlessS is offline   Reply With Quote
Old 22nd October 2018, 18:20   #5  |  Link
color
Registered User
 
color's Avatar
 
Join Date: May 2016
Posts: 235
johnmeyer, I don't think it does a great job, it does not have so I can get exactly the color I want.

poisondeathray, yes, blend mode is what I ment. I did search but never found out so I called it gradient. I will check out the link.

StainlessS, I did try MSU Old Cinema, but it does have sepia, and possible to change to some colors. But I don't like the result. The Tint-plugin for avisynth is great, but I want the features like just writing the name on the color I want and on what frames like yellow on frame 100-300 and be able to change color on the other scenes. I don't know how to add this/modify the tint-plugin. Also how to add feature with the once needed for Overlay with two colors, one on the darker and another on the lighter.

EDIT: I do understand I need to add "Trim()" somwhere in the tint-script, but where and how so I only need to put the frames I need when using "Tint(frame=200, endframe=300)" or something. Also, I don't understand how to add so I can use the name light_amber and similar and get the tint color I want.
__________________
Automatic Colorization

Last edited by color; 22nd October 2018 at 18:36.
color is offline   Reply With Quote
Old 22nd October 2018, 19:03   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Are the colors from post #1 from Colors_RGB.avsi (or whatever its called) ?

EDIT: Forget it, the are not from that file.
__________________
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; 22nd October 2018 at 19:25.
StainlessS is offline   Reply With Quote
Old 22nd October 2018, 20:31   #7  |  Link
color
Registered User
 
color's Avatar
 
Join Date: May 2016
Posts: 235
StainlessS, they are accoully from some scanned tinted frames that I have looked up the color. ��
Is it possible to edit the tint? I have a few movies, and right now I have done one with changing the color manually and export scene by scene and it's so hard and take a lot of time. So I want to do complete script that is just to export the full movie. I have tried to figure out how to add the features but I can not manage to get it to work. I thought I understand first how the script worked so I can addm but I need help.

Edit: or is it applyrange() and not trim()?
__________________
Automatic Colorization

Last edited by color; 22nd October 2018 at 20:35.
color is offline   Reply With Quote
Old 22nd October 2018, 22:21   #8  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Am In Process of writing script using ClipClop, which I hope will suffice for what you want.
Look up ClipClop, I shall be using NickNames which allow for showing color names (NickNames) when SHOW=True.
(or Could superimpose names on clips).

What do you want for Strength, fixed, or variable (a separate clip will be necessary for each).
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 22nd October 2018, 22:49   #9  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
You can also use Photoshop or any other photo editor. Save the video as a series of images. Import one image into Photoshop and tint it the way you want. Use the Batch Process feature to apply that tint to all the other images. Then, reassemble as a video.

Sounds complicated, but it is actually really easy to do.

This approach gives you the ultimate flexibility to get the tint you want.
johnmeyer is offline   Reply With Quote
Old 23rd October 2018, 00:20   #10  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Something to play with,
Ive made two sets of lists, with fixed Strength, and SCmd string
and with variable Strength, embedded in color names and SCmd String.
STRENGTH selects which set to use in this demo, when you decide which you want, edit out the other set..

Code:
# Req Avs+, RT_Stats

# Set STRENGTH to eg 128 for fixed strength, or -1 with strength embedded at end of NickNames

#Avisource("D:\PN.avi")
ColorBars(Pixel_type="YV12").Killaudio
ORG=Last
myName="ColorScript: "
SHOW=True               # ClipClop SHOW arg
STRENGTH = -1           # -1 = Appended as Dec digits to ColorNames, else fixed strength (should NOT be appended to name).
                        # Set eg STRENGTH=128 for fixed Strength
DB="D:\MyDBase.DB"
###############################
# Fixed Strength Names (STRENGTH>=0)
if(STRENGTH>=0) {
    NamesList="""
        # Names with appended Hex code (without dollar), If STRENGTH==-1 then also append Strength to ColorName
        light_amber_FFD700
        lemon_yellow_dacca5
        Canary_Yellow_ffde00
        light_orange_f9f0af
        pink_79122c
        pink_darker_732928
        purple_d229fe
        purple_darker_3c303c
        violet_8437ff
        violet_darker_51135e
        dark_Orange_ffa027
        orange_red_cf7f7e
        fire_red_ff6240
        fire_red_darker_a73f3e
        blue_28dcfd
        marine_blue_02feff
        blue_green_53ffff
        blue_green_darker_7de3b1
        crimson_fe0000
        carmine_ff4eae
        magenta_f468ef
        emerald_e0f6c1
        grass_green_7de3b1
        grass_green_darker_195d20
        sap_green_7ddd8a
        rose_f08188
        copper_b69574
        inferno_f5a120
        inferno_darker_fe0000
    """
    # Set Either CMD or SCmd with clip nickname and range
    Cmd=""
    sCmd="""
        light_amber_FFD700    100,199
        lemon_yellow_dacca5   300,399
        Canary_Yellow_ffde00  500,599
    """
} Else {
    # Variable Strength Names (STRENGTH==-1)
    NamesList="""
        # Names with appended Hex code (without dollar), If STRENGTH==-1 then also append Strength to ColorName
        light_amber_FFD700_128
        lemon_yellow_dacca5_100
        Canary_Yellow_ffde00_150
        light_orange_f9f0af_96
        pink_79122c_100
        pink_darker_732928_120
        purple_d229fe_63
        purple_darker_3c303c_24
        violet_8437ff_160
        violet_darker_51135e_200
        dark_Orange_ffa027_44
        orange_red_cf7f7e_67
        fire_red_ff6240_93
        fire_red_darker_a73f3e_28
        blue_28dcfd_99
        marine_blue_02feff_123
        blue_green_53ffff_25
        blue_green_darker_7de3b1_66
        crimson_fe0000_97
        carmine_ff4eae_23
        magenta_f468ef_42
        emerald_e0f6c1_51
        grass_green_7de3b1_62
        grass_green_darker_195d20_99
        sap_green_7ddd8a_125
        rose_f08188_201
        copper_b69574_65
        inferno_f5a120_124
        inferno_darker_fe0000_85
    """
    # Set Either CMD or SCmd with clip nickname and range
    Cmd=""
    SCmd="""
        light_amber_FFD700_128   100,199
        lemon_yellow_dacca5_100   300,399
        Canary_Yellow_ffde00_150  500,599
    """
}

Function Tint (clip Last, int color, int "strength") {
    strength = Default (strength, 128)
    hue = BlankClip (last, color = color, pixel_type = "YV12")
    # get chroma on new tint
    uhue = hue.UtoY ()
    vhue = hue.VtoY ()
    u = UtoY ()
    v = VtoY ()
    #set up mask. Assumes 0-255 RGB and 16-235 YUV.
    mask = GreyScale ()
    mask = mask.isYUV () ? mask.ColorYUV (levels = "tv->pc") : mask
    # mask 1 reduces chroma impact in shadows
    # mask 2 reduces chroma in highlights
    mask1 = mask.Levels (0, 1, 127, 0, 255, false)
    mask2 = mask.Levels (128, 1, 255, 255, 0, false)
    maskmask = mask.Levels (127, 1, 128, 0, 255, false)
    mask = Overlay (mask1, mask2, mask = maskmask).Levels (0, 1, 255, 0, strength, false)
    mask =  isYUY2 () ? mask.BilinearResize (Width/2, Height) : \
        isYV12 () ? mask.BilinearResize (Width/2, Height/2) : mask
    # mask combines the two masks and resizes to match chroma
    # apply tints to the chroma channels
    u1 = Overlay (u, uhue, mode = "luma", mask = mask)
    v1 = Overlay (v, vhue, mode = "luma", mask = mask)
    # mix new chroma into
    YtoUV (u1, v1, last)
}

Function ChrIsNul(String S)      {return RT_Ord(S)== 0}                             # End of String
Function ChrIsHash(String S)     {return RT_Ord(S)==35}                             # #
Function ChrEatWhite(String S)   {i=1 C=RT_Ord(S,i) While(C==32||C>=8&&C<=13) {i=i+1 C=RT_Ord(S,i)} return i>1?MidStr(S,i):S}

Function GetVarNameFromString(string s) {
    i=0    c=RT_Ord(s,i+1)
    While(c==95 || (c>=65&&c<=90||c>=97&&c<=122) || (i>0&&(c>=48&&c<=57)))  { i=i+1 c=RT_Ord(S,i+1) }
    return i>0?LeftStr(s,i):""
}


TYPESTRING="s64ii"      # Field 0=String(Max 64 chars), Field 1=int, Field 2=Int
FULLNAME_FLD  = 0       # Name Incl Hex trailer and Strength
COLOR_FLD     = 1       # Hex Color
STRENGTH_FLD  = 2       # Strength
RT_DBaseAlloc(DB,0,TYPESTRING)
# Create DBase with names and Color
LINES=RT_TxtQueryLines(NamesList)
for(i=0,LINES-1) {
    SS=ChrEatWhite(RT_TxtGetLine(NamesList,i))
    S=SS
    if(!ChrIsNul(S) && !ChrIsHash(S)) {
        FullName=GetVarNameFromString(S).UCase
        NameLen=StrLen(FullName)
        S=MidStr(S,NameLen+1).ChrEatWhite
        if(ChrIsHash(S)) {S=""}
        Assert(ChrIsNul(S),RT_String("%sError@Line_%d,  *** NON-PARSE ***\n'%s'",myName,i+1,SS))
        Name=FullName
        if(STRENGTH>=0) { # Strength is fixed, NOT appended to String Name
            strong=STRENGTH
        } Else {          # Get Strength from end of Name as Dec digits
            j=NameLen
            c=RT_Ord(Name,j)
            While(c>=48&&c<=57) { j=j-1  c=RT_Ord(Name,j) }
            DecS = RightStr(Name,Namelen-j)
            Strong=RT_NumberValue(DecS)
            Name=LeftStr(Name,j)
            While( RT_Ord(Name,StrLen(Name))==95 ) { Name=LeftStr(Name,StrLen(Name)-1) }
        }
        NameLen=StrLen(Name)
        j=NameLen
        c=RT_Ord(Name,j)
        While(c>=48&&c<=57||c>=65&&c<=70||c>=97&&c<=102) { j=j-1  c=RT_Ord(Name,j) }
        HexS = RightStr(Name,Namelen-j)
        HexCol=RT_HexValue(HexS)
        Name=LeftStr(Name,j)
        While( RT_Ord(Name,StrLen(Name))==95 ) { Name=LeftStr(Name,StrLen(Name)-1) }
        RT_DebugF("%d] FullName=%s : HexCol=$%X : Strong=%d",i+1,RT_StrPad(FullName,32),HexCol,Strong)
        RT_DBaseAppend(DB, FullName, HexCol,Strong)
    }
}

# Create Clips and NickNames and ClipClop filter Calling String.
Records=RT_DBaseRecords(DB) # Number of clips
Clips      = ""
FilterCall = ""
NickName   = ""

For(i=0,Records-1) {
    Name=RT_DBaseGetField(DB,i,FULLNAME_FLD)
    Color=RT_DBaseGetField(DB,i,COLOR_FLD)
    Strong=RT_DBaseGetField(DB,i,STRENGTH_FLD)
    Clips = RT_String("%sV%d=ORG.Tint($%06X,%d)\n",Clips,i+1,Color,Strong)   # Append Clip string for Eval
    FilterCall = RT_String("%s,V%d",FilterCall,i+1)                          # Add Clip Name to filter call.
    NickName   = RT_String("%s%s = %d\n",NickName,Name,i+1)
}
FilterCall="ClipClop(ORG"+FilterCall+",scmd=SCMD,cmd=CMD,nickname=NickName,show=SHOW)"    # Complete FilterCall string
RT_DebugF("\nCLIPS =\n%s\n",Clips)
RT_DebugF("FILTERCALL =\n%s\n",FilterCall)
RT_DebugF("NICKNAME =\n%s\n",NickName)
Eval(Clips)                        # Create Clips
Eval(FilterCall)                   # Call ClipClop

Return Last
EDITED:

EDIT:
from the range in blue, Color=$FFD700, Strength=128.
Code:
SCmd="""
    light_amber_FFD700_128   100,199
    lemon_yellow_dacca5_100   300,399
    Canary_Yellow_ffde00_150  500,599
"""


EDIT: DebugView (Google) will show some stuff as text is parsed.
Above, {R1}[122] denotes replacement clip 1 (light_amber_FFD700_128), frame 122.
ClipClop supports up to 255 replacement clips, unlimited number of ranges from those clips.
__________________
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; 23rd October 2018 at 04:01.
StainlessS is offline   Reply With Quote
Old 23rd October 2018, 04:34   #11  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Or alternative,

Code:
Function Tint (clip Last, int color, int "strength") {
    strength = Default (strength, 128)
    hue = BlankClip (last, color = color, pixel_type = "YV12")
    # get chroma on new tint
    uhue = hue.UtoY ()
    vhue = hue.VtoY ()
    u = UtoY ()
    v = VtoY ()
    #set up mask. Assumes 0-255 RGB and 16-235 YUV.
    mask = GreyScale ()
    mask = mask.isYUV () ? mask.ColorYUV (levels = "tv->pc") : mask
    # mask 1 reduces chroma impact in shadows
    # mask 2 reduces chroma in highlights
    mask1 = mask.Levels (0, 1, 127, 0, 255, false)
    mask2 = mask.Levels (128, 1, 255, 255, 0, false)
    maskmask = mask.Levels (127, 1, 128, 0, 255, false)
    mask = Overlay (mask1, mask2, mask = maskmask).Levels (0, 1, 255, 0, strength, false)
    mask =  isYUY2 () ? mask.BilinearResize (Width/2, Height) : \
        isYV12 () ? mask.BilinearResize (Width/2, Height/2) : mask
    # mask combines the two masks and resizes to match chroma
    # apply tints to the chroma channels
    u1 = Overlay (u, uhue, mode = "luma", mask = mask)
    v1 = Overlay (v, vhue, mode = "luma", mask = mask)
    # mix new chroma into
    YtoUV (u1, v1, last)
}

#Avisource("D:\PN.avi")
ColorBars(Pixel_type="YV12").Killaudio

Function DoIt(clip c,int s, int e,string Name, Int Color, Int "Strength",Bool "Show",Bool "ShowFrmNum") {
    Strength=Default(Strength,128)  # Mod if you want fixed default
    Show=Default(Show,False)
    ShowFrmNum=Show?Default(ShowFrmNum,False):False
    ApplyRange (c, s,e,"Tint",Color,Strength)
    Tit = (SHOW)    ? "Name=" + Name + " : Color=$" + Hex(Color) + String(Strength," : Strength=%.0f") : ""
    Args= (ShowFrmNum) ? String(s,",First_frame=%.0f") + String(e,",last_frame=%.0f") + ",Align=5" : ""
    Return (!Show)
        \ ? Last
        \ : (!ShowFrmNum)
        \   ? SubTitle(Tit,First_Frame=s,Last_Frame=e,align=5)
        \   : Scriptclip("""Subtitle(String(current_frame,"%.0f] ") + """ + Chr(34) + Tit + Chr(34) + Args + ")")
}

Show       = True
ShowFrmNum = True

DoIt(100,199,"light_amber"  ,$FFD700,128,Show=Show,ShowFrmNum=ShowFrmNum)
DoIt(300,399,"lemon_yellow" ,$dacca5,100,Show=Show,ShowFrmNum=ShowFrmNum)
DoIt(500,599,"Canary_Yellow",$ffde00,150,Show=Show,ShowFrmNum=ShowFrmNum)

Return Last
EDIT: Added ShowFrmNum



EDIT: Above script will cause problems if same range/frames set multiple times, whereas first script will use later settings.
__________________
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; 23rd October 2018 at 08:10.
StainlessS is offline   Reply With Quote
Old 23rd October 2018, 08:40   #12  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Probably not what you want, but might prove useful instead of using Trim all the time. ReplaceFramesSimple is part of RemapFrames. Using it can save lots of time, especially if you reuse the same colors often:

B=BlankClip(Last, width=704, height=480, fps=23.976, pixel_type="YV12",color=$3E1F09)###Define resolution, framerate, colorspace and color
C=Overlay(Last,B,Opacity=0.5)###Adjust the opacity for stronger or weaker color overlay.
ReplaceFramesSimple(Last,C,Mappings="[0 1000] [3000 4000]")###start and end frames where color is to be used.


Set up a new three-line script for each different color used. As an example I used one of your pictures and:

ImageSource("c2trpy13.jpg")
Greyscale
B=BlankClip(Last,width=594, height=474, fps=23.976, pixel_type="YV12",color=$3E1F09)
C=Overlay(Last,B,Opacity=0.4)
ReplaceFramesSimple(Last,C,Mappings="[0 1000] ")
Attached Images
 

Last edited by manono; 23rd October 2018 at 08:54.
manono is offline   Reply With Quote
Old 23rd October 2018, 09:23   #13  |  Link
color
Registered User
 
color's Avatar
 
Join Date: May 2016
Posts: 235
It works great, but is it possible to do change so:
Code:
DoIt(1,1200,"light_amber",$FFD700, Strength=128, Show=False, ShowFrmNum=False)
can be simplier like:
Code:
DoIt(1,1200,"light_amber", Strength=128, Show=False, ShowFrmNum=False)
and can it be changed so It works with multiple lines, That would help and save me so mutch time.

I did try the first script but I cound not get it to work... I did save MyDBase.DB with the text under "###############################" and tint as tint.avsi and imported mydbase.db.

Aslo, this does not work of course like I write in the script below"#.BlankClip(color=$732928).MergeLuma(0.75)", is it possible to get this in somehow in the script on pink, inferno etc? Also, MergeLuma is not right, Soft Light, Hard Light, was it that I used in photo editing program, and it seems like this would work, but I cant get the script to work...

And thank you StainlessS, your a genius.

BTW changed DoIt() to KinoTint().

Code:
Function Tint (clip Last, int color, int "strength") {
    strength = Default (strength, 128)
    hue = BlankClip (last, color = color, pixel_type = "YV12")
    # get chroma on new tint
    uhue = hue.UtoY ()
    vhue = hue.VtoY ()
    u = UtoY ()
    v = VtoY ()
    #set up mask. Assumes 0-255 RGB and 16-235 YUV.
    mask = GreyScale ()
    mask = mask.isYUV () ? mask.ColorYUV (levels = "tv->pc") : mask
    # mask 1 reduces chroma impact in shadows
    # mask 2 reduces chroma in highlights
    mask1 = mask.Levels (0, 1, 127, 0, 255, false)
    mask2 = mask.Levels (128, 1, 255, 255, 0, false)
    maskmask = mask.Levels (127, 1, 128, 0, 255, false)
    mask = Overlay (mask1, mask2, mask = maskmask).Levels (0, 1, 255, 0, strength, false)
    mask =  isYUY2 () ? mask.BilinearResize (Width/2, Height) : \
        isYV12 () ? mask.BilinearResize (Width/2, Height/2) : mask
    # mask combines the two masks and resizes to match chroma
    # apply tints to the chroma channels
    u1 = Overlay (u, uhue, mode = "luma", mask = mask)
    v1 = Overlay (v, vhue, mode = "luma", mask = mask)
    # mix new chroma into
    YtoUV (u1, v1, last)
}

#DirectShowSource("D:\The_Phantom_of_the_Opera_1925-RGvuENSnQGw.mp4")


#ColorBars(Pixel_type="YV12").Killaudio

Function KinoTint(clip c,int s, int e,string Name, Int Color, Int "Strength",Bool "Show",Bool "ShowFrmNum") {
    Strength=Default(Strength,128)  # Mod if you want fixed default
    Show=Default(Show,False)
    ShowFrmNum=Show?Default(ShowFrmNum,False):False
    ApplyRange (c, s,e,"Tint",Color,Strength)
    Tit = (SHOW)    ? "Name=" + Name + " : Color=$" + Hex(Color) + String(Strength," : Strength=%.0f") : ""
    Args= (ShowFrmNum) ? String(s,",First_frame=%.0f") + String(e,",last_frame=%.0f") + ",Align=5" : ""
    Return (!Show)
        \ ? Last
        \ : (!ShowFrmNum)
        \   ? SubTitle(Tit,First_Frame=s,Last_Frame=e,align=5)
        \   : Scriptclip("""Subtitle(String(current_frame,"%.0f] ") + """ + Chr(34) + Tit + Chr(34) + Args + ")")
}

Show       = True
ShowFrmNum = True

KinoTint(100,199,"light_amber"  ,$FFD700,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(300,399,"lemon_yellow" ,$dacca5,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(500,599,"Canary_Yellow",$ffde00,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(100,101,"light_amber",$FFD700,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(100,101,"lemon_yellow",$dacca5,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(100,101,"Canary_Yellow",$ffde00,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(100,101,"light_orange",$f9f0af,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(100,101,"pink:",$79122c,128,Show=Show,ShowFrmNum=ShowFrmNum)#.BlankClip(color=$732928).MergeLuma(0.75)
KinoTint(100,101,"purple",$d229fe,128,Show=Show,ShowFrmNum=ShowFrmNum)#.BlankClip(color=$3c303c).MergeLuma(0.75)
KinoTint(100,101,"violet",$8437ff,128,Show=Show,ShowFrmNum=ShowFrmNum)#.BlankClip(color=$51135e).MergeLuma(0.75)
KinoTint(100,101,"dark_Orange",$ffa027,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(100,101,"orange_red",$cf7f7e,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(100,101,"fire_red",$ff6240,128,Show=Show,ShowFrmNum=ShowFrmNum)#.BlankClip(color=$a73f3e).MergeLuma(0.75)
KinoTint(100,101,"blue",$28dcfd,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(100,101,"marine_blue",$02feff,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(100,101,"blue_green",$53ffff,128,Show=Show,ShowFrmNum=ShowFrmNum)#.BlankClip(color=$7de3b1).MergeLuma(0.75)
KinoTint(100,101,"crimson",$fe0000,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(100,101,"carmine",$ff4eae,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(100,101,"magenta",$f468ef,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(100,101,"emerald",$e0f6c1,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(100,101,"grass_green",$7de3b1,128,Show=Show,ShowFrmNum=ShowFrmNum)#.BlankClip(color=$195d20).MergeLuma(0.75)
KinoTint(100,101,"sap_green",$7ddd8a,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(100,101,"rose",$f08188,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(100,101,"copper",$b69574,128,Show=Show,ShowFrmNum=ShowFrmNum)
KinoTint(100,101,"inferno",$f5a120,128,Show=Show,ShowFrmNum=ShowFrmNum)#.BlankClip(color=$fe0000).MergeLuma(0.75)

Return Last
Inferno, I know it looks more orange, but using orange color does only make the tint orange, not red in the darker.


So I want the once with "darker" color to be more like this, its not the best I can do in photo program, but it looks good in my eyes.


Here is the green, more torkois (spelling?) on the light part and dark green on the darker. Just like its often looks like when tinting in the old days.


Here is inferno on fire, light, then darker color and both. It looks more alive on the right with two color.



Original image:
__________________
Automatic Colorization

Last edited by color; 23rd October 2018 at 09:31.
color is offline   Reply With Quote
Old 23rd October 2018, 09:43   #14  |  Link
color
Registered User
 
color's Avatar
 
Join Date: May 2016
Posts: 235
manono, I did try, but the result is not what I'm looking for.
__________________
Automatic Colorization
color is offline   Reply With Quote
Old 24th October 2018, 20:38   #15  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Post #1 of 2

mod

Color_list.txt (in file) # You could use Colors_RGB.avsi from plugins with probably better names (and a lot more colors).
Code:
light_amber         = $FFD700
lemon_yellow        = $dacca5
Canary_Yellow       = $ffde00
light_orange        = $f9f0af
pink                = $79122c
pink_darker         = $732928
purple              = $d229fe
purple_darker       = $3c303c
violet              = $8437ff
violet_darker       = $51135e
dark_Orange         = $ffa027
orange_red          = $cf7f7e
fire_red            = $ff6240
fire_red_darker     = $a73f3e
blue                = $28dcfd
marine_blue         = $02feff
blue_green          = $53ffff
blue_green_darker   = $7de3b1
crimson             = $fe0000
carmine             = $ff4eae
magenta             = $f468ef
emerald             = $e0f6c1
grass_green         = $7de3b1
grass_green_darker  = $195d20
sap_green           = $7ddd8a
rose                = $f08188
copper              = $b69574
inferno             = $f5a120
inferno_darker      = $fe0000
Kino.avsi
Code:
Function Tint (clip Last, int color, int "strength") {
    strength = Default (strength, 128)
    hue = BlankClip (last, color = color, pixel_type = "YV12")
    # get chroma on new tint
    uhue = hue.UtoY ()
    vhue = hue.VtoY ()
    u = UtoY ()
    v = VtoY ()
    #set up mask. Assumes 0-255 RGB and 16-235 YUV.
    mask = GreyScale ()
    mask = mask.isYUV () ? mask.ColorYUV (levels = "tv->pc") : mask
    # mask 1 reduces chroma impact in shadows
    # mask 2 reduces chroma in highlights
    mask1 = mask.Levels (0, 1, 127, 0, 255, false)
    mask2 = mask.Levels (128, 1, 255, 255, 0, false)
    maskmask = mask.Levels (127, 1, 128, 0, 255, false)
    mask = Overlay (mask1, mask2, mask = maskmask).Levels (0, 1, 255, 0, strength, false)
    mask =  isYUY2 () ? mask.BilinearResize (Width/2, Height) : \
        isYV12 () ? mask.BilinearResize (Width/2, Height/2) : mask
    # mask combines the two masks and resizes to match chroma
    # apply tints to the chroma channels
    u1 = Overlay (u, uhue, mode = "luma", mask = mask)
    v1 = Overlay (v, vhue, mode = "luma", mask = mask)
    # mix new chroma into
    YtoUV (u1, v1, last)
}

Function KinoTint(clip c,int "Start", int "End",string "Name", Int "Color", Int "Strength",Bool "Show",Bool "ShowFrmNum") {
    # By Default applies to entire clip (useful to ClipClop for creation of entire tinted clips)
    Start=Default(Start,0)      End=Default(End,c.FrameCount-1)
    Name=Default(Name,"")       Color=Default(Color,$808080)                        Strength=Default(Strength,128)  # Mod if you want fixed default
    Show=Default(Show,False)    ShowFrmNum=Show?Default(ShowFrmNum,False):False
    ApplyRange (c, Start,End,"Tint",Color,Strength)
    Tit = (SHOW)       ? RT_String("Name=%s : Color=$%06X : Strength=%d",Name,Color,Strength) : ""
    Args= (ShowFrmNum) ? RT_String(",First_Frame=%d,Last_Frame=%d",Start,End) : ""
    Return (!Show)
        \ ? Last
        \ : (!ShowFrmNum)
        \   ? SubTitle(Tit,First_Frame=Start,Last_Frame=End)
        \   : Scriptclip("""Subtitle(String(current_frame,"%.0f] ") + """ + Chr(34) + Tit + Chr(34) + Args + ")")
}


Function ChrIsNul(String S)      {return RT_Ord(S)== 0}                             # End of String
Function ChrIsHash(String S)     {return RT_Ord(S)==35}                             # #
Function ChrIsDollar(String S)   {return RT_Ord(S)==36}                             # $
Function ChrIsEqual(String S)    {return RT_Ord(S)==61}                             # =
Function ChrIsHex(String S)      {C=RT_Ord(S) return C>=48&&C<=57||C>=65&&C<=70||C>=97&&C<=102}
Function ChrEatWhite(String S)   {i=1 C=RT_Ord(S,i) While(C==32||C>=8&&C<=13) {i=i+1 C=RT_Ord(S,i)} return i>1?MidStr(S,i):S}
Function ChrEatHex(String S)     {i=1 C=RT_Ord(S,i) While(C>=48&&C<=57||C>=65&&C<=70||C>=97&&C<=102) {i=i+1 C=RT_Ord(S,i)} return i>1?MidStr(S,i):S}

Function GetVarNameFromString(string s) {
    i=0    c=RT_Ord(s,i+1)
    While(c==95 || (c>=65&&c<=90||c>=97&&c<=122) || (i>0&&(c>=48&&c<=57)))  { i=i+1 c=RT_Ord(S,i+1) }
    return i>0?LeftStr(s,i):""
}

Function Kino_CreateDBase(String ColorList_Filename,String DB) {
    # Create DBase, Field 0=Name, Field 1=color
    myName="Kino_CreateDBase: "
    Assert(ColorList_Filename!="",RT_String("%sError, Colorlist_FileName cannot be ''",myName))
    Assert(DB!="",RT_String("%sError, DB name cannot be ''",myName))
    ColorList_Filename=RT_GetFullPathName(ColorList_Filename)
    DB=RT_GetFullPathName(DB)
    Assert(Exist(ColorList_Filename),RT_String("%sError, %s does not exist",myName,ColorList_Filename))
    RT_DBaseAlloc(DB,0,"s64i")          # Field 0=String(Max 64 chars), Field 1=int
    # Create DBase with names and Color
    Color_List=RT_ReadTxtFromFile(ColorList_Filename)
    LINES=RT_TxtQueryLines(Color_List)
    for(i=0,LINES-1) {
        SS=RT_TxtGetLine(Color_List,i).ChrEatWhite
        S=SS
        if(!ChrIsNul(S) && !ChrIsHash(S)) {
            Name=GetVarNameFromString(S).UCase
            NameLen=StrLen(Name)
            S=MidStr(S,NameLen+1).ChrEatWhite
            if(Name=="GLOBAL") {
                Name=GetVarNameFromString(S).UCase
                NameLen=StrLen(Name)
                S=MidStr(S,NameLen+1).ChrEatWhite
            }
            Assert(ChrIsEqual(S),RT_String("%sError@Line_%d,  Expecting '='\n'%s'",myName,i+1,SS))
            S=MidStr(S,2).ChrEatWhite    # Skip '='
            Assert(ChrIsDollar(S),RT_String("%sError@Line_%d,  Expecting '$'\n'%s'",myName,i+1,SS))
            S=MidStr(S,2).ChrEatWhite    # Skip '$'
            Assert(ChrIsHex(S),RT_String("%sError@Line_%d,  Expecting hex number\n'%s'",myName,i+1,SS))
            HexCol=RT_HexValue(S)
            S=ChrEatHex(S).ChrEatWhite   # Skip Hex digits
            if(ChrIsHash(S)) {S=""}
            Assert(ChrIsNul(S),RT_String("%sError@Line_%d,  *** NON-PARSE ***\n'%s'",myName,i+1,SS))
            RT_DebugF("%d] Name=%s : HexCol=$%X",i+1,RT_StrPad(Name,32),HexCol,name=myName)
            RT_DBaseAppend(DB, Name, HexCol)
        }
    }
}

Function Kino_MakeClipString(clip c, String DB, Int "Strength") {
    # Eval on return string will create all clips
    myName="Kino_MakeClipString: "
    Strength=Default(Strength,128)
    Assert(DB!="",RT_String("%sError, DB name cannot be ''",myName))
    DB=RT_GetFullPathName(DB)
    End=c.Framecount-1
    Clips=""
    Records=RT_DBaseRecords(DB) # Number of clips
    For(i=0,Records-1) {
        Name  = RT_DBaseGetField(DB,i,0)
        Color = RT_DBaseGetField(DB,i,1)
        Clips = RT_String("""%s%s=ORG.KinoTint(0,%d,"%s",$%06X,%d,SHOW,SHOWFRMNUM)\n""",Clips,Name,End,Name,Color,Strength)
    }
    RT_DebugF("\nClips=\n%s",Clips,name=myName)
    Return Clips
}

Function Kino_MakeNickNameString(String DB) {
    myName="Kino_MakeNickNameString: "
    Assert(DB!="",RT_String("%sError, DB name cannot be ''",myName))
    DB=RT_GetFullPathName(DB)
    NickName = ""
    Records=RT_DBaseRecords(DB) # Number of clips
    For(i=0,Records-1) {
        Name     = RT_DBaseGetField(DB,i,0)
        NickName = RT_String("%s%s=%d\n",NickName,Name,i+1)
    }
    RT_DebugF("\nNickName=\n%s",NickName,name=myName)
    Return NickName
}

Function Kino_MakeFilterString(String DB) {
    myName="Kino_MakeFilterString: "
    Assert(DB!="",RT_String("%sError, DB name cannot be ''",myName))
    DB=RT_GetFullPathName(DB)
    FilterString = "ClipClop(ORG"
    Records=RT_DBaseRecords(DB) # Number of clips
    For(i=0,Records-1) {
        Name = RT_DBaseGetField(DB,i,0)
        FilterString = RT_String("%s,\n    \ %s",FilterString,Name)
    }
    FilterString = RT_String("%s,\n    \ SCmd=SCMD,Cmd=CMD,NickName=NickName\n\\ )\n",FilterString)
    RT_DebugF("\nFilterString=\n%s",FilterString,name=myName)
    Return FilterString
}

Function Kino_MakeDemoString(clip c,String DB,Int "Len",Int "Gap") {
    myName="Kino_MakeDemoString: "
    Len=Default(Len,100)        Gap=Default(Gap,Len)   # GAP defaults to Len
    Assert(DB!="",RT_String("%sError, DB name cannot be ''",myName))
    DB=RT_GetFullPathName(DB)
    FC=c.FrameCount
    DemoString = ""
    Records=RT_DBaseRecords(DB) # Number of clips
    Start=Gap
    For(i=0,Records-1) {
        Name = RT_DBaseGetField(DB,i,0).RT_StrPad(32)
        End = Start + Len-1
        End = (End == 0) ? -1 : (End >= FC) ? FC-1 : End
        DemoString = RT_String("%s%s %d,%d\n",DemoString,Name,Start,End)
        Start=Start+Len+Gap
    }
    RT_DebugF("\nDemoString=\n%s",DemoString,name=myName)
    Return DemoString
}
EDITED

KinoScript.avs
Code:
# KinoScript.avs
# Requirements:-
#   Avs+:-     https://github.com/pinterf/AviSynthPlus/releases
#   RT_Stats:- https://forum.doom9.org/showthread.php?t=165479&highlight=rt_stats
#   ClipClop:- https://forum.doom9.org/showthread.php?t=162266&highlight=clipclop
######

Import("D:\Kino.avsi")

#ColorList_Filename = "D:\Colors_RGB.avsi"      # YOU MUST Uncomment SCMD=ORG.Kino_MakeDemoString at END of script if you use this one
ColorList_Filename = "D:\Color_List.txt"        # You could use Colors_RGB.avsi from plugins with probably better names.
DB                 = "D:\KinoDBase.DB"

##########################

# Avisource("D:\PN.avi")
ColorBars(Pixel_type="YV12").Killaudio
SHOW       = True
SHOWFRMNUM = True
TITLEBAR   = True
STRENGTH   = 128            # As you seem to be using fixed strength (is no longer variable)

Last = (SHOW && TITLEBAR) ? AddBorders(0,20,0,0) : Last
ORG=Last

Kino_CreateDBase(ColorList_Filename,DB)                         # Make the DBase, Could do this only once and then reuse later

# Create Clip, and NickName, and ClipClop filter Calling Strings.
Clips     = Kino_MakeClipString(ORG,DB,Strength=STRENGTH)
NickName  = Kino_MakeNickNameString(DB)
Filter    = Kino_MakeFilterString(DB)

# DEMO COMMANDS
# Set Either CMD or SCMD with color name and range (Color Names must exist in Color_List and therefore DB)
CMD=""      # Can Point to File instead of using SCmd string below (make below SCMD="" if using file)
SCMD="""
    light_amber         100,199
    lemon_yellow        300,399
    Canary_Yellow       500,599
    light_orange        700,799
    pink                900,999
    pink_darker         1100,1199
    purple              1300,1399
    purple_darker       1500,1599
    violet              1700,1799
    violet_darker       1900,1999
    dark_Orange         2100,2199
    orange_red          2300,2399
    fire_red            2500,2599
    fire_red_darker     2700,2799
    blue                2900,2999
    marine_blue         3100,3199
    blue_green          3300,3399
    blue_green_darker   3500,3599
    crimson             3700,3799
    carmine             3900,3999
    magenta             4100,4199
    emerald             4300,4399
    grass_green         4500,4599
    grass_green_darker  4700,4799
    sap_green           4900,4999
    rose                5100,5100
    copper              5300,5399
    inferno             5500,5599
    inferno_darker      5700,5799

"""

#SCMD=ORG.Kino_MakeDemoString(DB,Len=100,Gap=100)    # ADDED: Recreate Above SCMD with less Effort, easy test for Colors_RGB.avsi

Eval(Clips)             # Create Clips
Eval(Filter)            # Call ClipClop Filter
Return Last
EDITED

EDIT: If using BOTH SCMD and CMD, then CMD processed first and then SCMD afterwards, relevant as later overrides earlier.######
__________________
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; 25th October 2018 at 14:44.
StainlessS is offline   Reply With Quote
Old 24th October 2018, 20:38   #16  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Post #2 of 2

Output of DebugView
Code:
Kino_CreateDBase: 1] Name=LIGHT_AMBER                      : HexCol=$FFD700
Kino_CreateDBase: 2] Name=LEMON_YELLOW                     : HexCol=$DACCA5
Kino_CreateDBase: 3] Name=CANARY_YELLOW                    : HexCol=$FFDE00
Kino_CreateDBase: 4] Name=LIGHT_ORANGE                     : HexCol=$F9F0AF
Kino_CreateDBase: 5] Name=PINK                             : HexCol=$79122C
Kino_CreateDBase: 6] Name=PINK_DARKER                      : HexCol=$732928
Kino_CreateDBase: 7] Name=PURPLE                           : HexCol=$D229FE
Kino_CreateDBase: 8] Name=PURPLE_DARKER                    : HexCol=$3C303C
Kino_CreateDBase: 9] Name=VIOLET                           : HexCol=$8437FF
Kino_CreateDBase: 10] Name=VIOLET_DARKER                    : HexCol=$51135E
Kino_CreateDBase: 11] Name=DARK_ORANGE                      : HexCol=$FFA027
Kino_CreateDBase: 12] Name=ORANGE_RED                       : HexCol=$CF7F7E
Kino_CreateDBase: 13] Name=FIRE_RED                         : HexCol=$FF6240
Kino_CreateDBase: 14] Name=FIRE_RED_DARKER                  : HexCol=$A73F3E
Kino_CreateDBase: 15] Name=BLUE                             : HexCol=$28DCFD
Kino_CreateDBase: 16] Name=MARINE_BLUE                      : HexCol=$2FEFF
Kino_CreateDBase: 17] Name=BLUE_GREEN                       : HexCol=$53FFFF
Kino_CreateDBase: 18] Name=BLUE_GREEN_DARKER                : HexCol=$7DE3B1
Kino_CreateDBase: 19] Name=CRIMSON                          : HexCol=$FE0000
Kino_CreateDBase: 20] Name=CARMINE                          : HexCol=$FF4EAE
Kino_CreateDBase: 21] Name=MAGENTA                          : HexCol=$F468EF
Kino_CreateDBase: 22] Name=EMERALD                          : HexCol=$E0F6C1
Kino_CreateDBase: 23] Name=GRASS_GREEN                      : HexCol=$7DE3B1
Kino_CreateDBase: 24] Name=GRASS_GREEN_DARKER               : HexCol=$195D20
Kino_CreateDBase: 25] Name=SAP_GREEN                        : HexCol=$7DDD8A
Kino_CreateDBase: 26] Name=ROSE                             : HexCol=$F08188
Kino_CreateDBase: 27] Name=COPPER                           : HexCol=$B69574
Kino_CreateDBase: 28] Name=INFERNO                          : HexCol=$F5A120
Kino_CreateDBase: 29] Name=INFERNO_DARKER                   : HexCol=$FE0000
Kino_MakeClipString:
Kino_MakeClipString: Clips=
Kino_MakeClipString: LIGHT_AMBER=ORG.KinoTint(0,107891,"LIGHT_AMBER",$FFD700,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: LEMON_YELLOW=ORG.KinoTint(0,107891,"LEMON_YELLOW",$DACCA5,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: CANARY_YELLOW=ORG.KinoTint(0,107891,"CANARY_YELLOW",$FFDE00,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: LIGHT_ORANGE=ORG.KinoTint(0,107891,"LIGHT_ORANGE",$F9F0AF,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: PINK=ORG.KinoTint(0,107891,"PINK",$79122C,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: PINK_DARKER=ORG.KinoTint(0,107891,"PINK_DARKER",$732928,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: PURPLE=ORG.KinoTint(0,107891,"PURPLE",$D229FE,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: PURPLE_DARKER=ORG.KinoTint(0,107891,"PURPLE_DARKER",$3C303C,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: VIOLET=ORG.KinoTint(0,107891,"VIOLET",$8437FF,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: VIOLET_DARKER=ORG.KinoTint(0,107891,"VIOLET_DARKER",$51135E,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: DARK_ORANGE=ORG.KinoTint(0,107891,"DARK_ORANGE",$FFA027,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: ORANGE_RED=ORG.KinoTint(0,107891,"ORANGE_RED",$CF7F7E,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: FIRE_RED=ORG.KinoTint(0,107891,"FIRE_RED",$FF6240,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: FIRE_RED_DARKER=ORG.KinoTint(0,107891,"FIRE_RED_DARKER",$A73F3E,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: BLUE=ORG.KinoTint(0,107891,"BLUE",$28DCFD,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: MARINE_BLUE=ORG.KinoTint(0,107891,"MARINE_BLUE",$02FEFF,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: BLUE_GREEN=ORG.KinoTint(0,107891,"BLUE_GREEN",$53FFFF,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: BLUE_GREEN_DARKER=ORG.KinoTint(0,107891,"BLUE_GREEN_DARKER",$7DE3B1,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: CRIMSON=ORG.KinoTint(0,107891,"CRIMSON",$FE0000,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: CARMINE=ORG.KinoTint(0,107891,"CARMINE",$FF4EAE,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: MAGENTA=ORG.KinoTint(0,107891,"MAGENTA",$F468EF,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: EMERALD=ORG.KinoTint(0,107891,"EMERALD",$E0F6C1,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: GRASS_GREEN=ORG.KinoTint(0,107891,"GRASS_GREEN",$7DE3B1,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: GRASS_GREEN_DARKER=ORG.KinoTint(0,107891,"GRASS_GREEN_DARKER",$195D20,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: SAP_GREEN=ORG.KinoTint(0,107891,"SAP_GREEN",$7DDD8A,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: ROSE=ORG.KinoTint(0,107891,"ROSE",$F08188,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: COPPER=ORG.KinoTint(0,107891,"COPPER",$B69574,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: INFERNO=ORG.KinoTint(0,107891,"INFERNO",$F5A120,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString: INFERNO_DARKER=ORG.KinoTint(0,107891,"INFERNO_DARKER",$FE0000,128,SHOW,SHOWFRMNUM)
Kino_MakeClipString:
Kino_MakeNickNameString:
Kino_MakeNickNameString: NickName=
Kino_MakeNickNameString: LIGHT_AMBER=1
Kino_MakeNickNameString: LEMON_YELLOW=2
Kino_MakeNickNameString: CANARY_YELLOW=3
Kino_MakeNickNameString: LIGHT_ORANGE=4
Kino_MakeNickNameString: PINK=5
Kino_MakeNickNameString: PINK_DARKER=6
Kino_MakeNickNameString: PURPLE=7
Kino_MakeNickNameString: PURPLE_DARKER=8
Kino_MakeNickNameString: VIOLET=9
Kino_MakeNickNameString: VIOLET_DARKER=10
Kino_MakeNickNameString: DARK_ORANGE=11
Kino_MakeNickNameString: ORANGE_RED=12
Kino_MakeNickNameString: FIRE_RED=13
Kino_MakeNickNameString: FIRE_RED_DARKER=14
Kino_MakeNickNameString: BLUE=15
Kino_MakeNickNameString: MARINE_BLUE=16
Kino_MakeNickNameString: BLUE_GREEN=17
Kino_MakeNickNameString: BLUE_GREEN_DARKER=18
Kino_MakeNickNameString: CRIMSON=19
Kino_MakeNickNameString: CARMINE=20
Kino_MakeNickNameString: MAGENTA=21
Kino_MakeNickNameString: EMERALD=22
Kino_MakeNickNameString: GRASS_GREEN=23
Kino_MakeNickNameString: GRASS_GREEN_DARKER=24
Kino_MakeNickNameString: SAP_GREEN=25
Kino_MakeNickNameString: ROSE=26
Kino_MakeNickNameString: COPPER=27
Kino_MakeNickNameString: INFERNO=28
Kino_MakeNickNameString: INFERNO_DARKER=29
Kino_MakeNickNameString:
Kino_MakeFilterString:
Kino_MakeFilterString: FilterString=
Kino_MakeFilterString: ClipClop(ORG,
Kino_MakeFilterString:     \ LIGHT_AMBER,
Kino_MakeFilterString:     \ LEMON_YELLOW,
Kino_MakeFilterString:     \ CANARY_YELLOW,
Kino_MakeFilterString:     \ LIGHT_ORANGE,
Kino_MakeFilterString:     \ PINK,
Kino_MakeFilterString:     \ PINK_DARKER,
Kino_MakeFilterString:     \ PURPLE,
Kino_MakeFilterString:     \ PURPLE_DARKER,
Kino_MakeFilterString:     \ VIOLET,
Kino_MakeFilterString:     \ VIOLET_DARKER,
Kino_MakeFilterString:     \ DARK_ORANGE,
Kino_MakeFilterString:     \ ORANGE_RED,
Kino_MakeFilterString:     \ FIRE_RED,
Kino_MakeFilterString:     \ FIRE_RED_DARKER,
Kino_MakeFilterString:     \ BLUE,
Kino_MakeFilterString:     \ MARINE_BLUE,
Kino_MakeFilterString:     \ BLUE_GREEN,
Kino_MakeFilterString:     \ BLUE_GREEN_DARKER,
Kino_MakeFilterString:     \ CRIMSON,
Kino_MakeFilterString:     \ CARMINE,
Kino_MakeFilterString:     \ MAGENTA,
Kino_MakeFilterString:     \ EMERALD,
Kino_MakeFilterString:     \ GRASS_GREEN,
Kino_MakeFilterString:     \ GRASS_GREEN_DARKER,
Kino_MakeFilterString:     \ SAP_GREEN,
Kino_MakeFilterString:     \ ROSE,
Kino_MakeFilterString:     \ COPPER,
Kino_MakeFilterString:     \ INFERNO,
Kino_MakeFilterString:     \ INFERNO_DARKER,
Kino_MakeFilterString:     \ SCmd=SCMD,Cmd=CMD,NickName=NickName
Kino_MakeFilterString: \ )
Kino_MakeFilterString:
EDIT: Manono's posted ReplaceFramesSimple() plug is similar to ClipClop(), but no where near as sexy
__________________
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; 24th October 2018 at 21:13.
StainlessS is offline   Reply With Quote
Old 25th October 2018, 00:16   #17  |  Link
magiblot
Eurobeat Fan
 
Join Date: Sep 2014
Posts: 108
I have been working on this filter that natively applies a tint defined with Hue and Saturation, that is, it does not depend on the way you perform overlaying nor it creates flat U and V planes. Hue and Saturation are, in fact, a more intuitive way of defining colors.

It allows you to adjust brightness in the sense that you can pick an HSL value for what you consider pure black in the source should look like in the result, and the same for pure white. This still has to be improved, though, since as of now you can only make the picture darker.

Unlike other HSL filters, this one preserves the brightness in the source clip (unless you apply the adjustment I explained just above), but it's not a simple pass-through of the source Y plane.

However, as opposed to the scans of real film tints I've seen or your sample pictures, all the pixels in the generated clip have exactly the same hue and saturation. So, the idea still has to be improved in order to simulate real film tint.

The filter is not finished yet. Performance is not optimal, since it could be implemented with a one-step LUT. In addition, it requires AviSynth+.

For example:

Code:
#https://www.welovepuzzle.ro/81759/puzzle-grafika-vintage-1000-piese-53507.jpg
ImageSource("puzzle-grafika-vintage-1000-piese-53507.jpg",end=0)
margin = width/16
AddBorders(margin,0,margin,0,$191919)
Spline64Resize(2*width/3,2*height/3)
ConvertToY(matrix="Rec601")
HSLtint(hue=35, sat=1.0, hueRange=240, satRange=1.0)


This is the whole script (pay attention to the notes about the version of AviSynth+):

Code:
#HSLTint WIP rev. 20181027 by magiblot1
#Requires AviSynth+, but doesn't work with the current last version r2728
#due to unnecessary restrictions added to Expr.
#Please use a version older than r2728, or install the test build at
#https://github.com/pinterf/AviSynthPlus/issues/15#issuecomment-402037746
#which is r2728 with a hotfix (then set oldAvsPlus=false).

#Changelog:
#20181027: added parameter oldAvsPlus for easier compatibility between old and new versions of AviSynth+
#20181024: initial release

/*
--- HSLTint ---

Create monochromatic tints given hue, saturation and lightness values.
This filter takes only the Luma the component of a YUV clip since it is thought for B&W films.
It does not overlay on already present color. Hue and Saturation are the same for
all the pixels in the resulting clip.

Arguments:

*** (Input clip)

Source clip must be YUV (or Y). All bitdepths are supported.
The resulting clip will be the same colorspace and bitdepth than the source.

*** hue, sat

Hue and Saturation values for the monochromatic tint.

*** minLight, maxLight

By default, pure black in the source clip (luma = 16d) will keep looking pure black
after applying the filter, and pure white (luma = 235d) will keep looking pure white.

These parameters adjust this setting. Take any color picker tool of your choice that
supports HSL and choose the color you think pure black in the source should turn into
in the resulting clip, then use its Lightness value for the minLight parameter. Likewise,
choose the color you consider pure white in the source should become in the resulting clip
and put its Lightness value in the maxLight parameter.

If you specify values such that maxLight < minLight, the resulting clip will look inverted
in brighness but not in color.

If you don't modify these parameters, luma values in the resulting clip will be exactly
the same as in the source clip.

*** hueRange, satRange, lightRange

These parameters allow you to specify the range of values for the hue, sat,
minLight and maxLight parameters explained above. The purpose of this is to
allow compatibility with your favourite color picker tool.

Default values are 360.0, 1.0 and 1.0, respectively.
Values smaller than 1.0 cannot be used.

*** matrix

Color matrix for RGB <-> YUV conversion.
The default value is decided by the following statement:
c.Width() > 1100 || c.Height() > 600 ? "Rec709" : "Rec601"

*** tv_range

This is true by default because YUV clips are expected to use the TV range.
This parameter determines wheter luma values in the source clip
are to be considered in the range 16d to 235d (TV range)
or in the range 0d to 255d (Full Range).

*/

function HSLTint(clip c, float "hue", float "sat", float "minLight", float "maxLight", float "hueRange", float "satRange", float "lightRange", string "matrix", bool "tv_range", bool "oldAvsPlus") {
    
    Assert(c.IsYUV() || c.IsYUVA(), """FilmTint: Source must be YUV. All bit depths are accepted.
Color information (UV) will be ignored, so you can just convert from RGB with ConvertToY.""")
    
    hueRange = Default(hueRange, 360.0)
    satRange = Default(satRange, 1.0)
    lightRange = Default(lightRange, 1.0)

    Assert(1.0 <= hueRange && 1.0 <= satRange && 1.0 <= lightRange, """FilmTint: "hueRange", "satRange" and "lightRange" cannot be smaller than 1.0.""")

    hue = Default(hue, 0.0)
    sat = Default(sat, 0.625*satRange)
    minLight = Default(minLight, 0.0)
    maxLight = Default(maxLight, lightRange)
    
    Assert(0.0 <= hue <= hueRange, """FilmTint: "hue" must be in the range [0.0 , """+ String(hueRange)+"""],
where the upper bound is determined by "hueRange".""")
    Assert(0.0 <= sat <= satRange, """FilmTint: "sat" must be in the range [0.0 , """+ String(satRange)+"""],
where the upper bound is determined by "satRange".""")
    Assert(0.0 <= minLight <= lightRange && 0.0 <= maxLight <= lightRange, """FilmTint: "minLight" and "maxLight" must be in the range [0.0 , """+ String(lightRange)+"""],
where the upper bound is determined by "lightRange".""")
    
    hue = 360.0/hueRange*hue
    sat = sat/satRange
    minLight = minLight/lightRange
    maxLight = maxLight/lightRange
    
    matrix = Default(matrix, c.Width() > 1100 || c.Height() > 600 ? "Rec709" : "Rec601")
    tv_range = Default(tv_range, true)
    oldAvsPlus = Default(oldAvsPlus, true)
    
    if (matrix == "Rec601") {
        mR = 0.299
        mG = 0.587
        mB = 0.114
    } else if (matrix == "Rec709") {
        mR = 0.2126
        mG = 0.7152
        mB = 0.0722
    } else {
        Assert(false, """FilmTint: Valid "matrix" values are "Rec601" and "Rec709".""")
    }

    #Generate an RGB color with Hue=hue, Sat=1.0 and Lightness=0.5.

    if (0.0 <= hue <= 60.0) {
        hR = 1.0
        hG = hue/60.0
        hB = 0.0
    } else if (60.0 <= hue <= 120.0) {
        hR = (60.0 - (hue - 60.0))/60.0
        hG = 1.0
        hB = 0.0
    } else if (120.0 <= hue <= 180.0) {
        hR = 0.0
        hG = 1.0
        hB = (hue - 120.0)/60.0
    } else if (180.0 <= hue <= 240.0) {
        hR = 0.0
        hG = (60.0 - (hue - 180.0))/60.0
        hB = 1.0
    } else if (240.0 <= hue <= 300.0) {
        hR = (hue - 240.0)/60.0
        hG = 0.0
        hB = 1.0
    } else { # 300.0 <= hue <= 360.0
        hR = 1.0
        hG = 0.0
        hB = (60.0 - (hue - 300.0))/60.0
    }
    
    #Generate an RGB color with Hue=hue, Sat=sat and Lightness=0.5.
    #A saturation of 1 leaves the result the same.
    #A saturation of 0 makes all channels become 0.5 (out of 1.0).
    
    hsR = hR + (0.5 - hR)*(1 - sat)
    hsG = hG + (0.5 - hG)*(1 - sat)
    hsB = hB + (0.5 - hB)*(1 - sat)
    
    function _HSLtoRGB(float "hs", float "l") {
        #Applies lightness ('x') to the color component 'hs', which has been defined with Hue=hue, Sat=sat and Lightness=0.5.
        #A lightness of 0.5 leaves the result the same.
        #A lightness of 0 makes the component become 0.
        #A lightness of 1 makes the component become 1.
        return l <= 0.5 ? 2*hs*l : hs + 2*(1 - hs)*(l - 0.5)
    }
    
    #Translates the darkest and brightest colors from HSL to RGB, and then to Luma (Y).
    #The following is always true: a lightness of 0 always results in a luma of 0, and a lightness of 1 always results in a luma of 1
    
    minLight_Y = mR*_HSLtoRGB(hsR, minLight) + mG*_HSLtoRGB(hsG, minLight) + mB*_HSLtoRGB(hsB, minLight)
    maxLight_Y = mR*_HSLtoRGB(hsR, maxLight) + mG*_HSLtoRGB(hsG, maxLight) + mB*_HSLtoRGB(hsB, maxLight)
    
    bitDepth = c.BitsPerComponent()
    
    #http://avisynth.nl/index.php/Levels
    
    scale_to_32bit = tv_range ? 219.0/256.0*pow(2,bitDepth%32) : 255.0/256.0*pow(2,bitDepth%32)
    tv_range_start = tv_range ? 16.0/256.0*pow(2,bitDepth%32) : 0.0
    
    #Get luma of video and convert to [0 .. 1] range in float.
    
    Y = c.IsInterleaved() ? c.ConvertToY() : c
    Y = Expr(Y, "x "+String(tv_range_start)+" - "+String(scale_to_32bit)+" /", format="Y32")
    Y = (minLight != 0.0 || maxLight != 1.0) ? Expr(Y, "x "+String(maxLight_Y - minLight_Y)+" * "+String(minLight_Y)+" +", format="Y32") : Y
    
    #Calculate the lightness values that, when converted from HSL to RGB and then back to Luma (Y), will result in the same Luma values than the original, source clip.
    #Otherwise, using Luma values directly in the HSL->RGB conversion formulas (like Colorize filter in VirtualDub) will result in distortion.
    #This is undocumented math, the following operations are not meant to be comprehensive.
    
    Llow = Expr(Y, "x "+String(0.5/(hsB*mB+hsG*mG+hsR*mR))+" *",format="Y32")
    Lhigh = Expr(Y, String(2*((hsB-0.5)*mB+(hsG-0.5)*mG+(hsR-0.5)*mR))+" x - "+String(0.5/((hsB-1)*mB+(hsG-1)*mG+mR*(hsR-1)))+" *",format="Y32")
    L = Expr(Y,Llow,Lhigh, "x 0.5 <= y 0.5 <= y z ? z 0.5 > z y ? ?",format="Y32")
    
    function _HSLtoRGB_expr(float "hs") {
        #Generates a string for Expr that will apply lightness ('x') to the color component 'hs', which has been defined with Hue=hue, Sat=sat and lightness=0.5.
        return  "x 0.5 < "+String(2*hs)+" x * "+String(2*hs-1)+" "+String(2*(1-hs))+" x * + ?"
    }
    
    hslRGB =
    \ oldAvsPlus ? Expr(L, _HSLtoRGB_expr(hsG), _HSLtoRGB_expr(hsB), _HSLtoRGB_expr(hsR), format="RGBPS")
    \ : Expr(L, _HSLtoRGB_expr(hsR), _HSLtoRGB_expr(hsG), _HSLtoRGB_expr(hsB), format="RGBPS")
    
    #Workaround for https://github.com/pinterf/AviSynthPlus/issues/19
    hslYUV = hslRGB.ConvertToYUV444(matrix=matrix)
    hslYUV =
    \ c.Is420() ? hslYUV.ConvertToYUV420()
    \ : c.Is422() ? hslYUV.ConvertToYUV422()
    \ : hslYUV
    
    return hslYUV.ConvertBits(bitDepth)

}
Regarding the use of different tints at different times, I can only recommend ReplaceFramesSimple, just like manono said.

This is how I use this plugin for long videos:

Code:
yellow_string = "[74370 75293] [95035 95832] [119028 130202] [130397 149071] [149264 149353] "
\ + "[149834 149897] [151251 152684] [156962 162097] [163373 169301]"
blue_string = "[12060 21119] [59242 60450] [59242 60450] [69300 69612] "
\ + "[107635 109820] [110082 110431] [117165 117365] [117519 117662] [162103 163372]"

source_video
ReplaceFramesSimple(yellow_colored_clip, mappings=yellow_string)
ReplaceFramesSimple(blue_colored_clip, mappings=blue_string)
Cheers.

Last edited by magiblot; 27th October 2018 at 15:41. Reason: Updated HSLTint
magiblot is offline   Reply With Quote
Old 25th October 2018, 02:39   #18  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Oops, bugfix, scripts updated.

Forgot that Colors_Rgb.avsi used Global string eg "global color_aliceblue = $F0F8FF"

+ fixed bug in Kino_MakeDemoString where Len=1 and Gap=0 (Applied to whole clip).
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 25th October 2018, 14:22   #19  |  Link
color
Registered User
 
color's Avatar
 
Join Date: May 2016
Posts: 235
StainlessS: When opening KinoScript.avs I get error, what am I'm missing


magiblot: I did want to try yours also, but I got error with that to:


There should be an "complete package" with "all" plugins for avisynth.

BTW, original photo not that I used is CC0 and can be found on Pixabay.
__________________
Automatic Colorization
color is offline   Reply With Quote
Old 25th October 2018, 14:27   #20  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
First line of KinoScript.avs
Code:
# KinoScript.avs
# Req Avs+, RT_Stats
######
Looks like you may be on avs standard. (ie that line [EDIT: the error line] uses GSCript but without the GScript(""" ... """) wrapper.
Update to pinterf Avs+, its a lot nicer.
EDIT: I've used GSCript if / Else, for() etc throughout the scripts, I could re-write but very tedious and will be simple to just get avs+.

RT_Stats:- https://forum.doom9.org/showthread.p...light=rt_Stats

EDIT: Once you get avs+ and try it out, then can change to this [get Colors_RGB.avsi from your plugins folder]
Code:
ColorList_Filename = "D:\Colors_RGB.avsi"      # YOU MUST Uncomment SCMD=ORG.Kino_MakeDemoString at END of script if you use this one
#ColorList_Filename = "D:\Color_List.txt" # COMMENTED OUT
And uncomment this
Code:
SCMD=ORG.Kino_MakeDemoString(DB,Len=100,Gap=100)    # ADDED: Recreate Above SCMD with less Effort, easy test for Colors_RGB.avsi
Above will replace previously defined SCMD, and make demo using avs supplied Color_RGB.avsi, many more colors and
with standard color names.
If you just want single frame of each color, try "Len=1,Gap=0" in above line.

EDIT: Confirm that you are on avs standard, and intent for avs+.

EDIT: OOps, also requires ClipClop():- https://forum.doom9.org/showthread.p...light=clipclop

EDIT:
Code:
# KinoScript.avs
# Requirements:-
#   Avs+:-     https://github.com/pinterf/AviSynthPlus/releases
#   RT_Stats:- https://forum.doom9.org/showthread.php?t=165479&highlight=rt_stats
#   ClipClop:- https://forum.doom9.org/showthread.php?t=162266&highlight=clipclop
######
__________________
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; 25th October 2018 at 14:46.
StainlessS is offline   Reply With Quote
Reply

Tags
film tinting

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:37.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.