`Patchgenerator` is a simple tool to generate array indices, with or without overlap, to create numpy array patches. Only requires python.
Project description
patchgenerator
The patchgenerator
is a simple tool to generate array indices, with or without overlap, to create numpy array patches. Only requires python.
Example usage:
from patch_indices.patch_indices import PatchGenerator
patch_generator = PatchGenerator(100, 80, 10, 20, y_overlap=2, x_overlap=3)
for patch in patch_generator:
row_start, cols_start, row_end, cols_end = patch
print("row_start, cols_start, row_end, cols_end", row_start, cols_start, row_end, cols_end)
import numpy as np
from patch_indices.patch_indices import PatchGenerator
np_array = np.ones((100, 80, 3), dtype=np.uint8)
y_size, x_size, z_size = np_array.shape
patch_size_y = 10
patch_size_x = 20
patch_generator = PatchGenerator(y_size, x_size, patch_size_y, patch_size_x, y_overlap=2, x_overlap=3)
for patch in patch_generator:
row_start, cols_start, row_end, cols_end = patch
print("row_start, cols_start, row_end, cols_end", row_start, cols_start, row_end, cols_end)
print(np_array[row_start:row_start + row_end, cols_start:cols_start + cols_end, :].shape)
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
patchgenerator-0.0.4.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for patchgenerator-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e95b3bc8e658be4acd99ea66dc638dfe259f0d7c7934cb303e52014c453f6264 |
|
MD5 | 1a003bbe8bad8c5e65edf94bb351019e |
|
BLAKE2b-256 | 451fefc1a9b177303167cfe13ff21cec0a62a68faacec0a2640b37c68130a99e |