File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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/" )
You can’t perform that action at this time.
0 commit comments