• 社区 —频道 春城壹网 七彩云南 一网天下 2019-06-15
  • 全国网络举报工作会议 2019-06-15
  • 珍贵!“国宝”林麝现身重庆金佛山 2019-06-11
  • 亚冠前瞻:恒大权健皆不容有失 两将伤情成上港争胜关键 2019-06-09
  • 端午节回归传统习俗 西安市民排队买艾草端午节艾叶-要闻 2019-06-09
  • 湖州唤醒“沉睡”的土地 2019-06-01
  • 在美中国留学生江玥被枪杀案宣判 罪犯获刑25年 2019-05-31
  • 日本大阪6.1级强震4死逾300伤 工厂及店铺恢复运营 2019-05-31
  • 台湾“裤子大王”:百姓三餐不济谈啥“台湾价值” 2019-05-23
  • 韩国釜山海滩变“垃圾场” 清洁工叫苦不堪 2019-05-23
  • 浙江宣讲十九大:之江大地“好声音”“红船”精神入人心 2019-05-19
  • “回天地区”下月开放千套人才公寓 ——凤凰网房产北京 2019-05-13
  • 中国智能手机在东南亚受追捧 2019-04-25
  • 阜阳网络达人“点赞”颍泉绿化提升专项工作 2019-04-23
  • 《国家人文历史》往期杂志汇总 2019-04-22
  • Welcome to

    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 15th March 2019, 22:55   #1  |  Link
    Registered User
     
    Join Date: Feb 2013
    Posts: 161
    Gamma settings - in YUV with preservation of saturation

    How to set gamma correctly in YUV, without convert to RGB (less rounding errors, without banding)

    Code:
    levels(0,1.32,255,0,255)
    tweak(sat...)
    dark parts are desaturated, light ones are oversaturated...


    The right way but converting to RGB:

    Code:
    converttorgb32
    levels(0,1.32,255,0,255)
    converttoyv12
    or the same:

    Code:
    converttorgb32
    RGBAdjust(rg=...,gg =...,bg=...)
    converttoyv12

    There are 2 ways:

    1) convert to "deeper bit" (or float) RGB -> change gamma -> convert back to YUV (slow)


    2) make it all "in one step" = stay in YUV:

    a) change gamma in luma
    b) change "saturation" of chroma "adaptively", in relation to each pixel value of luma (lower luma means higher saturation lost by gamma change)

    something like this (but it's still not ok):

    Code:
    y = converttoy8()
    u = utoy8()
    v = vtoy8()
    
    y_adjusted = mt_lut("x 16 - 219 / 1 1.32 / ^ 219 * 16 +", chroma="copy")
    y_scaled   = y.bilinearresize(width(u),height(u))
    u_adjusted = mt_lutxy(u,y_scaled,"x 128 - y 16 - 219 / 1 1.32 / ^ 219 * 16 + y / * 128 +")
    v_adjusted = mt_lutxy(v,y_scaled,"x 128 - y 16 - 219 / 1 1.32 / ^ 219 * 16 + y / * 128 +")
    
    ytouv(u_adjusted,v_adjusted,y_adjusted)

    In a nutshell:

    We take the gamma adjusted luma value of each pixel and divide it by the original luma value of each pixel.
    This gives a coefficient for each pixel to multiply the saturation adjustment according to the gamma change.
    The greater the luma change, the greater the saturation lost.

    Last edited by Stormborec; 17th March 2019 at 14:01.
    Stormborec is offline   Reply With Quote
    Old 16th March 2019, 02:22   #2  |  Link
    Registered User
     
    Join Date: Jul 2011
    Location: Tennessee, USA
    Posts: 263
    Quote:
    Originally Posted by Stormborec View Post
    Code:
    converttorgb32
    RGBAdjust(rg=...,gg =...,bg=...)
    converttoyv12
    Above is the only example that affects chroma's gamma. The others affect only luma's gamma. gamma_u and gamma_v have no effect -- which is clearly stated in the system documentation for ColorYUV:
    Quote:
    gamma adjusts gamma of the specified channel. A value of 0 is the same as gamma 1.0. When the value is set to 256 it is the same as gamma 2.0. The value is valid down to -256, where it is the same as gamma 0.0. Note: gamma for chroma is not implemented (gamma_u and gamma_v are dummy parameters).
    So, which gamma are you trying to work with? luma in YUV or chroma in RGB? In YUV, luma and chroma are stored separately. In RGB, "color" and "brightness" are integral.
    LemMotlow is offline   Reply With Quote
    Old 16th March 2019, 08:47   #3  |  Link
    Registered User
     
    Join Date: Feb 2013
    Posts: 161
    Quote:
    So, which gamma are you trying to work with? luma in YUV or chroma in RGB?
    In YUV (thus without color space conversion) but with the same result like in RGB...
    Stormborec is offline   Reply With Quote
    Old 16th March 2019, 10:38   #4  |  Link
    HeartlessS Usurer
     
    StainlessS's Avatar
     
    Join Date: Dec 2009
    Location: Over the rainbow
    Posts: 6,742
    Well I know that you are familiar with ColorYUV2 (as you have posted about it before), but here anyways in case you forgot:- //www.zs-x.com/showthread.p...ight=colorYUV2

    Groucho also has 64 bit build of it, in his stuff.



    Also RgbAdapt has RPow/SPow stuff. //www.zs-x.com/showthread.p...light=RgbAdapt




    EDIT: And demo of the iMin, iMax, OMin, OMax stuff (mask creation or whatever) [EDIT: Grid turned off].


    EDIT: Also, VirtualDub2 has some kind of 6 axis RGB adjustment function thingy.

    EDIT:
    Quote:
    In YUV (thus without color space conversion) but with the same result like in RGB...
    Nobody knows how to do it properley in YUV, Gamma is an RGB concept.
    __________________
    I sometimes post sober.
    [email protected] ::: AND/OR ::: [email protected]

    "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

    Last edited by StainlessS; 16th March 2019 at 21:33.
    StainlessS is offline   Reply With Quote
    Old 16th March 2019, 11:13   #5  |  Link
    Registered User
     
    Join Date: Feb 2013
    Posts: 161
    These tools can calculate proper values e.g. from RGBAdjust to ColorYUV ?
    Stormborec is offline   Reply With Quote
    Old 16th March 2019, 11:20   #6  |  Link
    HeartlessS Usurer
     
    StainlessS's Avatar
     
    Join Date: Dec 2009
    Location: Over the rainbow
    Posts: 6,742
    Nobody knows how to do it properley in YUV, Gamma is an RGB concept.
    __________________
    I sometimes post sober.
    [email protected] ::: AND/OR ::: [email protected]

    "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
    StainlessS is offline   Reply With Quote
    Reply

    Tags
    gamma correction


    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 14:06.


    Powered by vBulletin® Version 3.8.11
    Copyright ©2000 - 2019, vBulletin Solutions Inc.
  • 社区 —频道 春城壹网 七彩云南 一网天下 2019-06-15
  • 全国网络举报工作会议 2019-06-15
  • 珍贵!“国宝”林麝现身重庆金佛山 2019-06-11
  • 亚冠前瞻:恒大权健皆不容有失 两将伤情成上港争胜关键 2019-06-09
  • 端午节回归传统习俗 西安市民排队买艾草端午节艾叶-要闻 2019-06-09
  • 湖州唤醒“沉睡”的土地 2019-06-01
  • 在美中国留学生江玥被枪杀案宣判 罪犯获刑25年 2019-05-31
  • 日本大阪6.1级强震4死逾300伤 工厂及店铺恢复运营 2019-05-31
  • 台湾“裤子大王”:百姓三餐不济谈啥“台湾价值” 2019-05-23
  • 韩国釜山海滩变“垃圾场” 清洁工叫苦不堪 2019-05-23
  • 浙江宣讲十九大:之江大地“好声音”“红船”精神入人心 2019-05-19
  • “回天地区”下月开放千套人才公寓 ——凤凰网房产北京 2019-05-13
  • 中国智能手机在东南亚受追捧 2019-04-25
  • 阜阳网络达人“点赞”颍泉绿化提升专项工作 2019-04-23
  • 《国家人文历史》往期杂志汇总 2019-04-22
  • 15选5走势图体坛网 河南22选5开奖结果239 5分pk10计划软件 明日之后三层别墅样图 我叫mt4级符文 新疆时时彩三星和值走势图彩经网 彩票预测官方网 吉林11选5历史开奖记录 小小瓷围棋罐 老11选5开奖结果乐彩 网络时时彩计划员 三国全面战争1.99.5下载 完美世界手游兑换码在哪 足球明星 白狮子核桃 35选7走势图1000期