AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 703184
Accepted
marcanuy
marcanuy
Asked: 2015-11-28 05:46:35 +0800 CST2015-11-28 05:46:35 +0800 CST 2015-11-28 05:46:35 +0800 CST

如何从命令行将图像转换为卡通?

  • 772

我想使用命令行从照片创建这种卡通效果。

期望的效果示例:

  • 在此处输入图像描述

你能描述一下实现这种卡通效果的过程或给出一些提示吗?

信息:

  • 图片 1 来源:https ://stackoverflow.com/a/1357489/1165509
  • 相关问题(在 GIMP 中做同样的事情): https ://graphicdesign.stackexchange.com/q/63731/7253
command-line
  • 2 2 个回答
  • 6785 Views

2 个回答

  • Voted
  1. Rinzwind
    2015-11-28T06:57:50+08:002015-11-28T06:57:50+08:00

    我找到了Fred Weinhaus 为 imagemagick 做的 bash脚本。他的脚本仅可免费用于非商业用途。

    命令行用法:

    USAGE: cartoon [-p pattern] [-n numlevels] [-m method] [-e edgeamount] 
    [-b brightness] [-s saturation] infile outfile
    
    USAGE: cartoon [-h or -help]
    
    -p ... pattern ...... segmentation pattern (shape); 0<=integer<=100;
    ..................... default=70
    -n ... numlevels .... number of desired segmentation levels; integer>=2;
    ..................... default=6
    -m ... method ....... edge method; 1 or 2; default=1
    -e ... edgeamount ... amount of edges; float>=0; default=4
    -b ... brightness ... brightness of cartoon; integer>=0; default=100
    -s ... saturation ... saturation of cartoon; integer>=0; default=150
    
    PURPOSE: To create a cartoon-like appearance to an image.
    

    (更多关于网站本身。)脚本的作用......

    (Optionally) applies a median filter to the image
    Reduces the number of colors in the filtered image
    Converts the original image to grayscale
    (Optionally) applies a median filter to the grayscale image
    Applies a gradient edge detector to the grayscale image
    Thresholds the edge image to binary
    Composites the edge image with the color reduced image
    

    他的网站上有示例,但这些示例与您的示例不相近。您可能需要使用设置才能将其显示为图像的样子。

    • 9
  2. Best Answer
    Takkat
    2015-11-29T00:36:35+08:002015-11-29T00:36:35+08:00

    正如您可能已经发现的那样,来自各种图像处理解决方案的分色过滤器卡通可能需要对原始来源进行相当多的调整,然后我们才能获得与您的示例类似的结果。

    从命令行运行的两个解决方案可能会给您提供接近您的示例的结果,但我们获得的结果仍然在很大程度上取决于所使用的源图像。

    ImageMagick

    使用convertormogrify工具,我们可以将-paint滤镜应用于我们的来源:

    convert -paint <strength> <source> <output>
    

    替换<strength>为整数以指定画笔大小。越小,保留的细节越多。在您的示例中,我使用了4以下结果的强度:

    在此处输入图像描述

    跟踪矢量图形

    通过使用例如 Inkscape将位图追踪到矢量图形,可以获得比位图操作更好的结果。然后我们还可以添加笔触或调整生成的颜色以更好地满足我们的需求。

    可以使用autotrace安装命令行跟踪器(遗憾的是,此软件包仅在 Ubuntu 18.04 或更早版本的存储库中)。

    有许多选项可以调整使用 autotrace 获得的结果。下面的示例是使用这些选项生成的:

    autotrace -color-count 6 -filter-iterations 8 -remove-adjacent-corners -output-format svg input.png > output.svg
    

    在此处输入图像描述

    • 5

相关问题

  • 如何从命令行仅安装安全更新?关于如何管理更新的一些提示

  • 如何从命令行刻录双层 dvd iso

  • 如何从命令行判断机器是否需要重新启动?

  • 文件权限如何工作?文件权限用户和组

  • 如何在 Vim 中启用全彩支持?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve