GIMP Chat
http://gimpchat.com/

Turn photo to cartoon manually
http://gimpchat.com/viewtopic.php?f=23&t=19531
Page 1 of 1

Author:  cli345 [ Wed Aug 04, 2021 11:22 am ]
Post subject:  Turn photo to cartoon manually

Hello, :)

Here is a very short tutorial about turning a photo into a cartoon picture manually without:
  • G'MIC "Artistic" filters,
  • plug-ins (except G'MIC "Repair" filters),
  • drawing.

(It's just what I learned during my experiments to turn photos into cartoons.)

Warning: It aims to make simple style cartoons (not to make more artistic cartoons).

You can proceed, for example, like this:
  • Reduce the image to about 700px-1000px wide or high
  • Duplicate layer
  • On bottom layer, "Colors -> Saturation (scale=1.8)"
  • On bottom layer, "Colors -> Hue-Chroma (lightness=10)"
  • On top layer, "Filters -> G'MIC-Qt -> Repair -> Smooth [NL-Means]"
  • On top layer, "Filters -> G'MIC-Qt -> Repair -> Smooth [Bilateral]"
  • On top layer, "Filters -> Edge-Detect -> Difference of Gaussians (legacy)" (uncheck "Invert" option)
  • On top layer, "Colors -> Desaturate -> Desaturate (mode=Value)"
  • On top layer, "Colors -> Invert"
  • On top layer, "Colors -> Threshold : about 210-240, 255"
  • On top layer, set "layer mode" to "multiply"
  • On top layer, "Merge down"
  • "Filters -> G'MIC-Qt -> Repair -> Smooth [Bilateral]", multiple times

The following posts explain the reasons why this method works better (according to me) than :
  • desaturing first
  • or using "Filters -> Edge-Detect -> Edge...(Sobel)"

To be continued...

Author:  cli345 [ Thu Aug 05, 2021 6:37 am ]
Post subject:  Re: Turn photo to cartoon manually

1) The big steps

Here are the four big steps:
  • Intensify colors, that is:
    • On bottom layer, "Colors -> Saturation (scale=1.8)"
    • On bottom layer, "Colors -> Hue-Chroma (lightness=10)"
  • Stroke edges (the big part), that is:
    • On top layer, "Filters -> G'MIC-Qt -> Repair -> Smooth [NL-Means]"
    • On top layer, "Filters -> G'MIC-Qt -> Repair -> Smooth [Bilateral]"
    • On top layer, "Filters -> Edge-Detect -> Difference of Gaussians (legacy)" (uncheck "Invert" option)
    • On top layer, "Colors -> Desaturate -> Desaturate (mode=Value)"
    • On top layer, "Colors -> Invert"
    • On top layer, "Colors -> Threshold : about 210-240, 255"
  • Mix, that is:
    • On top layer, set "layer mode" to "multiply"
    • On top layer, "Merge down"
  • Flatten, that is just: "Filters -> G'MIC-Qt -> Repair -> Smooth [Bilateral]", multiple times

Attachment:
steps4.jpg
steps4.jpg [ 39.26 KiB | Viewed 4947 times ]

The very difficult step is "stroke edges".

To be continued...

Author:  Wallace [ Thu Aug 05, 2021 8:56 pm ]
Post subject:  Re: Turn photo to cartoon manually

Thank you cli345 for posting this tutorial.
We've added it to our Tutorial Index.


Gimp Chat Tutorial Index

Author:  cli345 [ Fri Aug 06, 2021 6:45 am ]
Post subject:  Re: Turn photo to cartoon manually

Thanks, Wallace! :)

2) The steps to "Stroke edges"

Here are the five steps to "Stroke edges":
  1. Smooth, that is:
    • On top layer, "Filters -> G'MIC-Qt -> Repair -> Smooth [NL-Means]"
    • On top layer, "Filters -> G'MIC-Qt -> Repair -> Smooth [Bilateral]"
  2. Detect edges, that is just: On top layer, "Filters -> Edge-Detect -> Difference of Gaussians (legacy)" (uncheck "Invert" option)
  3. Desaturate, that is just: On top layer, "Colors -> Desaturate -> Desaturate (mode=Value)"
  4. Invert, that is just: On top layer, "Colors -> Invert"
  5. Increase contrast, that is just: On top layer, "Colors -> Threshold : about 210-240, 255"

Attachment:
stepEdge5.jpg
stepEdge5.jpg [ 32 KiB | Viewed 4868 times ]

There are three choices to do:
  • Which smooth (I haven't understood the reason why one smooth works better than another one)
  • Which edge detection (see following posts)
  • In which order, to do the steps 2,3,4 (see following posts). There are three possibilities:
    • Detect, desaturate, invert
    • Detect, invert, desaturate
    • Desaturate, detect, invert

To be continued...

Author:  cli345 [ Sat Aug 07, 2021 8:13 am ]
Post subject:  Re: Turn photo to cartoon manually

3) "Detect, desaturate, invert"

To show that "Detect, desaturate, invert" is the best choice (in my view), here are three little experiments on the following image:
Attachment:
multiplColors.jpg
multiplColors.jpg [ 4.9 KiB | Viewed 4737 times ]

First experiment ("Desaturate, detect, invert"):
  • Desaturate the image (you choose the method yourself, try several ones), you can try:
    • Colors -> Desaturate -> Desaturate (choose the mode you want)
    • Colors -> Desaturate -> Color to Gray
  • Filters -> Edge-Detect -> Edge
  • Colors -> Invert

Second experiment ("Detect, invert, desaturate"):
  • Filters -> Edge-Detect -> Edge
  • Colors -> Invert
  • Colors -> Desaturate -> Desaturate (choose the mode you want)

Third experiment ("Detect, desaturate, invert"):
  • Filters -> Edge-Detect -> Edge
  • Colors -> Desaturate -> Desaturate (mode=Value) (compare with other modes)
  • Colors -> Invert

Have fun! :)

With which experiment do we obtain the edges more easily ?

In the first experiment, the desaturation of the image make you to lose some differences of colors. But, sometimes, limits of objects is visible as a difference of hue.

In the second experiment, some differences of colors is turned into yellow lines. But, it's difficult to find a desaturation method that turns yellow to dark gray.

The third experiment seems (to me) to give the best result. Some difference of colors is turned to blue lines. Only the "value" mode turns these to very light gray.

To be continued...

Author:  cli345 [ Sun Aug 08, 2021 3:24 pm ]
Post subject:  Re: Turn photo to cartoon manually

4) Stroke edges on the darker side

I think it's better to stroke edges on the darker side of edge locations (and not astride edge locations).

To show that, here are two little experiments on the following image:
Attachment:
smoothEye.jpg
smoothEye.jpg [ 1.88 KiB | Viewed 4703 times ]

First experiment:
  • Duplicate Layer
  • Filters -> Edge-Detect -> Edge (Sobel)
  • Colors -> Desaturate -> Desaturate (mode=Value)
  • Colors -> Invert
  • Colors -> Threshold : 170
  • Set mode to "multiply"
  • Toggle the visibility multiple times quickly (to see the effect well) (note the enlargement of dark zones)

Second experiment:
  • Duplicate Layer
  • Filters -> Edge-Detect -> Difference of Gaussians (legacy) (Radius1 = 8) (uncheck "Invert" option)
  • Colors -> Desaturate -> Desaturate (mode=Value)
  • Colors -> Invert
  • Colors -> Threshold : 232
  • Set mode to "multiply"
  • Toggle the visibility multiple times quickly (to see the effect well)

Have fun! :)

Which experiment gives the less distorted picture ?

To be continued...

Author:  cli345 [ Mon Aug 09, 2021 10:35 am ]
Post subject:  Re: Turn photo to cartoon manually

Here is the result of the first experiment:
Attachment:
smoothEyeExp1.jpg
smoothEyeExp1.jpg [ 2.95 KiB | Viewed 4678 times ]

Here is the result of the second experiment:
Attachment:
smoothEyeExp2.jpg
smoothEyeExp2.jpg [ 2.74 KiB | Viewed 4678 times ]

The difference between the two experiments was the method of edge detection (as implemented in Gimp).
  • First experiment (Sobel): strokes the edges astride the edge locations
  • Second experiment (Difference of Gaussians): strokes the edges onto the darker side of the edge locations

Stroking the edges astride enlarges dark zones of the image. This effect distorts the eyes of persons.
So, for "Comic Book" effect, I prefer stroking the edges onto the darker side.

Here are some Gimp (and G'MIC) filters that stroke astride:
  • Filters -> Edge-Detect -> Edge... (all the algorithms except Laplace),
  • Filters -> Edge-Detect -> Neon...
  • Filters -> Edge-Detect -> Sobel...
  • Filters -> Edge-Detect -> Image Gradient...
  • Filters -> G'MIC-Qt... -> Contours -> Edges
  • Filters -> G'MIC-Qt... -> Contours -> Edge
  • Filters -> G'MIC-Qt... -> Artistic -> Cartoon
  • Filters -> G'MIC-Qt... -> Artistic -> Poster Edges
  • Filters -> G'MIC-Qt... -> Testing -> Jayprich -> Jpr Line Edges
  • Filters -> G'MIC-Qt... -> Testing -> Joan Rake -> Artistic -> Neon
  • Filters -> G'MIC-Qt... -> Testing -> Joan Rake -> Contours -> Gradient Norm [JR's mod]
  • Filters -> G'MIC-Qt... -> Testing -> Naggobot -> Smooth Sketch
  • Filters -> G'MIC-Qt... -> Testing -> PhotoComix -> Color Sketch

Here are some methods that stroke onto the darker side:
  • Filters -> Edge-Detect -> Edge... (Laplace),
  • Filters -> Edge-Detect -> Laplace...,
  • Filters -> Edge-Detect -> Difference of Gaussians... (radius1 greater than radius2),
  • Filters -> Edge-Detect -> Difference of Gaussians (legacy)... (radius1 greater than radius2),
    • Duplicate layer
    • On bottom layer, "Filters -> Blur -> Gaussian Blur..."
    • On top layer, set "layer mode" to "subtract"
    • On top layer, "Merge down"
  • Filters -> Artistic -> Cartoon...
  • Filters -> G'MIC-Qt... -> Contours -> Morphological Filter (Action = Dilation - Original, size=2)
  • Filters -> G'MIC-Qt... -> Artistic -> Comic Book
  • Colors -> Tone Mapping -> Retinex... (Low, 16, 3, 0.1)

(Exception: For more artistical results, some little distortions can be needed. So, I think, in this case, it's better not to follow this tutorial!)

The tutorial is finished. :)

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/