13
$\begingroup$

I want to use Mathematica to generate a cartoon of a face. For example, some thing like this:

enter image description here

I think it can be done using Mathematica, but I really don't know how to do it. How can it be done, and what kind of a cartoon can Mathematica generate?

$\endgroup$
7
  • $\begingroup$ Have a look at MeanShiftFilter to get you started. $\endgroup$
    – Verbeia
    Sep 23, 2014 at 6:41
  • 1
    $\begingroup$ Havw a look at Michael Trott's post on the Wolfram Blog. $\endgroup$
    – m_goldberg
    Sep 23, 2014 at 11:09
  • 8
    $\begingroup$ Also, note that Mathematica won't zip up the guy's hoodie for you. The pictures don't match. $\endgroup$
    – Verbeia
    Sep 23, 2014 at 11:45
  • $\begingroup$ @Verbeia I know that. what I am looking at is the face only. $\endgroup$ Sep 23, 2014 at 13:28
  • 1
    $\begingroup$ stat.ucla.edu/~mtzhao/research/nprbookchapter/… $\endgroup$
    – Greg Hurst
    Jan 9, 2018 at 18:53

1 Answer 1

18
$\begingroup$

Here is an idea based on MeanShiftFilter:

start = ImageCrop[ExampleData[{"TestImage", "Girl3"}], 200, Left];
step1 = MeanShiftFilter[start, 3, 0.05, MaxIterations -> 10]

enter image description here

step2 = Binarize[ColorNegate[DerivativeFilter[step1, {0, 1}]], 0.95]

enter image description here

ImageMultiply[step1, step2]

enter image description here

Obviously you can play with filters to get a different outline effect. Here is a quick Manipulate:

Manipulate[
 With[{colorversion = 
    MeanShiftFilter[start, ms1, ms2, MaxIterations -> 10]}, 
  ImageMultiply[colorversion, 
   ImageMultiply[
    Binarize[ColorNegate[DerivativeFilter[colorversion, {0, 1}]], v1],
     Binarize[ColorNegate[DerivativeFilter[colorversion, {1, 0}]], 
     h1]]] ], {ms1, 1, 6, 1}, {ms2, 0.01, 0.1}, {v1, 0.8, 0.999}, {h1, 0.8, 0.999}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.