def compute_pairwise_shifts(imstack):
# Calculates the pairwise shifts for images in a stack of format [frame, x, y].
# returns shift vector as [y, x] for each pair, a 2 x N-1 array where N is num_frames
scan_shape = imstack.shape
num_pairs = scan_shape[0]-1
print('Correcting ' + str(num_pairs) + ' frames...')
# Prepare window function (Hann)
win = np.outer(np.hanning(scan_shape[1]),np.hanning(scan_shape[2]))
# Pairwise shifts
shift = np.zeros((2, num_pairs))
for iPair in range(0, num_pairs):
image = imstack[iPair]
offset_image = imstack[iPair+1]
shift[:,iPair], error, diffphase = register_translation_hybrid(image*win, offset_image*win,
exponent = 0.3, upsample_factor = 100)
# Shifts are defined as [y, x] where y is shift of imaging location
# with respect to positive y axis, similarly for x
return shift
drift_correction.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录