Script to rebin stacks of jp2 images. This is designed to minimise memory usage, and scale across multiple processes.
⚠️ The JPEG2000 compression parameters are tailored to HiP-CT images, so may not be appropriate for other datasets.
To get this working on any operating system, it's recommended to install miniconda. Once you have a terminal (or "Anaconda prompt" on Windows) open after installation, these steps will set you up to run the rebinning:
- Change to a directory where you want to download this code.
git clone https://github.com/HiPCTProject/rebin
cd rebin
conda env create -f conda-env.yml
conda activate rebin
Now you should be able to run the rebinning code using the example below.
Download rebin.py
.
Example run:
python rebin.py --bin-factor=2 --cratio=10 --num-workers=8 --directory path/to/jp2/directory --output-directory path/to/output/directory
python rebin.py --help
Usage: rebin.py [OPTIONS]
Options:
--bin-factor INTEGER Number of pixels in each bin.
--cratio INTEGER Compression ratio to use to save jp2 images.
--num-workers INTEGER Number of workers used to process in parallel.
--directory TEXT Directory with jp2 images.
--output-directory TEXT Directory to output images to.
--fname-prefix TEXT String to add the beginning of all output jp2
files.
--help Show this message and exit.