python图片像素化_Python 生成像素化的图片

分享一个 python 的工具,将图片生成像素化的图片。

可以用来生成桌面,图片背景

安装

pip3 install git+https://github.com/sedthh/pyxelate.git

编写 test.py

from pyxelate import Pyxelate

from skimage import io

import matplotlib.pyplot as plt

img = io.imread("blade_runner.jpg") #图片的地址

# generate pixel art that is 1/14 the size

height, width, _ = img.shape

factor = 14

colors = 6

dither = True

p = Pyxelate(height // factor, width // factor, colors, dither)

img_small = p.convert(img) # convert an image with these settings

_, axes = plt.subplots(1, 2, figsize=(16, 16))

axes[0].imshow(img)

axes[1].imshow(img_small)

plt.show()

运行

python3 test.py

哈哈可能图片的原因,没有官方 GitHub 的效果好

更多效果,大家自己挖掘哈

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值