It is currently Thu Apr 25, 2024 12:39 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 30 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Convert Color Photo to Line Art (Plug-in or instructions)
PostPosted: Mon Apr 04, 2022 11:19 am  (#21) 
Offline
GimpChat Member

Joined: Apr 19, 2021
Posts: 121
Location: France
Hello! :)

I intend to propose a new dedicated G'Mic filter "Line Art".
With default parameters, it would give these results:
Attachment:
lineArtExamples2.jpg
lineArtExamples2.jpg [ 169.15 KiB | Viewed 1104 times ]

With "type=Gray Patches", it would give:
Attachment:
lineArtExamples.jpg
lineArtExamples.jpg [ 159.52 KiB | Viewed 1104 times ]

Here is its code:
#@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}

Installation:
  • Copy and paste the above code into the file "~/.gmic" on Linux or the file "%APPDATA%\user.gmic" on Windows.
  • The new filter appears in "Filters -> G'MIC -> Artistic -> Line Art (prerelease)".

Have fun! :)

_________________
Photo to cartoon : https://github.com/cl4cnam/gimp_cartoon_plugin


Top
 Post subject: Re: Convert Color Photo to Line Art (Plug-in or instructions)
PostPosted: Tue Apr 05, 2022 4:02 am  (#22) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2424
Very nice effect, works fine with gmic version 3.0.2 but this error with 3.1.0

*** Error in ./cl_lineart_prerelease/*repeat/*local/ *** Unknown command or filename 'endl'; did you mean 'and'?

More changes in gmic syntax, David has been fixing existing filters, additional work for you ;)

_________________
Image


Top
 Post subject: Re: Convert Color Photo to Line Art (Plug-in or instructions)
PostPosted: Wed Apr 06, 2022 2:35 pm  (#23) 
Offline
GimpChat Member

Joined: Apr 19, 2021
Posts: 121
Location: France
Thanks, rich2005! :)
I think I'll have to replace "endl done" by "done done".

_________________
Photo to cartoon : https://github.com/cl4cnam/gimp_cartoon_plugin


Top
 Post subject: Re: Convert Color Photo to Line Art (Plug-in or instructions)
PostPosted: Thu Apr 07, 2022 4:41 am  (#24) 
Offline
GimpChat Member
User avatar

Joined: Feb 12, 2021
Posts: 17
Thanks Claude!
Now added to G'MIC 3.1.0_pre.
Added a news about it on the Twitter account: https://twitter.com/gmic_eu/status/1512002150343319554


Top
 Post subject: Re: Convert Color Photo to Line Art (Plug-in or instructions)
PostPosted: Thu Apr 07, 2022 6:32 am  (#25) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Excellent filter, Claude !

_________________
"Where am I ?"


Top
 Post subject: Re: Convert Color Photo to Line Art (Plug-in or instructions)
PostPosted: Thu Apr 07, 2022 10:20 am  (#26) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2424
@dtschump

This using kubuntu 20.04 / Gimp 2.10.30 / gmic 3.1.0 and updated (shows 576 filters)

*** Error in ./cl_lineart/*foreach/fx_curves_interactive/ *** Unknown command or filename '=>'; did you mean '='?

Ooops, needed to update the plugin file as well, works now using 3.1.0_pre#220406

_________________
Image


Top
 Post subject: Re: Convert Color Photo to Line Art (Plug-in or instructions)
PostPosted: Thu Apr 07, 2022 5:49 pm  (#27) 
Offline
GimpChat Member
User avatar

Joined: Apr 15, 2017
Posts: 1826
Love the effect of this filter, Claude. Thanks for it.

Attachment:
Bike-lineart.jpg
Bike-lineart.jpg [ 329.8 KiB | Viewed 975 times ]


Top
 Post subject: Re: Convert Color Photo to Line Art (Plug-in or instructions)
PostPosted: Thu Apr 07, 2022 10:19 pm  (#28) 
Offline
Global Moderator
User avatar

Joined: Apr 01, 2012
Posts: 7714
Location: On the other side of this screen
cool :)

_________________


Top
 Post subject: Re: Convert Color Photo to Line Art (Plug-in or instructions)
PostPosted: Thu Feb 02, 2023 2:45 pm  (#29) 
Offline
GimpChat Member

Joined: Apr 19, 2021
Posts: 121
Location: France
Hello! :)

Thanks to Miguel Pineau for the video (in French)! :tyspin

_________________
Photo to cartoon : https://github.com/cl4cnam/gimp_cartoon_plugin


Top
 Post subject: Re: Convert Color Photo to Line Art (Plug-in or instructions)
PostPosted: Sat Feb 11, 2023 9:28 am  (#30) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12518
ref: https://images.pexels.com/photos/400346 ... 750&w=1260

Sorry for the belated reply; meant to do so a week ago but got busy. lol

Anyway, one of my favorite ways to create line art is G'MIC's Engrave preset. Of course I added some secret pre and post processing to the mix (it's what I do). :)


Attachments:
Elephant Engraved.jpg
Elephant Engraved.jpg [ 1.44 MiB | Viewed 614 times ]

_________________
Lyle

Psalm 109:8

Image
Top
Post new topic Reply to topic  [ 30 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Calling GIMP Plug-in From Command Line - on Windows

0

No new posts Attachment(s) How to restore the photo with more black color

23

No new posts Attachment(s) How to restore color and increase sharpness on old photo

0

No new posts Attachment(s) convert a gbr bristles to abr

2

No new posts Attachment(s) GEGL Color Light Fusion (12 blend modes for color overlay)

9



* Login  



Powered by phpBB3 © phpBB Group