COSIE.image_preprocessing.generate_homograph

generate_homograph(keypoints_src, keypoints_dst, transform_type='rigid')[source]

Generate a geometric transformation matrix from source to destination keypoints, using either rigid or affine transformation.

Parameters

keypoints_srcnp.ndarray

Source keypoints of shape (N, 2), e.g., from image A.

keypoints_dstnp.ndarray

Destination keypoints of shape (N, 2), e.g., from image B.

transform_typestr, optional

Type of transformation to apply. Must be one of {“rigid”, “affine”}.

  • “rigid”: Applies rotation and translation only.

  • “affine”: Allows for rotation, translation, and shearing/skewing.

Default is “rigid”.

Returns

trans_matnp.ndarray

The transformation matrix:

  • Shape is (2, 3) for “rigid” transforms.

  • Shape is (3, 3) for “affine” transforms.