NAME#
pict.to_npy - Convert picture/text data into a numpy .npy file
SYNOPSIS#
homcloud-pict-to-npy
[-h] [-V] [-T TYPE] -o OUTPUT [-O OUTPUT_TYPE] [-t THRESHOLD]
[--license]
[input ...]
This program can also be invoked as python3 -m homcloud.cli.pict.to_npy.
ALIAS#
homcloud-pict-to-npy
DESCRIPTION#
This program loads N-dimensional picture data (in any of the input
formats accepted by homcloud-pict-binarize-nd) and saves it as a
numpy .npy file, optionally converting the data type.
This is convenient for pre-converting text2d/text_nd/picture2d/
pictures3d data (which can be slow to parse) into an .npy file
that other homcloud-pict-* tools can then load quickly with
-T npy, or for use with homcloud-pict-slice3d.
OPTIONS#
-h, --help show this help message and exit
-V, --version show program's version number and exit
-T TYPE, --type TYPE input data format
(text2d,text_nd(default),picture2d,pictures3d,npy)
-o OUTPUT, --output OUTPUT
output complex file name
-O OUTPUT_TYPE, --output-type OUTPUT_TYPE
output data type (float, int, bool)
-t THRESHOLD, --threshold THRESHOLD
threshold for boolean output
--license show license and exit
-t/--threshold is required when -O bool is given: each pixel
is converted to True if its value is greater than THRESHOLD, else
False.
INPUT FILE FORMAT#
Same formats as homcloud-pict-binarize-nd: text2d, text_nd,
picture2d, pictures3d, and npy. See that document for the
detailed format description.
OUTPUT FORMAT#
A numpy .npy file (written with numpy.save) containing the
loaded picture as an array of dtype float, int, or bool
according to -O/--output-type.
EXAMPLES#
# Stack a series of PNG slices into a single float32 npy volume
homcloud-pict-to-npy -T pictures3d -o volume.npy slice001.png slice002.png slice003.png
# Convert text_nd data into a boolean npy mask
homcloud-pict-to-npy -T text_nd -O bool -t 128 -o mask.npy data.txt