 |
| GimpChat Member |
Joined: Feb 08, 2014 Posts: 26
|
It works nicely! Thanks a lot! Here's the filter: # Color Grading v1.5.3 # Copyright (c) 2012-2014 John Lakkas # [email protected] # Licence: GNU GPLv3 ( http://www.gnu.org/licenses/ )
# HSV conversions taken from libgimpcolor/gimphsv.c # LIBGIMP - The GIMP Library # Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
# Saturation kindly provided from # David Tschumperlé
rgb_to_hsv : # * gimp_rgb_to_hsv4: # * @rgb: RGB triplet, rgb[0] is red channel, rgb[1] is green, # * rgb[2] is blue (0..255) # * @hue: Pointer to hue channel (0..1) # * @saturation: Pointer to saturation channel (0..1) # * @value: Pointer to value channel (0..1)
#double red, green, blue; #double h, s, v; #double min, max; #double delta;
#double hue; #double saturation; #double value;
_red={$1/255.0} _green={$2/255.0} _blue={$3/255.0} # Shut up -Wall _h=0.0
-if {$_red>$_green} _maxc={max($_red,$_blue)} _minc={min($_green,$_blue)} -else _maxc={max($_green,$_blue)} _minc={min($_red,$_blue)} -endif _v=$_maxc
-if {$_maxc!=0.0} _s={($_maxc-$_minc)/$_maxc} -else _s=0.0 -endif
-if {$_s==0.0} _h=0.0 -else _delta={$_maxc-$_minc}
-if ($_delta==0.0): _delta=1.0 -endif
-if {$_red==$_maxc} _h={($_green-$_blue)/$_delta} -elif {$_green==$_maxc} _h={2+($_blue-$_red)/$_delta} -elif {$_blue==$_maxc} _h={4+($_red-$_green)/$_delta} -endif
_h={$_h/6.0}
-if {$_h<0.0} _h=$_h+1.0 -elif ($_h>1.0) _h=$_h-1.0 -endif -endif
#hue = h #saturation = s #value = v -status $_h,$_s,$_v -return
hsv_to_rgb : # * gimp_hsv_to_rgb4: # * @rgb: RGB triplet, rgb[0] is red channel, rgb[1] is green, # * rgb[2] is blue (0..255) # * @hue: Hue channel (0..1) # * @saturation: Saturation channel (0..1) # * @value: Value channel (0..1) #double h, s, v; #double f, p, q, t;
_hue=$1 _saturation=$2 _value=$3
-if {$_saturation==0.0} _hue=$_value _saturation=$_value #value = value -else _h={$_hue*6.0} _s=$_saturation _v=$_value
-if {$_h==6.0} _h=0.0 -endif
_f={$_h-int($_h)} _p={$_v*(1.0-$_s)} _q={$_v*(1.0-$_s*$_f)} _t={$_v*(1.0-$_s*(1.0-$_f))}
-if {int($_h)==0} _hue=$_v _saturation=$_t _value=$_p -elif {int($_h)==1} _hue=$_q _saturation=$_v _value=$_p -elif {int($_h)==2} _hue=$_p _saturation=$_v _value=$_t -elif {int($_h)==3} _hue=$_p _saturation=$_q _value=$_v -elif {int($_h)==4} _hue=$_t _saturation=$_p _value=$_v -elif {int($_h)==5} _hue=$_v _saturation=$_p _value=$_q -endif -endif
#return rgb -status {round($_hue*255.0)},{round($_saturation*255.0)},{round($_value*255.0)}
# LEVELS input low-high gamma output low/high levels : _inplow={int($1)} _inphigh={int($2)} _gamma=$3 _outlow={int($4)} _outhigh={int($5)} _tmp2="" -if {$_gamma!=1} _tmp2="-apply_gamma "$_gamma -apply_channels $_tmp2,$6,0 -endif _curve1="0," -if {$_inplow>0} _tmp1="0," _curve1=$_curve1$_tmp1$_outlow"," -endif _curve1=$_curve1$_inplow","$_outlow","$_inphigh","$_outhigh -if {$_inphigh<255} _curve1=$_curve1",255,"$_outhigh -endif -echo "levels:"$_curve1 -if {$_curve1'!='"0,0,0,255,255"} #-apply_curve $_curve1 #-apply_curve 0,100,100,200,200 _tmp2="-apply_curve "$_curve1 -echo $tmp2 -apply_channels $_tmp2,$6,0 -endif
gimp_equalize_s : -repeat @# -l[$>] -split_opacity -l[0] -to_rgb -rgb2hsv -sh 1,1 -*[-1] $1 -+[-1] $2 -c[-1] 0,1 -rm[-1] -hsv2rgb -endl -a c -endl -done
#@gimp Color Grading : colorgradingmain, colorgradingmain #@gimp : note = note("Basic photo editing and Color Grading.") #@gimp : sep = separator() #@gimp : Cool / Warm = int(0,-50,50) #@gimp : Saturation = float(1,0.1,3) #@gimp : sep = separator() #@gimp : S Curve Contrast = int(0,-30,30) #@gimp : Shadows = int(0,-50,50) #@gimp : Highlights = int(0,-50,50) #@gimp : Blacks = int(0,0,50) #@gimp : Bightness = int(0,-50,50) #@gimp : Contrast = int(0,-50,50) #@gimp : Gamma = float(1,0.1,3) #@gimp : sep = separator() #@gimp : Local Contrant Enhance = float(0,0,3) #@gimp : Tone Map = bool(0) #@gimp : Tone Map Strength = float(0.75,0.55,1) #@gimp : sep = separator() #@gimp : Color Grading = bool(0) #@gimp : Highlights Color Intensity = int(70,0,130) #@gimp : Highlights Hue = int(0,0,360) #@gimp : Highlights Bightness = int(0,-100,100) #@gimp : sep = separator() #@gimp : Midtones Color Intensity = int(0,0,130) #@gimp : Midtones Hue = int(0,0,360) #@gimp : Midtones Bightness = int(0,-100,100) #@gimp : sep = separator() #@gimp : Shadows Color Intensity = int(70,0,130) #@gimp : Shadows Hue Offset = int(180,0,360) #@gimp : Shadows Bightness = int(0,-100,100) #@gimp : sep = separator() #@gimp : Output Saturation = float(1,0,2) #@gimp : sep = separator() #@gimp : note = note("S Curve is Shadows and Highlights control in one slider. Avoid using Local Contrant and Tone Mapping together because of doing similar things so both over process images.") #@gimp : sep = separator(), note = note("<small>Author: <i>John Lakkas</i>. Latest update: <i>2014/02/12</i>.</small>")
colorgradingmain : _ystr="" # COLOR MANIPULATION # COOL / WARM filter -if {$1>0} _mymin={$1} _mymax={255-$1} -apply_channels "-apply_curve 0,0,$_mymin,255,255",6,0 -apply_channels "-apply_curve 0,0,0,255,$_mymax",5,0 -endif -if {$1<0} _mymin={-$1} _mymax={255+$1} -apply_channels "-apply_curve 0,0,$_mymin,255,255",5,0 -apply_channels "-apply_curve 0,0,0,255,$_mymax",6,0 -endif
# HSV SATURATION (gamma) -if {$2!=1.0} -apply_channels "-apply_gamma $2",12,0 -endif # VALUE MANIPULATION # S CURVE -if {$3!=0} _p1={64-$3} _p2={192+$3} #-apply_channels "-apply_curve 1,0,0,64,$_p1,192,$_p2,255,255",13,0 _ystr=$_ystr" -apply_curve 1,0,0,64,$_p1,192,$_p2,255,255" -endif
# SHADOWS -if {$4!=0} _p3={64-$4} #-apply_channels "-apply_curve 1,0,0,64,$_p3,128,128,192,192,255,255",13,0 _ystr=$_ystr" -apply_curve 1,0,0,64,$_p3,128,128,192,192,255,255" -endif
# HIGHLIGHTS -if {$5!=0} _p4={192+$5} #-apply_channels "-apply_curve 1,0,0,64,64,128,128,192,$_p4,255,255",13,0 _ystr=$_ystr" -apply_curve 1,0,0,64,64,128,128,192,$_p4,255,255" -endif # BLACKS -if {$6>0} #-apply_channels "-apply_curve 1,$6,0,64,64,255,255",13,0 _ystr=$_ystr" -apply_curve 1,$6,0,64,64,255,255" -endif # BRIGHTNESS -if {$7>0} _p5=0 #-apply_channels "-apply_curve 0,0,$7,255,255",13,0 _ystr=$_ystr" -apply_curve 0,0,$7,255,255" -endif -if {$7<0} _p5={255+$7} #-apply_channels "-apply_curve 0,0,0,255,$_p5",13,0 _ystr=$_ystr" -apply_curve 0,0,0,255,$_p5" -endif # CONTRAST -if {$8>0} _p6=$8 _p7={255-$8} -echo $_p7 #-apply_channels "-apply_curve 0,0,0,$_p6,0,$_p7,255,255,255",13,0 _ystr=$_ystr" -apply_curve 0,0,0,$_p6,0,$_p7,255,255,255" -endif -if {$8<0} _p6={-$8} _p7={255+$8} #-apply_channels "-apply_curve 0,0,$_p6,255,$_p7",13,0 _ystr=$_ystr" -apply_curve 0,0,$_p6,255,$_p7" -endif # GAMMA -if {$9!=1.0} #-apply_channels "-apply_gamma $9",13,0 _ystr=$_ystr" -apply_gamma $9" -endif # LOCAL CONTRAST (unsharp mask) -if {$10>0} #-apply_channels "-unsharp 20,$10,0",13,0 _ystr=$_ystr" -unsharp 20,$10,0" -endif # TONE MAPPING -if {$11} #-apply_channels "-map_tones 0.5,$12,0.1,30",13,0 _ystr=$_ystr" -map_tones 0.5,$12,0.1,30" -endif # APPLY VALUE PROCESSING -if {$_ystr'!='""} -apply_channels $_ystr,13,0 #-apply_channels "-apply_gamma 3",13,0 -endif
# Color Grading -if {$13} -if {$15+$21>360} _shh={($15+$21-360)/360} -else _shh={($15+$21)/360} -endif _shs={$20/100} _shlev={$22} _midh={$18/360} _mids={$17/100} _midlev={$19} _highh={$15/360} _highs={$14/100} _highlev={$16} _satlev={$23} -color_grade $_shh,$_shs,$_shlev,$_midh,$_mids,$_midlev,$_highh,$_highs,$_highlev,$_satlev #-apply_channels "-apply_gamma $_satlev",12,0 -endif -if {$23!=1.0} -gimp_equalize_s $23,0 -endif
color_grade : #convert_to_levels : # input: # shh, shs, shlev, midh, mids, midlev, highh, highs, highlev, satlev
_shadownrgb=@{-hsv_to_rgb" "$1,1.0,{$2*0.40}} _midtonesrgb=@{-hsv_to_rgb" "$4,1.0,{$5*0.40}} _highlightsrgb=@{-hsv_to_rgb" "$7,1.0,{$8*0.40}} # make: # crsh, mgsh, ybsh, shlev, crmid, mgmid, ybmid, midlev, crhigh, mghigh, ybhigh, highlev, satlev _crsh=@{-arg" 1,"$_shadownrgb} _mgsh=@{-arg" 2,"$_shadownrgb} _ybsh=@{-arg" 3,"$_shadownrgb} _shlev=$3 _crmid=@{-arg" 1,"$_midtonesrgb} _mgmid=@{-arg" 2,"$_midtonesrgb} _ybmid=@{-arg" 3,"$_midtonesrgb} _midlev=$6 _crhigh=@{-arg" 1,"$_highlightsrgb} _mghigh=@{-arg" 2,"$_highlightsrgb} _ybhigh=@{-arg" 3,"$_highlightsrgb} _highlev=$9 _satlev=$10 _lowinred=0 _hiinred=255 _lowingreen=0 _hiingreen=255 _lowinblue=0 _hiinblue=255 _gammared=0. _gammagreen=0. _gammablue=0. _lowoutred=0 _hioutred=255 _lowoutgreen=0 _hioutgreen=255 _lowoutblue=0 _hioutblue=255
#MIDTONES -if {$_crmid>0.} _gammared={$_gammared+0.4*$_crmid/100.} _gammagreen={$_gammagreen-0.3*$_crmid/100.} _gammablue={$_gammablue-0.3*$_crmid/100.} -endif -if {$_crmid<0.} _gammared={$_gammared+0.3*$_crmid/100.} _gammagreen={$_gammagreen-0.4*$_crmid/100.} _gammablue={$_gammablue-0.4*$_crmid/100.} -endif -if {$_mgmid>0.} _gammared={$_gammared-0.3*$_mgmid/100.} _gammagreen={$_gammagreen+0.4*$_mgmid/100.} _gammablue={$_gammablue-0.3*$_mgmid/100.} -endif -if {$_mgmid<0.} _gammared={$_gammared-0.4*$_mgmid/100.} _gammagreen={$_gammagreen+0.3*$_mgmid/100.} _gammablue={$_gammablue-0.4*$_mgmid/100.} -endif -if {$_ybmid>0.} _gammared={$_gammared-0.3*$_ybmid/100.} _gammagreen={$_gammagreen-0.3*$_ybmid/100.} _gammablue={$_gammablue+0.4*$_ybmid/100.} -endif -if {$_ybmid<0.} _gammared={$_gammared-0.4*$_ybmid/100.} _gammagreen={$_gammagreen-0.4*$_ybmid/100.} _gammablue={$_gammablue+0.3*$_ybmid/100.} -endif _gammared={$_gammared+1.} _gammagreen={$_gammagreen+1.} _gammablue={$_gammablue+1.} -if {$_midlev>0.} _gammared={$_gammared+0.4*$_midlev/100.} _gammagreen={$_gammagreen+0.4*$_midlev/100.} _gammablue={$_gammablue+0.4*$_midlev/100.} -endif -if {$_midlev<0.} _gammared={$_gammared+0.3*$_midlev/100.} _gammagreen={$_gammagreen+0.3*$_midlev/100.} _gammablue={$_gammablue+0.3*$_midlev/100.} -endif #SHADOWS _crsh={$_crsh*0.3} _mgsh={$_mgsh*0.3} _ybsh={$_ybsh*0.3} -if {$_crsh>0} _lowingreen={$_lowingreen+$_crsh} _lowinblue={$_lowinblue+$_crsh} _lowoutred={$_lowoutred+$_crsh} -else _lowinred={$_lowinred-$_crsh} _lowoutgreen={$_lowoutgreen-$_crsh} _lowoutblue={$_lowoutblue-$_crsh} -endif -if {$_mgsh>0} _lowinred={$_lowinred+$_mgsh} _lowinblue={$_lowinblue+$_mgsh} _lowoutgreen={$_lowoutgreen+$_mgsh} -else _lowingreen={$_lowingreen-$_mgsh} _lowoutred={$_lowoutred-$_mgsh} _lowoutblue={$_lowoutblue-$_mgsh} -endif -if {$_ybsh>0} _lowinred={$_lowinred+$_ybsh} _lowingreen={$_lowingreen+$_ybsh} _lowoutblue={$_lowoutblue+$_ybsh} -else _lowinblue={$_lowinblue-$_ybsh} _lowoutred={$_lowoutred-$_ybsh} _lowoutgreen={$_lowoutgreen-$_ybsh} -endif -if {$_shlev>0} _lowoutred={$_lowoutred+$_shlev} _lowoutgreen={$_lowoutgreen+$_shlev} _lowoutblue={$_lowoutblue+$_shlev} -endif -if {$_shlev<0} _lowinred={$_lowinred-$_shlev} _lowingreen={$_lowingreen-$_shlev} _lowinblue={$_lowinblue-$_shlev} -endif #HIGHLIGHTS _crhigh={$_crhigh*0.3} _mghigh={$_mghigh*0.3} _ybhigh={$_ybhigh*0.3} -if {$_crhigh>0} _hiinred={$_hiinred-$_crhigh} _hioutgreen={$_hioutgreen-$_crhigh} _hioutblue={$_hioutgreen-$_crhigh} -else _hiingreen={$_hiingreen+$_crhigh} _hiinblue={$_hiinblue+$_crhigh} _hioutred={$_hioutred+$_crhigh} -endif -if {$_mghigh>0} _hiingreen={$_hiingreen-$_mghigh} _hioutred={$_hioutred-$_mghigh} _hioutblue={$_hioutblue-$_mghigh} -else _hiinred={$_hiinred+$_mghigh} _hiinblue={$_hiinblue+$_mghigh} _hioutgreen={$_hioutgreen+$_mghigh} -endif -if {$_ybhigh>0} _hiinblue={$_hiinblue-$_ybhigh} _hioutred={$_hioutred-$_ybhigh} _hioutgreen={$_hioutgreen-$_ybhigh} -else _hiinred={$_hiinred+$_ybhigh} _hiingreen={$_hiingreen+$_ybhigh} _hioutblue={$_hioutblue+$_ybhigh} -endif -if {$_highlev>0} _hiinred={$_hiinred-$_highlev} _hiingreen={$_hiingreen-$_highlev} _hiinblue={$_hiinblue-$_highlev} -endif -if {$_highlev<0} _hioutred={$_hioutred+$_highlev} _hioutgreen={$_hioutgreen+$_highlev} _hioutblue={$_hioutblue+$_highlev} -endif #return # [[lowinred, hiinred, gammared, lowoutred, hioutred] # [lowingreen, hiingreen, gammagreen, lowoutgreen, hioutgreen] # [lowinblue, hiinblue, gammablue, lowoutblue, hioutblue], [satlev]] #-apply_channels "-levels "$_lowinred","$_hiinred","$_gammared","$_lowoutred","$_hioutred,19,0 #-apply_channels "-levels "$_lowingreen","$_hiingreen","$_gammagreen","$_lowoutgreen","$_hioutgreen,20,0 #-apply_channels "-levels "$_lowinblue","$_hiinblue","$_gammablue","$_lowoutblue","$_hioutblue,21,0 -levels $_lowinred,$_hiinred,$_gammared,$_lowoutred,$_hioutred,19 -levels $_lowingreen,$_hiingreen,$_gammagreen,$_lowoutgreen,$_hioutgreen,20 -levels $_lowinblue,$_hiinblue,$_gammablue,$_lowoutblue,$_hioutblue,21 #-if {$_satlev!=1.0} # #-apply_channels "-apply_gamma $_satlev",12,0 # -gimp_equalize_s $_satlev,0 #-endif
|
|