s2p icon indicating copy to clipboard operation
s2p copied to clipboard

Bug in s2p.visualisation.plot_matches_low_level

Open lionlai1989 opened this issue 2 years ago • 0 comments

In s2p.visualisation.plot_matches_low_level, it enforces images to be 3 dimensional like below.

    if img1.ndim < 3:
        img1 = np.dstack([img1] * 3)
    if img2.ndim < 3:
        img2= np.dstack([img2] * 3)

    # if images have more than 3 channels, keep only the first 3
    if img1.shape[2] > 3:
        img1 = img1[:, :, 0:3]
    if img2.shape[2] > 3:
        img2 = img2[:, :, 0:3]

Issues are:

  1. rasterio.read by default returns 3D array, (dim, height, width) = array.shape. If reading a panchromatic image (1 band only), its dimension is still 3D but img1.ndim < 3 is False.
  2. The dimension is at the first position not the last position. Thus, it should be if img2.shape[0] > 3:

Possible Solutions:

  1. Modify the code in s2p.visualisation.plot_matches_low_level.
  2. Or modify the code in s2p.visualisation.plot_matches.

Thanks.

lionlai1989 avatar Jun 22 '22 05:06 lionlai1989