I intend to propose a new dedicated G'Mic filter "Line Art".
#@gui ____<b>Artistic</b>
#------------------
#@gui Line Art (prerelease): cl_lineart_prerelease, cl_lineart_prerelease_preview(0)
#@gui : note = note("<b>Photo to Line Art</b>")
#@gui : sep = separator()
#@gui : note = note(" ")
#@gui : Local Contrast Enhancement = int(0,0,4)
#@gui : sep = separator()
#@gui : note = note("<b>For edges:</b>")
#@gui : Flattening for Edge (bilateral) = int(2,0,5)
#@gui : Line Thickness = float(1,0.5,2)
#@gui : Line Strength = float(15,0,19)
#@gui : sep = separator()
#@gui : Add Black or Gray = bool(1)
#@gui : note = note("<b>For black and grays:</b>")
#@gui : Luminosity Increase = int(0,0,40)
#@gui : Final Flattening (bilateral) = int(6,0,10)
#@gui : Lines Antialias = int(15,0,100)
#@gui : Type = choice(2, "Soft Threshold", "Gray Patches", "Lines and Black", "Black and Lines")
#@gui : sep = separator()
#@gui : Final Antialias = choice(2, "None", "Light Simple", "Simple", "Very Strong")
#@gui : sep = separator()
#@gui : Preview Type = choice("Full","Forward Horizontal","Forward Vertical","Backward Horizontal",
#@gui : "Backward Vertical","Duplicate Top","Duplicate Left","Duplicate Bottom","Duplicate Right",
#@gui : "Duplicate Horizontal","Duplicate Vertical","Checkered","Checkered Inverse")
#@gui : Preview Split = point(50,50,0,0,200,200,200,0,10)_0
#@gui : sep = separator()
#@gui : url = link("Filter discussed here","http://gimpchat.com/viewtopic.php?f=15&t=5328&start=10#p270912")
#@gui : note = note("<small>Author: <i>Claude Lion</i>. Latest Update: <i>2022/04/03</i>.</small>")
#@gui : note = note("<small>It uses filters of David Tschumperlé and a few filters of Jérôme Boulanger.</small>")
#@gui : note = note("<small>Type='Lines and Black' is a shortcut of 'Black and Lines' with 'Local Contrast Enhancement = 1' and 'Luminosity Increase = 40'. In this case, 'Local Contrast Enhancement' and 'Luminosity Increase' cursors have no effect.</small>")
cl_lineart_prerelease:
locContEnh=$1
nbBilatBord=$2
lineThick=$3
forceTrait=$4
addGrays=$5
augmLum=$6
nbBilatFin=$7
antialias=$8
type=$9
finalAntialias=$10
repeat $! l[$>]
if $type==2
locContEnh=1
augmLum=40
fi
fx_LCE. 80,{$locContEnh/2},1,1,0,0
curv="0,0,"{50-$augmLum}","{50+$augmLum}",100,100,-1,0,0,30,70,100,100,-1,0,0,100,100,-1,0,0,100,100,-1"
+fx_curves_interactive. 7,0,1,"7",$curv
fx_smooth_nlmeans.. 4,4,10,5,0,0,24,0
fx_smooth_bilateral.. 10,7,$nbBilatBord,0,0
+cut.. 0,255
reverse[-2,-1]
blur[-3] {$lineThick}
sub[-3,-2]
fill.. "M = max(R,G,B); [M, M, M]"
cut.. 0,255 n.. 0,255
negate..
threshold.. {$forceTrait+80}%
n.. 0,255
fx_smooth_antialias.. $antialias,0,1,0,50,50
if $addGrays==1
mul[-2,-1]
n. 0,255
fx_smooth_bilateral. 10,7,$nbBilatFin,0,0
if $type==0
fx_curves_interactive. 7,0,1,"7","0,0,60,0,80,100,100,100,-1,0,0,100,0,-1,0,0,100,100,-1,0,0,100,100,-1"
elif $type==1
if s==2 split_opacity. rm. fi
+colormap. 8
index.. [-1],0,1
rm.
rgb2hsl. split. c
n. 0,1
append c hsl2rgb
fx_blackandwhite. 0.299,0,0.587,0,0.114,0,0,0,0,0,0,0,0,0,2,0,0,0,16,4,0,0,0,50,50
fx_curves_interactive. 7,0,1,"7","0,0,20,80,100,100,-1,0,0,100,100,-1,0,0,100,100,-1,0,0,100,100,-1"
elif $type>=2
fx_blackandwhite. 0.299,0,0.587,0,0.114,0,0,0,0,0,0,0,0,0,2,0,0,0,16,4,0,0,0,50,50
otsu 4
n 0,255
fi
else
remove[-1]
fi
if $finalAntialias==1
fx_smooth_antialias. 15,0,1,0,50,50
elif $finalAntialias==2
fx_smooth_antialias. 15,0,1,0,50,50
fx_smooth_antialias. 50,50,2.5,0,50,50
#gcd_despeckle 50,1
#fx_smooth_antialias. 15,20,1,0,50,50
#fx_smooth_antialias 100,50,1,0,50,50
#fx_smooth_antialias 100,50,5,0,50,50
#gcd_despeckle 50,1
elif $finalAntialias==3
fx_smooth_antialias. 100,0.5,5,0,50,50
fx_smooth_antialias. 100,0.5,5,0,50,50
fi
endl done
cl_lineart_prerelease_preview:
gui_split_preview "cl_lineart_prerelease $*",${-3--1}