linumpy.registration.transforms#

Transform construction and mosaic-level transform estimation.

Functions#

create_transform(tx, ty, angle_deg, center)

Create a 3D SimpleITK Euler transform from 2D parameters.

compute_motor_transform(tile_shape, overlap_fraction)

Compute the transform matrix for motor-based tile positions.

estimate_mosaic_transform(mosaics[, ...])

Estimate the 2x2 mosaic transform from pairwise phase-correlation registration.

Module Contents#

linumpy.registration.transforms.create_transform(tx, ty, angle_deg, center)[source]#

Create a 3D SimpleITK Euler transform from 2D parameters.

Parameters:
  • tx (float) – Translation in pixels.

  • ty (float) – Translation in pixels.

  • angle_deg (float) – Rotation angle in degrees (around Z axis).

  • center (sequence) – (cx, cy) rotation center.

Return type:

sitk.Euler3DTransform

linumpy.registration.transforms.compute_motor_transform(tile_shape, overlap_fraction)[source]#

Compute the transform matrix for motor-based tile positions.

Creates a diagonal transform where tile index (i, j) maps to a pixel position based on the expected overlap, corresponding to precise motor/stage positions from acquisition.

Parameters:
  • tile_shape (tuple or list) – Tile shape as (height, width) in pixels.

  • overlap_fraction (float) – Expected overlap between tiles (0-1).

Returns:

2x2 transform matrix where transform @ [i, j] gives the pixel position of tile (i, j).

Return type:

np.ndarray

linumpy.registration.transforms.estimate_mosaic_transform(mosaics, max_empty_fraction=0.9, n_samples=512, seed=None)[source]#

Estimate the 2x2 mosaic transform from pairwise phase-correlation registration.

For each mosaic, neighbouring tile pairs are registered with pair_wise_phase_correlation() and the resulting pixel displacements are assembled into a least-squares system to recover the underlying affine transform.

Parameters:
  • mosaics (list of MosaicGrid) – Loaded mosaic grids to use for estimation.

  • max_empty_fraction (float, optional) – Maximum fraction of empty pixels in an overlap region to still use the pair (default 0.9).

  • n_samples (int, optional) – Maximum number of tile pairs to sample across all mosaics (default 512).

  • seed (int, optional) – Random seed for reproducible tile-pair sampling.

Returns:

  • transform (np.ndarray) – 2x2 transform matrix.

  • residuals (np.ndarray) – Residuals from the least-squares fit.

  • tile_count (int) – Number of tile pairs actually used.

Return type:

tuple[numpy.ndarray, numpy.ndarray, int]