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:
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.
The dimension is at the first position not the last position. Thus, it should be if img2.shape[0] > 3:
Possible Solutions:
Modify the code in s2p.visualisation.plot_matches_low_level.
Or modify the code in s2p.visualisation.plot_matches.
In s2p.visualisation.plot_matches_low_level, it enforces images to be 3 dimensional like below.
Issues are:
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 butimg1.ndim < 3
isFalse
.if img2.shape[0] > 3:
Possible Solutions:
s2p.visualisation.plot_matches_low_level
.s2p.visualisation.plot_matches
.Thanks.