Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a8b71fd

Browse filesBrowse files
committed
乌鸦 代码提交
1 parent 0331284 commit a8b71fd
Copy full SHA for a8b71fd

File tree

Expand file treeCollapse file tree

2 files changed

+26
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+26
-0
lines changed
Open diff view settings
Collapse file

‎wuya/README.md‎

Copy file name to clipboardExpand all lines: wuya/README.md
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- [midAutumn](https://github.com/JustDoPython/python-examples/tree/master/wuya/midAutumn) : 中秋假期,回不了家的程序员,竟然用Python做了这件事...
66
- [level](https://github.com/JustDoPython/python-examples/tree/master/wuya/level) : 多亏学了这个python库,一晚上端掉了一个传销团伙。。。
77
- [find_house](https://github.com/JustDoPython/python-examples/tree/master/wuya/find_house) : 别再听野中介忽悠了,用python租到最合适的房子!
8+
- [imgmodify](https://github.com/JustDoPython/python-examples/tree/master/wuya/imgmodify) : 跟女朋友旅游三天,Python治好了我的精神内耗...
89

910
---
1011

Collapse file

‎wuya/imgmodify/imgmodify.py‎

Copy file name to clipboard
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import cv2
2+
import numpy as np
3+
import os
4+
5+
def modify_image(img_path, target_dir):
6+
# 读取全部图片
7+
pic = cv2.imread(img_path, cv2.IMREAD_UNCHANGED)
8+
# 将图片修改为HSV
9+
pichsv = cv2.cvtColor(pic, cv2.COLOR_BGR2HSV)
10+
# 提取饱和度和明度
11+
H,S,V = cv2.split(pichsv)
12+
# S为饱和度,V为明度
13+
new_pic = cv2.merge([np.uint8(H), np.uint8(S*1.4), np.uint8(V*0.9)])
14+
# 将合并后的图片重置为RGB
15+
pictar = cv2.cvtColor(new_pic, cv2.COLOR_HSV2BGR)
16+
# 获取原文件名
17+
file_name = img_path.split("/")[-1]
18+
# 将图片写入目录
19+
cv2.imwrite(os.path.join(target_dir, file_name), pictar)
20+
21+
root, dirs, files = next(os.walk("./test/"))
22+
23+
for item in files:
24+
img_path = os.path.join(root,item)
25+
process_image(img_path, "./target/")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.