It is currently Wed Apr 24, 2024 10:50 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Saturation filter
PostPosted: Wed Feb 12, 2014 7:33 am  (#1) 
Offline
GimpChat Member

Joined: Feb 08, 2014
Posts: 26
Is there in gmic a simple saturation filter? Like the typical control in gimp (Colors->Hue-Saturation) ?

Thanks


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Saturation filter
PostPosted: Wed Feb 12, 2014 7:46 am  (#2) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Not particularly. What kind of operations do you want to achieve.
A really simple saturation filter for a RGB image could be :

foo : -repeat @# -l[$>] -rgb2hsv -sh 1,1 -*[-1] $1 -+[-1] $2 -c[-1] 0,1 -rm[-1] -hsv2rgb


where $1 = contrast (in [0,+inf[) and $2 = brightness (in [-1,-1] probably).


Top
 Post subject: Re: Saturation filter
PostPosted: Wed Feb 12, 2014 8:12 am  (#3) 
Offline
GimpChat Member

Joined: Feb 08, 2014
Posts: 26
If I can understand correctly you apply Contrast / Brightness in the S of the HSV?


Top
 Post subject: Re: Saturation filter
PostPosted: Wed Feb 12, 2014 8:14 am  (#4) 
Offline
GimpChat Member

Joined: Feb 08, 2014
Posts: 26
I am making a Color Grading filter, which is almost finished, based on the http://registry.gimp.org/node/26187


Top
 Post subject: Re: Saturation filter
PostPosted: Wed Feb 12, 2014 8:33 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
johnlak wrote:
If I can understand correctly you apply Contrast / Brightness in the S of the HSV?


Yes, exactly.

Interesting goal, indeed. If you get something working, I would be able to see the code, and eventually try to improve it (if possible), and finally make it available for everyone after a filter update :)
(If you want to share it of course).


Top
 Post subject: Re: Saturation filter
PostPosted: Wed Feb 12, 2014 8:58 am  (#6) 
Offline
GimpChat Member

Joined: Feb 08, 2014
Posts: 26
I have tried brightness in the S part of HSV but in the clipped parts of cloudy skies I get nasty artefacts, with pure whites becoming red while the surroundings being blue. Gamma in S isn't much better causing posterization in the sky...


Top
 Post subject: Re: Saturation filter
PostPosted: Wed Feb 12, 2014 9:11 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Here is my try, it seems it works as expected. Copy this in your $HOME/.gmic file, then run the plug-in and select filter 'S-equalizer' at the very top of the filter list :

#@gimp S-equalizer : gimp_equalize_s, gimp_equalize_s
#@gimp : Contrast = float(1,0,2)
#@gimp : Brightness = float(0,-1,1)
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


Top
 Post subject: Re: Saturation filter
PostPosted: Wed Feb 12, 2014 10:18 am  (#8) 
Offline
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
# john_lakkas@yahoo.gr
# 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
     


Top
 Post subject: Re: Saturation filter
PostPosted: Wed Feb 12, 2014 1:20 pm  (#9) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Hello John, thanks for the submission.
I've cleaned the code a little bit, then added your filter to 'Colors/'.
Feel free to test and let me know if everything looks fine !

Attachment:
gmic_color_grading.png
gmic_color_grading.png [ 289.27 KiB | Viewed 4383 times ]


Thanks again !


Top
 Post subject: Re: Saturation filter
PostPosted: Wed Feb 12, 2014 1:40 pm  (#10) 
Offline
GimpChat Member
User avatar

Joined: Jun 02, 2013
Posts: 2075
Very cool:

Image

Image

_________________
Image


Top
 Post subject: Re: Saturation filter
PostPosted: Thu Feb 13, 2014 6:02 am  (#11) 
Offline
GimpChat Member

Joined: Feb 08, 2014
Posts: 26
Working fine! Thanks a lot David! Greatly appreciated!

@The Warrior happy you liked it :)


Top
 Post subject: Re: Saturation filter
PostPosted: Thu Feb 13, 2014 6:14 am  (#12) 
Offline
GimpChat Member
User avatar

Joined: Mar 23, 2012
Posts: 7309
Location: Göteborg at last!
A very impressive filter

Image

Image


Top
 Post subject: Re: Saturation filter
PostPosted: Sat Feb 15, 2014 7:24 am  (#13) 
Offline
GimpChat Member

Joined: Feb 08, 2014
Posts: 26
Thanks for the kind words!


Top
 Post subject: Re: Saturation filter
PostPosted: Sat Feb 15, 2014 8:18 am  (#14) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
John, I've put a little announcement on the G+ page of G'MIC, about the availability of your filter :

https://plus.google.com/117441237982283 ... SUqfvWxUTA

Feedback is already good :)


Top
 Post subject: Re: Saturation filter
PostPosted: Sat Feb 15, 2014 1:10 pm  (#15) 
Offline
GimpChat Member
User avatar

Joined: Jun 02, 2013
Posts: 2075
Congrats John. I love this filter. Very easy to use, and very handy. Great job.

_________________
Image


Top
 Post subject: Re: Saturation filter
PostPosted: Mon Feb 17, 2014 5:50 am  (#16) 
Offline
GimpChat Member

Joined: Feb 08, 2014
Posts: 26
Hi

I have made some changes in the main routine of the filter, the first Saturation slider is using "-gimp_equalize_s" now (like Output saturation) and previous "Saturation" was renamed to "Saturation channel gamma" in case anyone wants to use it.

#@gimp Color grading : jl_colorgrading, jl_colorgrading_preview
#@gimp : Note = note("A filter for basic photo editing and color grading.")
#@gimp : Note = note("<small><b>Note:</b> S-curve controls shadows and highlights in one slider. Avoid using Local Contrast and Tone Mapping together because of doing similar things so both over process images. Saturation channel gamma changes color saturation differently than standard Saturation.</small>")
#@gimp : Sep = separator()
#@gimp : Cool / warm = int(0,-50,50)
#@gimp : Saturation = float(1,0,2)
#@gimp : Saturation channel gamma = 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 : Brightness = int(0,-50,50)
#@gimp : Contrast = int(0,-50,50)
#@gimp : Gamma = float(1,0.1,3)
#@gimp : Sep = separator()
#@gimp : Local contrast 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 brightness = int(0,-100,100)
#@gimp : Sep = separator()
#@gimp : Midtones color intensity = int(0,0,130)
#@gimp : Midtones hue = int(0,0,360)
#@gimp : Midtones brightness = int(0,-100,100)
#@gimp : Sep = separator()
#@gimp : Shadows color intensity = int(70,0,130)
#@gimp : Shadows hue = int(180,0,360)
#@gimp : Shadows brightness = int(0,-100,100)
#@gimp : Sep = separator()
#@gimp : Output saturation = float(1,0,2)
#@gimp : Sep = separator(), Preview type = choice("Full","Forward horizontal","Forward vertical","Backward horizontal","Backward vertical","Duplicate horizontal","Duplicate vertical")
#@gimp : Sep = separator(), note = note("<small>Author: <i>John Lakkas</i>.      Latest update: <i>2014/02/12</i>.</small>")
jl_colorgrading :
  _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

  -if {$2!=1.0}
    -gimp_equalize_s $2,0
  -endif

  # HSV SATURATION (gamma)
  -if {$3!=1.0}
  -apply_channels "-apply_gamma $3",12,0
  -endif

  # VALUE MANIPULATION

  # S CURVE
  -if {$4!=0}
  _p1={64-$4}
  _p2={192+$4}
  _ystr=$_ystr" -apply_curve 1,0,0,64,$_p1,192,$_p2,255,255"
  -endif

  # SHADOWS
  -if {$5!=0}
  _p3={64-$5}
  _ystr=$_ystr" -apply_curve 1,0,0,64,$_p3,128,128,192,192,255,255"
  -endif

  # HIGHLIGHTS
  -if {$6!=0}
  _p4={192+$6}
  _ystr=$_ystr" -apply_curve 1,0,0,64,64,128,128,192,$_p4,255,255"
  -endif

  # BLACKS
  -if {$7>0}
  _ystr=$_ystr" -apply_curve 1,$7,0,64,64,255,255"
  -endif

  # BRIGHTNESS
  -if {$8>0}
  _p5=0
  _ystr=$_ystr" -apply_curve 0,0,$8,255,255"
  -endif
  -if {$8<0}
  _p5={255+$8}
  _ystr=$_ystr" -apply_curve 0,0,0,255,$_p5"
  -endif

  # CONTRAST
  -if {$9>0}
  _p6=$9
  _p7={255-$9}
  _ystr=$_ystr" -apply_curve 0,0,0,$_p6,0,$_p7,255,255,255"
  -endif
  -if {$9<0}
  _p6={-$9}
  _p7={255+$9}
  _ystr=$_ystr" -apply_curve 0,0,$_p6,255,$_p7"
  -endif

  # GAMMA
  -if {$10!=1.0}
  _ystr=$_ystr" -apply_gamma $10"
  -endif

   # LOCAL CONTRAST (unsharp mask)
  -if {$11>0}
  _ystr=$_ystr" -unsharp 20,$11,0"
  -endif

  # TONE MAPPING
  -if {$12}
  _ystr=$_ystr" -map_tones 0.5,$13,0.1,30"
  -endif

  # APPLY VALUE PROCESSING
  -if {$_ystr'!='""}
  -apply_channels $_ystr,13,0
  -endif

  # Color Grading
  -if {$14}
    -if {$16+$22>360}
      _shh={($16+$22-360)/360}
    -else
      _shh={($16+$22)/360}
    -endif
    _shs={$21/100}
    _shlev={$23}
    _midh={$19/360}
    _mids={$18/100}
    _midlev={$20}
    _highh={$16/360}
    _highs={$15/100}
    _highlev={$17}
    _satlev={$24}

    -color_grade $_shh,$_shs,$_shlev,$_midh,$_mids,$_midlev,$_highh,$_highs,$_highlev,$_satlev
  -endif

  -if {$24!=1.0}
    -gimp_equalize_s $24,0
  -endif


Thanks again!


Top
 Post subject: Re: Saturation filter
PostPosted: Mon Feb 17, 2014 11:54 am  (#17) 
Offline
GimpChat Member
User avatar

Joined: Jun 02, 2013
Posts: 2075
Another example using this filter.

Before:

Image

After. Warmed it up a bit:

Image

Animation, showing the difference:

Image

_________________
Image


Top
 Post subject: Re: Saturation filter
PostPosted: Mon Jul 28, 2014 3:50 am  (#18) 
Offline
GimpChat Member

Joined: Feb 08, 2014
Posts: 26
Hi I have made some changes to "Color grading" filter, now it includes a new slider "Clarity". This slider enhances local contrast in the midtones somewhat like the photoshop slider.

Here is the main routine code:


#@gimp Color grading : jl_colorgrading, jl_colorgrading_preview
#@gimp : Note = note("A filter for basic photo editing and color grading.")
#@gimp : Note = note("<small><b>Note:</b> S-curve controls shadows and highlights in one slider. Avoid using Local Contrast and Tone Mapping together because of doing similar things so both over process images. Saturation channel gamma changes color saturation differently than standard Saturation.</small>")
#@gimp : Sep = separator()
#@gimp : Cool / warm = int(0,-50,50)
#@gimp : Saturation = float(1,0,2)
#@gimp : Saturation channel gamma = 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 : Brightness = int(0,-50,50)
#@gimp : Contrast = int(0,-50,50)
#@gimp : Clarity = float(0,0.0,2.0)
#@gimp : Gamma = float(1,0.1,3)
#@gimp : Sep = separator()
#@gimp : Local contrast 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 brightness = int(0,-100,100)
#@gimp : Sep = separator()
#@gimp : Midtones color intensity = int(0,0,130)
#@gimp : Midtones hue = int(0,0,360)
#@gimp : Midtones brightness = int(0,-100,100)
#@gimp : Sep = separator()
#@gimp : Shadows color intensity = int(70,0,130)
#@gimp : Shadows hue shift = int(180,0,360)
#@gimp : Shadows brightness = int(0,-100,100)
#@gimp : Sep = separator()
#@gimp : Output saturation = float(1,0,2)
#@gimp : Sep = separator(), Preview type = choice("Full","Forward horizontal","Forward vertical","Backward horizontal","Backward vertical","Duplicate horizontal","Duplicate vertical")
#@gimp : Sep = separator(), note = note("<small>Author: <i>John Lakkas</i>.      Latest update: <i>2014/07/28</i>.</small>")
jl_colorgrading :
  _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

  -if {$2!=1.0}
    -gimp_equalize_s $2,0
  -endif

  # HSV SATURATION (gamma)
  -if {$3!=1.0}
  -apply_channels "-apply_gamma $3",12,0
  -endif

  # VALUE MANIPULATION

  # S CURVE
  -if {$4!=0}
  _p1={64-$4}
  _p2={192+$4}
  _ystr=$_ystr" -apply_curve 1,0,0,64,$_p1,192,$_p2,255,255"
  -endif

  # SHADOWS
  -if {$5!=0}
  _p3={64-$5}
  _ystr=$_ystr" -apply_curve 1,0,0,64,$_p3,128,128,192,192,255,255"
  -endif

  # HIGHLIGHTS
  -if {$6!=0}
  _p4={192+$6}
  _ystr=$_ystr" -apply_curve 1,0,0,64,64,128,128,192,$_p4,255,255"
  -endif

  # BLACKS
  -if {$7>0}
  _ystr=$_ystr" -apply_curve 1,$7,0,64,64,255,255"
  -endif

  # BRIGHTNESS
  -if {$8>0}
  _p5=0
  _ystr=$_ystr" -apply_curve 0,0,$8,255,255"
  -endif
  -if {$8<0}
  _p5={255+$8}
  _ystr=$_ystr" -apply_curve 0,0,0,255,$_p5"
  -endif

  # CONTRAST
  -if {$9>0}
  _p6=$9
  _p7={255-$9}
  _ystr=$_ystr" -apply_curve 0,0,0,$_p6,0,$_p7,255,255,255"
  -endif
  -if {$9<0}
  _p6={-$9}
  _p7={255+$9}
  _ystr=$_ystr" -apply_curve 0,0,$_p6,255,$_p7"
  -endif

  # CLARITY (midtones unsharp mask)
  -if {$10>0}
  _ystr=$_ystr"-to_rgb --rgb2hsl -split[-1] c -rm[-2] -rm[-2] -*[-1] 255 -apply_curve[-1] 1,0,0,63,0,127,255,192,0,255,0 --unsharp[0] 150,$10,0 -cut[-1] 0,255 -cut[-2] 0,255 -reverse[-1,-2] -append[-1,-2] c -blend alpha"
  -endif

  # GAMMA
  -if {$11!=1.0}
  _ystr=$_ystr" -apply_gamma $11"
  -endif

   # LOCAL CONTRAST (unsharp mask)
  -if {$12>0}
  _ystr=$_ystr" -unsharp 20,$12,0"
  -endif

  # TONE MAPPING
  -if {$13}
  _ystr=$_ystr" -map_tones 0.5,$14,0.1,30"
  -endif

  # APPLY VALUE PROCESSING
  -if {$_ystr'!='""}
  -apply_channels $_ystr,13,0
  -endif

  # Color Grading
  -if {$15}
    -if {$17+$23>360}
      _shh={($17+$23-360)/360}
    -else
      _shh={($17+$23)/360}
    -endif
    _shs={$22/100}
    _shlev={$24}
    _midh={$20/360}
    _mids={$19/100}
    _midlev={$21}
    _highh={$17/360}
    _highs={$16/100}
    _highlev={$18}
    _satlev={$25}

    -color_grade $_shh,$_shs,$_shlev,$_midh,$_mids,$_midlev,$_highh,$_highs,$_highlev,$_satlev
  -endif

  -if {$25!=1.0}
    -gimp_equalize_s $25,0
  -endif

color_grade :
#convert_to_levels :
      # input:
      # shh, shs, shlev, midh, mids, midlev, highh, highs, highlev, satlev

      _shadownrgb=@{-jl_hsv_to_rgb" "$1,1.0,{$2*0.40}}
      _midtonesrgb=@{-jl_hsv_to_rgb" "$4,1.0,{$5*0.40}}
      _highlightsrgb=@{-jl_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

      -levels $_lowinred,$_hiinred,$_gammared,$_lowoutred,$_hioutred,19
      -levels $_lowingreen,$_hiingreen,$_gammagreen,$_lowoutgreen,$_hioutgreen,20
      -levels $_lowinblue,$_hiinblue,$_gammablue,$_lowoutblue,$_hioutblue,21

jl_colorgrading_preview :
  -gimp_split_preview "-jl_colorgrading $*",$-1



Top
 Post subject: Re: Saturation filter
PostPosted: Mon Jul 28, 2014 4:55 am  (#19) 
Offline
GimpChat Member

Joined: Feb 08, 2014
Posts: 26
More fixes and enhancements to Color grading filter, below there is the code.


#@gimp Color grading : jl_colorgrading, jl_colorgrading_preview
#@gimp : Note = note("A filter for basic photo editing and color grading.")
#@gimp : Note = note("<small><b>Note:</b> S-curve contrast, controls shadows and highlights in one slider. Avoid using any of Clarity, Local Contrast or Tone Mapping at the same time, they are of similar effect and tend to over process images. Saturation channel gamma changes color saturation differently than standard Saturation. Saturation channel gamma may introduce artefacts depending on the image.</small>")
#@gimp : Sep = separator()
#@gimp : Cool / warm = int(0,-50,50)
#@gimp : Saturation = float(1,0,2)
#@gimp : Saturation channel gamma = 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 : Brightness = int(0,-50,50)
#@gimp : Contrast = int(0,-50,50)
#@gimp : Gamma = float(1,0.1,3)
#@gimp : Sep = separator()
#@gimp : Clarity = float(0,0.0,2.0)
#@gimp : Local contrast 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 brightness = int(0,-100,100)
#@gimp : Sep = separator()
#@gimp : Midtones color intensity = int(0,0,130)
#@gimp : Midtones hue = int(0,0,360)
#@gimp : Midtones brightness = int(0,-100,100)
#@gimp : Sep = separator()
#@gimp : Shadows color intensity = int(70,0,130)
#@gimp : Shadows hue shift = int(180,0,360)
#@gimp : Shadows brightness = int(0,-100,100)
#@gimp : Sep = separator()
#@gimp : Output saturation = float(1,0,2)
#@gimp : Sep = separator(), Preview type = choice("Full","Forward horizontal","Forward vertical","Backward horizontal","Backward vertical","Duplicate horizontal","Duplicate vertical")
#@gimp : Sep = separator(), note = note("<small>Author: <i>John Lakkas</i>.      Latest update: <i>2014/07/28</i>.</small>")
jl_colorgrading :
  _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

  -if {$2!=1.0}
    -gimp_equalize_s $2,0
  -endif

  # HSV SATURATION (gamma)
  -if {$3!=1.0}
  -apply_channels "-apply_gamma $3",12,0
  -endif

  # VALUE MANIPULATION

  # S CURVE
  -if {$4!=0}
  _p1={64-$4}
  _p2={192+$4}
  _ystr=$_ystr" -apply_curve 1,0,0,64,$_p1,192,$_p2,255,255"
  -endif

  # SHADOWS
  -if {$5!=0}
  _p3={64-$5}
  _ystr=$_ystr" -apply_curve 1,0,0,64,$_p3,128,128,192,192,255,255"
  -endif

  # HIGHLIGHTS
  -if {$6!=0}
  _p4={192+$6}
  _ystr=$_ystr" -apply_curve 1,0,0,64,64,128,128,192,$_p4,255,255"
  -endif

  # BLACKS
  -if {$7>0}
  _ystr=$_ystr" -apply_curve 1,$7,0,64,64,255,255"
  -endif

  # BRIGHTNESS
  -if {$8>0}
  _p5=0
  _ystr=$_ystr" -apply_curve 0,0,$8,255,255"
  -endif
  -if {$8<0}
  _p5={255+$8}
  _ystr=$_ystr" -apply_curve 0,0,0,255,$_p5"
  -endif

  # CONTRAST
  -if {$9>0}
  _p6=$9
  _p7={255-$9}
  _ystr=$_ystr" -apply_curve 0,0,0,$_p6,0,$_p7,255,255,255"
  -endif
  -if {$9<0}
  _p6={-$9}
  _p7={255+$9}
  _ystr=$_ystr" -apply_curve 0,0,$_p6,255,$_p7"
  -endif

  # GAMMA
  -if {$10!=1.0}
  _ystr=$_ystr" -apply_gamma $10"
  -endif

  # APPLY VALUE PROCESSING
  -if {$_ystr'!='""}
  -apply_channels $_ystr,13,0
  -endif
 
  # CLARITY (midtones unsharp mask)
  -if {$11>0}
  -to_rgb --rgb2hsl -split[-1] c -rm[-2] -rm[-2] -*[-1] 255 -apply_curve[-1] 1,0,0,63,0,127,255,192,0,255,0 --unsharp[0] 150,$11,0 -cut[-1] 0,255 -cut[-2] 0,255 -reverse[-1,-2] -append[-1,-2] c -blend alpha
  -endif

   # LOCAL CONTRAST (unsharp mask)
  -if {$12>0}
  -unsharp 20,$12,0
  -cut[-1] 0,255
  -endif

  # TONE MAPPING
  -if {$13}
  -map_tones 0.5,$14,0.1,30
  -endif



  # Color Grading
  -if {$15}
    -if {$17+$23>360}
      _shh={($17+$23-360)/360}
    -else
      _shh={($17+$23)/360}
    -endif
    _shs={$22/100}
    _shlev={$24}
    _midh={$20/360}
    _mids={$19/100}
    _midlev={$21}
    _highh={$17/360}
    _highs={$16/100}
    _highlev={$18}
    _satlev={$25}

    -color_grade $_shh,$_shs,$_shlev,$_midh,$_mids,$_midlev,$_highh,$_highs,$_highlev,$_satlev
  -endif

  -if {$25!=1.0}
    -gimp_equalize_s $25,0
  -endif

color_grade :
#convert_to_levels :
      # input:
      # shh, shs, shlev, midh, mids, midlev, highh, highs, highlev, satlev

      _shadownrgb=@{-jl_hsv_to_rgb" "$1,1.0,{$2*0.40}}
      _midtonesrgb=@{-jl_hsv_to_rgb" "$4,1.0,{$5*0.40}}
      _highlightsrgb=@{-jl_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

      -levels $_lowinred,$_hiinred,$_gammared,$_lowoutred,$_hioutred,19
      -levels $_lowingreen,$_hiingreen,$_gammagreen,$_lowoutgreen,$_hioutgreen,20
      -levels $_lowinblue,$_hiinblue,$_gammablue,$_lowoutblue,$_hioutblue,21

jl_colorgrading_preview :
  -gimp_split_preview "-jl_colorgrading $*",$-1



Top
 Post subject: Re: Saturation filter
PostPosted: Mon Jul 28, 2014 12:19 pm  (#20) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Thanks, I will push the update as soon as possible !


Top
Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Saturation H M L plug-in

17

No new posts Getting Black from Hue/Saturation

1

No new posts Attachment(s) GEGL Vibrance - fancy saturation plugin (probably canceled)

8

No new posts Attachment(s) cli345's cartoon filter as a native GEGL Filter.

10

No new posts Attachment(s) My last Aquarelle filter

21



* Login  



Powered by phpBB3 © phpBB Group