├── 2025 ├── DDPM_ir_Code_github │ ├── ReadMe.txt │ ├── datasetting.py │ ├── interpolator.py │ ├── jupyter_test │ │ ├── m_1.mat │ │ ├── mt_1.mat │ │ ├── test.ipynb │ │ ├── x_1.mat │ │ ├── x_ir_1.mat │ │ └── y_1.mat │ ├── models.py │ ├── train.py │ └── utils.py ├── DLR_huyue │ ├── data │ │ └── registration │ │ │ ├── F3.mat │ │ │ ├── Kerry.mat │ │ │ ├── seismic.mat │ │ │ └── sigmoid.mat │ ├── models │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-38.pyc │ │ │ ├── common.cpython-38.pyc │ │ │ ├── downsampler.cpython-38.pyc │ │ │ ├── resnet.cpython-38.pyc │ │ │ ├── skip.cpython-38.pyc │ │ │ ├── texture_nets.cpython-38.pyc │ │ │ └── unet.cpython-38.pyc │ │ ├── common.py │ │ ├── dcgan.py │ │ ├── downsampler.py │ │ ├── resnet.py │ │ ├── skip.py │ │ ├── texture_nets.py │ │ └── unet.py │ ├── registeration_replica.py │ ├── requirment.txt │ └── utils │ │ ├── Untitled-1.ipynb │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── __init__.cpython-38.pyc │ │ ├── __init__.cpython-39.pyc │ │ ├── common_utils.cpython-37.pyc │ │ ├── common_utils.cpython-38.pyc │ │ ├── common_utils.cpython-39.pyc │ │ ├── denoising_utils.cpython-37.pyc │ │ ├── denoising_utils.cpython-38.pyc │ │ ├── denoising_utils.cpython-39.pyc │ │ ├── measure.cpython-37.pyc │ │ ├── measure.cpython-38.pyc │ │ ├── measure.cpython-39.pyc │ │ └── sr_utils.cpython-38.pyc │ │ ├── common_utils.py │ │ ├── denoising_utils.py │ │ ├── feature_inversion_utils.py │ │ ├── fuben.py │ │ ├── inpainting_utils.py │ │ ├── matcher.py │ │ ├── measure.py │ │ ├── perceptual_loss │ │ ├── __init__.py │ │ ├── matcher.py │ │ ├── perceptual_loss.py │ │ └── vgg_modified.py │ │ └── sr_utils.py ├── DTW_dealiased__interpolation │ ├── LARDTW.cpp │ ├── LARDTW.m │ ├── LARDTW.mexw64 │ ├── Readme.txt │ ├── demo.m │ ├── hyper.mat │ └── snr_xuf.m ├── FWIGAN-main │ ├── FWIGAN │ │ ├── FWIDIP_main.py │ │ ├── FWIGAN_main.py │ │ ├── FWI_main.py │ │ ├── LibConfig.py │ │ ├── Models │ │ │ ├── Discriminator.py │ │ │ └── skip.py │ │ ├── ParamConfig.py │ │ ├── PathConfig.py │ │ ├── data │ │ │ ├── mar_big_117_567.bin │ │ │ ├── mar_smal_100_310.bin │ │ │ └── over_94_400.bin │ │ ├── dip_pretrain.py │ │ ├── plotting.ipynb │ │ └── utils │ │ │ ├── PhySimulator.py │ │ │ ├── misfit.py │ │ │ ├── plotting.py │ │ │ └── utils.py │ ├── LICENSE │ ├── README.md │ ├── deepwave-order │ │ ├── LICENSE │ │ ├── MANIFEST.in │ │ ├── README.md │ │ ├── deepwave │ │ │ ├── __init__.py │ │ │ ├── base │ │ │ │ ├── __init__.py │ │ │ │ ├── extract.py │ │ │ │ ├── model.py │ │ │ │ ├── pad.py │ │ │ │ └── propagator.py │ │ │ ├── scalar │ │ │ │ ├── __init__.py │ │ │ │ ├── scalar.cpp │ │ │ │ ├── scalar.h │ │ │ │ ├── scalar.py │ │ │ │ ├── scalar_born.py │ │ │ │ ├── scalar_cpu.cpp │ │ │ │ ├── scalar_cpu.h │ │ │ │ ├── scalar_device.h │ │ │ │ ├── scalar_gpu.cu │ │ │ │ ├── scalar_gpu.h │ │ │ │ └── scalar_wrapper.cpp │ │ │ ├── utils.py │ │ │ └── wavelets.py │ │ ├── requirements.txt │ │ └── setup.py │ └── images │ │ ├── flowchat.png │ │ ├── mar_big_rec.png │ │ ├── mar_smal_rec.png │ │ └── over_rec.png ├── POCS-Net_github │ ├── POCS-Net-2D │ │ ├── SNR_training_computation_2d.py │ │ ├── SNR_validation_computation_2d.py │ │ ├── datasetting.py │ │ ├── loss_validation_computation_2d.py │ │ ├── models.py │ │ ├── prediction.py │ │ ├── train.py │ │ └── utils.py │ ├── POCS-Net-3D │ │ ├── SNR_training_computation_3d2.py │ │ ├── SNR_validation_computation_3d2.py │ │ ├── datasetting.py │ │ ├── loss_training_computation.py │ │ ├── loss_validation_computation.py │ │ ├── models.py │ │ ├── prediction.py │ │ ├── train.py │ │ └── utils.py │ └── ReadMe.txt ├── Regularized_FWI_With_Shearlet_Transform_and_TGV │ ├── Marmousi_Model │ │ ├── TGV_diff.py │ │ ├── add_noise.py │ │ ├── data_loader.py │ │ ├── shearlet.py │ │ ├── shearlet_m3.mat │ │ ├── train.py │ │ └── vp.zip │ ├── Modified_2004_BP_Model │ │ ├── 04BP_120_450.bin │ │ ├── TGV_diff.py │ │ ├── add_noise.py │ │ ├── data_loader.py │ │ ├── shearlet.py │ │ ├── shearlet_n3.mat │ │ └── train.py │ ├── Regularized_Full-Waveform_Inversion_With_Shearlet_Transform_and_Total_Generalized_Variation.pdf │ ├── SEG_Overthrust_Model │ │ ├── TGV_diff.py │ │ ├── add_noise.py │ │ ├── data_loader.py │ │ ├── shearlet.py │ │ ├── shearlet_n3.mat │ │ ├── train.py │ │ └── vp.bin │ ├── Simple_Synthetic_Model │ │ ├── TGV_diff.py │ │ ├── add_noise.py │ │ ├── data_loader.py │ │ ├── matlab_SAmodel.mat │ │ ├── shearlet.py │ │ └── train.py │ ├── environment.yml │ └── 简要说明.docx ├── W2_RNN_FWI │ ├── fwi_acs_rnn │ │ ├── .gitignore │ │ ├── README.md │ │ └── code │ │ │ ├── NIM_loss.py │ │ │ ├── W2_loss.py │ │ │ ├── W2_square_loss.py │ │ │ ├── __pycache__ │ │ │ ├── NIM_loss.cpython-36.pyc │ │ │ ├── W2_loss.cpython-36.pyc │ │ │ ├── forward2d.cpython-36.pyc │ │ │ ├── forward2d.cpython-37.pyc │ │ │ ├── fwi.cpython-36.pyc │ │ │ ├── gen_data.cpython-36.pyc │ │ │ ├── gen_resi.cpython-36.pyc │ │ │ ├── setup_mar.cpython-36.pyc │ │ │ ├── setup_mar.cpython-37.pyc │ │ │ ├── setup_par.cpython-36.pyc │ │ │ ├── setup_par.cpython-37.pyc │ │ │ ├── wavelets.cpython-36.pyc │ │ │ └── wavelets.cpython-37.pyc │ │ │ ├── calc_r2.py │ │ │ ├── forward2d.py │ │ │ ├── fwi.py │ │ │ ├── gen_data.py │ │ │ ├── gen_resi.py │ │ │ ├── interpvel.py │ │ │ ├── make_adj_data.py │ │ │ ├── make_fwi_adam.py │ │ │ ├── make_fwi_sgd.py │ │ │ ├── make_seis_data.py │ │ │ ├── plot_IC.py │ │ │ ├── plot_loss.py │ │ │ ├── plot_model.py │ │ │ ├── plot_shot.py │ │ │ ├── plot_vel_curve.py │ │ │ ├── plot_wave.py │ │ │ ├── setup_mar.py │ │ │ ├── setup_par.py │ │ │ └── wavelets.py │ └── 基于最优输运与循环神经网络的全波形反演.pdf └── ssl_pocsnet_github_code │ ├── 2D │ ├── datasetting.py │ ├── generation.sh │ ├── models.py │ ├── prediction.py │ ├── prediction_pretrain.py │ ├── train.py │ └── utils.py │ ├── 3D │ ├── datasetting.py │ ├── generation.sh │ ├── models.py │ ├── prediction.py │ ├── train.py │ └── utils.py │ └── ReadMe.txt ├── AGCM ├── AGCMfreq_bestStep.m ├── Example_AGCM_transform.m └── sepAGCM.m ├── CVMD_Denoising ├── VMDC.m ├── dn.mat └── example_CVMD_denoising.m ├── DDTF3D ├── Example_denoise.m ├── Example_interp.m ├── setup.m ├── solvers │ ├── ddtfdenoise3d.m │ ├── gen_dic_by_iwt_3d.m │ ├── inter3d.m │ └── train3d.m └── utilities │ ├── DisplayH3d_all.m │ ├── InpaintingInterp2.m │ ├── clip.m │ ├── pb3d.m │ ├── pf3d.m │ ├── proj_mask.m │ ├── proj_mask_regular.m │ ├── seishow3D.m │ └── snr3d.m ├── Decurtain ├── Example.m ├── curtainDropping.m └── softShrinkage.m ├── Deep_learning ├── CNN-POCS │ ├── CNN-POCS-tools.rar │ ├── Demo_cnndenoise.m │ ├── Demo_cnndenoise3D.m │ ├── Demo_pocs_cnn.m │ ├── LICENSE │ ├── README.md │ ├── figs │ │ └── flowchart.png │ ├── generateHyperbolic.m │ ├── makeMask.m │ ├── models │ │ ├── model.part1.rar │ │ └── model.part2.rar │ └── seismicData │ │ ├── X3Dsyn.part1.rar │ │ ├── X3Dsyn.part2.rar │ │ ├── X3Dsyn.part3.rar │ │ ├── hyperbolic-events-half.mat │ │ ├── hyperbolic-events.mat │ │ └── masks │ │ └── mask751x191iregc50.mat ├── FCNVMB-Deep-learning-based-seismic-velocity-model-building-master │ ├── FCNVMB-data.zip │ ├── FCNVMB_test.py │ ├── FCNVMB_train.py │ ├── LibConfig.py │ ├── ParamConfig.py │ ├── PathConfig.py │ ├── README.md │ ├── data │ │ └── train_data │ │ │ ├── SEGSaltData │ │ │ ├── georec_train │ │ │ │ └── readme.md │ │ │ └── vmodel_train │ │ │ │ └── readme.md │ │ │ └── SimulateData │ │ │ ├── georec_train │ │ │ └── readme.md │ │ │ └── vmodel_train │ │ │ └── readme.md │ ├── func │ │ ├── DataLoad_Test.py │ │ ├── DataLoad_Train.py │ │ ├── UnetModel.py │ │ └── utils.py │ └── images │ │ ├── SEGresult.png │ │ ├── schematic.png │ │ └── simulateresult.png ├── FCNVMB │ ├── FCNVMB_test.py │ ├── FCNVMB_train.py │ ├── LibConfig.py │ ├── ParamConfig.py │ ├── PathConfig.py │ ├── README.md │ ├── func │ │ ├── DataLoad_Test.py │ │ ├── DataLoad_Train.py │ │ ├── UnetModel.py │ │ └── utils.py │ └── images │ │ ├── SEGresult.png │ │ ├── schematic.png │ │ └── simulateresult.png ├── deep-learning-geophysics-tutorial │ ├── README.en.md │ ├── README.md │ ├── code.py │ └── imgs │ │ ├── prediction.png │ │ └── trainingsets.png └── python_segy │ ├── README.md │ ├── data │ └── test │ │ └── test.segy │ ├── download_data.py │ ├── gain.py │ ├── get_patch.py │ ├── main_test_denoise.py │ ├── main_test_inter.py │ ├── main_train_denoise.py │ ├── main_train_inter.py │ ├── models_denoise │ ├── DnCNN_sigma25 │ │ └── model.pth │ └── DnCNN_sigma50 │ │ └── model.pth │ ├── models_inter │ └── DnCNN_rate2 │ │ └── model.pth │ └── requirements.txt ├── Dictionary_learning ├── D.mat ├── D1.mat ├── OMP.m ├── OMPerr.m ├── SNR.m ├── WangHR.asv ├── X1.mat ├── X_elf3D.mat ├── extract_patch.m ├── getoptions.m ├── noisy.mat ├── noisy1.mat ├── noisy2.mat ├── noisy3.mat ├── patch_center.m ├── patch_decenter.m ├── perform_dictionary_denoising.asv ├── perform_dictionary_denoising.m ├── perform_dictionary_learning.m ├── shot9a.mat ├── test.asv └── test.m ├── EMPCR_mathgeo ├── Antiaverage.m ├── Antiaverage_B.m ├── Antiaverage_B_end.m ├── Antiaverage_end.m ├── EOR1MP.m ├── E_3D.mat ├── Example_EMPCR.m ├── Hankel_2D.m ├── Hankel_3D.m ├── SNR.m ├── X_3D.mat ├── readme.m ├── recover_imag_3D.m ├── recover_real_3D.m ├── sparse_inp.mexglx ├── sparse_inp.mexmaci64 ├── sparse_inp.mexw32 ├── sparse_inp.mexw64 ├── sparse_update.mexglx ├── sparse_update.mexmaci64 ├── sparse_update.mexw32 └── sparse_update.mexw64 ├── GMD ├── core │ ├── GMD.m │ ├── HRMD.m │ └── HRMD1D.m ├── data │ ├── gom_cdp_nmo.su │ ├── line3.mat │ └── para.mat ├── paper_examples │ ├── fig05_VMD_2D_test_seis.m │ ├── fig06_VMD_2D_test_convergency_seis.m │ ├── fig07_RMD_para.m │ ├── fig09_RMD_para1d.m │ ├── fig10_VMD_2D_test_denoise.m │ ├── fig11_RMD_para_inter.m │ └── fig14_RMD_para1d_multiple.m ├── setup.m ├── test.png └── util │ ├── fun_mpfi.m │ ├── ipradon.m │ └── pradon.m ├── GVRO ├── SOR.m ├── SOR_2dip1.m ├── SOR_3dip.m ├── SOR_single_2.m ├── SOR_single_sor.m ├── fx_decon_patch.m ├── get_Gradientmatrix_backward.m ├── get_Gradientmatrix_backward_3point.m ├── get_Gradientmatrix_center.m ├── get_Gradientmatrix_forward.m ├── get_Gradientmatrix_forward_3point.m ├── get_Gradientmatrix_sobel.m ├── get_patches.m ├── get_patches_location.m ├── get_patches_slides.m ├── sigmoid.mat ├── test.png ├── test4compare_sigmoid.m ├── write_patches.m ├── write_patches_center.m ├── write_patches_tv_sor.m └── write_patches_tv_sor_center.m ├── LDMM ├── example_LDMM.m ├── f.mat ├── fun_ldmm.p ├── gmresm.p ├── iterapp2.p ├── iterchk2.p └── weight_ann.p ├── LICENSE ├── MCDDTF3D ├── Example_interp_MC_2D.m ├── Example_interp_MC_3D.m ├── codes │ ├── DisplayH3d_all.m │ ├── ddtfdenoise3d.m │ ├── displayH.m │ ├── filter_learning_2D.m │ ├── filter_learning_3D.m │ ├── gen_dic_by_iwt_3d.m │ ├── inter2d_yu.m │ ├── inter3d_yu.m │ └── train3d.m ├── setup.m └── tool │ ├── DctInit.m │ ├── InpaintingInterp2.m │ ├── Psnr.m │ ├── acknowledgement.txt │ ├── clip.m │ ├── col2imstep.c │ ├── col2imstep.m │ ├── col2imstep.mexw32 │ ├── col2imstep.mexw64 │ ├── im2colstep.c │ ├── im2colstep.m │ ├── im2colstep.mexw32 │ ├── im2colstep.mexw64 │ ├── im2colsvar.c │ ├── im2colsvar.m │ ├── pb2d.m │ ├── pb3d.m │ ├── pf2d.m │ ├── pf3d.m │ ├── proj_mask.m │ ├── proj_mask_regular.m │ ├── seishow3D.m │ └── wigb.m ├── MathGeo中文简介.md ├── README.md ├── RegistrationMultiComponent ├── Example_multi_match.m ├── dpp.mat ├── dps.mat └── note.txt ├── SR1 ├── ex.mat ├── sr1.m └── sr1_demo.m └── TSDL ├── Build_Tree.m ├── Build_Tree_Second.m ├── Denoising_test_images ├── Cameraman256.png ├── Lena512.png ├── barbara.png ├── boat.png ├── couple.png ├── fingerprint.png ├── hill.png ├── house.png ├── man.png ├── montage.png ├── pentagon.tif └── peppers256.png ├── NormDict.m ├── Test_tree_dic.m ├── desktop.ini ├── ksvd.zip ├── leigs.m ├── omp2.zip ├── seismic.mat ├── test.png └── tool ├── DctInit.m ├── Psnr.m ├── acknowledgement.txt ├── col2imstep.c ├── col2imstep.m ├── col2imstep.mexw32 ├── col2imstep.mexw64 ├── im2colstep.c ├── im2colstep.m ├── im2colstep.mexw32 └── im2colstep.mexw64 /2025/DDPM_ir_Code_github/ReadMe.txt: -------------------------------------------------------------------------------- 1 | Data Download Link: 2 | https://www.kaggle.com/datasets/supercy8250/ddpm-ir 3 | 4 | Python Package Requirements: 5 | 6 | Pytorch 7 | 8 | scipy 9 | 10 | h5py 11 | 12 | 13 | 14 | train.py:train the unet for DDPM. 15 | 16 | jupyter_test:jupyter style process for generative interpolation. 17 | -------------------------------------------------------------------------------- /2025/DDPM_ir_Code_github/datasetting.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch.utils.data import Dataset 3 | import h5py 4 | import numpy as np 5 | import scipy.io as sio 6 | 7 | class RandomDataset(Dataset): 8 | def __init__(self, X_ir, Y, M, MT, length): 9 | self.X_ir = X_ir 10 | self.Y = Y 11 | self.M = M 12 | self.MT = MT 13 | self.length = length 14 | 15 | def __getitem__(self, index): 16 | return (torch.Tensor(self.X_ir[index, :, :]).float(),torch.Tensor(self.Y[index, :, :]).float(),torch.Tensor(self.M[index, :, :]).float(), torch.Tensor(self.MT[index, :, :])) 17 | 18 | def __len__(self): 19 | return self.length 20 | 21 | def dataload(Filename,Featurename,Labelname): 22 | f = h5py.File(Filename,'r') 23 | Features = np.array(f[Featurename]) 24 | Labels = np.array(f[Labelname]) 25 | f.close() 26 | return Features,Labels,Features.shape[0] 27 | 28 | def matload(Filename,dataname): 29 | data = sio.loadmat(Filename) 30 | data = data[dataname] 31 | return data -------------------------------------------------------------------------------- /2025/DDPM_ir_Code_github/jupyter_test/m_1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DDPM_ir_Code_github/jupyter_test/m_1.mat -------------------------------------------------------------------------------- /2025/DDPM_ir_Code_github/jupyter_test/mt_1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DDPM_ir_Code_github/jupyter_test/mt_1.mat -------------------------------------------------------------------------------- /2025/DDPM_ir_Code_github/jupyter_test/x_1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DDPM_ir_Code_github/jupyter_test/x_1.mat -------------------------------------------------------------------------------- /2025/DDPM_ir_Code_github/jupyter_test/x_ir_1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DDPM_ir_Code_github/jupyter_test/x_ir_1.mat -------------------------------------------------------------------------------- /2025/DDPM_ir_Code_github/jupyter_test/y_1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DDPM_ir_Code_github/jupyter_test/y_1.mat -------------------------------------------------------------------------------- /2025/DLR_huyue/data/registration/F3.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/data/registration/F3.mat -------------------------------------------------------------------------------- /2025/DLR_huyue/data/registration/Kerry.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/data/registration/Kerry.mat -------------------------------------------------------------------------------- /2025/DLR_huyue/data/registration/seismic.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/data/registration/seismic.mat -------------------------------------------------------------------------------- /2025/DLR_huyue/data/registration/sigmoid.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/data/registration/sigmoid.mat -------------------------------------------------------------------------------- /2025/DLR_huyue/models/__init__.py: -------------------------------------------------------------------------------- 1 | from .skip import skip 2 | from .texture_nets import get_texture_nets 3 | from .resnet import ResNet 4 | from .unet import UNet 5 | 6 | import torch.nn as nn 7 | 8 | def get_net(input_depth, NET_TYPE, pad, upsample_mode, n_channels=3, act_fun='LeakyReLU', skip_n33d=128, skip_n33u=128, skip_n11=4, num_scales=5, downsample_mode='stride'): 9 | if NET_TYPE == 'ResNet': 10 | # TODO 11 | net = ResNet(input_depth, 3, 10, 16, 1, nn.BatchNorm2d, False) 12 | elif NET_TYPE == 'skip': 13 | net = skip(input_depth, n_channels, num_channels_down = [skip_n33d]*num_scales if isinstance(skip_n33d, int) else skip_n33d, 14 | num_channels_up = [skip_n33u]*num_scales if isinstance(skip_n33u, int) else skip_n33u, 15 | num_channels_skip = [skip_n11]*num_scales if isinstance(skip_n11, int) else skip_n11, 16 | upsample_mode=upsample_mode, downsample_mode=downsample_mode, 17 | need_sigmoid=True, need_bias=True, pad=pad, act_fun=act_fun) 18 | 19 | elif NET_TYPE == 'texture_nets': 20 | net = get_texture_nets(inp=input_depth, ratios = [32, 16, 8, 4, 2, 1], fill_noise=False,pad=pad) 21 | 22 | elif NET_TYPE =='UNet': 23 | net = UNet(num_input_channels=input_depth, num_output_channels=3, 24 | feature_scale=4, more_layers=0, concat_x=False, 25 | upsample_mode=upsample_mode, pad=pad, norm_layer=nn.BatchNorm2d, need_sigmoid=True, need_bias=True) 26 | elif NET_TYPE == 'identity': 27 | assert input_depth == 3 28 | net = nn.Sequential() 29 | else: 30 | assert False 31 | 32 | return net -------------------------------------------------------------------------------- /2025/DLR_huyue/models/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/models/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/models/__pycache__/common.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/models/__pycache__/common.cpython-38.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/models/__pycache__/downsampler.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/models/__pycache__/downsampler.cpython-38.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/models/__pycache__/resnet.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/models/__pycache__/resnet.cpython-38.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/models/__pycache__/skip.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/models/__pycache__/skip.cpython-38.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/models/__pycache__/texture_nets.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/models/__pycache__/texture_nets.cpython-38.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/models/__pycache__/unet.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/models/__pycache__/unet.cpython-38.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/models/dcgan.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | 4 | def dcgan(inp=2, 5 | ndf=32, 6 | num_ups=4, need_sigmoid=True, need_bias=True, pad='zero', upsample_mode='nearest', need_convT = True): 7 | 8 | layers= [nn.ConvTranspose2d(inp, ndf, kernel_size=3, stride=1, padding=0, bias=False), 9 | nn.BatchNorm2d(ndf), 10 | nn.LeakyReLU(True)] 11 | 12 | for i in range(num_ups-3): 13 | if need_convT: 14 | layers += [ nn.ConvTranspose2d(ndf, ndf, kernel_size=4, stride=2, padding=1, bias=False), 15 | nn.BatchNorm2d(ndf), 16 | nn.LeakyReLU(True)] 17 | else: 18 | layers += [ nn.Upsample(scale_factor=2, mode=upsample_mode), 19 | nn.Conv2d(ndf, ndf, kernel_size=3, stride=1, padding=1, bias=False), 20 | nn.BatchNorm2d(ndf), 21 | nn.LeakyReLU(True)] 22 | 23 | if need_convT: 24 | layers += [nn.ConvTranspose2d(ndf, 3, 4, 2, 1, bias=False),] 25 | else: 26 | layers += [nn.Upsample(scale_factor=2, mode='bilinear'), 27 | nn.Conv2d(ndf, 3, kernel_size=3, stride=1, padding=1, bias=False)] 28 | 29 | 30 | if need_sigmoid: 31 | layers += [nn.Sigmoid()] 32 | 33 | model =nn.Sequential(*layers) 34 | return model -------------------------------------------------------------------------------- /2025/DLR_huyue/requirment.txt: -------------------------------------------------------------------------------- 1 | torch==2.1.0 2 | numpy==1.24.1 3 | matplotlib 4 | pandas 5 | scikit-learn 6 | -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/utils/__init__.py -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/utils/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/utils/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/utils/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/__pycache__/common_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/utils/__pycache__/common_utils.cpython-37.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/__pycache__/common_utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/utils/__pycache__/common_utils.cpython-38.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/__pycache__/common_utils.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/utils/__pycache__/common_utils.cpython-39.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/__pycache__/denoising_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/utils/__pycache__/denoising_utils.cpython-37.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/__pycache__/denoising_utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/utils/__pycache__/denoising_utils.cpython-38.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/__pycache__/denoising_utils.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/utils/__pycache__/denoising_utils.cpython-39.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/__pycache__/measure.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/utils/__pycache__/measure.cpython-37.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/__pycache__/measure.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/utils/__pycache__/measure.cpython-38.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/__pycache__/measure.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/utils/__pycache__/measure.cpython-39.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/__pycache__/sr_utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/utils/__pycache__/sr_utils.cpython-38.pyc -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/denoising_utils.py: -------------------------------------------------------------------------------- 1 | import os 2 | from .common_utils import * 3 | 4 | 5 | 6 | def get_noisy_image(img_np, sigma): 7 | """Adds Gaussian noise to an image. 8 | 9 | Args: 10 | img_np: image, np.array with values from 0 to 1 11 | sigma: std of the noise 12 | """ 13 | img_noisy_np = np.clip(img_np + np.random.normal(scale=sigma, size=img_np.shape), 0, 1).astype(np.float32) 14 | # img_noisy_pil = np_to_pil(img_noisy_np) 15 | 16 | return img_noisy_np 17 | 18 | def get_noisy_image_np(img_np, sigma): 19 | """Adds Gaussian noise to an image. 20 | 21 | Args: 22 | img_np: image, np.array with values from 0 to 1 23 | sigma: std of the noise 24 | """ 25 | img_noisy_np = img_np + np.random.normal(scale=sigma, size=img_np.shape).astype(np.float32) 26 | 27 | return img_noisy_np -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/inpainting_utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from PIL import Image 3 | import PIL.ImageDraw as ImageDraw 4 | import PIL.ImageFont as ImageFont 5 | from .common_utils import * 6 | 7 | def get_text_mask(for_image, sz=20): 8 | font_fname = '/usr/share/fonts/truetype/freefont/FreeSansBold.ttf' 9 | font_size = sz 10 | font = ImageFont.truetype(font_fname, font_size) 11 | 12 | img_mask = Image.fromarray(np.array(for_image)*0+255) 13 | draw = ImageDraw.Draw(img_mask) 14 | draw.text((128, 128), "hello world", font=font, fill='rgb(0, 0, 0)') 15 | 16 | return img_mask 17 | 18 | def get_bernoulli_mask(for_image, zero_fraction=0.95): 19 | img_mask_np=(np.random.random_sample(size=pil_to_np(for_image).shape) > zero_fraction).astype(int) 20 | img_mask = np_to_pil(img_mask_np) 21 | 22 | return img_mask 23 | -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/matcher.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | 4 | class Matcher: 5 | def __init__(self, how='gram_matrix', loss='mse'): 6 | self.mode = 'store' 7 | self.stored = {} 8 | self.losses = {} 9 | 10 | if how in all_features.keys(): 11 | self.get_statistics = all_features[how] 12 | else: 13 | assert False 14 | pass 15 | 16 | if loss in all_losses.keys(): 17 | self.loss = all_losses[loss] 18 | else: 19 | assert False 20 | 21 | def __call__(self, module, features): 22 | statistics = self.get_statistics(features) 23 | 24 | self.statistics = statistics 25 | if self.mode == 'store': 26 | self.stored[module] = statistics.detach().clone() 27 | elif self.mode == 'match': 28 | self.losses[module] = self.loss(statistics, self.stored[module]) 29 | 30 | def clean(self): 31 | self.losses = {} 32 | 33 | def gram_matrix(x): 34 | (b, ch, h, w) = x.size() 35 | features = x.view(b, ch, w * h) 36 | features_t = features.transpose(1, 2) 37 | gram = features.bmm(features_t) / (ch * h * w) 38 | return gram 39 | 40 | 41 | def features(x): 42 | return x 43 | 44 | 45 | all_features = { 46 | 'gram_matrix': gram_matrix, 47 | 'features': features, 48 | } 49 | 50 | all_losses = { 51 | 'mse': nn.MSELoss(), 52 | 'smoothL1': nn.SmoothL1Loss(), 53 | 'L1': nn.L1Loss(), 54 | } 55 | -------------------------------------------------------------------------------- /2025/DLR_huyue/utils/perceptual_loss/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DLR_huyue/utils/perceptual_loss/__init__.py -------------------------------------------------------------------------------- /2025/DTW_dealiased__interpolation/LARDTW.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DTW_dealiased__interpolation/LARDTW.mexw64 -------------------------------------------------------------------------------- /2025/DTW_dealiased__interpolation/Readme.txt: -------------------------------------------------------------------------------- 1 | # An open-source Matlab code for dealiased seismic data interpolation. 2 | >> Xu Y, Yu S, Dong L, Ma J. Dealiased seismic data interpolation by dynamic matching[J]. Geophysics, 2024, 89(5): V361-V376. 3 | >>We proposed a new interpolation framework for the regularly missing seismic data based on the LARDTW algorithm. The proposed approach has superior interpolation and antialiasing abilities. In addition, the proposed approach is computationally efficient and can successfully interpolate data with irregular gaps in the presence of noise. 4 | >>The demo illustrates the interpolation process of this method. 5 | 6 | 7 | -------------------------------------------------------------------------------- /2025/DTW_dealiased__interpolation/demo.m: -------------------------------------------------------------------------------- 1 | % DTW_dealiased_interpolation_demo 2 | clc;clear 3 | load hyper.mat 4 | d0 = d(:,2:end); %original data 5 | d2 = d(:,2:2:end); 6 | [nx,ny]=size(d0); 7 | m2=zeros(nx,ny); m2(:,1:2:end)=1; 8 | d3=d0.*m2; %sample data 9 | %% Interpolation process 10 | t1=tic; 11 | for j=1:1 12 | [nt,nx] = size(d2); 13 | sx = zeros(nt,nx); sy = sx; 14 | di = zeros(nt,nx*2-1); 15 | di(:,1:2:end) = d2; 16 | for i=1:nx-1 17 | [Distance, w] = LARDTW(d2(:,i),d2(:,i+1), 1,0.1, 0.2, 5); 18 | ix = w(:,1)'; iy = w(:,2)'; 19 | ix2 = [find(diff(ix)==1),length(ix)]; 20 | iy2 = [find(diff(iy)==1),length(ix)]; 21 | ixy = ix(iy2); 22 | iyx = iy(ix2); 23 | ixy2 = linspace(1,nt,nt) + round((ixy-linspace(1,nt,nt))/2); 24 | k1=round((ixy-linspace(1,nt,nt))/2); 25 | iyx2 = linspace(1,nt,nt) + round((iyx-linspace(1,nt,nt))/2); 26 | k2= round((iyx-linspace(1,nt,nt))/2); 27 | d2_ = ( d2(ixy2,i) + d2(iyx2,i+1))/2; 28 | di(:,2*i) = d2_; 29 | end 30 | d2 = di; 31 | end 32 | toc(t1) 33 | snr_xuf(d0,d2) 34 | %Plot 35 | figure,imagesc(d0,[-1 1]/2);colormap gray;colorbar; 36 | xlabel('Trace number');ylabel('Time sample number'); 37 | figure,imagesc(d3,[-1 1]/2);colormap gray;colorbar; 38 | xlabel('Trace number');ylabel('Time sample number'); 39 | figure,imagesc(d2,[-1 1]/2);colormap gray;colorbar; 40 | xlabel('Trace number');ylabel('Time sample number'); 41 | figure,imagesc(d0-d2,[-1 1]/2);colormap gray;colorbar; 42 | xlabel('Trace number');ylabel('Time sample number'); -------------------------------------------------------------------------------- /2025/DTW_dealiased__interpolation/hyper.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/DTW_dealiased__interpolation/hyper.mat -------------------------------------------------------------------------------- /2025/DTW_dealiased__interpolation/snr_xuf.m: -------------------------------------------------------------------------------- 1 | function y = snr_xuf(x0, x) 2 | mse = norm(x0 - x,'fro'); 3 | y = norm(x0, 'fro'); 4 | 5 | y = 20*log10(y/(mse + 1e-30)); 6 | end 7 | -------------------------------------------------------------------------------- /2025/FWIGAN-main/FWIGAN/LibConfig.py: -------------------------------------------------------------------------------- 1 | """ 2 | Spyder Editor 3 | 4 | 5 | @author: fangshuyang (yangfs@hit.edu.cn) 6 | 7 | """ 8 | 9 | # Need to restart runtime before this step 10 | from __future__ import print_function 11 | import time 12 | import torch 13 | import torch.nn as nn 14 | import numpy as np 15 | import scipy.ndimage 16 | import matplotlib 17 | matplotlib.use('Agg') 18 | import matplotlib.pyplot as plt 19 | import deepwave 20 | import os 21 | from timeit import default_timer as timer 22 | import scipy.io as spio 23 | import math 24 | 25 | from utils.utils import * 26 | from utils.plotting import * 27 | from utils.misfit import * 28 | from utils.PhySimulator import PhySimulator 29 | from torch import optim 30 | from IPython.core.debugger import set_trace 31 | from Models.Discriminator import Discriminator 32 | from Models.Discriminator import weights_init 33 | from Models.skip import skip,optimize 34 | -------------------------------------------------------------------------------- /2025/FWIGAN-main/FWIGAN/PathConfig.py: -------------------------------------------------------------------------------- 1 | ##Record the path 2 | 3 | """ 4 | Spyder Editor 5 | 6 | @author: fangshuyang (yangfs@hit.edu.cn) 7 | 8 | """ 9 | 10 | from ParamConfig import * 11 | import os 12 | #################################################### 13 | #### FILENAMES #### 14 | #################################################### 15 | # Define the data ('mar_smal','mar_big','over') 16 | dataname = 'mar_smal' 17 | sizestr = '_100_310' 18 | 19 | #################################################### 20 | #### PATHS 21 | #################################################### 22 | 23 | #### Main path 24 | main_dir = '/home/fangshu/Code/pytorch/FWIGAN/' 25 | if len(main_dir) == 0: 26 | raise Exception('Please specify path to correct directory!!') 27 | 28 | # Result path 29 | if not os.path.exists('./results/'): 30 | os.makedirs('./results/') 31 | 32 | results_dir = main_dir + 'results/' 33 | 34 | 35 | ResultPath = results_dir + str(dataname)+'_dim'+str(vmodel_dim)+'_pf'+str(peak_freq)+'_dx'+str(dx)+'_dt'+ \ 36 | str(dt)+'_T'+str(total_t)+'_ns'+str(num_shots)+'_nrps'+str(num_receivers_per_shot)+ \ 37 | '_sig'+str(gfsigma) 38 | 39 | 40 | if lipar != None: 41 | ResultPath = ResultPath+'_lip'+str(lipar) 42 | 43 | 44 | if source_depth > 0: 45 | ResultPath = ResultPath+'_sd'+str(source_depth) 46 | 47 | 48 | if receiver_depth > 0: 49 | ResultPath = ResultPath+'_rd'+str(receiver_depth) 50 | 51 | 52 | if fix_value_depth > 0: 53 | ResultPath = ResultPath+'_fixv'+str(fix_value_depth) 54 | 55 | 56 | if order != 4: 57 | ResultPath = ResultPath+'_order'+str(order) 58 | 59 | 60 | if pml_width != 10 and pml_width != None: 61 | ResultPath = ResultPath+'_pml'+str(pml_width) 62 | 63 | 64 | ResultPath = ResultPath + '/' 65 | 66 | 67 | if not os.path.exists(ResultPath): 68 | os.makedirs(ResultPath) 69 | 70 | 71 | 72 | 73 | # Data path 74 | datapath = '/home/fangshu/Code/pytorch/FWIGAN/' 75 | if not os.path.exists('./data/'): 76 | os.makedirs('./data/') 77 | 78 | data_dir = datapath + 'data/' 79 | data_path = data_dir+str(dataname)+str(sizestr)+'.bin' -------------------------------------------------------------------------------- /2025/FWIGAN-main/FWIGAN/data/mar_big_117_567.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/FWIGAN-main/FWIGAN/data/mar_big_117_567.bin -------------------------------------------------------------------------------- /2025/FWIGAN-main/FWIGAN/data/mar_smal_100_310.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/FWIGAN-main/FWIGAN/data/mar_smal_100_310.bin -------------------------------------------------------------------------------- /2025/FWIGAN-main/FWIGAN/data/over_94_400.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/FWIGAN-main/FWIGAN/data/over_94_400.bin -------------------------------------------------------------------------------- /2025/FWIGAN-main/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 YangFangShu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /2025/FWIGAN-main/deepwave-order/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Alan Richardson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /2025/FWIGAN-main/deepwave-order/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | include deepwave/scalar/*.cpp 3 | include deepwave/scalar/*.cu 4 | include deepwave/scalar/*.h 5 | exclude test/* 6 | -------------------------------------------------------------------------------- /2025/FWIGAN-main/deepwave-order/deepwave/__init__.py: -------------------------------------------------------------------------------- 1 | """Wave propagation modules for PyTorch.""" 2 | 3 | import deepwave.base 4 | import deepwave.scalar 5 | import deepwave.utils 6 | import deepwave.wavelets 7 | -------------------------------------------------------------------------------- /2025/FWIGAN-main/deepwave-order/deepwave/base/__init__.py: -------------------------------------------------------------------------------- 1 | """Base classes for Deepwave.""" 2 | 3 | import deepwave.base.model 4 | import deepwave.base.propagator 5 | import deepwave.base.pad 6 | import deepwave.base.extract 7 | -------------------------------------------------------------------------------- /2025/FWIGAN-main/deepwave-order/deepwave/base/pad.py: -------------------------------------------------------------------------------- 1 | """Pad a model.""" 2 | import torch 3 | 4 | 5 | class Pad(torch.nn.Module): 6 | """Pad the model. 7 | 8 | Args: 9 | pad_widths: Ints or Nones or lists of such of length 10 | 6, specifying padding at beginning and end of each dimension. 11 | When multiple pad_widths are specified, they will be added. 12 | """ 13 | 14 | def __init__(self, *pad_widths): 15 | super(Pad, self).__init__() 16 | self.pad_widths = pad_widths 17 | 18 | def forward(self, model): 19 | """Perform extraction. 20 | 21 | Args: 22 | model: A Model object 23 | 24 | Returns: 25 | Padded model as a Model object 26 | """ 27 | return model.pad(*self.pad_widths) 28 | -------------------------------------------------------------------------------- /2025/FWIGAN-main/deepwave-order/deepwave/scalar/__init__.py: -------------------------------------------------------------------------------- 1 | """Scalar wave equation (constant density acoustic) propagator.""" 2 | from deepwave.scalar.scalar import Propagator 3 | from deepwave.scalar.scalar_born import BornPropagator 4 | -------------------------------------------------------------------------------- /2025/FWIGAN-main/deepwave-order/deepwave/scalar/scalar_cpu.h: -------------------------------------------------------------------------------- 1 | #include "scalar_device.h" 2 | -------------------------------------------------------------------------------- /2025/FWIGAN-main/deepwave-order/deepwave/scalar/scalar_gpu.h: -------------------------------------------------------------------------------- 1 | #include "scalar_device.h" 2 | -------------------------------------------------------------------------------- /2025/FWIGAN-main/deepwave-order/deepwave/utils.py: -------------------------------------------------------------------------------- 1 | """Utilities to make Deepwave easier to use""" 2 | import torch 3 | 4 | 5 | class Tail(torch.nn.Module): 6 | """PyTorch Module to chop the predicted output to the true output length. 7 | """ 8 | 9 | def forward(self, y_pred, y_true): 10 | """Chop off the beginning of the predicted output if necessary. 11 | 12 | If y_pred is shorter than y_true then no changes are made. 13 | 14 | Args: 15 | y_pred: The predicted output Tensor of shape [num_steps, ...] 16 | y_true: The true output Tensor of shape [num_steps', ...] 17 | 18 | Returns: 19 | y_pred with the beginning chopped off to make it the same length 20 | as y_true 21 | y_true, unmodified 22 | """ 23 | num_steps = len(y_true) 24 | if len(y_pred) < num_steps: 25 | return y_pred, y_true 26 | y_pred = y_pred[-num_steps:] 27 | return y_pred, y_true 28 | -------------------------------------------------------------------------------- /2025/FWIGAN-main/deepwave-order/deepwave/wavelets.py: -------------------------------------------------------------------------------- 1 | """Common seismic wavelets.""" 2 | import math 3 | import torch 4 | 5 | 6 | def ricker(freq, length, dt, peak_time, dtype=None): 7 | """Return a Ricker wavelet with the specified central frequency. 8 | 9 | Args: 10 | freq: A float specifying the central frequency 11 | length: An int specifying the number of time samples 12 | dt: A float specifying the time sample spacing 13 | peak_time: A float specifying the time (in secs) of the peak amplitude 14 | dtype: The PyTorch datatype to use. Optional, defaults to default. 15 | """ 16 | t = torch.arange(float(length), dtype=dtype) * dt - peak_time 17 | y = (1 - 2 * math.pi**2 * freq**2 * t**2) \ 18 | * torch.exp(-math.pi**2 * freq**2 * t**2) 19 | return y.to(dtype) 20 | -------------------------------------------------------------------------------- /2025/FWIGAN-main/deepwave-order/requirements.txt: -------------------------------------------------------------------------------- 1 | numpy 2 | pytest 3 | scipy 4 | torch 5 | -------------------------------------------------------------------------------- /2025/FWIGAN-main/images/flowchat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/FWIGAN-main/images/flowchat.png -------------------------------------------------------------------------------- /2025/FWIGAN-main/images/mar_big_rec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/FWIGAN-main/images/mar_big_rec.png -------------------------------------------------------------------------------- /2025/FWIGAN-main/images/mar_smal_rec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/FWIGAN-main/images/mar_smal_rec.png -------------------------------------------------------------------------------- /2025/FWIGAN-main/images/over_rec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/FWIGAN-main/images/over_rec.png -------------------------------------------------------------------------------- /2025/POCS-Net_github/POCS-Net-2D/datasetting.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch.utils.data import Dataset 3 | import h5py 4 | import numpy as np 5 | import scipy.io as sio 6 | 7 | class RandomDataset(Dataset): 8 | def __init__(self, features, labels, length): 9 | self.features = features 10 | self.labels = labels 11 | self.length = length 12 | 13 | def __getitem__(self, index): 14 | return (torch.Tensor(self.features[index, :]).float(),torch.Tensor(self.labels[index, :]).float()) 15 | 16 | def __len__(self): 17 | return self.length 18 | 19 | def dataload(Filename,Featurename,Labelname): 20 | f = h5py.File(Filename,'r') 21 | Features = np.array(f[Featurename]) 22 | Labels = np.array(f[Labelname]) 23 | f.close() 24 | return Features,Labels,Features.shape[0] 25 | 26 | def matload(Filename,dataname): 27 | data = sio.loadmat(Filename) 28 | data = data[dataname] 29 | return data -------------------------------------------------------------------------------- /2025/POCS-Net_github/POCS-Net-2D/utils.py: -------------------------------------------------------------------------------- 1 | import math 2 | import numpy as np 3 | def SNR(img,imgn): 4 | return 10*math.log10(np.linalg.norm(img)**2 / np.linalg.norm(imgn - img)**2) -------------------------------------------------------------------------------- /2025/POCS-Net_github/POCS-Net-3D/datasetting.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch.utils.data import Dataset 3 | import h5py 4 | import numpy as np 5 | import scipy.io as sio 6 | class RandomDataset(Dataset): 7 | def __init__(self, features, labels, length): 8 | self.features = features 9 | self.labels = labels 10 | self.length = length 11 | 12 | def __getitem__(self, index): 13 | return (torch.Tensor(self.features[index, :]).float(),torch.Tensor(self.labels[index, :]).float()) 14 | 15 | def __len__(self): 16 | return self.length 17 | 18 | def dataload(Filename,Featurename,Labelname): 19 | f = h5py.File(Filename,'r') 20 | Features = np.array(f[Featurename]) 21 | Labels = np.array(f[Labelname]) 22 | f.close() 23 | return Features,Labels,Features.shape[0] 24 | 25 | def matload(Filename,dataname): 26 | data = sio.loadmat(Filename) 27 | data = data[dataname] 28 | return data -------------------------------------------------------------------------------- /2025/POCS-Net_github/POCS-Net-3D/utils.py: -------------------------------------------------------------------------------- 1 | import math 2 | import numpy as np 3 | def SNR(img,imgn): 4 | return 10*math.log10(np.linalg.norm(img)**2 / np.linalg.norm(imgn - img)**2) -------------------------------------------------------------------------------- /2025/POCS-Net_github/ReadMe.txt: -------------------------------------------------------------------------------- 1 | Python Package Requirements: 2 | 3 | Pytorch 4 | 5 | scipy 6 | 7 | h5py 8 | 9 | Python File description: 10 | 11 | train.py:train the POCS-Net. 12 | 13 | prediction.py:interpolate test data using pre-trained POCS-Net. 14 | 15 | loss_validation_computation.py: compute the loss of the dataset. 16 | 17 | SNR_training_computation.py: compute SNR of the dataset. 18 | 19 | The datasets and pretrained model links are listed as follows: 20 | https://www.kaggle.com/datasets/supercy8250/2dpocs-net-public 21 | 22 | https://www.kaggle.com/datasets/supercy8250/3dpocs-net-public -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Marmousi_Model/TGV_diff.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Mar 22 10:25:26 2023 4 | 5 | @author: 95424 6 | """ 7 | 8 | import numpy as np 9 | import torch 10 | 11 | #定义偏导函数 12 | def pardiv(A,method): 13 | if method == 'Dx': 14 | Dx=torch.diff(A,1,dim=1) 15 | return Dx 16 | elif method == 'Dy': 17 | Dy=torch.diff(A,1,dim=0) 18 | return Dy 19 | elif method == 'Dxx': 20 | Dxx =torch.diff(A,2,dim=1) 21 | return Dxx 22 | elif method == 'Dyy': 23 | Dyy=torch.diff(A,2,dim=0) 24 | return Dyy 25 | 26 | #这里使用的p=[u,u] 27 | def TGV(u,sigma): 28 | m,n=u.shape 29 | u = sigma*u 30 | Dx = pardiv(u,'Dx') 31 | Dy = pardiv(u,'Dy') 32 | p1 = 0.5*Dx 33 | p2 = 0.5*Dy 34 | p_dx = pardiv(p1,'Dx') 35 | p_dy = pardiv(p2,'Dy') 36 | p_dyx = pardiv(p1,'Dy') 37 | p_dxy = pardiv(p2,'Dx') 38 | TGV_1 = abs(Dx-p1).sum()+abs(Dy-p2).sum() 39 | TGV_2 = abs(p_dx).sum()+abs(1/2*(p_dyx+p_dxy)).sum()+abs(1/2*(p_dyx+p_dxy)).sum()+abs(p_dy).sum() 40 | return 2*TGV_1+TGV_2 41 | 42 | 43 | #x=torch.tensor([[1,2,3],[4,5,6],[7,8,9],[10,11,12],[13,14,15]],dtype=torch.float32,requires_grad=True) 44 | #x=torch.randn(5,3,requires_grad=True) 45 | #loss = TGV(x,0.1,0.2) 46 | #loss.backward() -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Marmousi_Model/add_noise.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | 5 | 6 | def add_noise(observed_data,SNR,L): 7 | [num_shots,nr,nt] = observed_data.shape 8 | for i in range (num_shots): 9 | din = observed_data[i,:,:].T 10 | h = torch.tensor(np.hamming(L)) 11 | noise = torch.randn(nt,nr) 12 | noise = torch.tensor(np.apply_along_axis(lambda m: np.convolve(m, h, mode='full'), axis=1, arr=noise.T)).T 13 | noise = noise[int(np.floor((L-1)/2)-1):(int(np.floor((L-1)/2))+nt-1),:] 14 | alpha = torch.sqrt((din**2).sum()/(SNR*noise**2).sum()) 15 | noise_add = alpha*noise 16 | dout = din+noise_add 17 | observed_data[i,:,:] = dout.T 18 | return observed_data -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Marmousi_Model/shearlet.py: -------------------------------------------------------------------------------- 1 | 2 | import torch 3 | from scipy.io import loadmat 4 | 5 | 6 | 7 | def shearlet(X,device): 8 | filename = "/home/wanghan/marmousi2/shearlet/shearlet_m3.mat" 9 | shearlet = loadmat(filename) 10 | y = 0 11 | m,n=X.shape 12 | for i in range(shearlet['H'].shape[2]): 13 | shear = torch.tensor(shearlet['H'][:,:,i],dtype=torch.float32).to(device) 14 | s_X=shear[:m,:n]*torch.fft.fftshift(torch.fft.fft2(X)) 15 | y =y+torch.sum(abs(torch.fft.ifft2(torch.fft.fftshift(s_X)))) 16 | return y 17 | -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Marmousi_Model/shearlet_m3.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Marmousi_Model/shearlet_m3.mat -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Marmousi_Model/vp.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Marmousi_Model/vp.zip -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Modified_2004_BP_Model/04BP_120_450.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Modified_2004_BP_Model/04BP_120_450.bin -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Modified_2004_BP_Model/TGV_diff.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Mar 22 10:25:26 2023 4 | 5 | @author: 95424 6 | """ 7 | 8 | import numpy as np 9 | import torch 10 | 11 | #定义偏导函数 12 | def pardiv(A,method): 13 | if method == 'Dx': 14 | Dx=torch.diff(A,1,dim=1) 15 | return Dx 16 | elif method == 'Dy': 17 | Dy=torch.diff(A,1,dim=0) 18 | return Dy 19 | elif method == 'Dxx': 20 | Dxx =torch.diff(A,2,dim=1) 21 | return Dxx 22 | elif method == 'Dyy': 23 | Dyy=torch.diff(A,2,dim=0) 24 | return Dyy 25 | 26 | #这里使用的p=[u,u] 27 | def TGV(u,sigma): 28 | m,n=u.shape 29 | u = sigma*u 30 | Dx = pardiv(u,'Dx') 31 | Dy = pardiv(u,'Dy') 32 | p1 = 0.5*Dx 33 | p2 = 0.5*Dy 34 | p_dx = pardiv(p1,'Dx') 35 | p_dy = pardiv(p2,'Dy') 36 | p_dyx = pardiv(p1,'Dy') 37 | p_dxy = pardiv(p2,'Dx') 38 | TGV_1 = abs(Dx-p1).sum()+abs(Dy-p2).sum() 39 | TGV_2 = abs(p_dx).sum()+abs(1/2*(p_dyx+p_dxy)).sum()+abs(1/2*(p_dyx+p_dxy)).sum()+abs(p_dy).sum() 40 | return 2*TGV_1+TGV_2 41 | 42 | 43 | #x=torch.tensor([[1,2,3],[4,5,6],[7,8,9],[10,11,12],[13,14,15]],dtype=torch.float32,requires_grad=True) 44 | #x=torch.randn(5,3,requires_grad=True) 45 | #loss = TGV(x,0.1,0.2) 46 | #loss.backward() -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Modified_2004_BP_Model/add_noise.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | 5 | 6 | def add_noise(observed_data,SNR,L): 7 | [num_shots,nr,nt] = observed_data.shape 8 | for i in range (num_shots): 9 | din = observed_data[i,:,:].T 10 | h = torch.tensor(np.hamming(L)) 11 | noise = torch.randn(nt,nr) 12 | noise = torch.tensor(np.apply_along_axis(lambda m: np.convolve(m, h, mode='full'), axis=1, arr=noise.T)).T 13 | noise = noise[int(np.floor((L-1)/2)-1):(int(np.floor((L-1)/2))+nt-1),:] 14 | alpha = torch.sqrt((din**2).sum()/(SNR*noise**2).sum()) 15 | noise_add = alpha*noise 16 | dout = din+noise_add 17 | observed_data[i,:,:] = dout.T 18 | return observed_data -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Modified_2004_BP_Model/shearlet.py: -------------------------------------------------------------------------------- 1 | 2 | import torch 3 | from scipy.io import loadmat 4 | 5 | 6 | 7 | def shearlet(X,device): 8 | filename = '/home/wanghan/test_BP/STFWI/shearlet_n3.mat' 9 | shearlet = loadmat(filename) 10 | y = 0 11 | m,n=X.shape 12 | for i in range(shearlet['H'].shape[2]): 13 | shear = torch.tensor(shearlet['H'][:,:,i],dtype=torch.float32).to(device) 14 | s_X=shear[:m,:n]*torch.fft.fftshift(torch.fft.fft2(X)) 15 | y =y+torch.sum(abs(torch.fft.ifft2(torch.fft.fftshift(s_X)))) 16 | return y 17 | -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Modified_2004_BP_Model/shearlet_n3.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Modified_2004_BP_Model/shearlet_n3.mat -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Regularized_Full-Waveform_Inversion_With_Shearlet_Transform_and_Total_Generalized_Variation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Regularized_Full-Waveform_Inversion_With_Shearlet_Transform_and_Total_Generalized_Variation.pdf -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/SEG_Overthrust_Model/TGV_diff.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Mar 22 10:25:26 2023 4 | 5 | @author: 95424 6 | """ 7 | 8 | import numpy as np 9 | import torch 10 | 11 | #定义偏导函数 12 | def pardiv(A,method): 13 | if method == 'Dx': 14 | Dx=torch.diff(A,1,dim=1) 15 | return Dx 16 | elif method == 'Dy': 17 | Dy=torch.diff(A,1,dim=0) 18 | return Dy 19 | elif method == 'Dxx': 20 | Dxx =torch.diff(A,2,dim=1) 21 | return Dxx 22 | elif method == 'Dyy': 23 | Dyy=torch.diff(A,2,dim=0) 24 | return Dyy 25 | 26 | #这里使用的p=[u,u] 27 | def TGV(u,sigma): 28 | m,n=u.shape 29 | u = sigma*u 30 | Dx = pardiv(u,'Dx') 31 | Dy = pardiv(u,'Dy') 32 | p1 = 0.5*Dx 33 | p2 = 0.5*Dy 34 | p_dx = pardiv(p1,'Dx') 35 | p_dy = pardiv(p2,'Dy') 36 | p_dyx = pardiv(p1,'Dy') 37 | p_dxy = pardiv(p2,'Dx') 38 | TGV_1 = abs(Dx-p1).sum()+abs(Dy-p2).sum() 39 | TGV_2 = abs(p_dx).sum()+abs(1/2*(p_dyx+p_dxy)).sum()+abs(1/2*(p_dyx+p_dxy)).sum()+abs(p_dy).sum() 40 | return 2*TGV_1+TGV_2 41 | 42 | 43 | #x=torch.tensor([[1,2,3],[4,5,6],[7,8,9],[10,11,12],[13,14,15]],dtype=torch.float32,requires_grad=True) 44 | #x=torch.randn(5,3,requires_grad=True) 45 | #loss = TGV(x,0.1,0.2) 46 | #loss.backward() -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/SEG_Overthrust_Model/add_noise.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | 5 | 6 | def add_noise(observed_data,SNR,L): 7 | [num_shots,nr,nt] = observed_data.shape 8 | for i in range (num_shots): 9 | din = observed_data[i,:,:].T 10 | h = torch.tensor(np.hamming(L)) 11 | noise = torch.randn(nt,nr) 12 | noise = torch.tensor(np.apply_along_axis(lambda m: np.convolve(m, h, mode='full'), axis=1, arr=noise.T)).T 13 | noise = noise[int(np.floor((L-1)/2)-1):(int(np.floor((L-1)/2))+nt-1),:] 14 | alpha = torch.sqrt((din**2).sum()/(SNR*noise**2).sum()) 15 | noise_add = alpha*noise 16 | dout = din+noise_add 17 | observed_data[i,:,:] = dout.T 18 | return observed_data -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/SEG_Overthrust_Model/shearlet.py: -------------------------------------------------------------------------------- 1 | 2 | import torch 3 | from scipy.io import loadmat 4 | 5 | 6 | 7 | def shearlet(X,shearlet_matrix,device): 8 | shearlet = shearlet_matrix 9 | y = 0 10 | m,n=X.shape 11 | for i in range(shearlet['H'].shape[2]): 12 | shear = torch.tensor(shearlet['H'][:,:,i],dtype=torch.float32).to(device) 13 | s_X=shear[:m,:n]*torch.fft.fftshift(torch.fft.fft2(X)) 14 | y =y+torch.sum(abs(torch.fft.ifft2(torch.fft.fftshift(s_X)))) 15 | return y 16 | -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/SEG_Overthrust_Model/shearlet_n3.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/SEG_Overthrust_Model/shearlet_n3.mat -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/SEG_Overthrust_Model/vp.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/SEG_Overthrust_Model/vp.bin -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Simple_Synthetic_Model/TGV_diff.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Mar 22 10:25:26 2023 4 | 5 | @author: 95424 6 | """ 7 | 8 | import numpy as np 9 | import torch 10 | 11 | #定义偏导函数 12 | def pardiv(A,method): 13 | if method == 'Dx': 14 | Dx=torch.diff(A,1,dim=1) 15 | return Dx 16 | elif method == 'Dy': 17 | Dy=torch.diff(A,1,dim=0) 18 | return Dy 19 | elif method == 'Dxx': 20 | Dxx =torch.diff(A,2,dim=1) 21 | return Dxx 22 | elif method == 'Dyy': 23 | Dyy=torch.diff(A,2,dim=0) 24 | return Dyy 25 | 26 | #这里使用的p=[u,u] 27 | def TGV(u,sigma): 28 | m,n=u.shape 29 | u = sigma*u 30 | Dx = pardiv(u,'Dx') 31 | Dy = pardiv(u,'Dy') 32 | p1 = 0.5*Dx 33 | p2 = 0.5*Dy 34 | p_dx = pardiv(p1,'Dx') 35 | p_dy = pardiv(p2,'Dy') 36 | p_dyx = pardiv(p1,'Dy') 37 | p_dxy = pardiv(p2,'Dx') 38 | TGV_1 = abs(Dx-p1).sum()+abs(Dy-p2).sum() 39 | TGV_2 = abs(p_dx).sum()+abs(1/2*(p_dyx+p_dxy)).sum()+abs(1/2*(p_dyx+p_dxy)).sum()+abs(p_dy).sum() 40 | return 2*TGV_1+1*TGV_2 41 | 42 | 43 | #x=torch.tensor([[1,2,3],[4,5,6],[7,8,9],[10,11,12],[13,14,15]],dtype=torch.float32,requires_grad=True) 44 | #x=torch.randn(5,3,requires_grad=True) 45 | #loss = TGV(x,0.1,0.2) 46 | #loss.backward() -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Simple_Synthetic_Model/add_noise.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | 5 | 6 | def add_noise(observed_data,SNR,L): 7 | [num_shots,nr,nt] = observed_data.shape 8 | for i in range (num_shots): 9 | din = observed_data[i,:,:].T 10 | h = torch.tensor(np.hamming(L)) 11 | noise = torch.randn(nt,nr) 12 | noise = torch.tensor(np.apply_along_axis(lambda m: np.convolve(m, h, mode='full'), axis=1, arr=noise.T)).T 13 | noise = noise[int(np.floor((L-1)/2)-1):(int(np.floor((L-1)/2))+nt-1),:] 14 | alpha = torch.sqrt((din**2).sum()/(SNR*noise**2).sum()) 15 | noise_add = alpha*noise 16 | dout = din+noise_add 17 | observed_data[i,:,:] = dout.T 18 | return observed_data -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Simple_Synthetic_Model/matlab_SAmodel.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Simple_Synthetic_Model/matlab_SAmodel.mat -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/Simple_Synthetic_Model/shearlet.py: -------------------------------------------------------------------------------- 1 | 2 | import torch 3 | from scipy.io import loadmat 4 | 5 | 6 | 7 | def shearlet(X,device): 8 | filename = "/home/wanghan/SA_model/STFWI/matlab_SAmodel.mat" 9 | shearlet = loadmat(filename) 10 | y = 0 11 | m,n=X.shape 12 | for i in range(shearlet['H'].shape[2]): 13 | shear = torch.tensor(shearlet['H'][:,:,i],dtype=torch.float32).to(device) 14 | s_X=shear[:m,:n]*torch.fft.fftshift(torch.fft.fft2(X)) 15 | y =y+torch.sum(abs(torch.fft.ifft2(torch.fft.fftshift(s_X)))) 16 | return y 17 | # Z = torch.zeros(m,m-n).to(device) 18 | # X = torch.cat([D,Z],1) 19 | # for i in range(shearlet['H'].shape[2]): 20 | # shear = torch.tensor(shearlet['H'][:,:,i],dtype=torch.float32).to(device) 21 | # s_X=shear*torch.fft.fftshift(torch.fft.fft2(X)) 22 | # y =y+torch.sum(abs(torch.fft.ifft2(torch.fft.fftshift(s_X)))) 23 | # return y 24 | -------------------------------------------------------------------------------- /2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/简要说明.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/Regularized_FWI_With_Shearlet_Transform_and_TGV/简要说明.docx -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/.gitignore: -------------------------------------------------------------------------------- 1 | data 2 | -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/README.md: -------------------------------------------------------------------------------- 1 | Using RNN for 2D Acoustic FWI. 2 | 3 | Author: Alan Richardson 4 | Modified by: Wenlong Wang 5 | 6 | ########环境依赖 7 | tensorflow 2.x.x 8 | 9 | 10 | 11 | ########使用说明 12 | (1)含code和data两个文件夹 13 | code:各种运行代码放置处 14 | data:速度模型数据以及地震数据放置处 15 | 16 | 17 | (2)code文件夹 18 | setup_mar.py:设置Marmousi模型参数(最大迭代epoch数:num_epochs、early stopping数:n_epochs_stop、batch_size、模型参数路径、模型参数、炮数、震源子波主频等) 19 | setup_par.py:设置Camembert模型参数 20 | forward2d.py:正演程序 21 | fwi.py:FWI程序,在__init__()中可设置不同的loss(L2/NIM/W2), 22 | 在_train_loop()中保存loss及反演model 23 | gen_data.py + make_seis_data.py:生成地震数据 24 | gen_resi.py + make_adj_data.py:生成伴随震源 25 | make_fwi_adam.py:运行FWI,得到反演loss、model(可设置不同的优化算法) 26 | NIM_loss.py:积分归一化函数((NIM loss) 27 | W2_loss.py:线性正变换二次Wasserstein度量函数(W2 loss) 28 | W2_square_loss.py:平方正变换二次Wasserstein度量函数(W2 loss) 29 | wavelets.py:Ricker子波函数 30 | 31 | 画图 32 | plot_loss.py:训练、验证损失 33 | plot_model.py:反演得到的速度模型 34 | plot_shot.py:某一炮的地震数据 35 | plot_source.py:Ricker子波及其频谱图 36 | plot_wave.py:波场 37 | plot_vel_curve.py:速度曲线 38 | calc_r2.py + plot_IC.py:交汇图及其相关系数 39 | 40 | 41 | (3)./data/model文件夹 42 | mar_60_100.bin:Marmousi纵波速度模型,大小为nx*nz = 100*60 43 | mar_60_100_init.bin:Marmousi初始速度模型 44 | 45 | 46 | mar_130_340.vp:Marmousi纵波速度模型,大小为nx*nz = 340*130 47 | mar_130_340_init1.vp:方差20的高斯滤波,初始模型1(较好的初始模型,L2/NIM/W2均可) 48 | mar_130_340_init2.vp:方差30的高斯滤波,初始模型2(较差的初始模型,L2/NIM出现cycle skipping) 49 | 50 | 51 | (4)参数 52 | receivers:观测地震记录(由真实速度模型正演得到),大小为nt*ns*nr(时间*炮数*检波器) 53 | out_receivers:模拟地震记录,大小为nt*ns*nr维(时间*炮数*检波器) -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/NIM_loss.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | 3 | def normalize(x): 4 | inputs_shape=tf.shape(x) 5 | nt = inputs_shape[0] 6 | #return tf.divide(x,tf.tile(tf.reduce_sum(x,axis=0,keepdims=True),[nt,1,1])) 7 | return tf.divide(x,tf.reduce_sum(x,axis=0,keepdims=True)) 8 | 9 | def NIM(labels, predictions): 10 | shift = tf.constant(100.) 11 | c = shift 12 | g = labels + c 13 | f = predictions + c 14 | scale = 10000. 15 | mu = normalize(f)*scale 16 | nu = normalize(g)*scale 17 | 18 | F = tf.cumsum(mu,axis=0) 19 | G = tf.cumsum(nu,axis=0) 20 | #scale = 10000. 21 | #scale = 1. 22 | #mu = normalize(F)*scale 23 | #nu = normalize(G)*scale 24 | # tf op 25 | losses = tf.compat.v1.losses.mean_squared_error(F,G) 26 | return losses 27 | ## man crafted op 28 | #@tf.custom_gradient 29 | #def mse(mu,nu): 30 | # losses = tf.compat.v1.losses.mean_squared_error(mu,nu) 31 | # div = tf.shape(labels)[0]*tf.shape(labels)[1]*tf.shape(labels)[2] 32 | # div = tf.cast(div, dtype=tf.float32) 33 | # def grad(dy): 34 | # return None, dy*(nu - mu)/div*2. 35 | # return losses, grad 36 | #return mse(mu,nu) 37 | -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/NIM_loss.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/NIM_loss.cpython-36.pyc -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/W2_loss.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/W2_loss.cpython-36.pyc -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/forward2d.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/forward2d.cpython-36.pyc -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/forward2d.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/forward2d.cpython-37.pyc -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/fwi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/fwi.cpython-36.pyc -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/gen_data.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/gen_data.cpython-36.pyc -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/gen_resi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/gen_resi.cpython-36.pyc -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/setup_mar.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/setup_mar.cpython-36.pyc -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/setup_mar.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/setup_mar.cpython-37.pyc -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/setup_par.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/setup_par.cpython-36.pyc -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/setup_par.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/setup_par.cpython-37.pyc -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/wavelets.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/wavelets.cpython-36.pyc -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/wavelets.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/W2_RNN_FWI/fwi_acs_rnn/code/__pycache__/wavelets.cpython-37.pyc -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/calc_r2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | def calc_r2(inpt1, inpt2): 4 | nt = inpt1.size 5 | true_avr = np.mean(inpt1) 6 | init_avr = np.mean(inpt2) 7 | diff1 = inpt1 - true_avr 8 | diff2 = inpt2 - init_avr 9 | diff1_2 = np.sum(np.multiply(diff1,diff1)) 10 | diff2_2 = np.sum(np.multiply(diff2,diff2)) 11 | 12 | r = np.sum(np.multiply(diff1, diff2))/np.sqrt(diff1_2*diff2_2) 13 | r2 = np.square(r) 14 | 15 | 16 | return r2 17 | 18 | -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/interpvel.py: -------------------------------------------------------------------------------- 1 | from sys import argv 2 | import numpy as np 3 | from scipy import interpolate 4 | 5 | def interpvel(): 6 | """Interpolate the SEAM model onto a coarse grid with and write the result 7 | to a file. 8 | 9 | Command-line arguments: 10 | 1. Path to input SEAM model 11 | 2. Path to output interpolated model 12 | 3. Number of x cells in input model 13 | 4. Number of depth cells in input model 14 | 5. X cell spacing in input model 15 | 6. Depth cell spacing in input model 16 | 7. X cell spacing in interpolated model 17 | 8. Depth cell spacing in interpolated model 18 | """ 19 | filebinary = argv[1] 20 | fileinterp = argv[2] 21 | n1old = int(argv[3]) 22 | n2old = int(argv[4]) 23 | d1old = float(argv[5]) 24 | d2old = float(argv[6]) 25 | d1new = float(argv[7]) 26 | d2new = float(argv[8]) 27 | 28 | print(filebinary, fileinterp, n1old, n2old, d1old, d2old, d1new, d2new) 29 | 30 | # Load data 31 | array = np.fromfile(filebinary, dtype=np.float32).reshape([n1old, n2old]) 32 | print('n1old', n1old, 'n2', n2old) 33 | 34 | # Interpolate 35 | xold = np.arange(0, n1old*d1old, d1old) 36 | zold = np.arange(0, n2old*d2old, d2old) 37 | print('z', zold.shape, 'x', xold.shape, 'a', array.shape) 38 | f = interpolate.interp2d(zold, xold, array, kind='quintic') 39 | 40 | xnew = np.arange(0, n1old*d1old, d1new) 41 | znew = np.arange(0, n2old*d2old, d2new) 42 | 43 | print(znew.shape, xnew.shape) 44 | 45 | new_array = f(znew, xnew).astype(np.float32) 46 | print(new_array.shape) 47 | 48 | new_array.tofile(fileinterp) 49 | 50 | if __name__ == '__main__': 51 | interpvel() 52 | -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/make_adj_data.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import numpy as np 3 | from setup_mar import setup_par 4 | from gen_resi import gen_resi 5 | 6 | def make_seis_data(): 7 | """Generate synthetic data from the chosen section of the model.""" 8 | # seam_model_path = sys.argv[1] 9 | model = setup_par() 10 | vpmodel_true = model['vpmodel_init'] 11 | dx = model['dx'] 12 | dt = model['dt'] 13 | sources = model['sources'] 14 | sources_x = model['sources_x'] 15 | receivers_x = model['receivers_x'] 16 | propagator = model['propagator'] 17 | seis_file = model['seis_path'] 18 | adj_file = './adj_source' 19 | batch_size = model['batch_size'] 20 | source_file = model['source_path'] 21 | 22 | seis_file = model['seis_path'] + '.npy' 23 | receivers_true = np.load(seis_file) 24 | 25 | receivers = gen_resi(vpmodel_true, dx, dt, sources, sources_x, receivers_x,receivers_true, 26 | propagator, batch_size) 27 | 28 | np.save(adj_file, receivers) 29 | #np.save('seam_wave', out_wave ) 30 | 31 | if __name__ == '__main__': 32 | make_seis_data() 33 | -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/make_seis_data.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import numpy as np 3 | from setup_mar import setup_par 4 | #from setup_par import setup_par 5 | from gen_data import gen_data 6 | 7 | def make_seis_data(): 8 | """Generate synthetic data from the chosen section of the model.""" 9 | # seam_model_path = sys.argv[1] 10 | model = setup_par() 11 | vpmodel_true = model['vpmodel_true'] 12 | dx = model['dx'] 13 | dt = model['dt'] 14 | sources = model['sources'] 15 | sources_x = model['sources_x'] 16 | receivers_x = model['receivers_x'] 17 | propagator = model['propagator'] 18 | seis_path = model['seis_path'] 19 | batch_size = model['batch_size'] 20 | source_path = model['source_path'] 21 | 22 | receivers = gen_data(vpmodel_true, dx, dt, sources, sources_x, receivers_x, 23 | propagator, batch_size) 24 | 25 | np.save(seis_path, receivers) 26 | np.save(source_path, sources) 27 | #np.save('seam_wave', out_wave ) 28 | 29 | if __name__ == '__main__': 30 | make_seis_data() 31 | -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/plot_shot.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib 3 | import matplotlib.pyplot as plt 4 | from matplotlib import gridspec 5 | from mpl_toolkits.axes_grid1 import make_axes_locatable 6 | from scipy.signal import butter, lfilter 7 | 8 | from setup_mar import setup_par 9 | 10 | 11 | def butter_bandpass(lowcut, highcut, dt, order=5): 12 | fs = 1./dt 13 | nyq = 0.5 * fs 14 | low = lowcut / nyq 15 | high = highcut / nyq 16 | b, a = butter(order, [low, high], btype='band') 17 | return b, a 18 | 19 | 20 | def butter_bandpass_filter(data, lowcut, highcut, dt, order=5): 21 | b, a = butter_bandpass(lowcut, highcut, dt, order=order) 22 | y = lfilter(b, a, data) 23 | return y 24 | 25 | model = setup_par() 26 | dx = model['dx'] 27 | dt = model['dt'] 28 | nx = model['nx'] 29 | nt = model['nt'] 30 | seis_path = model['seis_path'] + '.npy' 31 | #seis_path = 'receiverdata_inv_adam.npy' 32 | #seis_path = 'adj_source.npy' 33 | receivers = np.load(seis_path) 34 | print(receivers.shape) 35 | 36 | shot = receivers[:,13,:].T 37 | clip = np.max(np.abs(shot))/20 38 | print(np.min(shot),np.max(shot)) 39 | 40 | 41 | # bandpass filter; can be implemented later 42 | #for ishot in range(shot.shape[0]): 43 | # shot[ishot,:] = butter_bandpass_filter(shot[ishot,:], 0.1, 1., dt, order=3) 44 | 45 | fig, ax2 = plt.subplots() 46 | im2=ax2.imshow(np.transpose(shot),extent=[0, nx*dx/1000.,nt*dt,0],vmin=-clip,vmax=clip,cmap='bwr') 47 | divider = make_axes_locatable(ax2) 48 | cax2 = divider.append_axes("right", size="5%", pad=0.05) 49 | plt.colorbar(im2,ax=ax2,cax=cax2).set_label('Relative amplitude') 50 | ax2.set_xlabel('Position (km)') 51 | ax2.set_ylabel('Time (s)') 52 | ax2.xaxis.tick_top() 53 | ax2.xaxis.set_label_position('top') 54 | 55 | plt.show() 56 | 57 | 58 | -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/plot_vel_curve.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from setup_mar import setup_par 4 | 5 | 6 | 7 | model = setup_par() 8 | dx = model['dx'] 9 | dt = model['dt'] 10 | nz = model['nz'] 11 | depth = np.linspace(0, dx*nz/1000., num=nz) 12 | vpmodel_true = model['vpmodel_true'] 13 | print(np.max(vpmodel_true)) 14 | vpmodel_init = model['vpmodel_init'] 15 | vpmodel_inv_path = model['vpmodel_inv_path'] 16 | vpmodel_inv=np.load('./inv/vpmodel_inv_mar_W2_RMSProp.npy', allow_pickle= True) 17 | 18 | vpmodel_inv1 = vpmodel_inv[0][1] # #Epoch #Step 19 | vpmodel_inv2 = vpmodel_inv[-1][1] # #Epoch #Step 20 | 21 | nx = 200 #the position of velocity 22 | vel_true = vpmodel_true[:,nx]/1000. 23 | vel_init = vpmodel_init[:,nx]/1000. 24 | vel_inv = vpmodel_inv2[:,nx]/1000. 25 | 26 | 27 | _, ax1 = plt.subplots(figsize=(5, 8)) 28 | left=-0.1 29 | top=1.02 30 | ax1.text(left,top,'d)',horizontalalignment='left',verticalalignment='bottom',transform=ax1.transAxes,fontsize=13) 31 | ax1.set_xlabel("Vp(km/s)",fontsize=14) 32 | ax1.set_ylabel("Depth(km)",fontsize=14) 33 | ax1.plot(vel_true, depth,color='r',label='vpmodel_true',lw=2) 34 | ax1.plot(vel_init, depth,color='black',label='vpmodel_init',linestyle=':',lw=2) 35 | ax1.plot(vel_inv, depth,color='b',label='vpmodel_inv',linestyle='--',lw=2) 36 | plt.legend(loc=1,fontsize=13) 37 | # ax1.xaxis.tick_top() 38 | # ax1.xaxis.set_label_position('top') 39 | ax1.invert_yaxis() 40 | ax1.set_title('RMSProp',fontsize=15) 41 | plt.show() -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/plot_wave.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib 3 | import matplotlib.pyplot as plt 4 | from matplotlib import gridspec 5 | from mpl_toolkits.axes_grid1 import make_axes_locatable 6 | from setup_mar import setup_par 7 | import tensorflow as tf 8 | model = setup_par() 9 | dx = model['dx'] 10 | dt = model['dt'] 11 | nx = model['nx'] 12 | nt = model['nt'] 13 | vpmodel_true = model['vpmodel_true'] 14 | out_wave = np.load('./seam_wave.npy') 15 | print('outwavefield.shape =',np.shape(out_wave)) 16 | 17 | 18 | 19 | 20 | snapshot = out_wave[1100,0,:,:] # snap 21 | #snapshot = out_wave[:,:] # model 22 | clip = np.max(np.abs(snapshot))/40. 23 | extent = [0, vpmodel_true.shape[1]*dx/1e3, (vpmodel_true.shape[0])*dx/1e3, 0.] 24 | 25 | fig, ax2 = plt.subplots(figsize=(5.4, 4.85)) 26 | #im2=ax2.imshow(np.transpose(receivers[:,:,1]),extent=[0,12,90*dx/1000.,0],vmin=-clip,vmax=clip,cmap='bwr') 27 | im2=ax2.imshow(np.transpose(snapshot),extent=extent,vmin=-clip,vmax=clip,cmap='bwr') 28 | # divider = make_axes_locatable(ax2) 29 | # cax2 = divider.append_axes("right", size="5%", pad=0.05) 30 | # plt.colorbar(im2,ax=ax2,cax=cax2).set_label('Relative amplitude') 31 | ax2.set_xlabel('Position (km)') 32 | ax2.set_ylabel('Depth (s)') 33 | ax2.xaxis.tick_top() 34 | ax2.xaxis.set_label_position('top') 35 | 36 | plt.show() 37 | -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/fwi_acs_rnn/code/wavelets.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from scipy.signal import butter, lfilter 3 | 4 | def butter_highpass_filter(data, highcut, dt, order=5): 5 | fs = 1. / dt 6 | nyq = 0.5 * fs 7 | high = highcut / nyq 8 | b, a = butter(order, high, btype='highpass') 9 | y = lfilter(b, a, data) 10 | return y 11 | 12 | 13 | def ricker(freq, length, dt, peak_time): 14 | """Return a Ricker wavelet with the specified central frequency. 15 | 16 | Args: 17 | freq: A float specifying the central frequency of the wavelet 18 | length: An integer specifying the number of time steps to use 19 | dt: A float specifying the time interval between time steps 20 | peak_time: A float specifying the time (in time units) at which the 21 | peak amplitude of the wavelet occurs 22 | 23 | Returns: 24 | A 1D Numpy array of length 'length' containing a Ricker wavelet 25 | """ 26 | t = (np.arange(length) * dt - peak_time).astype(np.float32) 27 | y = (1 - 2 * np.pi**2 * freq**2 * t**2) \ 28 | * np.exp(-np.pi**2 * freq**2 * t**2) 29 | # y = butter_highpass_filter(y,3.,dt,order=8) 30 | return y 31 | -------------------------------------------------------------------------------- /2025/W2_RNN_FWI/基于最优输运与循环神经网络的全波形反演.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/2025/W2_RNN_FWI/基于最优输运与循环神经网络的全波形反演.pdf -------------------------------------------------------------------------------- /2025/ssl_pocsnet_github_code/2D/datasetting.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch.utils.data import Dataset 3 | import h5py 4 | import numpy as np 5 | import scipy.io as sio 6 | 7 | class RandomDataset(Dataset): 8 | def __init__(self, features, masks, labels, length): 9 | self.features = features 10 | self.masks = masks 11 | self.labels = labels 12 | self.length = length 13 | 14 | def __getitem__(self, index): 15 | return (torch.Tensor(self.features[:, :, index]).float(),torch.Tensor(self.masks[:,:, index]).float(),torch.Tensor(self.labels[:, :, index]).float()) 16 | 17 | def __len__(self): 18 | return self.length 19 | 20 | def dataload(Filename,Featurename,Labelname): 21 | f = h5py.File(Filename,'r') 22 | Features = np.array(f[Featurename]) 23 | Labels = np.array(f[Labelname]) 24 | f.close() 25 | return Features,Labels,Features.shape[0] 26 | 27 | def matload(Filename,dataname): 28 | data = sio.loadmat(Filename) 29 | data = data[dataname] 30 | return data -------------------------------------------------------------------------------- /2025/ssl_pocsnet_github_code/2D/generation.sh: -------------------------------------------------------------------------------- 1 | python train.py --layer_num 35 2 | python prediction.py 3 | python prediction_pretrain.py -------------------------------------------------------------------------------- /2025/ssl_pocsnet_github_code/2D/utils.py: -------------------------------------------------------------------------------- 1 | import math 2 | import numpy as np 3 | def SNR(img,imgn): 4 | return 10*math.log10(np.linalg.norm(img)**2 / np.linalg.norm(imgn - img)**2) -------------------------------------------------------------------------------- /2025/ssl_pocsnet_github_code/3D/datasetting.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch.utils.data import Dataset 3 | import h5py 4 | import numpy as np 5 | import scipy.io as sio 6 | class RandomDataset(Dataset): 7 | def __init__(self, features, masks, mask_uss, length): 8 | self.features = features 9 | self.masks = masks 10 | self.mask_uss = mask_uss 11 | self.length = length 12 | 13 | def __getitem__(self, index): 14 | return (torch.Tensor(self.features[index, :]).float(), torch.Tensor(self.masks[index, :]).float(), torch.Tensor(self.mask_uss[index, :]).float()) 15 | 16 | def __len__(self): 17 | return self.length 18 | 19 | def dataload(Filename,Featurename,Labelname): 20 | f = h5py.File(Filename,'r') 21 | Features = np.array(f[Featurename]) 22 | Labels = np.array(f[Labelname]) 23 | f.close() 24 | return Features,Labels,Features.shape[0] 25 | 26 | def matload(Filename,dataname): 27 | data = sio.loadmat(Filename) 28 | data = data[dataname] 29 | return data -------------------------------------------------------------------------------- /2025/ssl_pocsnet_github_code/3D/generation.sh: -------------------------------------------------------------------------------- 1 | python train.py --layer_num 20 2 | python prediction.py -------------------------------------------------------------------------------- /2025/ssl_pocsnet_github_code/3D/utils.py: -------------------------------------------------------------------------------- 1 | import math 2 | import numpy as np 3 | def SNR(img,imgn): 4 | return 10*math.log10(np.linalg.norm(img)**2 / np.linalg.norm(imgn - img)**2) -------------------------------------------------------------------------------- /2025/ssl_pocsnet_github_code/ReadMe.txt: -------------------------------------------------------------------------------- 1 | Python Package Requirements: 2 | 3 | Pytorch 4 | 5 | scipy 6 | 7 | h5py 8 | 9 | Python File description: 10 | 11 | train.py:train the POCS-Net. 12 | 13 | prediction.py:interpolate test data using pre-trained POCS-Net. 14 | 15 | loss_validation_computation.py: compute the loss of the dataset. 16 | 17 | SNR_training_computation.py: compute SNR of the dataset. 18 | 19 | The datasets and pretrained model links are listed as follows: 20 | 2D: https://www.kaggle.com/datasets/supercy8250/ssl-2d-pocs-net-public 21 | 22 | 3D: https://www.kaggle.com/datasets/supercy8250/ssl-3dpocs-net-public -------------------------------------------------------------------------------- /CVMD_Denoising/dn.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/CVMD_Denoising/dn.mat -------------------------------------------------------------------------------- /CVMD_Denoising/example_CVMD_denoising.m: -------------------------------------------------------------------------------- 1 | % Complex VMD denoising by YSW 2 | % Author: Siwei Yu 3 | % Reference: Yu S, Ma J. Complex Variational Mode Decomposition for 4 | % Slop-preserving Denoising, summited to IEEE TRANSACTIONS ON GEOSCIENCE AND REMOTE SENSING 5 | % Email: jma@hit.edu.cn 6 | % March 22, 2017 7 | 8 | clear 9 | load dn; 10 | [n1,n2] = size(dn); 11 | 12 | % parameters of CVMD 13 | alpha = 5000; % moderate bandwidth constraint 14 | tau = 0.0; % noise-tolerance (no strict fidelity enforcement) 15 | K = 5; % 3 modes 16 | DC = 0; % no DC part imposed 17 | init = 0; % initialize omegas uniformly 18 | tol = 1e-7; 19 | 20 | % parameters of window 21 | nl = 100; %space window length 22 | nt = 128; %time window length 23 | dd = zeros(n1,n2); 24 | dw = zeros(n1,n2); 25 | tic 26 | for i=1:round(nl*0.6):(n2-round(0.4*nl)) %0.6 and 0.4 are parameter for window overlapping. 27 | i 28 | if (i<=n2-nl+1) 29 | dnw = dn(:,i:i+nl-1); 30 | nlt = nl; 31 | else 32 | dnw = dn(:,i:n2); 33 | nlt = n2 - i+1; 34 | end 35 | for j=1:round(nt*0.6):(n1-round(0.4*nt)) 36 | j 37 | if (j<=n1-nt+1) 38 | dnwt = dnw(j:j+nt-1,:); 39 | ntt = nt; 40 | else 41 | dnwt = dnw(j:n1,:); 42 | ntt = n1 - j+1; 43 | end 44 | ff = fft(dnwt); 45 | u_ = zeros(ntt,nlt); 46 | for wi=1:ntt/2+1 47 | fr = ff(wi,:); 48 | [u, u_hat, omega] = VMDC(fr, alpha, tau, K, DC, init, tol); 49 | [~, sortIndex] = sort(omega(end,:)); 50 | omega = omega(:,sortIndex); 51 | u_hat = u_hat(:,sortIndex); 52 | u = u(sortIndex,:); 53 | u_(wi,:) = sum(u); 54 | end 55 | u_(ceil(ntt/2)+2:ntt,:)=conj(flipud(u_(2:floor(ntt/2),:))); 56 | dd(j:j+ntt-1,i:i+nlt-1) = dd(j:j+ntt-1,i:i+nlt-1) + real(ifft(u_)); 57 | dw(j:j+ntt-1,i:i+nlt-1) = dw(j:j+ntt-1,i:i+nlt-1) + ones(ntt,nlt); 58 | end 59 | end 60 | toc 61 | result = dd./dw; 62 | subplot(121);imagesc(dn);colormap gray; 63 | subplot(122);imagesc(result);colormap gray; 64 | -------------------------------------------------------------------------------- /DDTF3D/Example_denoise.m: -------------------------------------------------------------------------------- 1 | % DDTF3D by YSW 2 | % Interpolation and denoising of high-dimensional seismic data by learning a tight frame 3 | % Author: Siwei Yu 4 | % Reference: Yu S, Ma J, Zhang X, et al. Interpolation and denoising of high-dimensional seismic data by learning a tight frame[J]. Geophysics, 2015, 80(5):V119-V132. 5 | % Email: jma@hit.edu.cn 6 | % March 22, 2017 7 | 8 | clear;clc;close all; 9 | 10 | %% 1,******************* load data ************************** 11 | % model 1: X_3D_syn, 128x128x128, model 2: elf3D, 256x256x16 12 | % u_: data without noise, u0: adding noise 13 | 14 | load 3Dsbb.mat 15 | % load elf3D; 16 | n = 64; 17 | [n1,n2,n3] = size(D); 18 | u_ = D(101:164,round(n2/2-n/2+1:n2/2+n/2),round(n3/2-n/2+1:n3/2+n/2)); 19 | [n1, n2, n3]=size(u_); 20 | 21 | u_ = u_/max(abs(u_(:))); 22 | 23 | u0 = u_ + 0.2 * randn(n1,n2,n3); 24 | 25 | lam = 1.5; thr = 0.8; 26 | 27 | %denoise 28 | out=ddtfdenoise3d(u0,lam,thr); 29 | 30 | %display 31 | seishow3D(u0);title('noisy data'); 32 | seishow3D(out);title('denoised data'); 33 | -------------------------------------------------------------------------------- /DDTF3D/Example_interp.m: -------------------------------------------------------------------------------- 1 | % DDTF3D by YSW 2 | % Interpolation and denoising of high-dimensional seismic data by learning a tight frame 3 | % Author: Siwei Yu 4 | % Reference: Yu S, Ma J, Zhang X, et al. Interpolation and denoising of high-dimensional seismic data by learning a tight frame[J]. Geophysics, 2015, 80(5):V119-V132. 5 | % Email: jma@hit.edu.cn 6 | % March 22, 2017 7 | 8 | clear all;clc;close all; 9 | addpath(genpath('.')); 10 | 11 | %% 1,******************* load data ************************** 12 | % model 1: X_3D_syn, 128x128x128, model 2: elf3D, 256x256x16 13 | % u_: data without noise, u0: adding noise 14 | 15 | load 3Dsbb.mat 16 | % load X_3D_syn.mat; 17 | u_ = D(101:164,101:164,101:164)*0.04; 18 | [n1, n2, n3]=size(u_); 19 | 20 | u0 = u_ + 0.0 * randn(n1,n2,n3); 21 | %volume_browser(u0); 22 | 23 | %% 2,******************* initialize dictionary ************************** 24 | 25 | lvl = 2;wname = 'db1'; 26 | [d0,r] = gen_dic_by_iwt_3d(2^lvl,wname); % initial dictionary with inverse wavelet transform 27 | 28 | %% 3,******************* sparse sampling ************************** 29 | 30 | ratio = 0.5; 31 | mask = proj_mask(zeros(n2,n3), ratio, 'p'); %irregular sampling 32 | % mask = proj_mask_regular(n2,n3,ratio); %regular sampling 33 | mask3 = u0; % make 3D sampling matrix 34 | for i=1:n1 35 | mask3(i,:,:)= mask; 36 | end 37 | u4 = u0.*mask3; 38 | 39 | %% 3,******************* pre-interpolation with zero nearest point method ************************** 40 | 41 | out1 = u4; 42 | for i = 1:n1 43 | temp = u4(i,:,:); 44 | temp = reshape(temp(:),n2,n3); 45 | temp = InpaintingInterp2(temp,mask, 'nearest'); 46 | out1(i,:,:) = temp; 47 | end 48 | 49 | %% 50 | % 4,**************** train dictionary with zero order interpolated initial data ******************** 51 | % 5,**************** interpolation sampled data with trained filters *********** 52 | 53 | 54 | lambdat =1.5; 55 | d_ = d0; 56 | u5 = out1; 57 | for i=1:1 58 | tic;d_ = train3d(d_,u5,r,lambdat); 59 | %55 for elf, 70 for X_syn 60 | u5 = inter3d(u5,u4,mask3,ratio,d_,r,0.8);toc; 61 | snr_(i) = snr3d(u5,u_) 62 | end 63 | 64 | 65 | %% 6,**************** plot the results *********** 66 | seishow3D(u4);title('subsampled data'); 67 | seishow3D(u5);title('reconstructed data'); 68 | 69 | -------------------------------------------------------------------------------- /DDTF3D/setup.m: -------------------------------------------------------------------------------- 1 | addpath(genpath('.')); -------------------------------------------------------------------------------- /DDTF3D/solvers/ddtfdenoise3d.m: -------------------------------------------------------------------------------- 1 | function out=ddtfdenoise3d(in,lam,thr) 2 | 3 | %denoise with ddtf 4 | %in: input data 5 | %lam: training paramter 6 | %thre: denoise parameter 7 | 8 | %out: denoised result 9 | 10 | lvl = 2;wname = 'db1'; 11 | [n1,n2,n3] = size(in); 12 | [d0,r] = gen_dic_by_iwt_3d(2^lvl,wname); % initial dictionary with inverse wavelet transform 13 | 14 | tic;d = train3d(d0,in,r,lam); 15 | 16 | g = pf3d(in,r); 17 | 18 | coef = d'*g; 19 | coef = coef.* (abs(coef)>thr); 20 | f = d*coef; 21 | 22 | out = pb3d(f,n1,n2,n3); 23 | 24 | end -------------------------------------------------------------------------------- /DDTF3D/solvers/gen_dic_by_iwt_3d.m: -------------------------------------------------------------------------------- 1 | function [out2,r]=gen_dic_by_iwt_3d(n,wname) 2 | 3 | %initial 3d dictionary by idwt 4 | 5 | %n: size of dictionary 6 | %wname: the dwt type used 7 | %output: 8 | %out2: initial dictionary 9 | %r: size of dictionary 10 | 11 | %All materials are copyrighted to HIT University, and are used for 12 | %academic research purpose only. Unauthorized redistribution of the 13 | %materials is prohibited. 14 | %Author: Siwei Yu 15 | %Date: Dec,10,2016 16 | 17 | 18 | 19 | r = n; 20 | f = zeros(n,n,n); 21 | l = round(log(n)/log(2)); 22 | c = wavedec3(f,l,wname); 23 | 24 | pos = [ 1 0 0; 25 | 0 1 0; 26 | 1 1 0; 27 | 0 0 1; 28 | 1 0 1; 29 | 0 1 1; 30 | 1 1 1;]; 31 | n2 = n*n; 32 | out = zeros(n2,n2,n2); 33 | out2 = zeros(n*n*n,n*n*n); 34 | t = 1; 35 | for m=1:l+1 36 | 37 | if (m==1) 38 | c.dec{1} = 0*c.dec{1}; 39 | c.dec{1} = 1; 40 | x = waverec3(c); 41 | c.dec{1} = 0*c.dec{1}; 42 | out(1:n,1:n,1:n) = x ; 43 | out2(:,1) = x(:); 44 | t=t+1; 45 | else 46 | 47 | for p=1:7 48 | q = (m-2)*7+p+1; 49 | ni = size(c.dec{q},1); 50 | nj = size(c.dec{q},2); 51 | nk = size(c.dec{q},3); 52 | i0 = 2^(m-2)*pos(p,1);j0 = 2^(m-2)*pos(p,2);k0 = 2^(m-2)*pos(p,3); 53 | for i=1:ni 54 | for j=1:nj 55 | for k=1:nk 56 | 57 | c.dec{q} = 0*c.dec{q}; 58 | c.dec{q}(i,j,k)=1; 59 | x = waverec3(c); 60 | c.dec{q} = 0*c.dec{q}; 61 | 62 | ib = (i0+i-1)*n +1 ; ie = ib + n-1 ; 63 | jb = (j0+j-1)*n +1 ; je = jb + n-1 ; 64 | kb = (k0+k-1)*n +1 ; ke = kb + n-1 ; 65 | out(ib:ie,jb:je,kb:ke) = x ; 66 | out2(:,t) = x(:); 67 | t = t + 1; 68 | % convert to block i,j position 69 | end 70 | end 71 | end 72 | end 73 | end 74 | 75 | end 76 | 77 | 78 | end -------------------------------------------------------------------------------- /DDTF3D/solvers/inter3d.m: -------------------------------------------------------------------------------- 1 | % interpolation by ddtf 2 | function out= inter3d(out1,raw,mask,ratio,d,r,lambda) 3 | 4 | %out1: initial data 5 | %raw: subsampled data 6 | %mask: sampling mask 7 | %ratio: sampling ratio: no use 8 | %d: dictionary used 9 | %r: size of dictioanry 10 | %lambda:threshold parameter 11 | 12 | %output 13 | %out: interpolated data 14 | 15 | %All materials are copyrighted to HIT University, and are used for 16 | %academic research purpose only. Unauthorized redistribution of the 17 | %materials is prohibited. 18 | %Author: Siwei Yu 19 | %Date: Dec,10,2016 20 | 21 | % interpolation by zero order. 22 | [n1,n2,n3]= size(raw); 23 | iter = 20; 24 | 25 | kk = 1; 26 | %interpolation with iteration threshhold method and low frequency constrain. 27 | for it = 1:iter 28 | 29 | g = pf3d(out1,r); 30 | 31 | coef = d'*g; 32 | coef = coef.* (abs(coef)>(lambda*kk)); 33 | f = d*coef; 34 | 35 | u_ = pb3d(f,n1,n2,n3); 36 | kk = kk * 0.9; 37 | out1 = kk*(raw-mask.*u_)+u_; 38 | end 39 | 40 | out=out1; 41 | 42 | end -------------------------------------------------------------------------------- /DDTF3D/solvers/train3d.m: -------------------------------------------------------------------------------- 1 | function [d_] = train3d(d0,u,r,lambda) 2 | 3 | % ddtf dictionary training (no low frequency constrain) 4 | 5 | %d0: initial dictionary 6 | %u: training data 7 | %r: patch size 8 | %lambda:training paramter 9 | %d_: trained dictionary 10 | 11 | 12 | %using ddtf algorithm 13 | %1,rerange the data into small patches. patch size r*r*r, patches number 14 | %(n1-r+1)*(n2-r+1)*(n3-r+1),the data size is (r*r*r)*((n1-r+1)*(n2-r+1)*(n3-r+1)) 15 | [n1,n2,n3] = size(u); 16 | %pf3d: transform original data to patch data 17 | %pb3d: transform patch data to original data 18 | g = pf3d(u,r); 19 | %2, use the samples from data(data driven) to train the dictionary 20 | 21 | a = d0; 22 | iter = 25; 23 | r1 = 0.0;r2 = 0.0; % weight coefficient for low frequency item 24 | 25 | for i=1:iter 26 | 27 | %fix the dictionary to update the coefficient. 28 | kk = 1-(i-1)/iter; 29 | % kk =1; 30 | v = a' * g; 31 | v = wthresh(v, 'h', kk* lambda); 32 | 33 | %fix the coefficient and update the dictionary. 34 | 35 | gv= g * v'; 36 | [s, ~, x] = svd(gv); 37 | a = s * x'; 38 | 39 | end 40 | 41 | d_ = a; 42 | 43 | end -------------------------------------------------------------------------------- /DDTF3D/utilities/DisplayH3d_all.m: -------------------------------------------------------------------------------- 1 | function DisplayH3d_all(d0) 2 | %dispaly training dictionary in 3D 3 | 4 | %d0: input dictionary 5 | 6 | n1 = size(d0,1); 7 | n2 = size(d0,2); 8 | n = round(n1^(1.0/3.0)); 9 | d0(n1,:)=d0(n1,:)*1.00001; 10 | newd = zeros(n+1,n+1,n+1); 11 | % tm =[1 2 5 17 6 18 21 22]; % 4 12 | % tm =[1 2 9 65 10 66 73 74]; % 8 13 | % tm =[1 2 3 4 5 6 7 8]; % 8 14 | % tm =[1 2 4 6 8 9 10 11 24 25 26 28 31 32 41 44] ;%8-di-elf 15 | tm =[1 2 3 4 6 8 9 12 20 21 22 27 32 54 56 58] ;%8-d-X 16 | % tm = [1 2 8 50 9 51 57 58]; % 7 17 | % tm = [1 2 4 5 8 10 11 18 19 23 24 25 26 30 31 32 33 52 53 54]; % 7-2 18 | % tm = 1:64; 19 | for m = 1:1 20 | figure; 21 | for i=1:length(tm) 22 | 23 | subplot(4,4,i); 24 | newd = zeros(n+1,n+1,n+1); 25 | % DisplayH3d( reshape(d0(:,16/16*(i-1)+1),n,n,n)); 26 | % p = (m-1)*n*n+(i-1)+1; 27 | p = tm(i) ; 28 | newd(1:n,1:n,1:n) = reshape(d0(:,p),n,n,n); 29 | newd(:,:,n+1) = newd(:,:,n); 30 | newd(:,n+1,:) = newd(:,n,:); 31 | newd(n+1,:,:) = newd(n,:,:); 32 | slice(newd,[1,n+1],[1,n+1],[1,n+1]);%colormap gray; 33 | 34 | h=findobj(gca,'linestyle','-'); 35 | h(1)=h(2); 36 | set(h,'linestyle','none'); 37 | % if (i==1) 38 | % alpha(1); 39 | % else 40 | % alpha(0.7); 41 | % end 42 | 43 | axis equal; 44 | axis tight; 45 | 46 | xlabel('x'); 47 | ylabel('y'); 48 | zlabel('z'); 49 | axis off; 50 | grid off; 51 | end 52 | end 53 | 54 | 55 | 56 | end -------------------------------------------------------------------------------- /DDTF3D/utilities/InpaintingInterp2.m: -------------------------------------------------------------------------------- 1 | function Iout=InpaintingInterp2(Ip,Fmask,interp) 2 | %Pre-interpolation with matlab function griddata. 3 | 4 | %Ip: subsampled data 5 | %Fmask: sampling mask 6 | %interp:interpolation method 7 | 8 | %Iout: interpolated data 9 | 10 | 11 | if (~exist('interp','var')) 12 | interp='nearest'; 13 | end 14 | 15 | Ip=double(Ip); 16 | [N,M]=size(Ip); 17 | [X,Y]=meshgrid([1:M],[1:N]); 18 | x=X(Fmask==1); 19 | y=Y(Fmask==1); 20 | z=Ip(Fmask==1); 21 | 22 | xi=X(Fmask==0); 23 | yi=Y(Fmask==0); 24 | 25 | 26 | Iout=Ip; 27 | interp=lower(interp); 28 | zi = griddata(x,y,z,xi,yi,interp); 29 | zi(isnan(zi))=0.; 30 | Iout(Fmask==0)=zi; 31 | -------------------------------------------------------------------------------- /DDTF3D/utilities/clip.m: -------------------------------------------------------------------------------- 1 | function Dc = clip(D,cmin,cmax); 2 | %CLIP: A program to clip seismic data. 3 | % 4 | % Dc = clip(D, cmin, cmax); 5 | % 6 | % IN D: data to be clipped 7 | % cmin: lower clip in % (90% means clip at the 90% negative amplitude) 8 | % cmax: lower clip in % (90% means clip at the 90% positive amplitude) 9 | % 10 | % OUT Dc: data after being clipped 11 | % 12 | % Example: 13 | % 14 | % d = sin(2*pi*.02*[1:1:200]); plot(clip(d,90,90)); 15 | % 16 | % 17 | % Copyright (C) 2008, Signal Analysis and Imaging Group 18 | % For more information: http://www-geo.phys.ualberta.ca/saig/SeismicLab 19 | % Author: M.D.Sacchi 20 | % 21 | % This program is free software: you can redistribute it and/or modify 22 | % it under the terms of the GNU General Public License as published 23 | % by the Free Software Foundation, either version 3 of the License, or 24 | % any later version. 25 | % 26 | % This program is distributed in the hope that it will be useful, 27 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 29 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 30 | % 31 | 32 | 33 | if (nargin < 1 | nargin > 3) 34 | error('Wrong number of input parameters in CLIP.') 35 | end 36 | 37 | % [nt,nx] = size(D); 38 | 39 | % d = reshape(D,nx*nt,1); 40 | d = D(:); 41 | 42 | dmin = abs(min(d)); 43 | dmax = abs(max(d)); 44 | 45 | I = find(d>0 & d > cmax*dmax/100.); 46 | J = find(d<0 & abs(d) > cmin*dmin/100); 47 | 48 | d(I) = cmax*dmax/100.; 49 | d(J) = -cmin*dmin/100.; 50 | 51 | % Dc = reshape(d,nt,nx); 52 | Dc = reshape(d,size(D)); 53 | return; 54 | -------------------------------------------------------------------------------- /DDTF3D/utilities/pb3d.m: -------------------------------------------------------------------------------- 1 | function u = pb3d(p,n1,n2,n3) 2 | 3 | %backward patch transform 4 | %p: patch 5 | %n1~n3: data dimensino 6 | %u: output data 7 | 8 | u_ = zeros(n1,n2,n3);uw = u_; 9 | r = round(size(p,1)^(1/3)); 10 | l = 1; 11 | s = 2; 12 | for i=1:s:n1-r+1 13 | for j=1:s:n2-r+1 14 | for k=1:s:n3-r+1 15 | u_(i:i+r-1,j:j+r-1,k:k+r-1)=u_(i:i+r-1,j:j+r-1,k:k+r-1)+reshape(p(:,l),r,r,r); 16 | uw(i:i+r-1,j:j+r-1,k:k+r-1)=uw(i:i+r-1,j:j+r-1,k:k+r-1)+1; 17 | l = l + 1; 18 | end 19 | end 20 | end 21 | 22 | u = u_./uw; 23 | 24 | end -------------------------------------------------------------------------------- /DDTF3D/utilities/pf3d.m: -------------------------------------------------------------------------------- 1 | function out = pf3d(u,r) 2 | %forward patch transform 3 | 4 | %u: input data 5 | %r: patch size 6 | 7 | %out: output patches 8 | 9 | [n1,n2,n3] = size(u); 10 | g = zeros(r*r*r,(n1-r+1)*(n2-r+1)*(n3-r+1)); 11 | l = 1; 12 | s = 2; 13 | for i=1:s:n1-r+1 14 | for j=1:s:n2-r+1 15 | for k=1:s:n3-r+1 16 | g(:,l)=reshape(u(i:i+r-1,j:j+r-1,k:k+r-1),r*r*r,1); 17 | l = l + 1; 18 | end 19 | end 20 | end 21 | 22 | out = g; 23 | 24 | end -------------------------------------------------------------------------------- /DDTF3D/utilities/proj_mask.m: -------------------------------------------------------------------------------- 1 | function mask = proj_mask(u, r, type) 2 | % u, image 3 | % r, data KNOWN ratio 4 | % type: data missing type 5 | % 'r': random missing rows 6 | % 'c': random missing columns 7 | % 'p': random missing pixels 8 | 9 | % For ROW COLUMN missing cases, the max gap between two known 10 | % rows/columns is at most 2(1/r-1) with probability r^2 11 | 12 | % code duplicate for cases 'r' & 'c' 13 | 14 | [m,n] = size(u); 15 | 16 | mask = zeros(m,n); 17 | 18 | switch type 19 | 20 | case 'r' 21 | 22 | gap = 1/r; 23 | gap_ = ceil(gap); 24 | K = floor(m*r); 25 | 26 | for i=1:K 27 | j = floor((i-1)*gap) + randperm(gap_,1); 28 | mask(j,:) = 1; 29 | end 30 | 31 | case 'c' 32 | 33 | gap = 1/r; 34 | gap_ = ceil(gap); 35 | K = floor(n*r); 36 | 37 | for i=1:K 38 | j = floor((i-1)*gap) + randperm(gap_,1); 39 | mask(:,j) = 1; 40 | end 41 | 42 | case 'p' 43 | 44 | pix = randperm(m*n); 45 | r = fix(r*m*n); 46 | pix = pix(1:r); 47 | mask(pix) = 1; 48 | 49 | otherwise % pixel-wise missing 50 | 51 | pix = randperm(m*n); 52 | r = fix(r*m*n); 53 | pix = pix(1:r); 54 | mask(pix) = 1; 55 | 56 | end 57 | -------------------------------------------------------------------------------- /DDTF3D/utilities/proj_mask_regular.m: -------------------------------------------------------------------------------- 1 | function mask = proj_mask_regular(m, n, r) 2 | % u, image 3 | % r, data KNOWN ratio 4 | % type: data missing type 5 | % 'r': random missing rows 6 | % 'c': random missing columns 7 | % 'p': random missing pixels 8 | 9 | % For ROW COLUMN missing cases, the max gap between two known 10 | % rows/columns is at most 2(1/r-1) with probability r^2 11 | 12 | % code duplicate for cases 'r' & 'c' 13 | mask = zeros(m,n); 14 | % p=1/sqrt(r); 15 | p=1/r; 16 | 17 | mask(round(1:p:m),:) = 1; 18 | 19 | 20 | end 21 | -------------------------------------------------------------------------------- /DDTF3D/utilities/seishow3D.m: -------------------------------------------------------------------------------- 1 | function seishow3D(D,c,dmin,dmax) 2 | 3 | if (~exist('c' ,'var')) 4 | c=100; 5 | end 6 | 7 | cm = min(D(:)); 8 | [n1,n2,n3] = size(D); 9 | 10 | di = 0.05; dc = 0.05; dt = 0.004; 11 | % xt = [1, 50, 100, 129, 178, 228]; 12 | % xtl= [0, 1, 2, 0, 1 ,2]; 13 | % yt = [1, 50, 100, 129, 178, 228]; 14 | % ytl= [ 0, 1, 2, 0, 0.2, 0.4]; 15 | xt = [1, 50, 100, 150, 200]; 16 | xtl= [[0, 50, 100]*di, [50, 100]*dc]; 17 | yt = [1, 50, 100, 150, 200, 250]; 18 | ytl= [[0, 50, 100]*di, [50, 100, 150]*dt]; 19 | 20 | I = zeros(n1+n3+1,n2+n3+1); 21 | I(1:n3,1:n2) = squeeze( D(round(n1/2),:,:) )'; 22 | I(:,n2+1) = cm; 23 | I(1:n3,n2+2:n2+n3+1) = mean(D(:))*ones(n3,n3); 24 | I(n3+2:n3+n1+1,1:n2) = squeeze(D(:,:, round(n3/2))); 25 | I(n3+1,:) = cm; 26 | I(n3+2:n3+n1+1,n2+2:n2+n3+1) = squeeze( D(:,round(n2/2),:)); 27 | %figure, 28 | I = clip(I,c,c); 29 | 30 | if (~exist('dmin' ,'var')) 31 | dmin = min(I(:)) ; 32 | end 33 | if (~exist('dmax' ,'var')) 34 | dmax = max(I(:)) ; 35 | end 36 | 37 | figure,imagesc(I,[dmin,dmax]);axis image;colorbar; colormap gray; 38 | % set(gca,'XTick',xt,'YTick',yt); 39 | % set(gca,'XTickLabel',xtl,'YTickLabel',ytl); 40 | set(gca,'FontSize',12); 41 | xlabel('Midpoint (km) Offset (km)'); 42 | ylabel('Time (s) Offset (km)'); 43 | %imagesc(I);axis image; colormap gray; axis off;colorbar; 44 | % figure, plot(I(:,64)); 45 | end 46 | -------------------------------------------------------------------------------- /DDTF3D/utilities/snr3d.m: -------------------------------------------------------------------------------- 1 | function snr = snr3d(g, f) 2 | % g: ground truth image 3 | % f: noisy/restored image 4 | 5 | g = double(g); % in case of data format is unit8,12,16 6 | f = double(f); 7 | 8 | 9 | ps = norm(f(:)); % average power of signal 10 | pn = norm(f(:)-g(:)); % average power of noise 11 | snr = 20.*log10(ps/pn); 12 | 13 | 14 | 15 | end 16 | -------------------------------------------------------------------------------- /Decurtain/Example.m: -------------------------------------------------------------------------------- 1 | % Removal of curtaining effects by a variational model with directional forward differences 2 | % Author: Jan Henrik Fitschen 3 | % Reference: Jan Henrik Fitschen, Jianwei Ma, Sebastian Schuff, Removal of curtaining effects by a variational model with directional forward differences, Computer Vision and Image Understanding, Volume 155, February 2017, Pages 24-32, ISSN 1077-3142, http://dx.doi.org/10.1016/j.cviu.2016.12.008. 4 | % Email: jma@hit.edu.cn 5 | % March 22, 2017 6 | 7 | 8 | load('../MathGeo_testdata/new_artificial.mat'); 9 | 10 | [ u,s,t ] = curtainDropping( im(:,:,:), 30, .02, .4, .7, 300); 11 | 12 | implay(u); -------------------------------------------------------------------------------- /Decurtain/softShrinkage.m: -------------------------------------------------------------------------------- 1 | % Removal of curtaining effects by a variational model with directional forward differences 2 | % Author: Jan Henrik Fitschen 3 | % Reference: Jan Henrik Fitschen, Jianwei Ma, Sebastian Schuff, Removal of curtaining effects by a variational model with directional forward differences, Computer Vision and Image Understanding, Volume 155, February 2017, Pages 24-32, ISSN 1077-3142, http://dx.doi.org/10.1016/j.cviu.2016.12.008. 4 | % Email: jma@hit.edu.cn 5 | % March 22, 2017 6 | 7 | function A = softShrinkage(A,lambda) 8 | %compute soft-shrinkage of A with treshold lambda 9 | 10 | if(length(lambda) > 1) 11 | if(size(A,ndims(A)) ~= length(lambda)) 12 | error('A and lambda must be of same size!'); 13 | end 14 | 15 | %adjust lambda to shearlet data structure 16 | lambda = bsxfun(@times,ones(size(A)),reshape(lambda,[1,1,length(lambda)])); 17 | end 18 | 19 | %soft tresholding 20 | aA = abs(A) > lambda; 21 | A = ( A - ( sign(A) .* lambda ) ) .* aA; 22 | -------------------------------------------------------------------------------- /Deep_learning/CNN-POCS/CNN-POCS-tools.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/CNN-POCS/CNN-POCS-tools.rar -------------------------------------------------------------------------------- /Deep_learning/CNN-POCS/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Hao Zhang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Deep_learning/CNN-POCS/README.md: -------------------------------------------------------------------------------- 1 | # CNN-POCS 2 | CNN-POCS algorithm for seismic data interpolation. 3 | 4 | This repository contains the reproducible code for the article ["Can learning from image denoising be used for seismic data interpolation?"](https://library.seg.org/doi/10.1190/geo2019-0243.1) This article can also be reached at [Arxiv](https://arxiv.org/pdf/1902.10379.pdf) but it is somehow out of date. 5 | 6 | ## Requirements and Dependencies 7 | This repository depends on Matlab and matconvnet. Matlab beyond 2018a and [matconvnet](https://www.vlfeat.org/matconvnet/) 1.0beta25 are recommended. CUDA is required for training process/gpu testing. Please refer to [Matlab GPU support](https://www.mathworks.com/help/parallel-computing/gpu-support-by-release.html) to setup your environment. 8 | ## CNN-POCS workflow 9 | 10 | 11 | ## Training 12 | The training code can be found in [TrainingCodes](https://github.com/AlbertZhangHIT/CNN-POCS/tree/master/TrainingCodes). 13 | 14 | ## Seismic data interpolation & denoising 15 | We provide few demos for reproducing some results. The pre-trained models using natural images are in folder [models](https://github.com/AlbertZhangHIT/CNN-POCS/tree/master/models). The hyperbolic events data and the synthetic 3D data are included in [seismicData](https://github.com/AlbertZhangHIT/CNN-POCS/tree/master/seismicData). 16 | 17 | 1. [Demo\_pocs\_cnn.m](https://github.com/AlbertZhangHIT/CNN-POCS/tree/master/Demo_pocs_cnn.m) is provided for testing the CNN-POCS algorithm for seismic data interpolation. 18 | 2. [Demo_cnndenoise.m](https://github.com/AlbertZhangHIT/CNN-POCS/tree/master/Demo_cnndenoise.m) is provided for testing denoising 2D seismic data using natural images pretrained CNN models. 19 | 3. [Demo_cnndenoise3D.m](https://github.com/AlbertZhangHIT/CNN-POCS/tree/master/Demo_cnndenoise3D.m) is provided for testing denoising 3D seismic data. 20 | 21 | # Citation 22 | If this repository helps you with your research, please consider citing our work 23 | 24 | 25 | @article{zhang2020can, 26 | title={Can learning from natural image denoising be used for seismic data interpolation?}, 27 | author={Zhang, Hao and Yang, Xiuyan and Ma, Jianwei}, 28 | journal={Geophysics}, 29 | volume={85}, 30 | number={4}, 31 | pages={1--142}, 32 | year={2020}, 33 | publisher={Society of Exploration Geophysicists} 34 | } 35 | -------------------------------------------------------------------------------- /Deep_learning/CNN-POCS/figs/flowchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/CNN-POCS/figs/flowchart.png -------------------------------------------------------------------------------- /Deep_learning/CNN-POCS/generateHyperbolic.m: -------------------------------------------------------------------------------- 1 | %%% Generate hyperbolic events data 2 | %%% 3 | %%% 4 | addpath('SeismicLab/codes/synthetics') 5 | 6 | dt = 2./1000; 7 | tmax = 2.; 8 | n = 100; 9 | offset = (-n:n)*10; 10 | tau = [.5, .8, 1., 1.4]; 11 | v = [1700, 1800, 2000, 2300]; 12 | amp = [.4, .4, .6, .5]; 13 | f0 = 30; 14 | snr = Inf; 15 | L = 20; 16 | saveData = 1; 17 | saveFolder = 'seismicData/'; 18 | Dataname = 'hyperbolic-events'; 19 | 20 | D = hyperbolic_events(dt, f0, tmax, offset, tau, v, amp, snr, L); 21 | D = D(:, 1:floor(size(D,2)/4)*4); 22 | figure, imagesc(D), colormap(gray) 23 | 24 | if saveData 25 | save([saveFolder, Dataname], 'D'); 26 | end 27 | -------------------------------------------------------------------------------- /Deep_learning/CNN-POCS/makeMask.m: -------------------------------------------------------------------------------- 1 | clear; 2 | 3 | addpath('utilities'); 4 | addpath('seismicPlots'); 5 | addpath('seismicData'); 6 | % choose data 7 | dataChoice = 1; 8 | switch dataChoice 9 | case 1 10 | Data = 'hyperbolic-events'; 11 | otherwise 12 | error('Unexpected choice.'); 13 | end 14 | load([Data, '.mat']) 15 | if strcmp(Data, '7blocks') 16 | D = D{select}; 17 | end 18 | 19 | sampleType = 'randc'; 20 | Ratio= .3; 21 | saveMask = 1; 22 | 23 | [m, n] = size(D); 24 | mask = projMask(D, Ratio, sampleType); 25 | 26 | fig1 = figure(1); 27 | set(gcf, 'color', 'white'), set(gcf, 'Position', [100, 100, 900, 700]) 28 | imagesc(mask.*D); 29 | colormap(seismic(2)); 30 | 31 | if saveMask 32 | save(['seismicData/masks/','mask',num2str(m),'x',num2str(n),sampleType,num2str(floor(Ratio*100)),'.mat'], 'mask'); 33 | end -------------------------------------------------------------------------------- /Deep_learning/CNN-POCS/models/model.part1.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/CNN-POCS/models/model.part1.rar -------------------------------------------------------------------------------- /Deep_learning/CNN-POCS/models/model.part2.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/CNN-POCS/models/model.part2.rar -------------------------------------------------------------------------------- /Deep_learning/CNN-POCS/seismicData/X3Dsyn.part1.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/CNN-POCS/seismicData/X3Dsyn.part1.rar -------------------------------------------------------------------------------- /Deep_learning/CNN-POCS/seismicData/X3Dsyn.part2.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/CNN-POCS/seismicData/X3Dsyn.part2.rar -------------------------------------------------------------------------------- /Deep_learning/CNN-POCS/seismicData/X3Dsyn.part3.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/CNN-POCS/seismicData/X3Dsyn.part3.rar -------------------------------------------------------------------------------- /Deep_learning/CNN-POCS/seismicData/hyperbolic-events-half.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/CNN-POCS/seismicData/hyperbolic-events-half.mat -------------------------------------------------------------------------------- /Deep_learning/CNN-POCS/seismicData/hyperbolic-events.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/CNN-POCS/seismicData/hyperbolic-events.mat -------------------------------------------------------------------------------- /Deep_learning/CNN-POCS/seismicData/masks/mask751x191iregc50.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/CNN-POCS/seismicData/masks/mask751x191iregc50.mat -------------------------------------------------------------------------------- /Deep_learning/FCNVMB-Deep-learning-based-seismic-velocity-model-building-master/FCNVMB-data.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/FCNVMB-Deep-learning-based-seismic-velocity-model-building-master/FCNVMB-data.zip -------------------------------------------------------------------------------- /Deep_learning/FCNVMB-Deep-learning-based-seismic-velocity-model-building-master/LibConfig.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Import libraries 4 | 5 | Created on Feb 2018 6 | 7 | @author: fangshuyang (yfs2016@hit.edu.cn) 8 | 9 | """ 10 | 11 | ################################################ 12 | ######## LIBARIES ######## 13 | ################################################ 14 | 15 | import numpy as np 16 | import torch 17 | import os, sys 18 | sys.path.append(os.getcwd()) 19 | import time 20 | import pdb 21 | import argparse 22 | import torch 23 | import torch.nn as nn 24 | import scipy.io 25 | import torch.utils.data as data_utils 26 | from torch.autograd import Variable 27 | import torch.nn.functional as F 28 | import numpy as np 29 | import matplotlib 30 | matplotlib.use('Agg') 31 | import matplotlib.pylab as plt 32 | from mpl_toolkits.axes_grid1 import make_axes_locatable 33 | from func.utils import * 34 | from func.UnetModel import UnetModel 35 | from func.DataLoad_Train import DataLoad_Train 36 | from func.DataLoad_Test import DataLoad_Test 37 | from func.utils import turn, PSNR, SSIM 38 | -------------------------------------------------------------------------------- /Deep_learning/FCNVMB-Deep-learning-based-seismic-velocity-model-building-master/ParamConfig.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Parameters setting 4 | 5 | Created on Feb 2018 6 | 7 | @author: fangshuyang (yfs2016@hit.edu.cn) 8 | 9 | """ 10 | 11 | 12 | #################################################### 13 | #### MAIN PARAMETERS #### 14 | #################################################### 15 | SimulateData = True # If False denotes training the CNN with SEGSaltData 16 | ReUse = False # If False always re-train a network 17 | DataDim = [2000,301] # Dimension of original one-shot seismic data 18 | data_dsp_blk = (5,1) # Downsampling ratio of input 19 | ModelDim = [201,301] # Dimension of one velocity model 20 | label_dsp_blk = (1,1) # Downsampling ratio of output 21 | dh = 10 # Space interval 22 | 23 | 24 | #################################################### 25 | #### NETWORK PARAMETERS #### 26 | #################################################### 27 | if SimulateData: 28 | Epochs = 100 # Number of epoch 29 | TrainSize = 1600 # Number of training set 30 | TestSize = 100 # Number of testing set 31 | TestBatchSize = 10 32 | else: 33 | Epochs = 50 34 | TrainSize = 130 35 | TestSize = 10 36 | TestBatchSize = 1 37 | 38 | BatchSize = 10 # Number of batch size 39 | LearnRate = 1e-3 # Learning rate 40 | Nclasses = 1 # Number of output channels 41 | Inchannels = 29 # Number of input channels, i.e. the number of shots 42 | SaveEpoch = 20 43 | DisplayStep = 2 # Number of steps till outputting stats -------------------------------------------------------------------------------- /Deep_learning/FCNVMB-Deep-learning-based-seismic-velocity-model-building-master/data/train_data/SEGSaltData/georec_train/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Deep_learning/FCNVMB-Deep-learning-based-seismic-velocity-model-building-master/data/train_data/SEGSaltData/vmodel_train/readme.md: -------------------------------------------------------------------------------- 1 | SEG salt velocity models for training process. 2 | -------------------------------------------------------------------------------- /Deep_learning/FCNVMB-Deep-learning-based-seismic-velocity-model-building-master/data/train_data/SimulateData/georec_train/readme.md: -------------------------------------------------------------------------------- 1 | The corresponding synthetic seismic measurement by solving the 2D constant density acoustic wave equation 2 | -------------------------------------------------------------------------------- /Deep_learning/FCNVMB-Deep-learning-based-seismic-velocity-model-building-master/data/train_data/SimulateData/vmodel_train/readme.md: -------------------------------------------------------------------------------- 1 | Synthetic velocity models for training process 2 | -------------------------------------------------------------------------------- /Deep_learning/FCNVMB-Deep-learning-based-seismic-velocity-model-building-master/images/SEGresult.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/FCNVMB-Deep-learning-based-seismic-velocity-model-building-master/images/SEGresult.png -------------------------------------------------------------------------------- /Deep_learning/FCNVMB-Deep-learning-based-seismic-velocity-model-building-master/images/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/FCNVMB-Deep-learning-based-seismic-velocity-model-building-master/images/schematic.png -------------------------------------------------------------------------------- /Deep_learning/FCNVMB-Deep-learning-based-seismic-velocity-model-building-master/images/simulateresult.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/FCNVMB-Deep-learning-based-seismic-velocity-model-building-master/images/simulateresult.png -------------------------------------------------------------------------------- /Deep_learning/FCNVMB/LibConfig.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Import libraries 4 | 5 | Created on Feb 2018 6 | 7 | @author: fangshuyang (yfs2016@hit.edu.cn) 8 | 9 | """ 10 | 11 | ################################################ 12 | ######## LIBARIES ######## 13 | ################################################ 14 | 15 | import numpy as np 16 | import torch 17 | import os, sys 18 | sys.path.append(os.getcwd()) 19 | import time 20 | import pdb 21 | import argparse 22 | import torch 23 | import torch.nn as nn 24 | import scipy.io 25 | import torch.utils.data as data_utils 26 | from torch.autograd import Variable 27 | import torch.nn.functional as F 28 | import numpy as np 29 | import matplotlib 30 | matplotlib.use('Agg') 31 | import matplotlib.pylab as plt 32 | from mpl_toolkits.axes_grid1 import make_axes_locatable 33 | from func.utils import * 34 | from func.UnetModel import UnetModel 35 | from func.DataLoad_Train import DataLoad_Train 36 | from func.DataLoad_Test import DataLoad_Test 37 | from func.utils import turn, PSNR, SSIM 38 | -------------------------------------------------------------------------------- /Deep_learning/FCNVMB/ParamConfig.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Parameters setting 4 | 5 | Created on Feb 2018 6 | 7 | @author: fangshuyang (yfs2016@hit.edu.cn) 8 | 9 | """ 10 | 11 | 12 | #################################################### 13 | #### MAIN PARAMETERS #### 14 | #################################################### 15 | SimulateData = True # If False denotes training the CNN with SEGSaltData 16 | ReUse = False # If False always re-train a network 17 | DataDim = [2000,301] # Dimension of original one-shot seismic data 18 | data_dsp_blk = (5,1) # Downsampling ratio of input 19 | ModelDim = [201,301] # Dimension of one velocity model 20 | label_dsp_blk = (1,1) # Downsampling ratio of output 21 | dh = 10 # Space interval 22 | 23 | 24 | #################################################### 25 | #### NETWORK PARAMETERS #### 26 | #################################################### 27 | if SimulateData: 28 | Epochs = 100 # Number of epoch 29 | TrainSize = 1600 # Number of training set 30 | TestSize = 100 # Number of testing set 31 | TestBatchSize = 10 32 | else: 33 | Epochs = 50 34 | TrainSize = 130 35 | TestSize = 10 36 | TestBatchSize = 1 37 | 38 | BatchSize = 10 # Number of batch size 39 | LearnRate = 1e-3 # Learning rate 40 | Nclasses = 1 # Number of output channels 41 | Inchannels = 29 # Number of input channels, i.e. the number of shots 42 | SaveEpoch = 20 43 | DisplayStep = 2 # Number of steps till outputting stats -------------------------------------------------------------------------------- /Deep_learning/FCNVMB/images/SEGresult.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/FCNVMB/images/SEGresult.png -------------------------------------------------------------------------------- /Deep_learning/FCNVMB/images/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/FCNVMB/images/schematic.png -------------------------------------------------------------------------------- /Deep_learning/FCNVMB/images/simulateresult.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/FCNVMB/images/simulateresult.png -------------------------------------------------------------------------------- /Deep_learning/deep-learning-geophysics-tutorial/README.en.md: -------------------------------------------------------------------------------- 1 | # DeepLearningGeophysics 2 | 3 | #### Description 4 | Source code for Deep learning for geophysics: current and future trends 5 | 6 | #### Software Architecture 7 | Software architecture description 8 | 9 | #### Installation 10 | 11 | 1. xxxx 12 | 2. xxxx 13 | 3. xxxx 14 | 15 | #### Instructions 16 | 17 | 1. xxxx 18 | 2. xxxx 19 | 3. xxxx 20 | 21 | #### Contribution 22 | 23 | 1. Fork the repository 24 | 2. Create Feat_xxx branch 25 | 3. Commit your code 26 | 4. Create Pull Request 27 | 28 | 29 | #### Gitee Feature 30 | 31 | 1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md 32 | 2. Gitee blog [blog.gitee.com](https://blog.gitee.com) 33 | 3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) 34 | 4. The most valuable open source project [GVP](https://gitee.com/gvp) 35 | 5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) 36 | 6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) 37 | -------------------------------------------------------------------------------- /Deep_learning/deep-learning-geophysics-tutorial/code.py: -------------------------------------------------------------------------------- 1 | import h5py 2 | import tensorflow 3 | from tensorflow.keras.layers import Input,Conv2D,BatchNormalization,ReLU,Subtract 4 | from tensorflow.keras.models import Model 5 | print(tensorflow.__version__) 6 | ftrain = h5py.File(r'E:\Datasets\noise_dataset.h5','r') 7 | X, Y=ftrain['/X'][()],ftrain['/Y'][()] 8 | input = Input(shape=(None,None,1)) 9 | x=Conv2D(64,3,padding='same',activation='relu')(input) 10 | for i in range(15): 11 | x= Conv2D(64,3,padding='same',use_bias = False)(x) 12 | x= ReLU()(BatchNormalization(axis=3,momentum=0.0,epsilon=0.0001)(x)) 13 | x= Conv2D(1,3,padding='same',use_bias = False)(x) 14 | model = Model(inputs=input,outputs=Subtract()([input,x])) 15 | model.compile(optimizer="rmsprop",loss="mean_squared_error") 16 | model.fit(X[:-1000],Y[:-1000],batch_size=32,epochs=50,shuffle=True) 17 | Y_ = model.predict(X[-1000:]) -------------------------------------------------------------------------------- /Deep_learning/deep-learning-geophysics-tutorial/imgs/prediction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/deep-learning-geophysics-tutorial/imgs/prediction.png -------------------------------------------------------------------------------- /Deep_learning/deep-learning-geophysics-tutorial/imgs/trainingsets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/deep-learning-geophysics-tutorial/imgs/trainingsets.png -------------------------------------------------------------------------------- /Deep_learning/python_segy/data/test/test.segy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/python_segy/data/test/test.segy -------------------------------------------------------------------------------- /Deep_learning/python_segy/gain.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import math 3 | from scipy.signal.windows import triang 4 | from scipy.signal import convolve2d as conv2 5 | 6 | def gain(data,dt,option1,parameters,option2): 7 | ''' 8 | GAIN: Gain a group of traces. 9 | 10 | gain(d,dt,option1,parameters,option2); 11 | 12 | IN d(nt,nx): traces 13 | dt: sampling interval 14 | option1 = 'time' parameters = [a,b], gain = t.^a . * exp(-bt) 15 | = 'agc' parameters = [agc_gate], length of the agc gate in secs 16 | option2 = 0 No normalization 17 | = 1 Normalize each trace by amplitude 18 | = 2 Normalize each trace by rms value 19 | 20 | OUT dout(nt,nx): traces after application of gain function 21 | ''' 22 | 23 | nt,nx = data.shape 24 | 25 | dout = np.zeros(data.shape) 26 | if option1 == 'time': 27 | a = parameters[0] 28 | b = parameters[1] 29 | t = [x*dt for x in range(nt)] 30 | tgain = [(x**a)*math.exp(x*b) for x in t] 31 | 32 | for k in range(nx): 33 | dout[:,k] = data[:,k]*tgain 34 | 35 | 36 | elif option1 == 'agc': 37 | L = parameters/dt+1 38 | L = np.floor(L/2) 39 | h = triang(2*L+1) 40 | shaped_h = h.reshape(len(h),1) 41 | 42 | for k in range(nx): 43 | aux = data[:,k] 44 | e = aux**2 45 | shaped_e = e.reshape(len(e),1) 46 | 47 | rms = np.sqrt(conv2(shaped_e,shaped_h,"same")) 48 | epsi = 1e-10*max(rms) 49 | op = rms/(rms**2+epsi) 50 | op = op.reshape(len(op),) 51 | 52 | dout[:,k] = data[:,k]*op 53 | 54 | #Normalize by amplitude 55 | if option2==1: 56 | for k in range(nx): 57 | aux = dout[:,k] 58 | amax = max(abs(aux)) 59 | dout[:,k] = dout[:,k]/amax 60 | 61 | #Normalize by rms 62 | if option2==2: 63 | for k in range(nx): 64 | aux = dout[:,k] 65 | amax = np.sqrt(sum(aux**2)/nt) 66 | dout[:,k] = dout[:,k]/amax 67 | 68 | 69 | return dout -------------------------------------------------------------------------------- /Deep_learning/python_segy/models_denoise/DnCNN_sigma25/model.pth: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/python_segy/models_denoise/DnCNN_sigma25/model.pth -------------------------------------------------------------------------------- /Deep_learning/python_segy/models_denoise/DnCNN_sigma50/model.pth: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/python_segy/models_denoise/DnCNN_sigma50/model.pth -------------------------------------------------------------------------------- /Deep_learning/python_segy/models_inter/DnCNN_rate2/model.pth: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Deep_learning/python_segy/models_inter/DnCNN_rate2/model.pth -------------------------------------------------------------------------------- /Deep_learning/python_segy/requirements.txt: -------------------------------------------------------------------------------- 1 | scipy 2 | numpy 3 | h5py 4 | segyio 5 | progressbar 6 | urllib3 7 | opencv-python 8 | -------------------------------------------------------------------------------- /Dictionary_learning/D.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Dictionary_learning/D.mat -------------------------------------------------------------------------------- /Dictionary_learning/D1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Dictionary_learning/D1.mat -------------------------------------------------------------------------------- /Dictionary_learning/OMP.m: -------------------------------------------------------------------------------- 1 | function [A]=OMP(D,X,L,options) 2 | %============================================= 3 | % Sparse coding of a group of signals based on a given 4 | % dictionary and specified number of atoms to use. 5 | % input arguments: 6 | % D - the dictionary (its columns MUST be normalized). 7 | % X - the signals to represent 8 | % L - the max. number of coefficients for each signal. 9 | % output arguments: 10 | % A - sparse coefficient matrix. 11 | %============================================= 12 | options.null = 0; 13 | [n,P]=size(X); 14 | [n,K]=size(D); 15 | for k=1:1:P, 16 | a=[]; 17 | x=X(:,k); 18 | residual=x; 19 | indx=zeros(L,1); 20 | for j=1:1:L, 21 | proj=D'*residual; 22 | [maxVal,pos]=max(abs(proj)); 23 | pos=pos(1); 24 | indx(j)=pos; 25 | a=D(:,indx(1:j))\x; 26 | residual=x-D(:,indx(1:j))*a; 27 | if sum(residual.^2) < 1e-6 28 | break; 29 | end 30 | end; 31 | temp=zeros(K,1); 32 | temp(indx(1:j))=a; 33 | A(:,k)=sparse(temp); 34 | end; 35 | return; 36 | -------------------------------------------------------------------------------- /Dictionary_learning/OMPerr.m: -------------------------------------------------------------------------------- 1 | function [A]=OMPerr(D,P,epsilon,options) 2 | %============================================= 3 | % Sparse coding of a group of signals based on a given 4 | % dictionary and specified number of atoms to use. 5 | % input arguments: D - the dictionary 6 | % X - the signals to represent 7 | % epsilon - the maximal allowed representation error for 8 | % each siganl. 9 | % output arguments: A - sparse coefficient matrix. 10 | %============================================= 11 | options.null = 0; 12 | verbose = getoptions(options,'verbose',0); 13 | 14 | 15 | [~,L]=size(P); 16 | [n,K]=size(D); 17 | E2 = epsilon^2*n; 18 | % E2 = epsilon*n; 19 | maxNumCoef = n/2; 20 | A = sparse(size(D,2),size(P,2)); 21 | if verbose 22 | tic 23 | end 24 | for k=1:1:L, 25 | if mod(20*k,20*floor(L/20)) == 0 && verbose 26 | time = toc; 27 | display(['OMPerr Processing ',num2str(floor(100*k/L)),'%, ',num2str(floor(time)),'/',num2str(floor(time/k*L)),' sec']) 28 | end 29 | x=P(:,k); 30 | residual=x; 31 | indx = []; 32 | a = []; 33 | currResNorm2 = sum(residual.^2); 34 | j = 0; 35 | while currResNorm2>E2 && j < maxNumCoef, 36 | j = j+1; 37 | proj=D'*residual; 38 | pos=find(abs(proj)==max(abs(proj))); 39 | pos=pos(1); 40 | indx(j)=pos; 41 | a=D(:,indx(1:j))\x; 42 | residual=x-D(:,indx(1:j))*a; 43 | currResNorm2 = sum(residual.^2); 44 | end; 45 | if ~isempty(indx) 46 | A(indx,k)=a; 47 | end 48 | end; 49 | return; 50 | 51 | -------------------------------------------------------------------------------- /Dictionary_learning/SNR.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Dictionary_learning/SNR.m -------------------------------------------------------------------------------- /Dictionary_learning/X1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Dictionary_learning/X1.mat -------------------------------------------------------------------------------- /Dictionary_learning/X_elf3D.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Dictionary_learning/X_elf3D.mat -------------------------------------------------------------------------------- /Dictionary_learning/extract_patch.m: -------------------------------------------------------------------------------- 1 | function[P] = extract_patch(M,w,m,pos) 2 | 3 | % M : Image to extract patches from 4 | % w : patch size 5 | % m : number of patches to extract 6 | % pos : optional patch position list 7 | % Random position if not specified as input 8 | % Simon Beckouche 9 | % simon@beckouche.fr 10 | 11 | [n1,n2] = size(M); 12 | 13 | if nargin < 4 14 | pos = randperm(n1*n2); 15 | pos = pos(1:m); 16 | end 17 | 18 | 19 | % Extract patches 20 | P = zeros(w,w,m); 21 | for k = 1:m 22 | cx = mod(pos(k)-1,n1)+1; 23 | cy = ceil(pos(k)/n1); 24 | 25 | x = cx:cx+w-1; 26 | y = cy:cy+w-1; 27 | 28 | x(x>n1) = 2*n1-x(x>n1); 29 | y(y>n2) = 2*n2-y(y>n2); 30 | 31 | 32 | P(:,:,k) = M(x,y); 33 | 34 | 35 | end -------------------------------------------------------------------------------- /Dictionary_learning/getoptions.m: -------------------------------------------------------------------------------- 1 | function v = getoptions(options, name, v, mendatory) 2 | 3 | % getoptions - retrieve options parameter 4 | % 5 | % v = getoptions(options, 'entry', v0, mendatory); 6 | % is equivalent to the code: 7 | % if isfield(options, 'entry') 8 | % v = options.entry; 9 | % else 10 | % v = v0; 11 | % end 12 | % 13 | % Copyright (c) 2007 Gabriel Peyre 14 | 15 | if nargin<3 16 | error('Not enough arguments.'); 17 | end 18 | if nargin<4 19 | mendatory = 0; 20 | end 21 | 22 | if isfield(options, name) 23 | v = eval(['options.' name ';']); 24 | elseif mendatory 25 | error(['You have to provide options.' name '.']); 26 | end 27 | -------------------------------------------------------------------------------- /Dictionary_learning/noisy.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Dictionary_learning/noisy.mat -------------------------------------------------------------------------------- /Dictionary_learning/noisy1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Dictionary_learning/noisy1.mat -------------------------------------------------------------------------------- /Dictionary_learning/noisy2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Dictionary_learning/noisy2.mat -------------------------------------------------------------------------------- /Dictionary_learning/noisy3.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Dictionary_learning/noisy3.mat -------------------------------------------------------------------------------- /Dictionary_learning/patch_center.m: -------------------------------------------------------------------------------- 1 | function[Q,centers] = patch_center(P,options) 2 | 3 | options.null = 0; 4 | w = getoptions(options,'w',sqrt(size(P,1))); 5 | m = getoptions(options,'m',size(P,2)); 6 | or_size = size(P); 7 | linear = getoptions(options,'linear',0); 8 | if not(linear) 9 | centers = zeros(2,m); 10 | if size(P,3) ==1 11 | P = reshape(P, [w w m]); 12 | end 13 | Q = zeros(size(P)); 14 | for k = 1:m 15 | patch = P(:,:,k); 16 | center_pos = options.center_pos(:,k); 17 | [~,max_pos] = max(patch(:)); 18 | [x,y] = ind2sub([w w],max_pos); 19 | centers(:,k) = [x,y]; 20 | dx = center_pos - x; 21 | dy = center_pos - y; 22 | if dx==1 23 | x0 = w; 24 | else 25 | x0 = mod(1-dx,w); 26 | end 27 | if dy ==1 28 | y0 = w; 29 | else 30 | y0 = mod(1-dy,w); 31 | end 32 | tx = [x0:w,1:x0-1]; 33 | ty = [y0:w,1:y0-1]; 34 | 35 | patch = patch(tx,:); 36 | patch = patch(:,ty); 37 | Q(:,:,k) = patch; 38 | end 39 | Q = reshape(Q,[or_size]); 40 | else 41 | centers = zeros(1,m); 42 | if size(P,2)>1 43 | P = reshape(P,[w*w,m]); 44 | end 45 | Q = zeros(size(P)); 46 | for k = 1:m 47 | center_pos = options.center_pos(k); 48 | inv = 0; 49 | patch = P(:,k); 50 | [~,max_pos] = max(patch); 51 | centers(k) = max_pos; 52 | dpos = center_pos - max_pos; 53 | if dpos>0 54 | patch = patch(end:-1:1); 55 | inv = 1; 56 | dpos = -dpos; 57 | end 58 | if dpos<0 59 | patch2 = [patch(1-dpos:end);patch(1:-dpos)]; 60 | if inv 61 | patch2 = patch2(end:-1:1); 62 | end 63 | else 64 | patch2 = patch; 65 | end 66 | Q(:,k) = patch2; 67 | end 68 | Q = reshape(Q,or_size); 69 | end -------------------------------------------------------------------------------- /Dictionary_learning/patch_decenter.m: -------------------------------------------------------------------------------- 1 | function[P] = patch_decenter(Q,options) 2 | or_size = size(Q); 3 | options.null = 0; 4 | w = getoptions(options,'w',sqrt(size(Q,1))); 5 | m = getoptions(options,'m',size(Q,2)); 6 | center_pos = getoptions(options,'center_pos',ceil(w^2/2)); 7 | linear = getoptions(options,'linear',0); 8 | 9 | if not(linear) 10 | cx = options.orig(1,:); 11 | cy = options.orig(2,:); 12 | if (size(Q,3) ==1) 13 | Q = reshape(Q, [w w m]); 14 | end 15 | P = zeros(w,w,m); 16 | for k = 1:m 17 | patch = Q(:,:,k); 18 | % [~,max_pos] = max(patch(:)); 19 | % [x,y] = ind2sub([w w],max_pos); 20 | dx = (center_pos(1,k) - cx); 21 | dy = (center_pos(2,k) - cy); 22 | if dx==1 23 | x0 = w; 24 | else 25 | x0 = mod(1-dx,w); 26 | end 27 | if dy ==1 28 | y0 = w; 29 | else 30 | y0 = mod(1-dy,w); 31 | end 32 | tx = [x0:w,1:x0-1]; 33 | ty = [y0:w,1:y0-1]; 34 | 35 | patch2 = patch(:,ty(end:-1:1)); 36 | patch2 = patch2(tx(end:-1:1),:); 37 | patch2(:) = patch2(end:-1:1); 38 | P(:,:,k) = patch2; 39 | end 40 | P = reshape(P,or_size); 41 | else 42 | if size(Q,3)>1 43 | Q = reshape(Q,[w^2,m]); 44 | end 45 | P = zeros(size(Q)); 46 | for k = 1:m 47 | inv = 0; 48 | patch = Q(:,k); 49 | center = centers(k); 50 | dpos = center_pos - center; 51 | if dpos>0 52 | patch = patch(end:-1:1); 53 | inv = 1; 54 | dpos = -dpos; 55 | end 56 | if dpos<0 57 | patch2 = [patch(1+-dpos:end);patch(1:-dpos)]; 58 | if inv 59 | patch2 = patch2(end:-1:1); 60 | end 61 | else 62 | patch2 = patch; 63 | end 64 | P(:,k) = patch2; 65 | end 66 | P = reshape(P,or_size); 67 | end -------------------------------------------------------------------------------- /Dictionary_learning/shot9a.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/Dictionary_learning/shot9a.mat -------------------------------------------------------------------------------- /Dictionary_learning/test.asv: -------------------------------------------------------------------------------- 1 | clf reset 2 | clc 3 | clear all; 4 | close all; 5 | echo off 6 | options.sparse_coding = 'omp_err'; 7 | options.manual=1; 8 | %options.dico_sigm = sigma; 9 | options.centerize = 0; 10 | options.centerize_den = 0; 11 | options.q=1; 12 | options.linearis=0 13 | %options.w=8;%defaul 9 14 | 15 | load X_elf3D; 16 | M0=X_elf3D(1:256,1:256); clear X_elf3D; 17 | %load X1 18 | %M0=X1(101:356,101:356); 19 | %M0=M0/max(M0(:)); 20 | %level=0.2; 21 | %noisy3=level*randn(size(M0)); 22 | %save noisy3.mat noisy3 23 | load noisy2 24 | M= M0 + noisy2; 25 | %options.sigm2=MAD(M(:)); 26 | SNR_noisy=SNR(M,M0) 27 | figure, imagesc(M0), colormap(gray); 28 | figure, imagesc(M), colormap(gray); 29 | 30 | %tic 31 | %u_new=nonlocalTV(M); 32 | %tic 33 | %SNR_NTV=SNR(u_new,M0) 34 | %figure, imagesc(u_new), colormap(gray); 35 | 36 | 37 | %dt=0.0028;time=30;%0.0004 38 | %tic 39 | %atv_M = atv(M,dt,time); 40 | %toc 41 | %figure, imagesc(atv_M), colormap(gray); 42 | %SNR_atv=SNR(atv_M,M0) 43 | 44 | 45 | %[C,Ct]=curveletTh(M,0.14);%0.035 for level 0.05; 0.055 for 0.08 46 | %figure, imagesc(C), colormap(gray); 47 | %SNR_curvelet=SNR(C,M0) 48 | 49 | 50 | %W=waveletTh2(M,0.14);%matlab toolbox 51 | %figure, imagesc(W), colormap(gray); 52 | %SNR_wavelet=SNR(W,M0) 53 | 54 | %[Yw,C1]=waveletTh(X1,cutoff) 55 | 56 | for i=1:1 57 | tic 58 | [D1,X] = perform_dictionary_learning(M,options); 59 | %load D1; 60 | %figure, imagesc(D1), colormap(gray); 61 | 62 | M = perform_dictionary_denoising(M0,D1,options); 63 | toc 64 | figure, imagesc(M), colormap(gray); 65 | SNR_denoised=SNR(M,M0) 66 | %%%%%%%%%%%%%%%%%%%%%%%% 67 | [n1,n2]=size(D1) 68 | H0=zeros(3,12); 69 | L0=zeros(9,3); 70 | B=[]; 71 | k=0; 72 | for j=1:10:160 73 | k=k+1; 74 | A=reshape(D1(:,j),sqrt(n1),sqrt(n1));A=[A,L0];A=[A;H0]; 75 | B=[B,A]; 76 | end 77 | C=[B(:,1:48);B(:,49:96);B(:,97:144);B(:,145:192)]; 78 | figure, imagesc(C(1:45,1:45)), colormap(gray); 79 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 80 | [n1,n2]=size(D1) 81 | H0=zeros(3,12); 82 | L0=zeros(9,3); 83 | B=[]; 84 | k=0; 85 | for j=1:6:150 86 | k=k+1; 87 | A=reshape(D1(:,j),sqrt(n1),sqrt(n1));A=[A,L0];A=[A;H0]; 88 | B=[B,A]; 89 | end 90 | C=[B(:,1:60);B(:,61:120);B(:,121:180);B(:,181:240);B(:,241:300)]; 91 | figure, imagesc(C(1:57,1:57)), colormap(gray); 92 | end -------------------------------------------------------------------------------- /EMPCR_mathgeo/Antiaverage.m: -------------------------------------------------------------------------------- 1 | function A= Antiaverage(Q,I,J) 2 | j=J;Num=0;Sum=0;i=I; 3 | N=size(Q); 4 | while i>=1&&j<=N(2) 5 | Sum=Sum+Q(i,j); 6 | Num=Num+1; 7 | i=i-1;j=j+1; 8 | end 9 | A=Sum/Num; 10 | end 11 | 12 | -------------------------------------------------------------------------------- /EMPCR_mathgeo/Antiaverage_B.m: -------------------------------------------------------------------------------- 1 | function A= Antiaverage_B( Q,I,J ,ny) 2 | i=I;j=J;Num=0;Sum=zeros(ny/2,ny/2+1); 3 | N=size(Q); 4 | N=[N(1)/(ny/2),N(2)/(ny/2+1)]; 5 | while i>=1 && j<=N(2) 6 | Sum=Sum+Q((i-1)*(ny/2)+1:i*(ny/2),(j-1)*(ny/2+1)+1:j*(ny/2+1)); 7 | Num=Num+1; 8 | i=i-1;j=j+1; 9 | end 10 | A=Sum/Num; 11 | end 12 | 13 | -------------------------------------------------------------------------------- /EMPCR_mathgeo/Antiaverage_B_end.m: -------------------------------------------------------------------------------- 1 | function Anti_B= Antiaverage_B_end(Q,ny ) 2 | F=size(Q);F=[F(1)/(ny/2),F(2)/(ny/2+1)]; 3 | Anti_B=[]; 4 | for i=1:F(1) 5 | A=Antiaverage_B(Q,i,1,ny); 6 | B=Antiaverage_end(A); 7 | Anti_B=[Anti_B;B]; 8 | end 9 | for j=2:F(2) 10 | C=Antiaverage_B(Q,F(1),j,ny); 11 | D=Antiaverage_end(C); 12 | Anti_B=[Anti_B;D]; 13 | end 14 | Anti_B; 15 | end 16 | 17 | -------------------------------------------------------------------------------- /EMPCR_mathgeo/Antiaverage_end.m: -------------------------------------------------------------------------------- 1 | function de= Antiaverage_end(Z) 2 | F=size(Z);de=[]; 3 | for i=1:F(1) 4 | A=Antiaverage(Z,i,1); 5 | de=[de A]; 6 | end 7 | for j=2:F(2) 8 | A=Antiaverage(Z,F(1),j); 9 | de=[de A]; 10 | end 11 | end 12 | 13 | -------------------------------------------------------------------------------- /EMPCR_mathgeo/E_3D.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/EMPCR_mathgeo/E_3D.mat -------------------------------------------------------------------------------- /EMPCR_mathgeo/Example_EMPCR.m: -------------------------------------------------------------------------------- 1 | %% Reference: 2 | %Authors: Yongna Jia; Siwei Yu; Lina Liu; Jianwei Ma. 3 | %A fast rank reduction algorithm for three-dimensional seismic data interpolation. 4 | % Journal of applied geophysics, 2016, 132: 137-145. 5 | %% Code author: Yongna Jia 6 | 7 | %% Acknowledge the following authors and their code (function: EOR1MP) 8 | %Wang Z, Lai M J, Lu Z, et al. Orthogonal rank-one matrix pursuit for low rank matrix completion[J]. 9 | %SIAM Journal on Scientific Computing, 2015, 37(1): A488-A514. 10 | 11 | 12 | 13 | %% The code is used as a fast algorithm for 3D seismic data interpolation based on Hankel matrix. 14 | 15 | 16 | %%data: X_3D; sample_matrix:E_3D; 17 | 18 | warning off; 19 | clear;clc;close all; 20 | load X_3D; load E_3D; rank=3; 21 | [nt,nx ,ny]=size(X_3D);U=find(E_3D); 22 | M_3D=X_3D.*E_3D; 23 | M_f_3D=fft(M_3D);M_f=zeros(nt,nx,ny); 24 | for i=1:nt 25 | i; 26 | %%recovery the real data values and the imaginary values 27 | [Known1,S_r_real]=recover_real_3D(M_f_3D(i,:,:),ny,rank); 28 | [Known2,S_r_imag]=recover_imag_3D(M_f_3D(i,:,:),ny,rank); 29 | %% 30 | if sum(Known1)==0 31 | S_r_real=zeros(nx,ny); 32 | else 33 | end 34 | if sum(Known2)==0 35 | S_r_imag=zeros(nx,ny); 36 | else 37 | end 38 | %% 39 | S_r=S_r_real+S_r_imag*1i; 40 | M_f(i,:,:)=S_r; 41 | end 42 | M_r=real(ifft(M_f)); 43 | M_r(U)=X_3D(U); 44 | snr=SNR(M_r(:),X_3D(:)); 45 | 46 | 47 | -------------------------------------------------------------------------------- /EMPCR_mathgeo/Hankel_2D.m: -------------------------------------------------------------------------------- 1 | function M = Hankel_2D( df1,r ) 2 | N=size(df1); 3 | n=N(2); 4 | C=df1(1:r); 5 | R=df1(r:n); 6 | M=hankel(C,R); 7 | end 8 | 9 | -------------------------------------------------------------------------------- /EMPCR_mathgeo/Hankel_3D.m: -------------------------------------------------------------------------------- 1 | function M_H_nx= Hankel_3D( A ) 2 | A=squeeze( A); 3 | % figure;colormap(gray);imagesc(A); 4 | [nx,ny]=size(A); 5 | r=ny/2; 6 | M_H_ny=[]; 7 | for i=1:nx 8 | M_ny=Hankel_2D(A(i,:),r); 9 | M_H_ny=[ M_H_ny,M_ny]; 10 | end 11 | M_H_nx=zeros(nx/2*ny/2,(nx/2+1)*(ny/2+1)); 12 | for k=1:nx/2 13 | M_H_nx(((k-1)*ny/2+1):k*ny/2,:)=M_H_ny(:,(ny/2+1)*(k-1)+1:(ny/2+1)*(k+nx/2)); 14 | end 15 | % figure;colormap(gray);imagesc(M_H_nx); 16 | end 17 | 18 | -------------------------------------------------------------------------------- /EMPCR_mathgeo/SNR.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/EMPCR_mathgeo/SNR.m -------------------------------------------------------------------------------- /EMPCR_mathgeo/X_3D.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/EMPCR_mathgeo/X_3D.mat -------------------------------------------------------------------------------- /EMPCR_mathgeo/readme.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/EMPCR_mathgeo/readme.m -------------------------------------------------------------------------------- /EMPCR_mathgeo/recover_imag_3D.m: -------------------------------------------------------------------------------- 1 | function [Known,S_r_imag] = recover_imag_3D( A,ny,rank) 2 | A=imag(A); 3 | M_n=Hankel_3D(A); 4 | [m,n]=size(M_n); 5 | Known = find(M_n); 6 | 7 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%EOR1MP 8 | [~,~,data]=find(M_n); 9 | 10 | [U, Theta, V,~,~] = EOR1MP(m, n, rank, Known, data); 11 | M_r=U*diag(Theta)*V'; 12 | M_r(Known)=M_n(Known); 13 | S_r_imag=Antiaverage_B_end(M_r,ny); 14 | end 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /EMPCR_mathgeo/recover_real_3D.m: -------------------------------------------------------------------------------- 1 | function [Known, S_r_real] = recover_real_3D( A,ny,rank) 2 | A=real(A); 3 | M_n=Hankel_3D(A); 4 | [m,n]=size(M_n); 5 | Known = find(M_n); 6 | 7 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%EOR1MP 8 | [~,~,data]=find(M_n); 9 | 10 | [U, Theta, V,~,~] = EOR1MP(m, n, rank, Known, data); 11 | M_r=U*diag(Theta)*V'; 12 | M_r(Known)=M_n(Known); 13 | S_r_real=Antiaverage_B_end(M_r,ny); 14 | end 15 | 16 | 17 | -------------------------------------------------------------------------------- /EMPCR_mathgeo/sparse_inp.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/EMPCR_mathgeo/sparse_inp.mexglx -------------------------------------------------------------------------------- /EMPCR_mathgeo/sparse_inp.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/EMPCR_mathgeo/sparse_inp.mexmaci64 -------------------------------------------------------------------------------- /EMPCR_mathgeo/sparse_inp.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/EMPCR_mathgeo/sparse_inp.mexw32 -------------------------------------------------------------------------------- /EMPCR_mathgeo/sparse_inp.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/EMPCR_mathgeo/sparse_inp.mexw64 -------------------------------------------------------------------------------- /EMPCR_mathgeo/sparse_update.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/EMPCR_mathgeo/sparse_update.mexglx -------------------------------------------------------------------------------- /EMPCR_mathgeo/sparse_update.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/EMPCR_mathgeo/sparse_update.mexmaci64 -------------------------------------------------------------------------------- /EMPCR_mathgeo/sparse_update.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/EMPCR_mathgeo/sparse_update.mexw32 -------------------------------------------------------------------------------- /EMPCR_mathgeo/sparse_update.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/EMPCR_mathgeo/sparse_update.mexw64 -------------------------------------------------------------------------------- /GMD/core/GMD.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/GMD/core/GMD.m -------------------------------------------------------------------------------- /GMD/core/HRMD.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/GMD/core/HRMD.m -------------------------------------------------------------------------------- /GMD/core/HRMD1D.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/GMD/core/HRMD1D.m -------------------------------------------------------------------------------- /GMD/data/gom_cdp_nmo.su: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/GMD/data/gom_cdp_nmo.su -------------------------------------------------------------------------------- /GMD/data/line3.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/GMD/data/line3.mat -------------------------------------------------------------------------------- /GMD/data/para.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/GMD/data/para.mat -------------------------------------------------------------------------------- /GMD/paper_examples/fig05_VMD_2D_test_seis.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/GMD/paper_examples/fig05_VMD_2D_test_seis.m -------------------------------------------------------------------------------- /GMD/paper_examples/fig06_VMD_2D_test_convergency_seis.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/GMD/paper_examples/fig06_VMD_2D_test_convergency_seis.m -------------------------------------------------------------------------------- /GMD/paper_examples/fig07_RMD_para.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/GMD/paper_examples/fig07_RMD_para.m -------------------------------------------------------------------------------- /GMD/paper_examples/fig09_RMD_para1d.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/GMD/paper_examples/fig09_RMD_para1d.m -------------------------------------------------------------------------------- /GMD/paper_examples/fig10_VMD_2D_test_denoise.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/GMD/paper_examples/fig10_VMD_2D_test_denoise.m -------------------------------------------------------------------------------- /GMD/paper_examples/fig11_RMD_para_inter.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/GMD/paper_examples/fig11_RMD_para_inter.m -------------------------------------------------------------------------------- /GMD/paper_examples/fig14_RMD_para1d_multiple.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/GMD/paper_examples/fig14_RMD_para1d_multiple.m -------------------------------------------------------------------------------- /GMD/setup.m: -------------------------------------------------------------------------------- 1 | addpath(genpath('./')) 2 | 3 | if ~exist('readsegy','file') 4 | disp('download Seismiclab'); 5 | untar('http://seismic-lab.physics.ualberta.ca/SeismicLab.tar.gz','.'); 6 | disp('include Seismiclab'); 7 | addpath(genpath('SeismicLab')); 8 | end -------------------------------------------------------------------------------- /GMD/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/GMD/test.png -------------------------------------------------------------------------------- /GMD/util/fun_mpfi.m: -------------------------------------------------------------------------------- 1 | function w= fun_mpfi(dd,K) 2 | w = zeros(1,K); 3 | for t=1:K 4 | 5 | ddf = fftshift(fft(dd)); 6 | [y,ind]=max(abs(ddf)); 7 | tmp = ddf*0; 8 | tmp(ind) = ddf(ind); 9 | ddr = ifft(fftshift(tmp)); 10 | dd = dd-ddr; 11 | w(t) = ind; 12 | end 13 | 14 | w = sort(w); 15 | 16 | end 17 | -------------------------------------------------------------------------------- /GMD/util/ipradon.m: -------------------------------------------------------------------------------- 1 | function [d]=ipradon(m,h,p,N) 2 | %FORWARD_RADON_FREQ: Forward linear and parabolic Radon transform. 3 | % Freq. domain algorithm 4 | % 5 | % [d] = forward_radon_freq(m,dt,h,p,N,flow,fhigh); 6 | % 7 | % IN m: the Radon panel, a matrix m(nt,np) 8 | % dt: sampling in sec 9 | % h(nh): offset or position of traces in mts 10 | % p(np): ray parameter to retrieve if N=1 11 | % curvature of the parabola if N=2 12 | % N: N=1 linear tau-p 13 | % N=2 parabolic tau-p 14 | % flow: min freq. in Hz 15 | % fhigh: max freq. in Hz 16 | % 17 | % OUT d: data 18 | 19 | dt = 0.004; 20 | 21 | flow = 1; 22 | fhigh = 100; 23 | 24 | % Reference: Hampson, D., 1986, Inverse velocity stacking for multiple elimination, 25 | % Journal of the CSEG, vol 22, no 1., 44-55. 26 | % 27 | % 28 | % Copyright (C) 2008, Signal Analysis and Imaging Group 29 | % For more information: http://www-geo.phys.ualberta.ca/saig/SeismicLab 30 | % Author: M.D.Sacchi 31 | % 32 | % This program is free software: you can redistribute it and/or modify 33 | % it under the terms of the GNU General Public License as published 34 | % by the Free Software Foundation, either version 3 of the License, or 35 | % any later version. 36 | % 37 | % This program is distributed in the hope that it will be useful, 38 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 39 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 40 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 41 | % 42 | 43 | 44 | [nt,nq] = size(m); 45 | nh = length(h); 46 | 47 | if N==2; 48 | h=(h/max(abs(h))).^2; 49 | end; 50 | 51 | nfft = 2*(2^nextpow2(nt)); 52 | 53 | M = fft(m,nfft,1); 54 | D = zeros(nfft,nh); 55 | i = sqrt(-1); 56 | 57 | ilow = floor(flow*dt*nfft)+1; 58 | if ilow < 1; ilow=1; end; 59 | ihigh = floor(fhigh*dt*nfft)+1; 60 | if ihigh > floor(nfft/2)+1; ihigh = floor(nfft/2)+1; end 61 | 62 | for ifreq=ilow:ihigh 63 | f = 2.*pi*(ifreq-1)/nfft/dt; 64 | L = exp(i*f*(h'*p )); 65 | x = M(ifreq,:)'; 66 | y = L * x; 67 | D(ifreq,:) = y'; 68 | D(nfft+2-ifreq,:) = conj(y)'; 69 | end 70 | 71 | D(nfft/2+1,:) = zeros(1,nh); 72 | d = real(ifft(D,[],1)); 73 | d = d(1:nt,:); 74 | 75 | return; 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /GVRO/SOR_single_sor.m: -------------------------------------------------------------------------------- 1 | function [ out] = SOR_single_sor( data, Gx, Gt ,pinv_A,lambda,max_iter) 2 | %MDCA : Multi Directional component analysis 3 | % min (mu/2) || data - d1||_2 + lambda||G(d1)-p*q||^2 4 | % 5 | 6 | % 7 | % Input: data - the observed vectorized noisy image 8 | % inv_mat - to speed up the calculation, we store 9 | % precalculated inverse matrices 10 | % m,n - size of data 11 | % Gx,Gt - precalculated differential matrices 12 | % max_iter - max iteration numbers 13 | % ** default values of opts are given in { }. 14 | % 15 | % Output: d1,d2 - output components data 16 | % p1,p2 - dips 17 | % data=patches(:,100); 18 | % energy(energy<0.7*mean(energy))=0; 19 | alf=1.5; 20 | % d1=randn(size(data)); 21 | d1=data;%d2=d1; 22 | % p1=0; alf = 0.5; increment = 1; 23 | % Z=[ones(size(Gx*data)) zeros(size(Gx*data))]';[r,c]=size(Z);datanrm = max(1,norm(data)); 24 | % X = zeros(r,1); Y = eye(1,c); Res = data; res = datanrm; 25 | Z=[Gx*d1 Gt*d1]';[X,Y,~] = qr(Z,0);X=X(:,1);Y=Y(1,:); 26 | for iter = 1:max_iter 27 | Z=[Gx*d1 Gt*d1]'; 28 | X0 = X; Y0 = Y; d0=d1; 29 | % 30 | % Zo = Z; 31 | X = Z*Y';% X=alf*Xo+(1-alf)*X; 32 | 33 | % if est_rank == 1 34 | % [X,~,~] = qr(X,0); Y = X'*Z; %Y=alf*Yo+(1-alf)*Y; 35 | X = X/sqrt(X'*X); 36 | X=alf*X+(1-alf)*X0; 37 | 38 | Y = X'*Z; 39 | Y=alf*Y+(1-alf)*Y0; 40 | 41 | d1=pinv_A*[lambda*X(1)*Y';lambda*X(2)*Y';data]; 42 | d1=alf*d1+(1-alf)*d0; 43 | 44 | end %iter 45 | 46 | % out11=reshape(d1,m,n); 47 | % out110=out11(1:end-1,1:end-1); 48 | % out110=out110(:); 49 | % % out110=out110-mean(out110);out120=out120-mean(out120); 50 | % out110=(d1-mean(out110))/sqrt((out110-mean(out110))'*(out110-mean(out110))); 51 | % 52 | % G11x=Gx*out110;G11t=Gt*out110; 53 | % tv1=G11x'*G11x+G11t'*G11t; 54 | d11=d1/(d1'*d1); 55 | tv=(Gx*d11)'*(Gx*d11)+ (Gt*d11)'*(Gt*d11); 56 | energy=d1'*d1; 57 | out=[d1;tv/energy;X(1)/X(2)]; 58 | % figure;imagesc([reshape(d1,m,n);reshape(d2,m,n);reshape(data,m,n )]);axis image; 59 | end 60 | 61 | -------------------------------------------------------------------------------- /GVRO/get_Gradientmatrix_backward.m: -------------------------------------------------------------------------------- 1 | function [ Gx, Gt ] = get_Gradientmatrix_backward( m,n ); 2 | %GET_GRADIENTMATRIX : calculate matrix G_1/2*X=gradient with respect to x/y 3 | %dimension(not include the last row and last column) 4 | % ttt=10; 5 | % data1=get_data('noiz.rsf'); 6 | % data1=data1(ttt+[1:10],1:25);figure;imagesc(data1);axis image 7 | % 8 | % gradient_vec1=[vec(data1(2:end,1:end-1)-data1(1:end-1,1:end-1)) ... 9 | % vec(data1(1:end-1,2:end)-data1(1:end-1,1:end-1))]'; 10 | % figure(1);plot(gradient_vec1(1,:),gradient_vec1(2,:),'r*') 11 | % figure;plot(gradient_vec1(1,:)./gradient_vec1(2,:),'r*') 12 | % data1=rand([m, n]) 13 | % data1_vec=vec(data1); 14 | % [m n]=size(data1); 15 | Gx=zeros((m-2)*(n-2),m*n); 16 | for i=2:(m-1) 17 | for j=2:(n-1) 18 | gx=zeros(m,n); 19 | gx(i,j)=1; 20 | gx(i,j-1)=-1; 21 | Gx((i-1)+(j-2)*(m-2),:)=gx(:)'; 22 | end 23 | end 24 | %figure;imagesc(Gx) 25 | 26 | % tt=-data1(2:end-1,1:end-2)+data1(2:end-1,2:end-1);figure;imagesc(tt) 27 | % plot(Gx*data1_vec-vec(tt)); 28 | Gt=zeros((m-2)*(n-2),m*n); 29 | for i=2:(m-1) 30 | for j=2:(n-1) 31 | gt=zeros(m,n); 32 | gt(i,j)=1; 33 | gt(i-1,j)=-1; 34 | Gt((i-1)+(j-2)*(m-2),:)=gt(:)'; 35 | end 36 | end 37 | %figure;imagesc(Gt) 38 | 39 | % tt=imfilter(data1,y_mask,'replicate');figure;imagesc(tt) 40 | % plot(Gt*data1_vec-vec(tt(2:end-1,2:end-1))); 41 | 42 | end 43 | 44 | -------------------------------------------------------------------------------- /GVRO/get_Gradientmatrix_backward_3point.m: -------------------------------------------------------------------------------- 1 | function [ Gx, Gt ] = get_Gradientmatrix_backward_3point( m,n ); 2 | %GET_GRADIENTMATRIX : calculate matrix G_1/2*X=gradient with respect to x/y 3 | %dimension(not include the last row and last column) 4 | % ttt=10; 5 | % data1=get_data('noiz.rsf'); 6 | % data1=data1(ttt+[1:10],1:25);figure;imagesc(data1);axis image 7 | % 8 | % gradient_vec1=[vec(data1(2:end,1:end-1)-data1(1:end-1,1:end-1)) ... 9 | % vec(data1(1:end-1,2:end)-data1(1:end-1,1:end-1))]'; 10 | % figure(1);plot(gradient_vec1(1,:),gradient_vec1(2,:),'r*') 11 | % figure;plot(gradient_vec1(1,:)./gradient_vec1(2,:),'r*') 12 | % data1=rand([m, n]) 13 | % data1_vec=vec(data1); 14 | % [m n]=size(data1); 15 | Gx=zeros((m-2)*(n-2),m*n); 16 | for j=2:(m-1) 17 | for i=2:(n-1) 18 | gx=zeros(m,n); 19 | gx(i-1,j)=0.25;gx(i,j)=0.5;gx(i+1,j)=0.25; 20 | gx(i-1,j-1)=-0.250;gx(i,j-1)=-0.5;gx(i+1,j-1)=-0.250;%figure;imagesc(gx) 21 | Gx((i-1)+(j-2)*(m-2),:)=gx(:)'; 22 | 23 | end 24 | end 25 | %figure;imagesc(Gx) 26 | 27 | % tt=imfilter(data1,x_mask,'replicate');figure;imagesc(tt) 28 | % plot(Gx*data1_vec-vec(tt(2:end-1,2:end-1))); 29 | Gt=zeros((m-2)*(n-2),m*n); 30 | for j=2:(m-1) 31 | for i=2:(n-1) 32 | gt=zeros(m,n); 33 | gt(i,j-1)=0.250;gt(i,j)=0.5;gt(i,j+1)=0.250; 34 | gt(i-1,j-1)=-0.250;gt(i-1,j)=-0.5;gt(i-1,j+1)=-0.250;%figure;imagesc(gx) 35 | Gt((i-1)+(j-2)*(m-2),:)=gt(:)'; 36 | 37 | end 38 | end 39 | %figure;imagesc(Gt) 40 | 41 | % tt=imfilter(data1,y_mask,'replicate');figure;imagesc(tt) 42 | % plot(Gt*data1_vec-vec(tt(2:end-1,2:end-1))); 43 | 44 | end 45 | 46 | -------------------------------------------------------------------------------- /GVRO/get_Gradientmatrix_center.m: -------------------------------------------------------------------------------- 1 | function [ Gx, Gy ] = get_Gradientmatrix_center( m,n ); 2 | %GET_GRADIENTMATRIX : calculate matrix G_1/2*X=gradient with respect to x/y 3 | %dimension(not include the last row and last column) 4 | % ttt=10; 5 | % data1=get_data('noiz.rsf'); 6 | % data1=data1(ttt+[1:10],1:25);figure;imagesc(data1);axis image 7 | % 8 | % gradient_vec1=[vec(data1(2:end,1:end-1)-data1(1:end-1,1:end-1)) ... 9 | % vec(data1(1:end-1,2:end)-data1(1:end-1,1:end-1))]'; 10 | % figure(1);plot(gradient_vec1(1,:),gradient_vec1(2,:),'r*') 11 | % figure;plot(gradient_vec1(1,:)./gradient_vec1(2,:),'r*') 12 | % data1=rand([m, n]) 13 | % data1_vec=vec(data1); 14 | % [m n]=size(data1); 15 | 16 | Gx=-diag(ones(m*n,1))+diag(ones(m*n-2*m,1),2*m); 17 | Gx(end-2*m+1:end,:)=[]; 18 | index=[1 m]; 19 | for i=1:n-3 20 | index=[index [1 m]+i*m]; 21 | end 22 | Gx(index,:)=[]; 23 | 24 | % plot(Gx*data1_vec-vec(data1(2:end-1,3:end)-data1(2:end-1,1:end-2))); 25 | 26 | % Gy=-diag(ones(m*n,1))+diag(ones(m*n-1,1),+1); 27 | % Gy(end-m+1:end,:)=[]; 28 | % Gy(m*(1:n-1),:)=[]; 29 | Gy=-diag(ones(m*n,1))+diag(ones(m*n-2,1),+2); 30 | Gy(1:m,:)=[];Gy(end-m+1:end,:)=[]; 31 | index=[m-1 m]; 32 | for i=1:n-3 33 | index=[index [m-1 m]+i*m]; 34 | end 35 | Gy(index,:)=[]; 36 | % plot(Gy*data1_vec-vec(data1(3:end,2:end-1)-data1(1:end-2,2:end-1))); 37 | % plot((Gy-Gx)*data1_vec); 38 | %figure;imagesc([Gx]);figure;imagesc([Gy]) 39 | end 40 | 41 | -------------------------------------------------------------------------------- /GVRO/get_Gradientmatrix_forward.m: -------------------------------------------------------------------------------- 1 | function [ Gx, Gt ] = get_Gradientmatrix_forward( m,n ); 2 | %GET_GRADIENTMATRIX : calculate matrix G_1/2*X=gradient with respect to x/y 3 | %dimension(not include the last row and last column) 4 | % ttt=10; 5 | % data1=get_data('noiz.rsf'); 6 | % data1=data1(ttt+[1:10],1:25);figure;imagesc(data1);axis image 7 | % 8 | % gradient_vec1=[vec(data1(2:end,1:end-1)-data1(1:end-1,1:end-1)) ... 9 | % vec(data1(1:end-1,2:end)-data1(1:end-1,1:end-1))]'; 10 | % figure(1);plot(gradient_vec1(1,:),gradient_vec1(2,:),'r*') 11 | % figure;plot(gradient_vec1(1,:)./gradient_vec1(2,:),'r*') 12 | % data1=rand([m, n]) 13 | % data1_vec=vec(data1); 14 | % [m n]=size(data1); 15 | Gx=zeros((m-2)*(n-2),m*n); 16 | for i=2:(m-1) 17 | for j=2:(n-1) 18 | gx=zeros(m,n); 19 | gx(i,j)=1; 20 | gx(i,j+1)=-1; 21 | Gx((i-1)+(j-2)*(m-2),:)=gx(:)'; 22 | end 23 | end 24 | %figure;imagesc(Gx) 25 | 26 | % tt=imfilter(data1,x_mask,'replicate');figure;imagesc(tt) 27 | % plot(Gx*data1_vec-vec(tt(2:end-1,2:end-1))); 28 | Gt=zeros((m-2)*(n-2),m*n); 29 | for i=2:(m-1) 30 | for j=2:(n-1) 31 | gt=zeros(m,n); 32 | gt(i,j)=1; 33 | gt(i+1,j)=-1; 34 | Gt((i-1)+(j-2)*(m-2),:)=gt(:)'; 35 | end 36 | end 37 | %figure;imagesc(Gt) 38 | 39 | % tt=imfilter(data1,y_mask,'replicate');figure;imagesc(tt) 40 | % plot(Gt*data1_vec-vec(tt(2:end-1,2:end-1))); 41 | 42 | end 43 | 44 | -------------------------------------------------------------------------------- /GVRO/get_Gradientmatrix_forward_3point.m: -------------------------------------------------------------------------------- 1 | function [ Gx, Gt ] = get_Gradientmatrix_forward( m,n ); 2 | %GET_GRADIENTMATRIX : calculate matrix G_1/2*X=gradient with respect to x/y 3 | %dimension(not include the last row and last column) 4 | % ttt=10; 5 | % data1=get_data('noiz.rsf'); 6 | % data1=data1(ttt+[1:10],1:25);figure;imagesc(data1);axis image 7 | % 8 | % gradient_vec1=[vec(data1(2:end,1:end-1)-data1(1:end-1,1:end-1)) ... 9 | % vec(data1(1:end-1,2:end)-data1(1:end-1,1:end-1))]'; 10 | % figure(1);plot(gradient_vec1(1,:),gradient_vec1(2,:),'r*') 11 | % figure;plot(gradient_vec1(1,:)./gradient_vec1(2,:),'r*') 12 | % data1=rand([m, n]) 13 | % data1_vec=vec(data1); 14 | % [m n]=size(data1); 15 | Gx=zeros((m-2)*(n-2),m*n); 16 | for j=2:(m-1) 17 | for i=2:(n-1) 18 | gx=zeros(m,n); 19 | gx(i-1,j)=0.25;gx(i,j)=0.5;gx(i+1,j)=0.25; 20 | gx(i-1,j+1)=-0.250;gx(i,j+1)=-0.5;gx(i+1,j+1)=-0.250;%figure;imagesc(gx) 21 | Gx((i-1)+(j-2)*(m-2),:)=gx(:)'; 22 | 23 | end 24 | end 25 | %figure;imagesc(Gx) 26 | 27 | % tt=imfilter(data1,x_mask,'replicate');figure;imagesc(tt) 28 | % plot(Gx*data1_vec-vec(tt(2:end-1,2:end-1))); 29 | Gt=zeros((m-2)*(n-2),m*n); 30 | for j=2:(m-1) 31 | for i=2:(n-1) 32 | gt=zeros(m,n); 33 | gt(i,j-1)=0.250;gt(i,j)=0.5;gt(i,j+1)=0.250; 34 | gt(i+1,j-1)=-0.250;gt(i+1,j)=-0.5;gt(i+1,j+1)=-0.250;%figure;imagesc(gx) 35 | Gt((i-1)+(j-2)*(m-2),:)=gt(:)'; 36 | 37 | end 38 | end 39 | %figure;imagesc(Gt) 40 | 41 | % tt=imfilter(data1,y_mask,'replicate');figure;imagesc(tt) 42 | % plot(Gt*data1_vec-vec(tt(2:end-1,2:end-1))); 43 | 44 | end 45 | 46 | -------------------------------------------------------------------------------- /GVRO/get_Gradientmatrix_sobel.m: -------------------------------------------------------------------------------- 1 | function [ Gx, Gt ] = get_Gradientmatrix_sobel( m,n ); 2 | %GET_GRADIENTMATRIX : calculate matrix G_1/2*X=gradient with respect to x/y 3 | %dimension(not include the last row and last column) 4 | % ttt=10; 5 | % data1=get_data('noiz.rsf'); 6 | % data1=data1(ttt+[1:10],1:25);figure;imagesc(data1);axis image 7 | % 8 | % gradient_vec1=[vec(data1(2:end,1:end-1)-data1(1:end-1,1:end-1)) ... 9 | % vec(data1(1:end-1,2:end)-data1(1:end-1,1:end-1))]'; 10 | % figure(1);plot(gradient_vec1(1,:),gradient_vec1(2,:),'r*') 11 | % figure;plot(gradient_vec1(1,:)./gradient_vec1(2,:),'r*') 12 | % data1=rand([m, n]) 13 | % data1_vec=vec(data1); 14 | % [m n]=size(data1); 15 | Gx=zeros((m-2)*(n-2),m*n); 16 | for j=2:(m-1) 17 | for i=2:(n-1) 18 | gx=zeros(m,n); 19 | gx(i-1,j-1)=0.250;gx(i,j-1)=0.5;gx(i+1,j-1)=0.250; 20 | gx(i-1,j+1)=-0.250;gx(i,j+1)=-0.5;gx(i+1,j+1)=-0.250;%figure;imagesc(gx) 21 | Gx((i-1)+(j-2)*(m-2),:)=gx(:)'; 22 | 23 | end 24 | end 25 | %figure;imagesc(Gx) 26 | 27 | % tt=imfilter(data1,x_mask,'replicate');figure;imagesc(tt) 28 | % plot(Gx*data1_vec-vec(tt(2:end-1,2:end-1))); 29 | Gt=zeros((m-2)*(n-2),m*n); 30 | for j=2:(m-1) 31 | for i=2:(n-1) 32 | gt=zeros(m,n); 33 | gt(i-1,j-1)=0.250;gt(i-1,j)=0.5;gt(i-1,j+1)=0.250; 34 | gt(i+1,j-1)=-0.250;gt(i+1,j)=-0.5;gt(i+1,j+1)=-0.250;%figure;imagesc(gx) 35 | Gt((i-1)+(j-2)*(m-2),:)=gt(:)'; 36 | 37 | end 38 | end 39 | %figure;imagesc(Gt) 40 | 41 | % tt=imfilter(data1,y_mask,'replicate');figure;imagesc(tt) 42 | % plot(Gt*data1_vec-vec(tt(2:end-1,2:end-1))); 43 | 44 | end 45 | 46 | -------------------------------------------------------------------------------- /GVRO/get_patches.m: -------------------------------------------------------------------------------- 1 | function [ patches, r_sub,c_sub ] = get_patches( image, patch_size, overlap ) 2 | % "patches" is an output whose columns respond to patches with leftup point 3 | % index stored in "r_sub,c_sub" 4 | % overlap: in percent,default,50% 5 | if nargin ==1 6 | patch_size=[10,10]; overlap=[0.4,0.4]; 7 | end 8 | if nargin ==2 9 | overlap=[0.5,0.5]; 10 | end 11 | [m,n]=size(image); 12 | r_slide=round(patch_size(1)*(1-overlap(1)));%nonoverlap part 13 | c_slide=round(patch_size(2)*(1-overlap(2))); 14 | if r_slide==patch_size(1) 15 | r_slide=patch_size(1)-1; 16 | end 17 | if c_slide==patch_size(2) 18 | c_slide=patch_size(2)-1; 19 | end 20 | r_sub=1: r_slide:m;%the left up point's row subindex of each patch 21 | r_sub(find(r_sub>=m+1-patch_size(1)))=[]; 22 | r_sub=[r_sub m+1-patch_size(1)]; 23 | c_sub=1: c_slide:n; 24 | c_sub(find(c_sub>=n+1-patch_size(2)))=[]; 25 | c_sub=[c_sub n+1-patch_size(2)]; 26 | patches=zeros(patch_size(1)*patch_size(2),length(r_sub)*length(c_sub)); 27 | nr=length(r_sub); 28 | nc=length(c_sub); 29 | for j=1:nc 30 | for i=1:nr 31 | patches(:,nr*(j-1)+i)=reshape(image(r_sub(i):r_sub(i)+patch_size(1)-1,c_sub(j):c_sub(j)... 32 | +patch_size(2)-1),[patch_size(1)*patch_size(2),1]); 33 | end 34 | end 35 | end 36 | 37 | -------------------------------------------------------------------------------- /GVRO/get_patches_location.m: -------------------------------------------------------------------------------- 1 | function [ r_sub,c_sub ] = get_patches_location( image, patch_size, overlap ) 2 | % "patches" is an output whose columns respond to patches with leftup point 3 | % index stored in "r_sub,c_sub" 4 | % overlap: in percent,default,50% 5 | if nargin ==1 6 | patch_size=[10,10]; overlap=[0.4,0.4]; 7 | end 8 | if nargin ==2 9 | overlap=[0.5,0.5]; 10 | end 11 | [m,n]=size(image); 12 | r_slide=round(patch_size(1)*(1-overlap(1)));%nonoverlap part 13 | c_slide=round(patch_size(2)*(1-overlap(2))); 14 | if r_slide==patch_size(1) 15 | r_slide=patch_size(1)-1; 16 | end 17 | if c_slide==patch_size(2) 18 | c_slide=patch_size(2)-1; 19 | end 20 | r_sub=1: r_slide:m;%the left up point's row subindex of each patch 21 | r_sub(find(r_sub>=m+1-patch_size(1)))=[]; 22 | r_sub=[r_sub m+1-patch_size(1)]; 23 | c_sub=1: c_slide:n; 24 | c_sub(find(c_sub>=n+1-patch_size(2)))=[]; 25 | c_sub=[c_sub n+1-patch_size(2)]; 26 | 27 | end 28 | 29 | -------------------------------------------------------------------------------- /GVRO/get_patches_slides.m: -------------------------------------------------------------------------------- 1 | function [ patches, r_sub,c_sub ] = get_patches_slides( image, patch_size, r_slide,c_slide) 2 | % "patches" is an output whose columns respond to patches with leftup point 3 | % index stored in "r_sub,c_sub" 4 | % overlap: in percent,default,50% 5 | [m,n]=size(image); 6 | r_sub=1: r_slide:m;%the left up point's row subindex of each patch 7 | r_sub(find(r_sub>=m+1-patch_size(1)))=[]; 8 | r_sub=[r_sub m+1-patch_size(1)]; 9 | c_sub=1: c_slide:n; 10 | c_sub(find(c_sub>=n+1-patch_size(2)))=[]; 11 | c_sub=[c_sub n+1-patch_size(2)]; 12 | patches=zeros(patch_size(1)*patch_size(2),length(r_sub)*length(c_sub)); 13 | nr=length(r_sub); 14 | nc=length(c_sub); 15 | for j=1:nc 16 | for i=1:nr 17 | patches(:,nr*(j-1)+i)=reshape(image(r_sub(i):r_sub(i)+patch_size(1)-1,c_sub(j):c_sub(j)... 18 | +patch_size(2)-1),[patch_size(1)*patch_size(2),1]); 19 | end 20 | end 21 | end 22 | 23 | -------------------------------------------------------------------------------- /GVRO/sigmoid.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/GVRO/sigmoid.mat -------------------------------------------------------------------------------- /GVRO/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/GVRO/test.png -------------------------------------------------------------------------------- /GVRO/write_patches.m: -------------------------------------------------------------------------------- 1 | function [ image_resto ] = write_patches( patches, patch_size,r_sub,c_sub ) 2 | % "patches" is an input whose columns respond to patches with leftup point 3 | % index stored in "r_sub,c_sub" 4 | image_resto=zeros(r_sub(end)+patch_size(1)-1,c_sub(end)+patch_size(2)-1); 5 | D_resto=zeros(r_sub(end)+patch_size(1)-1,c_sub(end)+patch_size(2)-1); 6 | d=ones(size(patches,1),1); 7 | d=reshape(d,patch_size); 8 | d(:,end)=[];d(end,:)=[]; 9 | for j=1:length(c_sub) 10 | for i=1:length(r_sub) 11 | d1=reshape(patches(:,length(r_sub)*(j-1)+i),patch_size); 12 | d1(:,end)=[];d1(end,:)=[]; 13 | image_resto(r_sub(i):r_sub(i)+patch_size(1)-2,c_sub(j):c_sub(j)... 14 | +patch_size(2)-2)=image_resto(r_sub(i):r_sub(i)+patch_size(1)-2,c_sub(j):c_sub(j)... 15 | +patch_size(2)-2)+d1; 16 | D_resto(r_sub(i):r_sub(i)+patch_size(1)-2,c_sub(j):c_sub(j)... 17 | +patch_size(2)-2)=D_resto(r_sub(i):r_sub(i)+patch_size(1)-2,c_sub(j):c_sub(j)... 18 | +patch_size(2)-2)+d; 19 | end 20 | end 21 | image_resto=image_resto./(D_resto+eps); 22 | % figure;imagesc(D_resto) 23 | end 24 | 25 | -------------------------------------------------------------------------------- /GVRO/write_patches_center.m: -------------------------------------------------------------------------------- 1 | function [ image_resto ] = write_patches_center( patches, patch_size,r_sub,c_sub ) 2 | % "patches" is an input whose columns respond to patches with leftup point 3 | % index stored in "r_sub,c_sub" 4 | image_resto=zeros(r_sub(end)+patch_size(1)-1,c_sub(end)+patch_size(2)-1); 5 | D_resto=zeros(r_sub(end)+patch_size(1)-1,c_sub(end)+patch_size(2)-1); 6 | d=ones(size(patches,1),1); 7 | d=reshape(d,patch_size); 8 | d(:,end)=[];d(end,:)=[];d(:,1)=[];d(1,:)=[]; 9 | for j=1:length(c_sub) 10 | for i=1:length(r_sub) 11 | d1=reshape(patches(:,length(r_sub)*(j-1)+i),patch_size); 12 | d1(:,end)=[];d1(end,:)=[];d1(:,1)=[];d1(1,:)=[]; 13 | % norm_d1=1; 14 | norm_d1=(norm(d1)~=0); 15 | % pause 16 | image_resto(r_sub(i)+1:r_sub(i)+patch_size(1)-2,c_sub(j)+1:c_sub(j)... 17 | +patch_size(2)-2)=image_resto(r_sub(i)+1:r_sub(i)+patch_size(1)-2,c_sub(j)+1:c_sub(j)... 18 | +patch_size(2)-2)+norm_d1*d1; 19 | % D_resto(r_sub(i):r_sub(i)+patch_size(1)-2,c_sub(j):c_sub(j)... 20 | % +patch_size(2)-2)=D_resto(r_sub(i):r_sub(i)+patch_size(1)-2,c_sub(j):c_sub(j)... 21 | % +patch_size(2)-2)+d; 22 | D_resto(r_sub(i)+1:r_sub(i)+patch_size(1)-2,c_sub(j)+1:c_sub(j)... 23 | +patch_size(2)-2)=D_resto(r_sub(i)+1:r_sub(i)+patch_size(1)-2,c_sub(j)+1:c_sub(j)... 24 | +patch_size(2)-2)+norm_d1*d; 25 | end 26 | end 27 | image_resto=image_resto./(D_resto+eps); 28 | % figure;imagesc(D_resto) 29 | end 30 | 31 | -------------------------------------------------------------------------------- /LDMM/example_LDMM.m: -------------------------------------------------------------------------------- 1 | % Noise attenuation in a low dimensional manifold 2 | % Author: Siwei Yu 3 | % Reference: Yu S, et. al. Noise attenuation in a low dimensional 4 | % manifold, accepted by geophysics. 5 | % Email: jma@hit.edu.cn 6 | % March 22, 2017 7 | 8 | clear; 9 | load f.mat; 10 | 11 | [n1,n2] = size(f); 12 | 13 | r = 11; % patch size 14 | 15 | nt = 4; % iteration times 16 | 17 | % with the above paramter this function takes about 2min. 18 | result = fun_ldmm(f,nt,r); 19 | 20 | subplot(121);imagesc(f);colormap gray; 21 | subplot(122);imagesc(result);colormap gray; 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /LDMM/f.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/LDMM/f.mat -------------------------------------------------------------------------------- /LDMM/fun_ldmm.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/LDMM/fun_ldmm.p -------------------------------------------------------------------------------- /LDMM/gmresm.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/LDMM/gmresm.p -------------------------------------------------------------------------------- /LDMM/iterapp2.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/LDMM/iterapp2.p -------------------------------------------------------------------------------- /LDMM/iterchk2.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/LDMM/iterchk2.p -------------------------------------------------------------------------------- /LDMM/weight_ann.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/LDMM/weight_ann.p -------------------------------------------------------------------------------- /MCDDTF3D/codes/DisplayH3d_all.m: -------------------------------------------------------------------------------- 1 | function DisplayH3d_all(d0) 2 | 3 | %Display 3D dictionary 4 | 5 | n1 = size(d0,1); 6 | n2 = size(d0,2); 7 | n = round(n1^(1.0/3.0)); 8 | d0(n1,:)=d0(n1,:)*1.00001; 9 | newd = zeros(n+1,n+1,n+1); 10 | % tm =[1 2 5 17 6 18 21 22]; % 4 11 | % tm =[1 2 9 65 10 66 73 74]; % 8 12 | % tm =[1 2 3 4 5 6 7 8]; % 8 13 | % tm =[1 2 4 6 8 9 10 11 24 25 26 28 31 32 41 44] ;%8-di-elf 14 | tm =[1 2 3 4 6 8 9 12 20 21 22 27 32 54 56 58] ;%8-d-X 15 | % tm = [1 2 8 50 9 51 57 58]; % 7 16 | % tm = [1 2 4 5 8 10 11 18 19 23 24 25 26 30 31 32 33 52 53 54]; % 7-2 17 | tm = 1:64; 18 | for m = 1:1 19 | figure; 20 | for i=1:length(tm) 21 | 22 | subplot(8,8,i); 23 | newd = zeros(n+1,n+1,n+1); 24 | % DisplayH3d( reshape(d0(:,16/16*(i-1)+1),n,n,n)); 25 | % p = (m-1)*n*n+(i-1)+1; 26 | p = tm(i) ; 27 | newd(1:n,1:n,1:n) = reshape(d0(:,p),n,n,n); 28 | newd(:,:,n+1) = newd(:,:,n); 29 | newd(:,n+1,:) = newd(:,n,:); 30 | newd(n+1,:,:) = newd(n,:,:); 31 | slice(newd,[1,n+1],[1,n+1],[1,n+1]);%colormap gray; 32 | 33 | h=findobj(gca,'linestyle','-'); 34 | h(1)=h(2); 35 | set(h,'linestyle','none'); 36 | % if (i==1) 37 | % alpha(1); 38 | % else 39 | % alpha(0.7); 40 | % end 41 | 42 | axis equal; 43 | axis tight; 44 | 45 | xlabel('x'); 46 | ylabel('y'); 47 | zlabel('z'); 48 | axis off; 49 | grid off; 50 | end 51 | end 52 | 53 | 54 | 55 | end -------------------------------------------------------------------------------- /MCDDTF3D/codes/ddtfdenoise3d.m: -------------------------------------------------------------------------------- 1 | function out=ddtfdenoise3d(in,lam,thr) 2 | 3 | %denoise with ddtf 4 | %in: input data 5 | %lam: training paramter 6 | %thre: denoise parameter 7 | 8 | %out: denoised result 9 | 10 | lvl = 2;wname = 'db1'; 11 | [n1,n2,n3] = size(in); 12 | [d0,r] = gen_dic_by_iwt_3d(2^lvl,wname); % initial dictionary with inverse wavelet transform 13 | 14 | tic;d = train3d(d0,in,r,lam); 15 | 16 | g = pf3d(in,r); 17 | 18 | coef = d'*g; 19 | coef = coef.* (abs(coef)>thr); 20 | f = d*coef; 21 | 22 | out = pb3d(f,n1,n2,n3); 23 | 24 | end -------------------------------------------------------------------------------- /MCDDTF3D/codes/displayH.m: -------------------------------------------------------------------------------- 1 | function displayH(H) 2 | 3 | %display 2d dictionary 4 | 5 | %%% try 1 6 | % hsize = sqrt(size(H,1)); 7 | % 8 | % figure, set(gcf, 'units', 'normalized', 'position', [.1 .06 .8 .8]); 9 | % 10 | % for i = 1:hsize 11 | % for j = 0:hsize-1 12 | % 13 | % subplot(hsize,hsize, i+j*hsize), imagesc(reshape(H(:,i+j*hsize), hsize,hsize)), colormap(gray), axis('image'); 14 | % axis off; 15 | % 16 | % end 17 | % end 18 | 19 | %%% try 2 20 | hsize = sqrt(size(H,1)); 21 | m = hsize^2 + hsize + 1; 22 | 23 | M = -0.1*ones(m,m); 24 | 25 | for i = 1:hsize 26 | for j = 0:hsize-1 27 | 28 | idx = i + j*hsize; 29 | h = H(:, idx); 30 | if (min(h(:))-max(h(:)))==0 31 | h(:) = h(:)/max(h(:)); 32 | else 33 | h = h - min(h(:)); h = h/max(h(:)); 34 | end 35 | h = reshape(h, hsize,hsize); 36 | 37 | jj = i + (i-1)*hsize; 38 | ii = j+1 + j*hsize; 39 | 40 | M(ii+1:ii+hsize, jj+1:jj+hsize) = h; 41 | 42 | end 43 | end 44 | 45 | 46 | set(gcf, 'units', 'normalized', 'position', [.3 .2 .4 .6]); 47 | imagesc(M), colormap(gray), axis('image'), axis off; -------------------------------------------------------------------------------- /MCDDTF3D/codes/filter_learning_3D.m: -------------------------------------------------------------------------------- 1 | function [filter_bank] = filter_learning_3D(data, lambda, opts) 2 | 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | % Learning orthogonal filter bank from input 5 | % input: 6 | % data - data is a matrix with p predictors and n obervations 7 | % lambda - parameter for thresholding 8 | % (optional) 9 | % opts: 10 | % A - initialization for A, whose atoms are orthogonal with each other. 11 | % nIter - number of Iteration for learning, default value (=50) 12 | % 13 | % output: 14 | % filter_bank - output of data-driven filter bank 15 | % 16 | %Reference: Jian-feng Cai, H. Ji, Z. Shen and Guibo Ye, 17 | %Data-driven tight frame construction and image denoising , 18 | %Applied and Computational Harmonic Analysis, 37 (1), 89-105, Jul. 2014 19 | % 20 | %Author: Chenlong Bao, Yuhui Quan, Sibin Huang, and Hui Ji 21 | % 22 | %Last Revision: 25-May-2014 23 | % 24 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 25 | 26 | 27 | %% Exception Management 28 | 29 | if nargin < 2; error('No enough input!'); end 30 | %% default options 31 | if ~exist('opts','var') opts = struct; end 32 | if isfield(opts,'A') A = opts.A; else A = []; end 33 | if isfield(opts,'nIter') nIter = opts.nIter; else nIter = 50; end 34 | 35 | %% whether A is empty 36 | flag_A = isempty(A); 37 | 38 | %% Input and initialization 39 | data = double(data); % input data 40 | p = size(data, 1); % dimension of data 41 | if ~flag_A 42 | A = double(A); 43 | tmpMat = (eye(p) - A*A')*data; 44 | end 45 | % D = DctInit(round(p^(1/2))); 46 | [D,~] = gen_dic_by_iwt_3d(round(p^(1/3)),'haar'); 47 | if ~flag_A 48 | r = size(A, 2); 49 | rperm = randperm(p); 50 | D = D(:,rperm(1:p-r)); 51 | end 52 | D = double(D); % input dictionary D 53 | 54 | %% Learning loop 55 | iter = 0; 56 | while iter < nIter 57 | % Soft thresholding for solving L-0 minimization 58 | tmpCoef = wthresh(D'*data, 'h', lambda); 59 | % SVD for solving dictionary update 60 | if ~flag_A 61 | [U, S, V] = svd(tmpMat*tmpCoef',0); 62 | else 63 | 64 | [U, S, V] = svd(data*tmpCoef',0); 65 | end 66 | D = U*V'; 67 | % next loop 68 | iter = iter + 1; 69 | end 70 | 71 | %% Output 72 | filter_bank = [A, D]; %Dictionary -------------------------------------------------------------------------------- /MCDDTF3D/codes/gen_dic_by_iwt_3d.m: -------------------------------------------------------------------------------- 1 | function [out2,r]=gen_dic_by_iwt_3d(n,wname) 2 | %initial 3d dictionary by idwt 3 | 4 | %n: size of dictionary 5 | %wname: the dwt type used 6 | %output: 7 | %out2: initial dictionary 8 | %r: size of dictionary 9 | 10 | %All materials are copyrighted to HIT University, and are used for 11 | %academic research purpose only. Unauthorized redistribution of the 12 | %materials is prohibited. 13 | %Author: Siwei Yu 14 | %Date: Dec,10,2016 15 | r = n; 16 | f = zeros(n,n,n); 17 | l = round(log(n)/log(2)); 18 | c = wavedec3(f,l,wname); 19 | 20 | pos = [ 1 0 0; 21 | 0 1 0; 22 | 1 1 0; 23 | 0 0 1; 24 | 1 0 1; 25 | 0 1 1; 26 | 1 1 1;]; 27 | n2 = n*n; 28 | out = zeros(n2,n2,n2); 29 | out2 = zeros(n*n*n,n*n*n); 30 | t = 1; 31 | for m=1:l+1 32 | 33 | if (m==1) 34 | c.dec{1} = 0*c.dec{1}; 35 | c.dec{1} = 1; 36 | x = waverec3(c); 37 | c.dec{1} = 0*c.dec{1}; 38 | out(1:n,1:n,1:n) = x ; 39 | out2(:,1) = x(:); 40 | t=t+1; 41 | else 42 | 43 | for p=1:7 44 | q = (m-2)*7+p+1; 45 | ni = size(c.dec{q},1); 46 | nj = size(c.dec{q},2); 47 | nk = size(c.dec{q},3); 48 | i0 = 2^(m-2)*pos(p,1);j0 = 2^(m-2)*pos(p,2);k0 = 2^(m-2)*pos(p,3); 49 | for i=1:ni 50 | for j=1:nj 51 | for k=1:nk 52 | 53 | c.dec{q} = 0*c.dec{q}; 54 | c.dec{q}(i,j,k)=1; 55 | x = waverec3(c); 56 | c.dec{q} = 0*c.dec{q}; 57 | 58 | ib = (i0+i-1)*n +1 ; ie = ib + n-1 ; 59 | jb = (j0+j-1)*n +1 ; je = jb + n-1 ; 60 | kb = (k0+k-1)*n +1 ; ke = kb + n-1 ; 61 | out(ib:ie,jb:je,kb:ke) = x ; 62 | out2(:,t) = x(:); 63 | t = t + 1; 64 | % convert to block i,j position 65 | end 66 | end 67 | end 68 | end 69 | end 70 | 71 | end 72 | 73 | 74 | end -------------------------------------------------------------------------------- /MCDDTF3D/codes/inter2d_yu.m: -------------------------------------------------------------------------------- 1 | % interpolation by ddtf 2 | function out= inter2d_yu(out1,raw,mask,d,lambda) 3 | %out1: initial data 4 | %raw: subsampled data 5 | %mask: sampling mask 6 | %d: dictionary used 7 | %lambda:threshold parameter 8 | 9 | %output 10 | %out: interpolated data 11 | 12 | %All materials are copyrighted to HIT University, and are used for 13 | %academic research purpose only. Unauthorized redistribution of the 14 | %materials is prohibited. 15 | %Author: Siwei Yu 16 | %Date: Dec,10,2016 17 | [n1,n2]= size(raw); 18 | iter = 20; 19 | r = round((size(d,1))^(1/2)); 20 | kk = 1; 21 | %interpolation with iteration threshhold method and low frequency constrain. 22 | for it = 1:iter 23 | it 24 | 25 | u_ = raw * 0; 26 | w = raw * 0; 27 | 28 | g = pf2d(out1,r); 29 | coef = d'*g; 30 | coef = coef.* (abs(coef)>(lambda*kk)); 31 | f = d*coef; 32 | u_ = u_ + pb2d(f,n1,n2); 33 | w = w + ones(n1,n2); 34 | 35 | u_ = u_./w; 36 | kk = kk * 0.9; 37 | 38 | out1 = kk*(raw-mask.*u_)+u_; % with noise 39 | % out1 = (raw-mask.*u_)+u_; % without noise 40 | end 41 | 42 | out = u_; 43 | 44 | end -------------------------------------------------------------------------------- /MCDDTF3D/codes/inter3d_yu.m: -------------------------------------------------------------------------------- 1 | % interpolation by ddtf 2 | function out= inter3d_yu(out1,raw,mask,d,lambda) 3 | %out1: initial data 4 | %raw: subsampled data 5 | %mask: sampling mask 6 | %d: dictionary used 7 | %lambda:threshold parameter 8 | 9 | %output 10 | %out: interpolated data 11 | 12 | %All materials are copyrighted to HIT University, and are used for 13 | %academic research purpose only. Unauthorized redistribution of the 14 | %materials is prohibited. 15 | %Author: Siwei Yu 16 | %Date: Dec,10,2016 17 | [n1,n2,n3]= size(raw); 18 | iter = 20; 19 | r = round((size(d,1))^(1/3)); 20 | kk = 1; 21 | %interpolation with iteration threshhold method and low frequency constrain. 22 | for it = 1:iter 23 | it 24 | 25 | u_ = raw * 0; 26 | w = raw * 0; 27 | for i=1:size(out1,1)-r+1 28 | 29 | g = pf3d(out1(i:i+r-1,:,:),r); 30 | coef = d'*g; 31 | coef = coef.* (abs(coef)>(lambda*kk)); 32 | f = d*coef; 33 | u_(i:i+r-1,:,:) = u_(i:i+r-1,:,:) + pb3d(f,r,n2,n3); 34 | w(i:i+r-1,:,:) = w(i:i+r-1,:,:) + ones(r,n2,n3); 35 | end 36 | 37 | u_ = u_./w; 38 | kk = kk * 0.9; 39 | 40 | out1 = (raw-mask.*u_)+u_; % with noise 41 | % out1 = (raw-mask.*u_)+u_; % without noise 42 | end 43 | 44 | out = out1; 45 | 46 | end -------------------------------------------------------------------------------- /MCDDTF3D/codes/train3d.m: -------------------------------------------------------------------------------- 1 | function [d_] = train3d(d0,u,r,lambda) 2 | 3 | % ddtf dictionary training (no low frequency constrain) 4 | 5 | %d0: initial dictionary 6 | %u: training data 7 | %r: patch size 8 | %lambda:training paramter 9 | %d_: trained dictionary 10 | 11 | 12 | %using ddtf algorithm 13 | %1,rerange the data into small patches. patch size r*r*r, patches number 14 | %(n1-r+1)*(n2-r+1)*(n3-r+1),the data size is (r*r*r)*((n1-r+1)*(n2-r+1)*(n3-r+1)) 15 | [n1,n2,n3] = size(u); 16 | %pf3d: transform original data to patch data 17 | %pb3d: transform patch data to original data 18 | g = pf3d(u,r); 19 | %2, use the samples from data(data driven) to train the dictionary 20 | 21 | a = d0; 22 | iter = 25; 23 | r1 = 0.0;r2 = 0.0; % weight coefficient for low frequency item 24 | 25 | for i=1:iter 26 | 27 | %fix the dictionary to update the coefficient. 28 | kk = 1-(i-1)/iter; 29 | % kk =1; 30 | v = a' * g; 31 | v = wthresh(v, 'h', kk* lambda); 32 | 33 | %fix the coefficient and update the dictionary. 34 | 35 | gv= g * v'; 36 | [s, ~, x] = svd(gv); 37 | a = s * x'; 38 | 39 | end 40 | 41 | d_ = a; 42 | 43 | end -------------------------------------------------------------------------------- /MCDDTF3D/setup.m: -------------------------------------------------------------------------------- 1 | addpath(genpath('.')); -------------------------------------------------------------------------------- /MCDDTF3D/tool/DctInit.m: -------------------------------------------------------------------------------- 1 | function [DCT, H] = DctInit(patchsize) 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3 | % Generate DCT Dictionary 4 | % input: 5 | % patchsize: patch size 6 | % output: 7 | % DCT: DCT dictionary 8 | % H: original DCT 9 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 10 | % Initial DCT dictionary 11 | % ======================================================== 12 | H = dctmtx(patchsize); 13 | DCT = kron(H,H); 14 | DCT = DCT'; 15 | -------------------------------------------------------------------------------- /MCDDTF3D/tool/InpaintingInterp2.m: -------------------------------------------------------------------------------- 1 | function Iout=InpaintingInterp2(Ip,Fmask,interp) 2 | %Pre-interpolation with matlab function griddata. 3 | 4 | %Ip: subsampled data 5 | %Fmask: sampling mask 6 | %interp:interpolation method 7 | 8 | %Iout: interpolated data 9 | 10 | 11 | if (~exist('interp','var')) 12 | interp='nearest'; 13 | end 14 | 15 | Ip=double(Ip); 16 | [N,M]=size(Ip); 17 | [X,Y]=meshgrid([1:M],[1:N]); 18 | x=X(Fmask==1); 19 | y=Y(Fmask==1); 20 | z=Ip(Fmask==1); 21 | 22 | xi=X(Fmask==0); 23 | yi=Y(Fmask==0); 24 | 25 | 26 | Iout=Ip; 27 | interp=lower(interp); 28 | zi = griddata(x,y,z,xi,yi,interp); 29 | zi(isnan(zi))=0.; 30 | Iout(Fmask==0)=zi; 31 | -------------------------------------------------------------------------------- /MCDDTF3D/tool/Psnr.m: -------------------------------------------------------------------------------- 1 | function val = Psnr(clear_img,calculating_img) 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3 | % Calculate PSNR for images 4 | % input: 5 | % clear_img: image in standard 6 | % calculating_img : image for calculating 7 | % output: 8 | % val: value of PSNR(dB) 9 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 10 | 11 | im = double(clear_img); 12 | imm = max(im(:)); 13 | denoised_im = double(calculating_img); 14 | err = im - denoised_im; 15 | val = 20*log10(imm/sqrt(sum(err(:).^2)/numel(err))); -------------------------------------------------------------------------------- /MCDDTF3D/tool/acknowledgement.txt: -------------------------------------------------------------------------------- 1 | Acknowledgement. 2 | 3 | The codes for col2imstep.m and im2clostep.m are copied from the implementation 4 | of K-SVD method "KSVD-Box v11" obtained from http://www.cs.technion.ac.il/~ronrubin/Software/ksvdsbox11.zip -------------------------------------------------------------------------------- /MCDDTF3D/tool/clip.m: -------------------------------------------------------------------------------- 1 | function Dc = clip(D,cmin,cmax); 2 | %CLIP: A program to clip seismic data. 3 | % 4 | % Dc = clip(D, cmin, cmax); 5 | % 6 | % IN D: data to be clipped 7 | % cmin: lower clip in % (90% means clip at the 90% negative amplitude) 8 | % cmax: lower clip in % (90% means clip at the 90% positive amplitude) 9 | % 10 | % OUT Dc: data after being clipped 11 | % 12 | % Example: 13 | % 14 | % d = sin(2*pi*.02*[1:1:200]); plot(clip(d,90,90)); 15 | % 16 | % 17 | % Copyright (C) 2008, Signal Analysis and Imaging Group 18 | % For more information: http://www-geo.phys.ualberta.ca/saig/SeismicLab 19 | % Author: M.D.Sacchi 20 | % 21 | % This program is free software: you can redistribute it and/or modify 22 | % it under the terms of the GNU General Public License as published 23 | % by the Free Software Foundation, either version 3 of the License, or 24 | % any later version. 25 | % 26 | % This program is distributed in the hope that it will be useful, 27 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 29 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 30 | % 31 | 32 | 33 | if (nargin < 1 | nargin > 3) 34 | error('Wrong number of input parameters in CLIP.') 35 | end 36 | 37 | % [nt,nx] = size(D); 38 | 39 | % d = reshape(D,nx*nt,1); 40 | d = D(:); 41 | 42 | dmin = abs(min(d)); 43 | dmax = abs(max(d)); 44 | 45 | I = find(d>0 & d > cmax*dmax/100.); 46 | J = find(d<0 & abs(d) > cmin*dmin/100); 47 | 48 | d(I) = cmax*dmax/100.; 49 | d(J) = -cmin*dmin/100.; 50 | 51 | % Dc = reshape(d,nt,nx); 52 | Dc = reshape(d,size(D)); 53 | return; 54 | -------------------------------------------------------------------------------- /MCDDTF3D/tool/col2imstep.m: -------------------------------------------------------------------------------- 1 | %COL2IMSTEP Rearrange matrix columns into blocks. 2 | % A = COL2IMSTEP(B,[MM NN],[N1 N2]) rearranges the columns of B into 3 | % sliding N1-by-N2 blocks producing the matrix A of size MM-by-NN. B is 4 | % usually the result of calling IM2COLSTEP(...) with a stepsize of 1, or 5 | % using Matlab's IM2COL(..,'sliding'). Overlapping blocks are summed in A. 6 | % 7 | % A = COL2IMSTEP(B,[MM NN],[N1 N2],[S1 S2]) arranges the blocks in A with 8 | % a step size of (S1,S2) between them. The first block is at A(1:N1,1:N2), 9 | % and the rest are at A((1:N1)+i*S1,(1:N2)+j*S2). Overlapping blocks are 10 | % summed in A. Note that B is usually the result of calling 11 | % IM2COLSTEP(...) with a stepsize of [S1 S2]. 12 | % 13 | % A = IM2COLSTEP(B,[MM NN KK],[N1 N2 N3],[S1 S2 S3]) generates a 3-D 14 | % output matrix A. The step size [S1 S2 S3] may be ommitted, and defaults 15 | % to [1 1 1]. 16 | % 17 | % See also IM2COLSTEP, IM2COL, COUNTCOVER. 18 | 19 | 20 | % Ron Rubinstein 21 | % Computer Science Department 22 | % Technion, Haifa 32000 Israel 23 | % ronrubin@cs 24 | % 25 | % August 2009 26 | -------------------------------------------------------------------------------- /MCDDTF3D/tool/col2imstep.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/MCDDTF3D/tool/col2imstep.mexw32 -------------------------------------------------------------------------------- /MCDDTF3D/tool/col2imstep.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/MCDDTF3D/tool/col2imstep.mexw64 -------------------------------------------------------------------------------- /MCDDTF3D/tool/im2colstep.m: -------------------------------------------------------------------------------- 1 | %IM2COLSTEP Rearrange matrix blocks into columns. 2 | % B = IM2COLSTEP(A,[N1 N2]) converts each sliding N1-by-N2 block of the 3 | % 2-D matrix A into a column of B, with no zero padding. B has N1*N2 rows 4 | % and will contain as many columns as there are N1-by-N2 neighborhoods in 5 | % A. Each column of B contains a neighborhood of A reshaped as NHOOD(:), 6 | % where NHOOD is a matrix containing an N1-by-N2 neighborhood of A. 7 | % 8 | % B = IM2COLSTEP(A,[N1 N2],[S1 S2]) extracts neighborhoods of A with a 9 | % step size of (S1,S2) between them. The first extracted neighborhood is 10 | % A(1:N1,1:N2), and the rest are of the form A((1:N1)+i*S1,(1:N2)+j*S2). 11 | % Note that to ensure coverage of all A by neighborhoods, 12 | % (size(A,i)-Ni)/Si must be whole for i=1,2. The default function behavior 13 | % corresponds to [S1 S2] = [1 1]. Setting S1>=N1 and S2>=N2 results in no 14 | % overlap between the neighborhoods. 15 | % 16 | % B = IM2COLSTEP(A,[N1 N2 N3],[S1 S2 S3]) operates on a 3-D matrix A. The 17 | % step size [S1 S2 S3] may be ommitted, and defaults to [1 1 1]. 18 | % 19 | % Note: the call IM2COLSTEP(A,[N1 N2]) produces the same output as 20 | % Matlab's IM2COL(A,[N1 N2],'sliding'). However, it is significantly 21 | % faster. 22 | % 23 | % See also COL2IMSTEP, IM2COL, COUNTCOVER. 24 | 25 | 26 | % Ron Rubinstein 27 | % Computer Science Department 28 | % Technion, Haifa 32000 Israel 29 | % ronrubin@cs 30 | % 31 | % August 2009 32 | -------------------------------------------------------------------------------- /MCDDTF3D/tool/im2colstep.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/MCDDTF3D/tool/im2colstep.mexw32 -------------------------------------------------------------------------------- /MCDDTF3D/tool/im2colstep.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/MCDDTF3D/tool/im2colstep.mexw64 -------------------------------------------------------------------------------- /MCDDTF3D/tool/im2colsvar.m: -------------------------------------------------------------------------------- 1 | %IM2COLSTEP Rearrange matrix blocks into columns. 2 | % B = IM2COLSTEP(A,[N1 N2]) converts each sliding N1-by-N2 block of the 3 | % 2-D matrix A into a column of B, with no zero padding. B has N1*N2 rows 4 | % and will contain as many columns as there are N1-by-N2 neighborhoods in 5 | % A. Each column of B contains a neighborhood of A reshaped as NHOOD(:), 6 | % where NHOOD is a matrix containing an N1-by-N2 neighborhood of A. 7 | % 8 | % B = IM2COLSTEP(A,[N1 N2],[S1 S2]) extracts neighborhoods of A with a 9 | % step size of (S1,S2) between them. The first extracted neighborhood is 10 | % A(1:N1,1:N2), and the rest are of the form A((1:N1)+i*S1,(1:N2)+j*S2). 11 | % Note that to ensure coverage of all A by neighborhoods, 12 | % (size(A,i)-Ni)/Si must be whole for i=1,2. The default function behavior 13 | % corresponds to [S1 S2] = [1 1]. Setting S1>=N1 and S2>=N2 results in no 14 | % overlap between the neighborhoods. 15 | % 16 | % B = IM2COLSTEP(A,[N1 N2 N3],[S1 S2 S3]) operates on a 3-D matrix A. The 17 | % step size [S1 S2 S3] may be ommitted, and defaults to [1 1 1]. 18 | % 19 | % Note: the call IM2COLSTEP(A,[N1 N2]) produces the same output as 20 | % Matlab's IM2COL(A,[N1 N2],'sliding'). However, it is significantly 21 | % faster. 22 | % 23 | % See also COL2IMSTEP, IM2COL, COUNTCOVER. 24 | 25 | 26 | % Ron Rubinstein 27 | % Computer Science Department 28 | % Technion, Haifa 32000 Israel 29 | % ronrubin@cs 30 | % 31 | % August 2009 32 | -------------------------------------------------------------------------------- /MCDDTF3D/tool/pb2d.m: -------------------------------------------------------------------------------- 1 | function u = pb2d(p,n1,n2) 2 | 3 | %backward patch transform 4 | %p: patch 5 | %n1~n2: data dimensino 6 | %u: output data 7 | 8 | u_ = zeros(n1,n2);uw = u_; 9 | r = round(sqrt(size(p,1))); 10 | k = 1; 11 | for i=1:n1-r+1 12 | for j=1:n2-r+1 13 | u_(i:i+r-1,j:j+r-1)=u_(i:i+r-1,j:j+r-1)+reshape(p(:,k),r,r); 14 | uw(i:i+r-1,j:j+r-1)=uw(i:i+r-1,j:j+r-1)+1; 15 | k = k + 1; 16 | end 17 | end 18 | 19 | u = u_./uw; 20 | 21 | end -------------------------------------------------------------------------------- /MCDDTF3D/tool/pb3d.m: -------------------------------------------------------------------------------- 1 | %displayH(d0); 2 | function u = pb3d(p,n1,n2,n3) 3 | 4 | %backward patch transform 5 | %p: patch 6 | %n1~n3: data dimensino 7 | %u: output data 8 | 9 | u_ = zeros(n1,n2,n3);uw = u_; 10 | r = round(size(p,1)^(1/3)); 11 | l = 1; 12 | s = 1; 13 | for i=1:s:n1-r+1 14 | for j=1:s:n2-r+1 15 | for k=1:s:n3-r+1 16 | u_(i:i+r-1,j:j+r-1,k:k+r-1)=u_(i:i+r-1,j:j+r-1,k:k+r-1)+reshape(p(:,l),r,r,r); 17 | uw(i:i+r-1,j:j+r-1,k:k+r-1)=uw(i:i+r-1,j:j+r-1,k:k+r-1)+1; 18 | l = l + 1; 19 | end 20 | end 21 | end 22 | 23 | u = u_./uw; 24 | 25 | end -------------------------------------------------------------------------------- /MCDDTF3D/tool/pf2d.m: -------------------------------------------------------------------------------- 1 | function out = pf2d(u,r) 2 | %forward patch transform 3 | 4 | %u: input data 5 | %r: patch size 6 | 7 | %out: output patches 8 | [n1,n2] = size(u); 9 | g = zeros(r*r,(n1-r+1)*(n2-r+1)); 10 | k = 1; 11 | 12 | for i=1:n1-r+1 13 | for j=1:n2-r+1 14 | g(:,k)=reshape(u(i:i+r-1,j:j+r-1),r*r,1); 15 | k = k + 1; 16 | end 17 | end 18 | 19 | out = g; 20 | 21 | end -------------------------------------------------------------------------------- /MCDDTF3D/tool/pf3d.m: -------------------------------------------------------------------------------- 1 | function out = pf3d(u,r) 2 | %forward patch transform 3 | 4 | %u: input data 5 | %r: patch size 6 | 7 | %out: output patches 8 | [n1,n2,n3] = size(u); 9 | g = zeros(r*r*r,(n1-r+1)*(n2-r+1)*(n3-r+1)); 10 | l = 1; 11 | s = 1; 12 | for i=1:s:n1-r+1 13 | for j=1:s:n2-r+1 14 | for k=1:s:n3-r+1 15 | g(:,l)=reshape(u(i:i+r-1,j:j+r-1,k:k+r-1),r*r*r,1); 16 | l = l + 1; 17 | end 18 | end 19 | end 20 | 21 | out = g; 22 | 23 | end -------------------------------------------------------------------------------- /MCDDTF3D/tool/proj_mask.m: -------------------------------------------------------------------------------- 1 | function mask = proj_mask(u, r, type) 2 | % u, image 3 | % r, data KNOWN ratio 4 | % type: data missing type 5 | % 'r': random missing rows 6 | % 'c': random missing columns 7 | % 'p': random missing pixels 8 | 9 | % For ROW COLUMN missing cases, the max gap between two known 10 | % rows/columns is at most 2(1/r-1) with probability r^2 11 | 12 | % code duplicate for cases 'r' & 'c' 13 | 14 | [m,n] = size(u); 15 | 16 | mask = zeros(m,n); 17 | 18 | switch type 19 | 20 | case 'r' 21 | 22 | gap = 1/r; 23 | gap_ = ceil(gap); 24 | K = floor(m*r); 25 | 26 | for i=1:K 27 | j = floor((i-1)*gap) + randperm(gap_,1); 28 | mask(j,:) = 1; 29 | end 30 | 31 | case 'c' 32 | 33 | gap = 1/r; 34 | gap_ = ceil(gap); 35 | K = floor(n*r); 36 | 37 | for i=1:K 38 | j = floor((i-1)*gap) + randperm(gap_,1); 39 | mask(:,j) = 1; 40 | end 41 | 42 | case 'p' 43 | 44 | pix = randperm(m*n); 45 | r = fix(r*m*n); 46 | pix = pix(1:r); 47 | mask(pix) = 1; 48 | 49 | otherwise % pixel-wise missing 50 | 51 | pix = randperm(m*n); 52 | r = fix(r*m*n); 53 | pix = pix(1:r); 54 | mask(pix) = 1; 55 | 56 | end 57 | -------------------------------------------------------------------------------- /MCDDTF3D/tool/proj_mask_regular.m: -------------------------------------------------------------------------------- 1 | function mask = proj_mask_regular(m, n, r) 2 | % u, image 3 | % r, data KNOWN ratio 4 | % type: data missing type 5 | % 'r': random missing rows 6 | % 'c': random missing columns 7 | % 'p': random missing pixels 8 | 9 | % For ROW COLUMN missing cases, the max gap between two known 10 | % rows/columns is at most 2(1/r-1) with probability r^2 11 | 12 | % code duplicate for cases 'r' & 'c' 13 | mask = zeros(m,n); 14 | % p=1/sqrt(r); 15 | p=1/r; 16 | 17 | mask(round(1:p:m),:) = 1; 18 | 19 | 20 | end 21 | -------------------------------------------------------------------------------- /MCDDTF3D/tool/seishow3D.m: -------------------------------------------------------------------------------- 1 | function seishow3D(D,c,dmin,dmax) 2 | 3 | if (~exist('c' ,'var')) 4 | c=100; 5 | end 6 | 7 | cm = min(D(:)); 8 | [n1,n2,n3] = size(D); 9 | 10 | di = 0.05; dc = 0.05; dt = 0.004; 11 | % xt = [1, 50, 100, 129, 178, 228]; 12 | % xtl= [0, 1, 2, 0, 1 ,2]; 13 | % yt = [1, 50, 100, 129, 178, 228]; 14 | % ytl= [ 0, 1, 2, 0, 0.2, 0.4]; 15 | xt = [1, 50, 100, 150, 200]; 16 | xtl= [[0, 50, 100]*di, [50, 100]*dc]; 17 | yt = [1, 50, 100, 150, 200, 250]; 18 | ytl= [[0, 50, 100]*di, [50, 100, 150]*dt]; 19 | 20 | I = zeros(n1+n3+1,n2+n3+1); 21 | I(1:n3,1:n2) = squeeze( D(round(n1/2),:,:) )'; 22 | I(:,n2+1) = cm; 23 | I(1:n3,n2+2:n2+n3+1) = mean(D(:))*ones(n3,n3); 24 | I(n3+2:n3+n1+1,1:n2) = squeeze(D(:,:, round(n3/2))); 25 | I(n3+1,:) = cm; 26 | I(n3+2:n3+n1+1,n2+2:n2+n3+1) = squeeze( D(:,round(n2/2),:)); 27 | %figure, 28 | I = clip(I,c,c); 29 | 30 | if (~exist('dmin' ,'var')) 31 | dmin = min(I(:)) ; 32 | end 33 | if (~exist('dmax' ,'var')) 34 | dmax = max(I(:)) ; 35 | end 36 | 37 | figure,imagesc(I,[dmin,dmax]);axis image;colorbar; colormap gray; 38 | % set(gca,'XTick',xt,'YTick',yt); 39 | % set(gca,'XTickLabel',xtl,'YTickLabel',ytl); 40 | set(gca,'FontSize',12); 41 | xlabel('Midpoint (km) Offset (km)'); 42 | ylabel('Time (s) Offset (km)'); 43 | %imagesc(I);axis image; colormap gray; axis off;colorbar; 44 | % figure, plot(I(:,64)); 45 | end 46 | -------------------------------------------------------------------------------- /RegistrationMultiComponent/dpp.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/RegistrationMultiComponent/dpp.mat -------------------------------------------------------------------------------- /RegistrationMultiComponent/dps.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/RegistrationMultiComponent/dps.mat -------------------------------------------------------------------------------- /RegistrationMultiComponent/note.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/RegistrationMultiComponent/note.txt -------------------------------------------------------------------------------- /SR1/ex.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/SR1/ex.mat -------------------------------------------------------------------------------- /SR1/sr1_demo.m: -------------------------------------------------------------------------------- 1 | disp('Loading example data'); 2 | load ex.mat; 3 | 4 | Res = DATA; 5 | 6 | disp('Calculating shifted rank-1 approximation using 3 matrices'); 7 | 8 | for k=1:3 9 | disp(['... (' num2str(k) '/3)']); 10 | 11 | % calculate approximation of resudal 12 | [B{k},u{k},v{k},lambda{k}] = sr1(Res); 13 | 14 | % update residual 15 | Res = Res-B{k}; 16 | 17 | % for better visuability shift each event such that its peak is at k/4 18 | % of its length 19 | [~,pos] = max(abs(u{k})); 20 | u{k} = circshift(u{k},round(pos+size(DATA,2)/4*k)); 21 | 22 | % also shift the vector lambda to show the actual position of the peak. 23 | % We have do calculate position modulo data length since the method 24 | % uses circulant shifts 25 | lambda{k} = mod(lambda{k} + pos,size(DATA,2)); 26 | end 27 | 28 | disp('Plotting results'); 29 | figure; 30 | 31 | % FIRST SUBPLOT: original data with shift vectors indicating the peak of 32 | % all events 33 | subplot(231); imagesc(DATA); colormap pink; hold on; 34 | plot(lambda{1},'x'); plot(lambda{2},'x'); plot(lambda{3},'x'); title('Data with tracked events'); 35 | 36 | % SECOND SUBPLOT: extracted waveforms 37 | subplot(232); hold on; plot(u{1}); plot(u{2}); plot(u{3}); axis tight; legend({'Event 1','Event 2','Event 3'}); title('Extracted waveforms'); 38 | 39 | % THIRD SUBPLOT: amplitudes of all events 40 | subplot(233); hold on; plot(abs(v{1})); plot(abs(v{2})); plot(abs(v{3})); axis tight; legend({'Event 1','Event 2','Event 3'}); title('Event amplitudes'); 41 | 42 | % SUBPLOT 4-6: all events 43 | subplot(234); imagesc(B{1}); colormap pink; title('Event 1'); 44 | subplot(235); imagesc(B{2}); colormap pink; title('Event 2'); 45 | subplot(236); imagesc(B{3}); colormap pink; title('Event 3'); 46 | 47 | disp('This example shows two drawbacks of the method that will be considered in future work:'); 48 | disp('- Overlapping events are hard to seperate and cause disturbance in the data'); 49 | disp('- Events that locally fanish (e.g., Event 3) are not yet implemented. Use e.g., a threshold on the amplitude to account these phenomenom'); -------------------------------------------------------------------------------- /TSDL/Build_Tree.m: -------------------------------------------------------------------------------- 1 | % the function is used to build a tree and learn the dictionary from the 2 | % knots of the tree 3 | %-------------------------------------------------------------------------- 4 | function [Lchild, Rchild,Ind1,Ind2,C1] = Build_Tree(y) 5 | C = y(1, : ,: ); 6 | [m1,m2,m3]=size(y); 7 | % caculate the mean of the training patches-------------------------------- 8 | for i=2:m1 9 | C= C+ y(i, : ,:); 10 | end 11 | C1(:,:)= C/m1; 12 | % caculate the left and right covariance matrix CL,CR---------------------- 13 | CL= zeros(m2,m3); 14 | for i=1:m1 15 | B1(:,:)=y(i,:,:)-C/m1; 16 | CL=CL+B1*B1'; 17 | end 18 | CL=CL/m1; 19 | CR= zeros(m2,m3); 20 | for i=1:m1 21 | B1(:,:)=y(i,:,:)-C/m1; 22 | CR=CR+B1'*B1; 23 | end 24 | CR=CR/m1; 25 | [~,~,V]=svd(CL); 26 | u1=V(:,1); 27 | [~,~,V]=svd(CR); 28 | v1=V(:,1); 29 | s=zeros(m1,1); 30 | for i=1:m1 31 | yk(:,:)=y(i,:,:); 32 | s(i)=u1'*yk*v1; 33 | end 34 | 35 | [s1,I1]=sort(s); 36 | sumall=sum(s1); 37 | for k=1:m1-1 38 | suma(k)=sum(s1(1:k)); sumb(k)=sumall-suma(k); 39 | suma(k)=suma(k)/k; sumb(k)=sumb(k)/(m1-k); 40 | amin(k)=0; 41 | for r=1:k 42 | amin(k)= amin(k)+(s1(r)-suma(k))^2; 43 | end 44 | for r=k+1:m1 45 | amin(k) = amin(k)+(s1(r)-sumb(k))^2; 46 | end 47 | end 48 | amin=amin; 49 | [~,k]=min(amin); 50 | Ind1=I1(1:k); 51 | Ind2=I1(k+1:m1); 52 | Lchild=y(Ind1,:,:); 53 | Rchild=y(Ind2,:,:); 54 | end 55 | 56 | -------------------------------------------------------------------------------- /TSDL/Build_Tree_Second.m: -------------------------------------------------------------------------------- 1 | % the function is used to build a tree and learn the dictionary from the 2 | % knots of the tree 3 | %-------------------------------------------------------------------------- 4 | function [Lchild, Rchild,Ind1,Ind2] = Build_Tree_Second(y) 5 | [m1,~,~]=size(y); 6 | y1=y(1,:,:); 7 | s=zeros(m1,1); 8 | for i=1:m1 9 | y2=y(i,:,:); 10 | s(i)=norm(y1(:,:)-y2(:,:)); 11 | end 12 | 13 | [s1,I1]=sort(s); 14 | sumall=sum(s1); 15 | for k=1:m1-1 16 | suma(k)=sum(s1(1:k)); sumb(k)=sumall-suma(k); 17 | suma(k)=suma(k)/k; sumb(k)=sumb(k)/(m1-k); 18 | amin(k)=0; 19 | for r=1:k 20 | amin(k)= amin(k)+(s1(r)-suma(k))^2; 21 | end 22 | for r=k+1:m1 23 | amin(k) = amin(k)+(s1(r)-sumb(k))^2; 24 | end 25 | end 26 | amin=amin; 27 | [~,k]=min(amin); 28 | Ind1=I1(1:k); 29 | Ind2=I1(k+1:m1); 30 | Lchild=y(Ind1,:,:); 31 | Rchild=y(Ind2,:,:); 32 | end 33 | 34 | -------------------------------------------------------------------------------- /TSDL/Denoising_test_images/Cameraman256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/Denoising_test_images/Cameraman256.png -------------------------------------------------------------------------------- /TSDL/Denoising_test_images/Lena512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/Denoising_test_images/Lena512.png -------------------------------------------------------------------------------- /TSDL/Denoising_test_images/barbara.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/Denoising_test_images/barbara.png -------------------------------------------------------------------------------- /TSDL/Denoising_test_images/boat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/Denoising_test_images/boat.png -------------------------------------------------------------------------------- /TSDL/Denoising_test_images/couple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/Denoising_test_images/couple.png -------------------------------------------------------------------------------- /TSDL/Denoising_test_images/fingerprint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/Denoising_test_images/fingerprint.png -------------------------------------------------------------------------------- /TSDL/Denoising_test_images/hill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/Denoising_test_images/hill.png -------------------------------------------------------------------------------- /TSDL/Denoising_test_images/house.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/Denoising_test_images/house.png -------------------------------------------------------------------------------- /TSDL/Denoising_test_images/man.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/Denoising_test_images/man.png -------------------------------------------------------------------------------- /TSDL/Denoising_test_images/montage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/Denoising_test_images/montage.png -------------------------------------------------------------------------------- /TSDL/Denoising_test_images/pentagon.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/Denoising_test_images/pentagon.tif -------------------------------------------------------------------------------- /TSDL/Denoising_test_images/peppers256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/Denoising_test_images/peppers256.png -------------------------------------------------------------------------------- /TSDL/NormDict.m: -------------------------------------------------------------------------------- 1 | function D = NormDict (A) 2 | D=zeros(size(A)); 3 | for i=1:size(A,2) 4 | if norm(A(:,i))~=0, 5 | D(:,i)=A(:,i)/norm(A(:,i)); 6 | end 7 | end 8 | end -------------------------------------------------------------------------------- /TSDL/Test_tree_dic.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/Test_tree_dic.m -------------------------------------------------------------------------------- /TSDL/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | IconResource=C:\Windows\system32\SHELL32.dll,205 3 | -------------------------------------------------------------------------------- /TSDL/ksvd.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/ksvd.zip -------------------------------------------------------------------------------- /TSDL/leigs.m: -------------------------------------------------------------------------------- 1 | function [E,V] = leigs(DATA, TYPE, PARAM, NE) 2 | 3 | % Laplacian Eigenmaps Algorithm 4 | % 5 | % please refer to University of Chicago 6 | % Computer Science Technical Report TR-2002-01 7 | % Mikhail Belkin, Partha Niyogi 8 | % Laplacian Eigenmaps for Dimensionality Reduction and Data Representation 9 | % Note that Laplacian, not normalized Laplacian is used here 10 | % http://www.cs.uchicago.edu/research/publications/techreports/TR-2002-1 11 | % 12 | % 13 | % Calculate the graph laplacian of the adjacency graph of data set DATA. 14 | % 15 | % L = laplacian(DATA, TYPE, PARAM, NE) 16 | % 17 | % DATA - NxK matrix. Data points are rows. 18 | % TYPE - string 'nn' or string 'epsballs' 19 | % PARAM - integer if TYPE='nn', real number if TYPE='epsballs' 20 | % NE - number of eigenvectors 21 | % 22 | % Returns: 23 | % E - NxNE matrix with eigenfunctions, 24 | % V is NExNE matrix with eigenvalues on the diagonal 25 | % 26 | % Author: 27 | % 28 | % Mikhail Belkin 29 | % misha@math.uchicago.edu 30 | % 31 | 32 | L = laplacian(DATA, TYPE, PARAM); 33 | 34 | % normalized Laplacian 35 | % for i=1:size (L) 36 | % D(i,i) = sum(L(i,:)); 37 | % if (D(i,i) ~= 0) 38 | % DD(i,i) = 1/sqrt(D(i,i)); 39 | % else disp ('warning 0'); 40 | % DD(i,i) = 0; 41 | % end 42 | % end 43 | % LL=DD*(D-L)*DD; 44 | 45 | 46 | opts.tol = 1e-9; 47 | opts.issym=1; 48 | opts.disp = 5; 49 | [E,V] = eigs(L,NE,'sm',opts); 50 | 51 | %A = DD*A; 52 | 53 | 54 | -------------------------------------------------------------------------------- /TSDL/omp2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/omp2.zip -------------------------------------------------------------------------------- /TSDL/seismic.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/seismic.mat -------------------------------------------------------------------------------- /TSDL/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/test.png -------------------------------------------------------------------------------- /TSDL/tool/DctInit.m: -------------------------------------------------------------------------------- 1 | function [DCT, H] = DctInit(patchsize) 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3 | % Generate DCT Dictionary 4 | % input: 5 | % patchsize: patch size 6 | % output: 7 | % DCT: DCT dictionary 8 | % H: original DCT 9 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 10 | % Initial DCT dictionary 11 | % ======================================================== 12 | H = dctmtx(patchsize); 13 | DCT = kron(H,H); 14 | DCT = DCT'; 15 | -------------------------------------------------------------------------------- /TSDL/tool/Psnr.m: -------------------------------------------------------------------------------- 1 | function val = Psnr(clear_img,calculating_img) 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3 | % Calculate PSNR for images 4 | % input: 5 | % clear_img: image in standard 6 | % calculating_img : image for calculating 7 | % output: 8 | % val: value of PSNR(dB) 9 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 10 | 11 | im = double(clear_img); 12 | denoised_im = double(calculating_img); 13 | err = im - denoised_im; 14 | val = 20*log10(255/sqrt(sum(err(:).^2)/numel(err)))+9; -------------------------------------------------------------------------------- /TSDL/tool/acknowledgement.txt: -------------------------------------------------------------------------------- 1 | Acknowledgement. 2 | 3 | The codes for col2imstep.m and im2clostep.m are copied from the implementation 4 | of K-SVD method "KSVD-Box v11" obtained from http://www.cs.technion.ac.il/~ronrubin/Software/ksvdsbox11.zip -------------------------------------------------------------------------------- /TSDL/tool/col2imstep.m: -------------------------------------------------------------------------------- 1 | %COL2IMSTEP Rearrange matrix columns into blocks. 2 | % A = COL2IMSTEP(B,[MM NN],[N1 N2]) rearranges the columns of B into 3 | % sliding N1-by-N2 blocks producing the matrix A of size MM-by-NN. B is 4 | % usually the result of calling IM2COLSTEP(...) with a stepsize of 1, or 5 | % using Matlab's IM2COL(..,'sliding'). Overlapping blocks are summed in A. 6 | % 7 | % A = COL2IMSTEP(B,[MM NN],[N1 N2],[S1 S2]) arranges the blocks in A with 8 | % a step size of (S1,S2) between them. The first block is at A(1:N1,1:N2), 9 | % and the rest are at A((1:N1)+i*S1,(1:N2)+j*S2). Overlapping blocks are 10 | % summed in A. Note that B is usually the result of calling 11 | % IM2COLSTEP(...) with a stepsize of [S1 S2]. 12 | % 13 | % A = IM2COLSTEP(B,[MM NN KK],[N1 N2 N3],[S1 S2 S3]) generates a 3-D 14 | % output matrix A. The step size [S1 S2 S3] may be ommitted, and defaults 15 | % to [1 1 1]. 16 | % 17 | % See also IM2COLSTEP, IM2COL, COUNTCOVER. 18 | 19 | 20 | % Ron Rubinstein 21 | % Computer Science Department 22 | % Technion, Haifa 32000 Israel 23 | % ronrubin@cs 24 | % 25 | % August 2009 26 | -------------------------------------------------------------------------------- /TSDL/tool/col2imstep.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/tool/col2imstep.mexw32 -------------------------------------------------------------------------------- /TSDL/tool/col2imstep.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/tool/col2imstep.mexw64 -------------------------------------------------------------------------------- /TSDL/tool/im2colstep.m: -------------------------------------------------------------------------------- 1 | %IM2COLSTEP Rearrange matrix blocks into columns. 2 | % B = IM2COLSTEP(A,[N1 N2]) converts each sliding N1-by-N2 block of the 3 | % 2-D matrix A into a column of B, with no zero padding. B has N1*N2 rows 4 | % and will contain as many columns as there are N1-by-N2 neighborhoods in 5 | % A. Each column of B contains a neighborhood of A reshaped as NHOOD(:), 6 | % where NHOOD is a matrix containing an N1-by-N2 neighborhood of A. 7 | % 8 | % B = IM2COLSTEP(A,[N1 N2],[S1 S2]) extracts neighborhoods of A with a 9 | % step size of (S1,S2) between them. The first extracted neighborhood is 10 | % A(1:N1,1:N2), and the rest are of the form A((1:N1)+i*S1,(1:N2)+j*S2). 11 | % Note that to ensure coverage of all A by neighborhoods, 12 | % (size(A,i)-Ni)/Si must be whole for i=1,2. The default function behavior 13 | % corresponds to [S1 S2] = [1 1]. Setting S1>=N1 and S2>=N2 results in no 14 | % overlap between the neighborhoods. 15 | % 16 | % B = IM2COLSTEP(A,[N1 N2 N3],[S1 S2 S3]) operates on a 3-D matrix A. The 17 | % step size [S1 S2 S3] may be ommitted, and defaults to [1 1 1]. 18 | % 19 | % Note: the call IM2COLSTEP(A,[N1 N2]) produces the same output as 20 | % Matlab's IM2COL(A,[N1 N2],'sliding'). However, it is significantly 21 | % faster. 22 | % 23 | % See also COL2IMSTEP, IM2COL, COUNTCOVER. 24 | 25 | 26 | % Ron Rubinstein 27 | % Computer Science Department 28 | % Technion, Haifa 32000 Israel 29 | % ronrubin@cs 30 | % 31 | % August 2009 32 | -------------------------------------------------------------------------------- /TSDL/tool/im2colstep.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/tool/im2colstep.mexw32 -------------------------------------------------------------------------------- /TSDL/tool/im2colstep.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sevenysw/MathGeo2022/800fc89596e4382923e868869354742b990c5c97/TSDL/tool/im2colstep.mexw64 --------------------------------------------------------------------------------