├── README.md └── utils.py /README.md: -------------------------------------------------------------------------------- 1 | # SSGN 2 | 3 | Q.Zhang, Q. Yuan, J. li, X. Liu, H. Shen, and L. Zhang, "Hybrid Noise Removal in Hyperspectral Imagery With a Spatial-Spectral Gradient Network," Accepted by IEEE TGRS, in press, 2019. https://ieeexplore.ieee.org/document/8734833 4 | -------------------------------------------------------------------------------- /utils.py: -------------------------------------------------------------------------------- 1 | import math 2 | import torch 3 | import torch.nn as nn 4 | import numpy as np 5 | from skimage.measure.simple_metrics import compare_psnr 6 | 7 | 8 | def weights_init_kaiming(m): 9 | classname = m.__class__.__name__ 10 | if classname.find('Conv') != -1: 11 | nn.init.kaiming_normal(m.weight.data, a=0, mode='fan_in') 12 | elif classname.find('Linear') != -1: 13 | nn.init.kaiming_normal(m.weight.data, a=0, mode='fan_in') 14 | elif classname.find('BatchNorm') != -1: 15 | # nn.init.uniform(m.weight.data, 1.0, 0.02) 16 | m.weight.data.normal_(mean=0, std=math.sqrt(2./9./64.)).clamp_(-0.025,0.025) 17 | nn.init.constant(m.bias.data, 0.0) 18 | 19 | def batch_PSNR(img, imclean, data_range): 20 | Img = img.data.cpu().numpy().astype(np.float32) 21 | Iclean = imclean.data.cpu().numpy().astype(np.float32) 22 | PSNR = 0 23 | for i in range(Img.shape[0]): 24 | PSNR += compare_psnr(Iclean[i,:,:,:], Img[i,:,:,:], data_range=data_range) 25 | return (PSNR/Img.shape[0]) 26 | 27 | def data_augmentation(image, mode): 28 | out = np.transpose(image, (1,2,0)) 29 | if mode == 0: 30 | # original 31 | out = out 32 | elif mode == 1: 33 | # flip up and down 34 | out = np.flipud(out) 35 | elif mode == 2: 36 | # rotate counterwise 90 degree 37 | out = np.rot90(out) 38 | elif mode == 3: 39 | # rotate 90 degree and flip up and down 40 | out = np.rot90(out) 41 | out = np.flipud(out) 42 | elif mode == 4: 43 | # rotate 180 degree 44 | out = np.rot90(out, k=2) 45 | elif mode == 5: 46 | # rotate 180 degree and flip 47 | out = np.rot90(out, k=2) 48 | out = np.flipud(out) 49 | elif mode == 6: 50 | # rotate 270 degree 51 | out = np.rot90(out, k=3) 52 | elif mode == 7: 53 | # rotate 270 degree and flip 54 | out = np.rot90(out, k=3) 55 | out = np.flipud(out) 56 | return np.transpose(out, (2,0,1)) 57 | --------------------------------------------------------------------------------