Python的图像像素。
pixelsort的Python项目详细描述
像素排序
什么是像素排序?
看看this post或{a2}
依赖性
应该可以在python2和python3中使用,但建议使用python3。在
使用
从命令行:
pip install pixelsort
python3 -m pixelsort %PathToImage% [options]
提示:要复制Kim Asendorf的原始processing script,首先在threshold
(默认)模式下垂直排序,然后水平排序:
作为一个包:
>>> 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>
参数:
Parameter | Flag | Description |
---|---|---|
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 ^{ |
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 ^{ |
Char. length | ^{ | Characteristic length for the random width generator. Used in mode ^{ |
Angle | ^{ | Angle at which you're pixel sorting in degrees. ^{ |
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 ^{ |
区间函数
^{tb2}$排序功能
Sorting function | Description |
---|---|
^{ | 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
python3 -m pixelsort examples/image.jpg -i edges -t .5
file
:从使用-f
指定的图像中获取的间隔。一定是黑白的。在
python3 -m pixelsort examples/image.jpg -i file -f examples/intervals.png
(使用elementary-ca生成)
mask
:从使用-m
指定的图像获取的掩码。一定是黑白的。在
python3 -m pixelsort examples/image.jpg -i random -c 20 -m examples/mask.png
待办事项
- 允许为不同的通道定义不同的间隔。在
基于https://gist.github.com/prophetgoddess/667c5554e5d9d9a25ae6
- 项目
标签: