将图片转换为字符画
-
创建并激活虚拟环境,使用的是 Python 3.6.2 开发
virtualenv --no-site-packages env source env/bin/activate
-
安装
pip install picturizer
-
使用
picturize -i ~/Downloads/a_picture.jpg -o ~/Downloads/result.txt -s 1.0
picturize -h
usage: picturize [-h] -i [source_path] [-o [store_path]] [-s [a_scale]]
optional arguments:
-h, --help show this help message and exit
-i [source_path], --input [source_path]
input file
-o [store_path], --output [store_path]
output file
-s [a_scale], --scale [a_scale]
scale of the picture, should be 0 < scale <= 1
-
心理学公式
Gray = R*0.299 + G*0.587 + B*0.114
-
计算机效率处理公式
Gray = (R*19595 + G*38469 + B*7472) >> 16