Python的图像像素。

pixelsort的Python项目详细描述


像素排序

什么是像素排序?

看看this post或{a2}

依赖性

应该可以在python2和python3中使用,但建议使用python3。在

使用

从命令行:

pip install pixelsort
python3 -m pixelsort %PathToImage% [options]

提示:要复制Kim Asendorf的原始processing script,首先在threshold(默认)模式下垂直排序,然后水平排序:

^{pr2}$

作为一个包:

>>> from pixelsort import pixelsort
>>> from PIL import Image
>>> a = Image.open("examples/image.jpg")
>>> a
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=576x324 at 0x7F8F6A2AC208>
>>> pixelsort(a)
<PIL.Image.Image image mode=RGBA size=576x324 at 0x7F8F66AA57B8>

参数:

ParameterFlagDescription
Interval function^{}Controls how the intervals used for sorting are defined. See below for more details and examples. Threshold by default.
Output path^{}Path of output file. Uses the current time for the file name by default.
Randomness^{}What percentage of intervals not to sort. 0 by default.
Threshold (lower)^{}How dark must a pixel be to be considered as a 'border' for sorting? Takes values from 0-1. 0.25 by default. Used in ^{} and ^{} modes.
Threshold (upper)^{}How bright must a pixel be to be considered as a 'border' for sorting? Takes values from 0-1. 0.8 by default. Used in ^{} mode.
Char. length^{}Characteristic length for the random width generator. Used in mode ^{} and ^{}.
Angle^{}Angle at which you're pixel sorting in degrees. ^{} (horizontal) by default.
External interval file^{}Image used to define intervals. Must be black and white.
Sorting function^{}Sorting function to use for sorting the pixels. Lightness by default.
Mask^{}Image used for masking parts of the image.
Logging level^{}Level of logging statements made visible. Choices include ^{}, ^{}, ^{}, ^{}, and ^{}. ^{} by default.

区间函数

^{tb2}$

排序功能

Sorting functionDescription
^{}Sort by the lightness of a pixel according to a HSV representation.
^{}Sort by the hue of a pixel according to a HSV representation.
^{}Sort by the saturation of a pixel according to a HSV representation.
^{}Sort by the intensity of a pixel, i.e. the sum of all the RGB values.
^{}Sort on the minimum RGB value of a pixel (either the R, G or B).

示例

python3 -m pixelsort examples/image.jpg -i random -c 20

random

python3 -m pixelsort examples/image.jpg -i edges -t .5

edges

  • file:从使用-f指定的图像中获取的间隔。一定是黑白的。在

python3 -m pixelsort examples/image.jpg -i file -f examples/intervals.png

file

(使用elementary-ca生成)

file

  • mask:从使用-m指定的图像获取的掩码。一定是黑白的。在

python3 -m pixelsort examples/image.jpg -i random -c 20 -m examples/mask.png

file

file

待办事项

  • 允许为不同的通道定义不同的间隔。在

基于https://gist.github.com/prophetgoddess/667c5554e5d9d9a25ae6

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Oracle Java:NLS_区域是否足以正确格式化数字?   java开放Api$ref以使用url   如何在java中使用synchronized方法实现线程的同步?   java无法创建JVM Android studio   使用基本Java检查两个字符串是否是彼此的字谜   spring:如何将java安全配置转换为yml   java如何扩展任何移动服务提供商的SMSC?   如何转换java。util。日期到soap支持的日期格式“yyyyMMdd'T'HH:mm:ss”,带区域id   java Hibernate:中间关系   java从main中的其他类调用方法   java找出由两个长历元值表示的两个日期之间的差异   java更新cloudera quickstart vm以使用java7   java jOOQ将字符串转换为布尔值   java定制Android Spinner XML w/SpinnerAdapter?