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 5th April 2014, 23:36   #21  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Quote:
Originally Posted by Bernardd View Post
Thanks for this new curves.
Thanks also for example script and for StrReplace function. You are master in knowledges that I have not learnt.
Thank you. I didn't write StrReplace though, I found it here: http://avisynth.nl/index.php/HDColorBars

Using it in mt_lut expressions helps readability I think, don't you?

Last edited by raffriff42; 6th April 2014 at 00:38. Reason: quote
raffriff42 is offline   Reply With Quote
Old 23rd April 2014, 22:16   #22  |  Link
Bernardd
Registered User
 
Join Date: Jan 2012
Location: Toulon France
Posts: 243
Hello RaffRiff42,

I have tried to use your curves proposal without success. I have found a difficulty, with your kind of mask. Coloryuv (autowhite=true) is not equal to
Overlay(Coloryuv (autowhite=true), mask=mask_lo).Overlay(Coloryuv (autowhite=true), mask=mask_mid).Overlay(Coloryuv (autowhite=true), mask=mask_hi).

This result, for me, is because masks are not complete black and white and thus some frame parts are filtered more once.

Thus i have rewritten my scripts with binaries masks. They are below (the second in follow post for technical thing):

Code:
function strength_Automatismes_ColorYUV(clip clip, 
                                        \ float "strength_autobalance_very_dark", float "strength_autobalance_dark",
                                        \ float "strength_autobalance_middle_dark",  float "strength_autobalance_middle", float "strength_autobalance_middle_light",
                                        \ float "strength_autobalance_light", float "strength_autobalance_very_light", float "strength_autobalance_hyper_light",
                                        \ float "strength_autogain_very_dark", float "strength_autogain_dark",
                                        \ float "strength_autogain_middle_dark",  float "strength_autogain_middle", float "strength_autogain_middle_light",
                                        \ float "strength_autogain_light", float "strength_autogain_very_light", float "strength_autogain_hyper_light",
                                        \ bool "show_displayed_help", bool "show_masks", bool "tuned_strength_autobalance_or_autogain")
{

Assert(clip.IsYUV, "CheapColorTemp: sorrce must be YUV")
    
show_displayed_help = Default(show_displayed_help, false)   
show_masks = Default(show_masks,false)
tuned_strength_autobalance_or_autogain = Default(tuned_strength_autobalance_or_autogain, true)

#--------------------------------------------- Info clip --------------------------------------------
 
ori=clip.Subtitle("original")
ori_chroma=clip.Info_Chroma().Subtitle("original")
ori_luma=clip.Info_Luma().Subtitle("original")

# -------------------------------------------------   tones masks  ------------------------------------------

very_dark=MT_Lut(clip,"x 32 <= 255 0 ?", y=3, u=1, v=1)
dark=MT_Lut(clip,"x 64 <= x 32 > & 255 0 ?", y=3,u=1, v=1)
middle_dark=MT_Lut(clip,"x 96 <= x 64 > & 255 0 ?", y=3,u=1, v=1)
middle =MT_Lut(clip,"x 128 <= x 96 > & 255 0 ?", y=3,u=1, v=1)
middle_light=MT_Lut(clip,"x 160 <= x 128 > & 255 0 ?", y=3,u=1, v=1)
light=MT_Lut(clip,"x 192 <= x 160 > & 255 0 ?", y=3,u=1, v=1)
very_light=MT_Lut(clip,"x 224 <= x 192 > & 255 0 ?", y=3,u=1, v=1)
hyper_light=MT_Lut(clip,"x 224 > 255 0 ?", y=3,u=1, v=1)

the_masks = StackHorizontal(very_dark.Subtitle("very dark tones"), dark.Subtitle("dark tones"), 
         \ middle_dark.Subtitle("dark midtons"), middle .Subtitle("midtons"), middle_light.Subtitle("light midtons"),
         \ light.Subtitle("light tones"), very_light.Subtitle("very light tones"), hyper_light.Subtitle("hyper light tones"))

#--------------------------------------------- Auto white balance tunning --------------------------------------

autobalance=clip.ColorYUV(autoWhite=true)
autobalance_info=autobalance.Info_Chroma().Subtitle("normal auto white balance")

strength_autobalance_very_dark = Default(strength_autobalance_very_dark, 1.0) # auto white balance strength on very dark tones, between 0.0 et 1.0, default 1.0
strength_autobalance_dark = Default(strength_autobalance_dark, 1.0) # auto white balance strength on dark tones, between 0.0 et 1.0, default 1.0
strength_autobalance_middle_dark = Default(strength_autobalance_middle_dark, 1.0) # auto white balance strength on dark midtones, between 0.0 et 1.0, default 1.0
strength_autobalance_middle = Default(strength_autobalance_middle, 1.0) # auto white balance strength on midtones, between 0.0 et 1.0, default 1.0
strength_autobalance_middle_light = Default(strength_autobalance_middle_light, 1.0) # auto white balance strength on light midtones, between 0.0 et 1.0, default 1.0
strength_autobalance_light = Default(strength_autobalance_light, 1.0) # auto white balance strength on light tones, between 0.0 et 1.0, default 1.0
strength_autobalance_very_light = Default(strength_autobalance_very_light, 1.0) # auto white balance strength on very light tones, between 0.0 et 1.0, default 1.0
strength_autobalance_hyper_light = Default(strength_autobalance_hyper_light, 1.0) # auto white balance strength on hyper light tones, between 0.0 et 1.0, default 1.0
# First action, auto white balance strength tunning for each tones
balance_very_dark=Overlay(clip,autobalance, opacity=strength_autobalance_very_dark, mode="chroma")
balance_dark=Overlay(clip,autobalance, opacity=strength_autobalance_dark, mode="chroma")
balance_middle_dark=Overlay(clip,autobalance, opacity=strength_autobalance_middle_dark, mode="chroma")
balance_middle=Overlay(clip,autobalance, opacity=strength_autobalance_middle, mode="chroma")
balance_middle_light=Overlay(clip,autobalance, opacity=strength_autobalance_middle_light, mode="chroma")
balance_light=Overlay(clip,autobalance, opacity=strength_autobalance_light, mode="chroma")
balance_very_light=Overlay(clip,autobalance,opacity=strength_autobalance_very_light, mode="chroma")
balance_hyper_light=Overlay(clip,autobalance,opacity=strength_autobalance_hyper_light, mode="chroma")
# Second action, patchwork with masks tones use
autobalance_mod=clip.Overlay(balance_very_dark,mask=very_dark, opacity=1.0, mode="chroma")
                               \.Overlay(balance_dark, mask=dark, opacity=1.0, mode="chroma")
                               \.Overlay(balance_middle_dark, mask=middle_dark, opacity=1.0, mode="chroma")
                               \.Overlay(balance_middle, mask=middle, opacity=1.0, mode="chroma")
                               \.Overlay(balance_middle_light, mask=middle_light, opacity=1.0, mode="chroma")
                               \.Overlay(balance_light, mask=light, opacity=1.0, mode="chroma")
                               \.Overlay(balance_very_light, mask = very_light, opacity=1.0, mode="chroma")
                               \.Overlay(balance_hyper_light, mask = hyper_light, opacity=1.0, mode="chroma")
                                                           
autobalance_mod_info=autobalance_mod.Info_Chroma().Subtitle("mod white balance")
autobalance_mod_luma=autobalance_mod.Info_Luma().Subtitle("mod white balance")

#--------------------------------------------- Autogain tunning ------------------------------------------

autogain = autobalance_mod.ColorYUV(autogain=true)
autogain_info = autogain.Info_luma().Subtitle("Autogain basique")

strength_autogain_very_dark = Default(strength_autogain_very_dark, 1.0) # autogain strength on very dark tones, between 0.0 et 1.0, default 1.0
strength_autogain_dark = Default(strength_autogain_dark, 1.0) # autogain balance strength on dark tones, between 0.0 et 1.0, default 1.0
strength_autogain_middle_dark = Default(strength_autogain_middle_dark, 1.0) # autogain balance strength on dark midtones, between 0.0 et 1.0, default 1.0
strength_autogain_middle = Default(strength_autogain_middle, 1.0) # autogain balance strength on midtones, between 0.0 et 1.0, default 1.0
strength_autogain_middle_light = Default(strength_autogain_middle_light, 1.0) # autogain balance strength on light midtones, between 0.0 et 1.0, default 1.0
strength_autogain_light = Default(strength_autogain_light, 1.0) # autogain balance strength on light tones, between 0.0 et 1.0, default 1.0
strength_autogain_very_light = Default(strength_autogain_very_light, 1.0) # autogain balance strength on very light tones, between 0.0 et 1.0, default 1.0
strength_autogain_hyper_light = Default(strength_autogain_hyper_light, 1.0) # autogain balance strength on hyper light tones, between 0.0 et 1.0, default 1.0
# First action, autogain strength tunning for each tones
gain_very_dark=Overlay(autobalance_mod,autogain, opacity=strength_autogain_very_dark, mode="luma")
gain_dark=Overlay(autobalance_mod,autogain, opacity=strength_autogain_dark, mode="luma")
gain_middle_dark=Overlay(autobalance_mod,autogain, opacity=strength_autogain_middle_dark, mode="luma")
gain_middle=Overlay(autobalance_mod,autogain, opacity=strength_autogain_middle, mode="luma")
gain_middle_light=Overlay(autobalance_mod,autogain, opacity=strength_autogain_middle_light, mode="luma")
gain_light=Overlay(autobalance_mod,autogain, opacity=strength_autogain_light, mode="luma")
gain_very_light=Overlay(autobalance_mod,autogain, opacity=strength_autogain_very_light, mode="luma")
gain_hyper_light=Overlay(autobalance_mod,autogain, opacity=strength_autogain_hyper_light, mode="luma")
# Second action, patchwork with masks tones use
autogain_mod=autobalance_mod.Overlay(gain_very_dark,mask=very_dark, opacity=1.0, mode="luma")
                          \.Overlay(gain_dark, mask=dark, opacity=1.0, mode="luma")
                          \.Overlay(gain_middle_dark, mask=middle_dark, opacity=1.0, mode="luma")
                          \.Overlay(gain_middle, mask=middle, opacity=1.0, mode="luma")
                          \.Overlay(gain_middle_light, mask=middle_light, opacity=1.0, mode="luma")
                          \.Overlay(gain_light, mask=light, opacity=1.0, mode="luma")
                          \.Overlay(gain_very_light, mask = very_light, opacity=1.0, mode="luma")
                          \.Overlay(gain_hyper_light, mask = hyper_light, opacity=1.0, mode="luma")

autogain_mod_info = autogain_mod.Info_luma().Subtitle("Autogain ajusté")

#------------------------------------------- Results

(show_displayed_help == true) ? ((show_masks == true) ? the_masks : 
\ ((tuned_strength_autobalance_or_autogain == true) ? StackHorizontal (ori_chroma,autobalance_info,autobalance_mod_info) :
\ StackHorizontal (autobalance_mod_luma,autogain_info.Histogram("levels"),autogain_mod_info.Histogram("levels")))):
\autogain_mod
return last
}

# ---------------------------------------- Info function

function Info_chroma(clip c)
{
c.ScriptClip("""
    acu = AverageChromaU()
    acv = AverageChromaV()
    Subtitle("127-U = " + String(127-acu),y=20)    
    Subtitle("127-V = " + String(127-acv),y=40)
   
    Subtitle("U and V average = " + String((acu+acv)/2),y=60)
""")
return last
}

function Info_luma(clip c)
{
c.ScriptClip("""
    aly = AverageLuma()
    Subtitle("AverageLuma = " + String(aly),y=40)
""")
return last
}

__End__

[Auto white balance and Autogain tunning =1]

LoadPlugin("C:\..........\masktools-v2.0a48\mt_masktools-25.dll")

Import("C:\..........\ColorYUV auto functions strength tune.avs")

[< separator="Auto function tunning beginning">]
show = [<"show help displays (no = 0 et yes = 1)", 0, 1, 1>]
compare_masque=[<"shows tones masks", 0, 1, 0>]
autobalance_or_autogain = [<"tune auto white balance (0) or autogain(1)", 0, 1, 0>]

show_displayed_help  = (show == 1) ? true : false
tuned_strength_autobalance_or_autogain = (autobalance_or_autogain == 0) ? true : false
show_masks = (compare_masque == 1) ? true : false

[< separator="Auto white balance strength tunning">]
strength_autobalance_very_dark = [<"auto white balance strength on very dark tones", 0.0, 1.0, 1.0>]
strength_autobalance_dark = [<"auto white balance strength on dark tones", 0.0, 1.0, 1.0>]
strength_autobalance_middle_dark = [<"auto white balance strength on dark midtones", 0.0, 1.0, 1.0>]
strength_autobalance_middle = [<"auto white balance strength on midtones", 0.0, 1.0, 1.0>]
strength_autobalance_middle_light = [<"auto white balance strength on light midtones", 0.0, 1.0, 1.0>]
strength_autobalance_light = [<"auto white balance strength on light tones", 0.0, 1.0, 1.0>]
strength_autobalance_very_light = [<"auto white balance strength on very light tones", 0.0, 1.0, 1.0>]
strength_autobalance_hyper_light = [<"auto white balance strength on hyper light tones", 0.0, 1.0, 1.0>]

[< separator="Autogain strength tunning">]
strength_autogain_very_dark = [<"autogain strength on very dark tones", 0.0, 1.0, 1.0>]
strength_autogain_dark = [<"autogain strength on dark tones", 0.0, 1.0, 1.0>]
strength_autogain_middle_dark = [<"autogain strength on dark midtones", 0.0, 1.0, 1.0>]
strength_autogain_middle = [<"autogain strength on midtones", 0.0, 1.0, 1.0>]
strength_autogain_middle_light = [<"autogain strength on light midtones", 0.0, 1.0, 1.0>]
strength_autogain_light = [<"autogain strength on light tones", 0.0, 1.0, 1.0>]
strength_autogain_very_light = [<"autogain strength on very light tones", 0.0, 1.0, 1.0>]
strength_autogain_hyper_light = [<"autogain strength on hyper light tones", 0.0, 1.0, 1.0>]

strength_Automatismes_ColorYUV(strength_autobalance_very_dark =strength_autobalance_very_dark, strength_autobalance_dark = strength_autobalance_dark,
\ strength_autobalance_middle_dark = strength_autobalance_middle_dark,  strength_autobalance_middle = strength_autobalance_middle, strength_autobalance_middle_light = strength_autobalance_middle_light,
\ strength_autobalance_light = strength_autobalance_light, strength_autobalance_very_light = strength_autobalance_very_light, strength_autobalance_hyper_light = strength_autobalance_hyper_light,
                          \strength_autogain_very_dark =strength_autogain_very_dark, strength_autogain_dark = strength_autogain_dark,
\ strength_autogain_middle_dark = strength_autogain_middle_dark,  strength_autogain_middle = strength_autogain_middle, strength_autogain_middle_light = strength_autogain_middle_light,
\ strength_autogain_light = strength_autogain_light, strength_autogain_very_light = strength_autogain_very_light, strength_autogain_hyper_light = strength_autogain_hyper_light,
                           \ show_displayed_help = show_displayed_help, show_masks=show_masks, tuned_strength_autobalance_or_autogain = tuned_strength_autobalance_or_autogain)
                           
[/Auto white balance and Autogain tunning]

But i have always the same problem. The differents Coloryuv (autowhite=true) masked overlayed addition is nearest but not equal to the ordinary Coloryuv (autowhite=true).
I do not know why. Have you an ideas ?

Thanks
Bernardd is offline   Reply With Quote
Old 23rd April 2014, 22:25   #23  |  Link
Bernardd
Registered User
 
Join Date: Jan 2012
Location: Toulon France
Posts: 243
Fo my second script, the text that I have entered is too long (28923 characters). thus i send a file.
Attached Files
File Type: txt RGB colors_tune.txt (54.3 KB, 72 views)
Bernardd is offline   Reply With Quote
Old 27th November 2014, 19:01   #24  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
Very interesting !
.
__________________
Warm and fuzzy (white and fluffy)
Jenyok is offline   Reply With Quote
Old 27th November 2014, 21:51   #25  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Quote:
Originally Posted by raffriff42 View Post
I took this image and carefully measured the graph values at red, green and blue (estimated from the rainbow bar at the bottom)
why would you- I don't even...

dude
you realize that image was created by graphing an equation, right? you can have the exact answer for any wavelength and temperature by just asking wolframalpha, jeez

Last edited by TheFluff; 27th November 2014 at 21:57.
TheFluff is offline   Reply With Quote
Old 27th November 2014, 22:22   #26  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
dude
Yes, I knew about teh equationz.
raffriff42 is offline   Reply With Quote
Reply

Tags
colour temperature, manual white balance, rgb, white balance, yuv

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 13:58.


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