def compute_shift(imp1, imp2): """ Compute a Point3i that expressed the translation of imp2 relative to imp1.""" phc = PhaseCorrelation(ImagePlusAdapter.wrap(imp1), ImagePlusAdapter.wrap(imp2), 5, True) phc.process() p = phc.getShift().getPosition() if len(p)==3: # 3D data p3 = p elif len(p)==2: # 2D data: add zero shift for z p3 = [p[0],p[1],0] return Point3i(p3)
def compute_shift_using_phasecorrelation(imp1, imp2, bg_level): IJ.run(imp1, "Subtract...", "value="+str(bg_level)+" stack"); IJ.run(imp2, "Subtract...", "value="+str(bg_level)+" stack"); """ Compute a Point3i that expressed the translation of imp2 relative to imp1.""" phc = PhaseCorrelation(ImagePlusAdapter.wrap(imp2), ImagePlusAdapter.wrap(imp1), 5, True) phc.process() p = phc.getShift().getPosition() #print(p) #pp = phc.getAllShifts() #for p in pp: # print(p.getPosition()) #ddd if len(p)==3: # 3D data p3 = p elif len(p)==2: # 2D data: add zero shift p3 = [p[0],p[1],0] return Point3i(p3)
def convert_shifts_to_integer(shifts): int_shifts = [] for shift in shifts: int_shifts.append(Point3i(int(round(shift.x)),int(round(shift.y)),int(round(shift.z)))) return int_shifts