layer.append(ConvLayer(PNN_model['layers'][i], PNN_model['layers'][i + 1]))
net = Network(layer)

#%% Pansharpening

#load images
inputImg = sio.loadmat(testset_path)
I_MS_LR = np.array(inputImg['I_MS'], dtype='double').transpose(2, 0, 1)
I_PAN = np.array(inputImg['I_PAN'], dtype='double')

#Testing
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)
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])
Esempio n. 2
0
elapsed = time.time() - tic
print("Time Brovey:", elapsed, 'sec')

#%% CNN_method
tic = time.time()
I_Fus_CNN = np.zeros(I_MS.shape)

I_Fus_CNN = PNN_test(I_MS_LR, I_PAN, inputImg, PNN_model, net, path, mode,
                     epochs)

elapsed = time.time() - tic
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])