def lanczosSubPixShiftStack( imageStack, translations, n_threads=16 ):
"""
Does subpixel translations shifts for a stack of images using a ThreadPool to distribute the load.
I could make this a general function utility by passing in the function handle.
"""
tPool = ThreadPool( n_threads )
if imageStack.ndim != 3:
raise ValueError( "lanczosSubPixShiftStack() only works on image stacks with Z-axis as the zero dimension" )
slices = imageStack.shape[0]
# Build parameters list for the threaded processeses, consisting of index
tArgs = [None] * slices
for J in np.arange(slices):
tArgs[J] = (J, imageStack, translations)
# All operations are done 'in-place'
tPool.map( lanczosIndexedShift, tArgs )
tPool.close()
tPool.join()
评论列表
文章目录