You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to multiprocess image pairs to speed up registration:
def regWorker(ref, cur):
sr = StackReg(StackReg.TRANSLATION)
ref_img = cv2.imread(ref, -1).astype(np.float64)
cur_img = cv2.imread(cur, -1).astype(np.float64)
registered = sr.register_transform(ref_img, cur_img).astype(np.uint16)
return cur, registered
def register_tseries(img_paths, n_proc):
l = list(img_paths.values())
inp = [(l[i], l[i+1]) for i in range(len(l)-1)]
p = Pool(processes=n_proc)
res = p.starmap(regWorker, inp)
for r in res:
cv2.imwrite(r[0], r[1])
The output from the code doesn't quite match that from the following sequential call and I'm wondering why?
def register_tseries(img_paths, n_proc):
l = list(img_paths.values())
inp = [(l[i], l[i + 1]) for i in range(len(l) - 1)]
sr = StackReg(StackReg.TRANSLATION)
for i in inp:
ref_img = cv2.imread(i[0], -1).astype(np.float64)
cur_img = cv2.imread(i[1], -1).astype(np.float64)
registered = sr.register_transform(ref_img, cur_img).astype(np.uint16)
cv2.imwrite(i[1], registered)
Thanks!
The text was updated successfully, but these errors were encountered:
in the sequential version you're replacing the second image ("cur") by the registered one and you then read that registered one back in the next iteration (now as "ref"). In the parallel version, you are often reading the unregistered one as the reference as it wasn't registered previously. Additionally you might be reading corrupt files if you happen to read a file in one process that is concurrently written in another process.
To parallelize you need to first determine the transformation matrix for each pair of images (you can do that in parallel), then sequentially multiply each transformation matrix with the previous one, then you can again in parallel apply the transformation matrices to each image. This won't work with the bilinear transformation.
I'm trying to multiprocess image pairs to speed up registration:
The output from the code doesn't quite match that from the following sequential call and I'm wondering why?
Thanks!
The text was updated successfully, but these errors were encountered: