当前位置:网站首页>2种手绘风格效果比较,你更喜欢哪一种呢?
2种手绘风格效果比较,你更喜欢哪一种呢?
2022-07-30 18:43:00 【果州做题家】
2种手绘风格比较,你更喜欢哪一种呢?
先看视频效果:
2种手绘效果与赵盼儿舞蹈剪辑之比较
下边看2种不同手绘风格的代码:
导入工具包
import cv2
import numpy as np
#导入python绘图matplotlib
import matplotlib.pyplot as plt
#使用ipython的魔法方法,将绘制出的图像直接嵌入在notebook单元格中
%matplotlib inline
#定义可视化图像函数
def look_img(img):
'''opencv读入图像格式为BGR,matplotlib可视化格式为RGB,因此需将BGR转RGB'''
img_RGB = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
plt.imshow(img_RGB)
plt.show()
手绘效果1
vec_el = np.pi/2.2 # 光源的俯视角度,弧度值
vec_az = np.pi/4. # 光源的方位角度,弧度值
depth = 10. # (0-100)
im=cv2.imread('zhaopaner.jpg',0) #加载灰度图
look_img(im)
a = np.asarray(im).astype('float')
grad = np.gradient(a) #取图像灰度的梯度值
grad_x, grad_y = grad #分别取横纵图像梯度值
grad_x = grad_x*depth/100.
grad_y = grad_y*depth/100.
dx = np.cos(vec_el)*np.cos(vec_az) #光源对x 轴的影响
dy = np.cos(vec_el)*np.sin(vec_az) #光源对y 轴的影响
dz = np.sin(vec_el) #光源对z 轴的影响
A = np.sqrt(grad_x**2 + grad_y**2 + 1.)
uni_x = grad_x/A
uni_y = grad_y/A
uni_z = 1./A
a2 = 255*(dx*uni_x + dy*uni_y + dz*uni_z) #光源归一化
a2 = a2.clip(0,255)
im2=np.asarray(a2).astype('uint8')
look_img(im2)
cv2.imwrite('zhaopaner_1.jpg',im2)


True
手绘效果2
img = cv2.imread('zhaopaner.jpg')
height=img.shape[0] #可自行修改尺寸,此处和原尺寸相同
width=img.shape[1] #可自行修改尺寸,此处和原尺寸相同
dim = (width,height)
resized = cv2.resize(img,dim,interpolation = cv2.INTER_AREA)
kernel_sharpening = np.array([[-1,-1,-1],
[-1, 9,-1],
[-1,-1,-1]])
sharpened = cv2.filter2D(resized,-1,kernel_sharpening)
gray = cv2.cvtColor(sharpened , cv2.COLOR_BGR2GRAY)
object_detection = cv2.cvtColor(sharpened, cv2.COLOR_BGR2HSV )
inv = 255-gray
gauss = cv2.GaussianBlur(inv,ksize=(15,15),sigmaX=0,sigmaY=0)
pencil = cv2.divide(gray,255-gauss,scale=256)
look_img(resized)
look_img(sharpened)
look_img(gray)
look_img(pencil)
cv2.imwrite('zhaopaner_2.jpg',pencil)




True
图片拼接
import cv2
from PIL import Image
im1 = cv2.imread('zhaopaner.jpg')
im2 = cv2.imread('zhaopaner_1.jpg')
im3 = cv2.imread('zhaopaner_2.jpg')
img0 = cv2.cvtColor(np.hstack((im1, im2,im3)), cv2.COLOR_BGR2RGB)
im=Image.fromarray(img0)
display(im)

边栏推荐
- DM8: Single database and single instance to build a local data guard service
- A senior with 13 years of experience in software testing, summed up 5 test employment suggestions....
- ESP8266-Arduino编程实例-HC-SR04超声波传感器驱动
- ByteArrayInputStream class source code analysis
- 好未来单季营收2.24亿美元:同比降84% 张邦鑫持股26.3%
- Hello, my new name is "Bronze Lock/Tongsuo"
- ESP8266-Arduino programming example-BMP180 air pressure temperature sensor driver
- Does the satellite phone communicate directly with the satellite or through a ground station?
- The sixteenth issue of eight-part article Balabala said (MQ)
- 怎么样的框架对于开发者是友好的?
猜你喜欢
![[Prometheus] An optimization record of the Prometheus federation [continued]](/img/5d/56e171b7a02584337a0cfe5c731fb2.png)
[Prometheus] An optimization record of the Prometheus federation [continued]

中集世联达飞瞳全球工业人工智能AI领军者,全球顶尖AI核心技术高泛化性高鲁棒性稀疏样本持续学习,工业级高性能成熟AI产品规模应用

图解LeetCode——11. 盛最多水的容器(难度:中等)

Scrapy框架介绍

node封装一个控制台进度条插件

SwiftUI iOS Boutique Open Source Project Complete Baked Food Recipe App based on SQLite (tutorial including source code)

- daily a LeetCode 】 【 191. A number of 1

Redis for infrastructure

【剑指 Offer】剑指 Offer 22. 链表中倒数第k个节点

使用postman调接口报Content type ‘text/plain;charset=UTF-8‘ not supported
随机推荐
自然语言处理nltk
设计消息队列存储消息数据的 MySQL 表格
(2022杭电多校四)1001-Link with Bracket Sequence II(区间动态规划)
一文读懂“语言模型”
【HMS core】【FAQ】HMS Toolkit典型问题合集1
nlohmann json 使用指南【visual studio 2022】
【总结】1396- 60+个 VSCode 插件,打造好用的编辑器
Swiper轮播图片并播放背景音乐
[Prometheus] An optimization record of the Prometheus federation [continued]
深化校企合作 搭建技术技能人才成长“立交桥”
DM8: Single database and single instance to build a local data guard service
The use of @ symbol in MySql
图解LeetCode——11. 盛最多水的容器(难度:中等)
ESP8266-Arduino programming example-BMP180 air pressure temperature sensor driver
Scrapy framework is introduced
Swiper rotates pictures and plays background music
Chapter 4 Controlling the Execution Flow
二分答案裸题(加一点鸽巢原理)
DTSE Tech Talk丨第2期:1小时深度解读SaaS应用系统设计
CMake库搜索函数居然不搜索LD_LIBRARY_PATH