Code and performance tests to demonstrate the COUNTLESS algorithm, a method for downsampling image labels based on taking the mode of small image patches to perform 2x2 and 2x2x2 downsampling. This algorithm works very well with vectorized instructions. It was originally designed to work around the weakness of Python's looping speed by taking advantage of numpy operators.
COUNTLESS 2D Downsample an image 2x2 (article)
Stippled COUNTLESS 2D Downsample an image 2x2 holding black as background (article)
COUNTLESS 3D Downsample an image 2x2x2 (article)
COUNTLESS N Downsample by any factor. Watch your memory consumption.
Several people contributed helpful advice and assistance in developing COUNTLESS. Chris Jordan provided the seed of the C implementation of counting and countless. Dr. George Nagy suggested testing countless_if and testing the performance differential on homogenous and non-homogenous images. Jeremy Maitin-Shepard at Google originally developed the Python code for striding and downsample_with_averaging for use with neuroglancer. Special thanks to Seung Lab for providing neural segmentation labels.