使用FFmpeg对图像进行调色-colorchannelmixer

前面介绍过两种调色的滤镜之后,相信大家对调色也有了一点认知,并且也能做一些并不是很艺术的技术化的调色了,这回再介绍一个调色滤镜,colorchannelmixer,看滤镜名称很显然是做色彩通道混合用的滤镜,例如在红色通道增加绿色增益、蓝色增益、红色增益、alpha增益的,下面看一下参数说明。


StevenLiu:ffmpeg StevenLiu$ ffmpeg -hide_banner -h filter=colorchannelmixer
Filter colorchannelmixer
  Adjust colors by mixing color channels.
    slice threading supported
    Inputs:
       #0: default (video)
    Outputs:
       #0: default (video)
colorchannelmixer AVOptions:
  rr                <double>     ..FV..... set the red gain for the red channel (from -2 to 2) (default 1)
  rg                <double>     ..FV..... set the green gain for the red channel (from -2 to 2) (default 0)
  rb                <double>     ..FV..... set the blue gain for the red channel (from -2 to 2) (default 0)
  ra                <double>     ..FV..... set the alpha gain for the red channel (from -2 to 2) (default 0)
  gr                <double>     ..FV..... set the red gain for the green channel (from -2 to 2) (default 0)
  gg                <double>     ..FV..... set the green gain for the green channel (from -2 to 2) (default 1)
  gb                <double>     ..FV..... set the blue gain for the green channel (from -2 to 2) (default 0)
  ga                <double>     ..FV..... set the alpha gain for the green channel (from -2 to 2) (default 0)
  br                <double>     ..FV..... set the red gain for the blue channel (from -2 to 2) (default 0)
  bg                <double>     ..FV..... set the green gain for the blue channel (from -2 to 2) (default 0)
  bb                <double>     ..FV..... set the blue gain for the blue channel (from -2 to 2) (default 1)
  ba                <double>     ..FV..... set the alpha gain for the blue channel (from -2 to 2) (default 0)
  ar                <double>     ..FV..... set the red gain for the alpha channel (from -2 to 2) (default 0)
  ag                <double>     ..FV..... set the green gain for the alpha channel (from -2 to 2) (default 0)
  ab                <double>     ..FV..... set the blue gain for the alpha channel (from -2 to 2) (default 0)
  aa                <double>     ..FV..... set the alpha gain for the alpha channel (from -2 to 2) (default 1)

This filter has support for timeline through the 'enable' option.

调整视频色彩的话,设置这些参数之后,有一个计算的公式:

红色部分:

red=red*rr + blue*rb + green*rg + alpha*ra

绿色部分:

green=red*gr + blue*gb + green*gg + alpha*ga

蓝色部分:

blue=red*br + blue*bb + green*bg + alpha*ba

Alpha部分:

alpha=red*ar + blue*ab + green*ag + alpha*aa

公式了解过了,下面看一下设一下测试的值,看看效果,首先还是拿开放版权的视频测试,争取不侵权,看一下原图像是什么样的。

图片

图像看上去挺棒的,一切正常,那么我们先调一下红色通道部分,看一下会变成什么样。

ffplay  -vf colorchannelmixer=rr=0.393:rg=0.769:rb=0.189:ra=0 graded_edit_final_00668.png

看一下效果

图片

颜色整体稍微偏褐色那么了一点,看来是有效果。如果把整体调整得大红色,可以试着这么干,把green和blue通道全部设置0,红色通道全部最大:

ffplay  -vf colorchannelmixer=rr=2:rg=2:rb=2:ra=0:gr=0:gg=0:gb=0:br=0:bg=0:bb=0 graded_edit_final_00668.png

看一下效果,确认一下是不是如我们所设置的值对应:

图片

当然,如果这只偏蓝色一点的话,可以这么设置:

ffplay  -vf colorchannelmixer=br=0.393:bg=0.769:bb=0.189:ba=0 graded_edit_final_00668.png

看一下效果:

图片

做一些基本的调色,用colorchannelmixer基本上可以做到微调色了,效果能好很多。

至于调API设置,可以参考《使用 FFmpeg 实现画中画效果

方法都是相通的。

这一次就介绍到这里,更多的colorchannelmixer的使用方式欢迎随时交流。

作者:悟空 公众号:流媒体技术

版权声明:本文内容转自互联网,本文观点仅代表作者本人。本站仅提供信息存储空间服务,所有权归原作者所有。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至1393616908@qq.com 举报,一经查实,本站将立刻删除。

(0)

相关推荐

发表回复

登录后才能评论