# Copyright (c) 2025, Maxime Paschoud.# All rights reserved.## This source code is licensed under the BSD-style license found in the# LICENSE file in the root directory of this source tree.## (http://opensource.org/licenses/BSD-3-Clause)## __author__ = "Maxime Paschoud, ETHZ: CMBM"#from.imageimportImageimportnumpyasnpfrom.geometryimportget_rotation_matrix
[docs]classImagePair:def__init__(self,img1:Image,img2:Image,tilt_axis):self.img1=img1self.img2=img2self.tilt_diff=img2.tilt-img1.tiltself.tilt_axis=tilt_axisifimg1.tilt_rad!=img2.tilt_rad:raiseValueError('one image has tilt in rad the other not')else:self.tilt_rad=img1.tilt_raddef__getitem__(self,index):ifindex==0:returnself.img1elifindex==1:returnself.img2else:raiseIndexError('Index for a pair should be 0 or 1')
[docs]defrotate(self,angle,rad=False):ifself.tilt_axisisNone:raiseAttributeError('tilt_axis is None for this image pair.')self.img1.rotate(angle)self.img2.rotate(angle)self.tilt_axis=self.tilt_axis@get_rotation_matrix([0.,0,1],angle,rad=rad).T