def show_pan_img(image): pan_ext=np.expand_dims(image,axis=0) plt.figure() th_pan = image_quantile(pan_ext, np.array([0.01, 0.99])) pan_ext = image_stretch(np.squeeze(pan_ext),np.squeeze(th_pan)) plt.imshow(pan_ext,cmap='gray',clim=[0,1]) plt.title('PANCHROMATIC'), plt.axis('off') plt.show()
def show_ms_img(image, rgb_idx): th_msrgb = image_quantile(np.squeeze(image[rgb_idx,:,:]), np.array([0.01, 0.99])); d = image_stretch(np.squeeze(image[rgb_idx,:,:]),th_msrgb) d[d<0] = 0 d[d>1] = 1 plt.imshow(d.transpose(1,2,0)) plt.title('MULTISPECTRAL LOW RESOLUTION'), plt.axis('off') plt.show()
epochs) #%% save data export2(I_MS_HR, test_dir_out) #%% Visualization from image_quantile import image_quantile, image_stretch import matplotlib.pyplot as plt plt.close('all') I_PAN = np.expand_dims(I_PAN, axis=0) plt.figure() plt.subplot(131) th_PAN = image_quantile(I_PAN, np.array([0.01, 0.99])) PAN = image_stretch(np.squeeze(I_PAN), np.squeeze(th_PAN)) plt.imshow(image_stretch(np.squeeze(I_PAN), np.squeeze(th_PAN)), cmap='gray', clim=[0, 1]) plt.title('PANCHROMATIC'), plt.axis('off') RGB_indexes = np.array(inputImg['RGB_indexes']) RGB_indexes = RGB_indexes - 1 plt.subplot(132) th_MSrgb = image_quantile(np.squeeze(I_MS_LR[RGB_indexes, :, :]), np.array([0.01, 0.99])) d = image_stretch(np.squeeze(I_MS_LR[RGB_indexes, :, :]), th_MSrgb) d[d < 0] = 0 d[d > 1] = 1 plt.imshow(d.transpose(1, 2, 0))
print("Time CNN:", elapsed, 'sec') #%% save data choice one for time export2(I_Fus_CNN, test_dir_out) #%% Visualization from image_quantile import image_quantile, image_stretch import matplotlib.pyplot as plt plt.close('all') I_PAN = np.expand_dims(I_PAN, axis=0) plt.figure() plt.subplot(231) th_PAN = image_quantile(I_PAN, np.array([0.01, 0.99])) PAN = image_stretch(np.squeeze(I_PAN), np.squeeze(th_PAN)) plt.imshow(image_stretch(np.squeeze(I_PAN), np.squeeze(th_PAN)), cmap='gray', clim=[0, 1]) plt.title('PAN Image'), plt.axis('off') RGB_indexes = np.array([3, 2, 1]) #RGB_indexes = RGB_indexes - 1 plt.subplot(232) th_MSrgb = image_quantile(np.squeeze(I_MS[RGB_indexes, :, :]), np.array([0.01, 0.99])) #modifico delle cose 06/04 d = image_stretch(np.squeeze(I_MS_LR[RGB_indexes, :, :]), th_MSrgb) d[d < 0] = 0 d[d > 1] = 1
#%% Visualization from image_quantile import image_quantile, image_stretch import matplotlib.pyplot as plt plt.close('all') RGB_indexes_MS = np.array([2, 1, 0]) #I_PAN=np.expand_dims(I_PAN,axis=0) # we do not use in this case I_PAN_show = I_PAN.transpose(2, 0, 1) plt.figure() plt.subplot(231) th_PANrgb = image_quantile(np.squeeze(I_PAN_show[RGB_indexes_MS, :, :]), np.array([0.01, 0.99])) PAN = image_stretch(np.squeeze(I_PAN_show[RGB_indexes_MS, :, :]), th_PANrgb) PAN[PAN < 0] = 0 PAN[PAN > 1] = 1 plt.imshow(PAN.transpose(1, 2, 0)) plt.title('MS Image'), plt.axis('off') #RGB_indexes = RGB_indexes - 1 RGB_indexes_HS = np.array([20, 14, 7 ]) # matlab 8,15,21, therefore transpose e less one plt.subplot(232) th_MSrgb = image_quantile(np.squeeze(I_MS_LR[RGB_indexes_HS, :, :]), np.array([0.01, 0.99])) d = image_stretch(np.squeeze(I_MS_LR[RGB_indexes_HS, :, :]), th_MSrgb) d[d < 0] = 0 d[d > 1] = 1
I_MS_HR = PNN_test(I_MS_LR,I_PAN,inputImg, PNN_model,net,path,mode,epochs) #%% save data export2(I_MS_HR,test_dir_out) #%% Visualization from image_quantile import image_quantile, image_stretch import matplotlib.pyplot as plt plt.close('all') I_PAN=np.expand_dims(I_PAN,axis=0) plt.figure() plt.subplot(131)#COLAB th_PAN = image_quantile(I_PAN, np.array([0.01, 0.99])) PAN = image_stretch(np.squeeze(I_PAN),np.squeeze(th_PAN)) plt.imshow( image_stretch(np.squeeze(I_PAN),np.squeeze(th_PAN)),cmap='gray',clim=[0,1]) plt.imsave("pan", image_stretch(np.squeeze(I_PAN),np.squeeze(th_PAN)),cmap='gray') plt.title('PANCHROMATIC'), plt.axis('off') RGB_indexes = np.array(inputImg['RGB_indexes']) RGB_indexes = RGB_indexes - 1 plt.subplot(132) #COLAB th_MSrgb = image_quantile(np.squeeze(I_MS_LR[RGB_indexes,:,:]), np.array([0.01, 0.99])); d=image_stretch(np.squeeze(I_MS_LR[RGB_indexes,:,:]),th_MSrgb) d[d<0]=0 d[d>1]=1 plt.imshow(d.transpose(1,2,0)) plt.imsave("ms_lr", d.transpose(1,2,0)) plt.title('MULTISPECTRAL LOW RESOLUTION'), plt.axis('off')