Maximum Entropy Textures
Project description
Metex - Maximum Entropy TEXtures
Utilities for generating maximum entropy textures, according to Victor and Conte 2012.
Metex can be used as a standalone software from the command line, or as a Python package to generate and manipulate textures.
Requirements
- Python 3
- numpy ≥ 1.7
- matplotlib
Installation
To install the latest release, run:
pip install metex
(depending on your system, you may need to use pip3
instead of pip
in the command above).
This should install the metex
package on your PYTHONPATH
, as well
as an executable script called metex
to your regular PATH
.
Testing
(requires setuptools
). If metex
is already installed on your
system, look for the copy of the test_library.py
and
test_cli_interface.sh
scripts installed alongside the rest of the
metex
files and execute it. For example:
python /usr/lib/python3.X/site-packages/metex/test/test_library.py
/bin/bash /usr/lib/python3.X/site-packages/metex/test/test_cli_interface.sh
Usage (command line)
Generate one sample of a fully random, square 10x10 texture, which will be saved to the current folder as '0.png':
metex 10
Save 10 samples of a 100x150 texture in folder named 'fig', with parameter 'alpha' set to -0.6. Name each sample 'fig_[n].png', where [n] takes on values 0,...,9:
metex --folder=fig --prefix=fig_ --n_samples=10 --alpha=-0.6 100 150
For more information on the command line parameters,
metex --help
(also see metex/core.py
).
Usage (library)
The library implements a Texture
class that represents the maximum
entropy distribution of textures with a given level of a statistic and
a given size. Objects of class Texture
can be sampled, generating
objects of class TextureSample
. This is a subclass of
numpy.ndarray
with support for array-like manipulation, image
generation for use in experiments (via matplotlib) and terminal-based
pretty-printing (for messing around).
>>> import metex
>>> texture = metex.Texture(height=15, width=25, beta1=0.7)
>>> sample = texture.sample()
>>> print(sample)
⬛⬛⬛⬛⬛⬜⬛⬛⬜⬛⬛⬛⬛⬛⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜⬜
⬜⬛⬛⬛⬛⬛⬛⬛⬜⬜⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛
⬜⬜⬜⬜⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬛⬜⬛⬜⬜⬜⬜⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬜⬜
⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬛⬛⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬛⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬛⬛⬜
⬜⬜⬜⬜⬜⬜⬛⬛⬛⬜⬜⬛⬛⬛⬛⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜
⬛⬛⬛⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬛⬜⬜⬜⬜⬜⬜⬛⬛
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬛⬜⬛⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬛⬜⬜⬛⬛⬛⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬛⬛⬜⬜
⬜⬜⬛⬜⬜⬜⬜⬜⬜⬛⬛⬛⬛⬛⬛⬛⬜⬜⬜⬛⬜⬛⬛⬜⬜
⬛⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜⬜⬜⬜⬛⬛⬜⬜⬛⬛⬛⬛⬛⬛⬛
⬜⬜⬜⬜⬛⬛⬛⬛⬛⬛⬛⬛⬛⬜⬛⬛⬜⬜⬜⬜⬜⬜⬜⬜⬜
>>> print(sample[:5,:])
⬛⬛⬛⬛⬛⬜⬛⬛⬜⬛⬛⬛⬛⬛⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜⬜
⬜⬛⬛⬛⬛⬛⬛⬛⬜⬜⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛
⬜⬜⬜⬜⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬛⬜⬛⬜⬜⬜⬜⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬜⬜
⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛
>>> print(sample[:,:5])
⬛⬛⬛⬛⬛
⬜⬛⬛⬛⬛
⬜⬜⬜⬜⬛
⬛⬜⬛⬜⬜
⬛⬛⬛⬛⬛
⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜
⬛⬛⬛⬜⬜
⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜
⬛⬜⬜⬛⬛
⬜⬜⬛⬜⬜
⬛⬛⬛⬛⬛
⬜⬜⬜⬜⬛
The exact rendering of the texture will depend on your terminal.
Changelog
See the CHANGELOG.md file for a list of changes from older versions.
Authors
metex
is maintained by Eugenio Piasini.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file metex-1.2.0.tar.gz
.
File metadata
- Download URL: metex-1.2.0.tar.gz
- Upload date:
- Size: 22.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38e2c913d0de746d4d9ef319c3fee9132124f5f7cd5b940018c79065725d6774 |
|
MD5 | 8276cea974c8d99060765a25e3c4f5ca |
|
BLAKE2b-256 | a70263beb4b3b4037cc9d73c65c06e106a25b62b02784b7ac51f1512a776dea2 |
File details
Details for the file metex-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: metex-1.2.0-py3-none-any.whl
- Upload date:
- Size: 21.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9197a5d1f44833dcac5fc87c5266826572abcf6c31850f0f7546019fbefd435 |
|
MD5 | 3f3f3a67c9ad512c5dd6f42948bb8be5 |
|
BLAKE2b-256 | 689b37e464ceb89815686fbc409a656a9d978c46bb2c17859cfea17175118eb4 |