当前位置:首页 > python > 正文内容

python 实现彩色图转素描图

zhangsir3年前 (2022-11-21)python446

python可以把彩色图片转化为铅笔素描草图,对人像、景色都有很好的效果。


而且只需几行代码就可以一键生成,适合批量操作,非常的快捷。


需要的第三方库:


Opencv - 计算机视觉工具,可以实现多元化的图像视频处理,有Python接口


""" Photo Sketching Using Python """
  import cv2
  img = cv2.imread("elon.jpg")
  ## Image to Gray Image
  gray_image = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
  ## Gray Image to Inverted Gray Image
  inverted_gray_image = 255-gray_image
  ## Blurring The Inverted Gray Image
  blurred_inverted_gray_image = cv2.GaussianBlur(inverted_gray_image, (19,19),0)
  ## Inverting the blurred image
  inverted_blurred_image = 255-blurred_inverted_gray_image
  ### Preparing Photo sketching
  sketck = cv2.divide(gray_image, inverted_blurred_image,scale= 256.0)
  cv2.imshow("Original Image",img)
  cv2.imshow("Pencil Sketch", sketck)
  cv2.waitKey(0)


zhangsir版权f8防采集https://mianka.xyz

扫描二维码推送至手机访问。

版权声明:本文由zhangsir or zhangmaam发布,如需转载请注明出处。

本文链接:https://www.mianka.xyz/post/67.html

分享给朋友:

“python 实现彩色图转素描图” 的相关文章

Python post请求报错 Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

Python用post方式请求接口数据的时候,报错:Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported这是由于没有设置 Content-Typ...

python之seleniumwire获取network(网络)信息

python之seleniumwire获取请求头参数import time from seleniumwire import webdriver # 创建Chrome驱动程序的新实例 driver = webdriver...

pip安装三方库 国内的一些镜像站点推荐

pip 国内的一些镜像站点推荐镜像套路:使用cmd;输入命令pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple 包名 即可开始安装。清华:https://pypi.tuna.tsinghua.edu.cn/simple 阿里云:http...

解决Django的request.POST获取不到请求参数的问题

这个是Django自身的问题:只要在请求头的添加"content-type":'application/x-www-form-urlencoded'就行。...

python selenium find_element_by_xpath 方法已经被弃用的解决办法

背景:在使用最新3.10.4Python版本时候,用selenium进行xpath定位元素,编译器提示:DeprecationWarning:find_element_by_xpath is deprecated. Please use find_element(by=By.XPATH, value...

python—pymysql的增删改查操作实例展示

Python使用pymysql连接数据库1.导包import pymysql2.连接数据库connection = pymysql.connect(     host='',  # ...