downscale
downscale
pads an image stack to make its dimensions evenly divisible by a target resolution, then downscales it to that resolution, effectively reducing the number of voxels for computations like Finite Element Analysis, resulting in a significant reduction in image resolution while adding padding to maintain dimension compatibility.
With recon3d
installed in a virtual environment called .venv
, the downscale
functionality is provided as a command line interface.
We will use the subject thunder_gray.tif
for demonstration:
The subject file, a grayscale image with 734x348
of pixel resolution, is shown in the Graphic app to demonstrate pixel height and width.
Contents of downscale_thunder.yml
:
cli_entry_points:
- downscale
downscale_tolerance: 0.0001
image_dir: tests/data/thunder_gray
image_limit_factor: 2.0
image_type: .tif
out_dir: tests/data/output # output path for the processed files
output_stack_type: padded
padding:
nx: 10
ny: 10
nz: 0
resolution_input:
dx: 10.0
dy: 10.0
dz: 10.0
resolution_output:
dx: 50.0
dy: 50.0
dz: 10.0
save_npy: true
writeVTR: true
downscale downscale_thunder.yml
produces:
Processing file: downscale_thunder.yml
Success: database created from file: downscale_thunder.yml
key, value, type
---, -----, ----
cli_entry_points, ['downscale'], <class 'list'>
downscale_tolerance, 0.0001, <class 'float'>
image_dir, tests/data/thunder_gray, <class 'str'>
image_limit_factor, 2.0, <class 'float'>
image_type, .tif, <class 'str'>
out_dir, tests/data/output, <class 'str'>
output_stack_type, padded, <class 'str'>
padding, {'nx': 10, 'ny': 10, 'nz': 0}, <class 'dict'>
resolution_input, {'dx': 10.0, 'dy': 10.0, 'dz': 10.0}, <class 'dict'>
resolution_output, {'dx': 50.0, 'dy': 50.0, 'dz': 10.0}, <class 'dict'>
save_npy, True, <class 'bool'>
writeVTR, True, <class 'bool'>
The output file is shown below:
Shown together, the grayscale image went from 734x348
to 147x70
(5x
reduction) plus 10+10
padding to 167x90
of pixel resolution. The downscales image is shown atop the subject image in the Graphic app to demonstrate pixel height and width. Note the black border padding width of 10
pixels.
A 50_dx.npy
and 50_dx.vtr
file are also saved to the specified out_dir
that can be used for additional analysis and visualization.