centreborelli / s2p

Satellite Stereo Pipeline
GNU Affero General Public License v3.0
209 stars 67 forks source link

Bug in s2p.visualisation.plot_matches_low_level #125

Open lionlai1989 opened 2 years ago

lionlai1989 commented 2 years ago

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.