├── README.md ├── demo_generate_synthetic_data.m ├── demo_generate_synthetic_data_twotarget.m ├── gen_synthetic_data_code ├── add_noise_to_dB.m ├── drchrnd.m ├── gen_2tar_data.m ├── gen_individual_LMM_point.m ├── gen_multi_tar_mixed_data.m ├── plotSpectra.m └── setParameters.m └── synthetic_data ├── E_truth.mat ├── highly_mixed_data_pt_03.mat ├── highly_mixed_data_pt_05.mat ├── highly_mixed_data_pt_07.mat ├── noisy_data_SNR_10.mat ├── noisy_data_SNR_20.mat ├── noisy_data_SNR_30.mat ├── noisy_data_SNR_40.mat ├── originalData.mat ├── random_data.mat └── wavelength.mat /README.md: -------------------------------------------------------------------------------- 1 | # Hyperspectral_Data_Simulation 2 | 3 | Multiple instance learning bag generation code for the ECOSTRESS Spectral Library 1.0 (Meerdink et al., 2019), formally known as the ASTER 2.0 hyperspectral library data (Baldridge et al., 2009). This code was written by Changzhe Jiao and Alina Zare and originally existed in the [FUMI repository](https://github.com/GatorSense/FUMI). It has been made it's own repository by James Bocinsky and Daniel Shats with editing help from Susan Meerdink. 4 | 5 | 6 | If you use this code, cite it: James Bocinsky, Daniel Shats, & Alina Zare. (2019, April 29). GatorSense/Hyperspectral_Data_Simulation v1.0 (Version v1.0). Zenodo. http://doi.org/10.5281/zenodo.2653922 [![DOI](https://zenodo.org/badge/179329388.svg)](https://zenodo.org/badge/latestdoi/179329388) 7 | 8 | ************ 9 | 10 | ### Demo 11 | demo_generate_synthetic_data.m - generates synthetic data 12 | demo_generate_synthetic_data_twotargets.m - generates synthetic data that includes two targets 13 | ************ 14 | 15 | ### Files 16 | 17 | gen_synthetic_data_code: //code to generate data 18 | * add_noise_to_dB.m - adds Gaussian white noise to synthetic data 19 | * drchrnd.m - generates random vector following Dirichlet distribution 20 | * gen_2tar_data.m - generates synthetic data for two targets 21 | * gen_individual_LMM_point.m - generates individual synthetic data point following the linear mixing model 22 | * gen_multi_tar_mixed_data.m - generates synthetic data set following the definition of multiple instance learning problem 23 | * plotSpectra.m - function that plots spectra/endmembers used as targets 24 | * setParameters.m - function that sets parameters for generating synthetic data 25 | ************ 26 | 27 | synthetic_data: //raw data files and pregenerated data files 28 | * E_truth.mat - groundtruth endmember and wavelength information used to generate synthetic data (see below for specific filenames used from ECOSTRESS Spectral Library) 29 | * highly_mixed_data_pt_03.mat - highly mixed synthetic data with P_t_mean=0.3; bag-level and instance-level labels 30 | * highly_mixed_data_pt_05.mat - highly mixed synthetic data with P_t_mean=0.5; bag-level and instance-level labels 31 | * highly_mixed_data_pt_07.mat - highly mixed synthetic data with P_t_mean=0.7; bag-level and instance-level labels 32 | * noisy_data_SNR_10.mat - noisy synthetic data with SNR=10 dB; bag-level and instance-level labels 33 | * noisy_data_SNR_20.mat - noisy synthetic data with SNR=20 dB; bag-level and instance-level labels 34 | * noisy_data_SNR_30.mat - noisy synthetic data with SNR=30 dB; bag-level and instance-level labels 35 | * noisy_data_SNR_40.mat - noisy synthetic data with SNR=40 dB; bag-level and instance-level labels 36 | * originalData.mat - table that contains sample names, wavelength, and original reflectance values from the ECOSTRESS Spectral Library. 37 | * random_data.mat - random synthetic data; bag-level and instance-level labels 38 | * wavelengths.mat - array of wavelengths associated with spectra 39 | 40 | **************************************************************** 41 | 42 | For any questions, please contact: 43 | 44 | Alina Zare 45 | 46 | Email Address: azare@ece.ufl.edu 47 | 48 | University of Florida, Department of Electrical and Computer Engineering 49 | 50 | 51 | **************************************************************** 52 | Endmembers/Spectra Extracted from ECOSTRESS Spectral Library: 53 | * Basalt: rock.igneous.basic.solid.vswir.ward34.jpl.perkin.spectrum 54 | * Pyroxenite: rock.igneous.ultramafic.solid.vswir.ward43.jpl.perkin.spectrum 55 | * Verde Antique: rock.metamorphic.marble.solid.vswir.ward98.jpl.perkin.spectrum 56 | * Phyllite: rock.metamorphic.phyllite.solid.vswir.ward85.jpl.perkin.spectrum 57 | * Slate: rock.metamorphic.slate.solid.vswir.ward91.jpl.perkin.spectrum 58 | * Quartz Conglomerate: rock.sedimentary.conglomerate.solid.vswir.ward48.jpl.perkin.spectrum 59 | 60 | ************ 61 | References: 62 | 63 | Meerdink, S. K., Hook, S. J., Roberts, D. A., & Abbott, E. A. (2019). The ECOSTRESS spectral library version 1.0. Remote Sensing of Environment, 230(111196), 1–8. https://doi.org/10.1016/j.rse.2019.05.015 64 | 65 | Baldridge, A. M., Hook, S. J., Grove, C. I., & Rivera, G. (2009). The ASTER spectral library version 2.0. Remote Sensing of Environment, 113(4), 711–715. https://doi.org/10.1016/j.rse.2008.11.007 66 | -------------------------------------------------------------------------------- /demo_generate_synthetic_data.m: -------------------------------------------------------------------------------- 1 | function [X,P,labels_bag,labels_point,bag_number,dataBagged] = demo_generate_synthetic_data() 2 | % This function generates synthetic data following definition of multiple instance learning problem 3 | 4 | % REFERENCE : 5 | % C. Jiao, A. Zare, 6 | % Functions of Multiple Instances for Learning Target Signatures, 7 | % IEEE transactions on Geoscience and Remote Sensing, Vol. 53, No. 8, Aug. 2015, DOI: 10.1109/TGRS.2015.2406334 8 | % 9 | % SYNTAX: [X,P,labels_bag,labels_point]= demo_generate_synthetic_data() 10 | 11 | % Inputs: 12 | % None 13 | % 14 | %Outputs: 15 | % X - dataset in column vectors 16 | % P - proportion set in column vectors 17 | % labels_bag - bag level label per data point 18 | % labels_point - instance level label per data point 19 | 20 | % Author: Changzhe Jiao, Alina Zare 21 | % University of Missouri, Department of Electrical and Computer Engineering 22 | % Email Address: cjr25@mail.missouri.edu; zarea@missouri.edu 23 | 24 | 25 | addpath('./gen_synthetic_data_code') 26 | addpath('./synthetic_data') 27 | 28 | load('E_truth') 29 | load('originalData') 30 | 31 | % Generate Single Target Synthetic Dataset 32 | parameters = setParameters(); 33 | [X,P,labels_bag,labels_point,bag_number,dataBagged] = gen_multi_tar_mixed_data(E_truth, parameters); 34 | 35 | % Plot 36 | plotSpectra(originalData, parameters) 37 | end -------------------------------------------------------------------------------- /demo_generate_synthetic_data_twotarget.m: -------------------------------------------------------------------------------- 1 | function [X,P,labels_bag,labels_point,bag_number,dataBagged] = demo_generate_synthetic_data_twotarget() 2 | 3 | % This function generates synthetic data following definition of multiple instance learning problem 4 | 5 | % REFERENCE : 6 | % C. Jiao, A. Zare, 7 | % Functions of Multiple Instances for Learning Target Signatures, 8 | % IEEE transactions on Geoscience and Remote Sensing, Vol. 53, No. 8, Aug. 2015, DOI: 10.1109/TGRS.2015.2406334 9 | % 10 | % SYNTAX: [X,P,labels_bag,labels_point]= demo_generate_synthetic_data() 11 | 12 | % Inputs: 13 | % None 14 | % 15 | %Outputs: 16 | % X - dataset in column vectors 17 | % P - proportion set in column vectors 18 | % labels_bag - bag level label per data point 19 | % labels_point - instance level label per data point 20 | 21 | % Author: Changzhe Jiao, Alina Zare 22 | % University of Missouri, Department of Electrical and Computer Engineering 23 | % Email Address: cjr25@mail.missouri.edu; zarea@missouri.edu 24 | 25 | 26 | addpath('./gen_synthetic_data_code') 27 | addpath('./synthetic_data') 28 | 29 | load('E_truth') 30 | load('originalData') 31 | 32 | % Generate Two Target Synthetic Dataset 33 | parameters = setParameters(); 34 | parameters.E_target = [1,2]; % index of target endmember 35 | parameters.E_minus = 3:6; % index of background endmembers 36 | [X,P,labels_bag,labels_point,bag_number,dataBagged] = gen_2tar_data(E_truth,parameters); 37 | 38 | % Plot 39 | plotSpectra(originalData, parameters) 40 | 41 | end -------------------------------------------------------------------------------- /gen_synthetic_data_code/add_noise_to_dB.m: -------------------------------------------------------------------------------- 1 | function [sig_out]=add_noise_to_dB(sig_in,expect_SdB) 2 | 3 | % This function adds Gaussian white noise to synthetic data 4 | 5 | % REFERENCE : 6 | % C. Jiao, A. Zare, 7 | % Functions of Multiple Instances for Learning Target Signatures,? 8 | % IEEE transactions on Geoscience and Remote Sensing, Vol. 53, No. 8, Aug. 2015, DOI: 10.1109/TGRS.2015.2406334 9 | % 10 | % SYNTAX: [sig_out]=add_noise_to_dB(sig_in,expect_SdB) 11 | 12 | % Inputs: 13 | % sig_in - the input signal; 14 | % expect_Sdb - the expected SNR for output signal 15 | 16 | %Outputs: 17 | 18 | % sig_out - the output signal with added noise; 19 | 20 | % Author: Changzhe Jiao, Alina Zare 21 | % University of Missouri, Department of Electrical and Computer Engineering 22 | % Email Address: cjr25@mail.missouri.edu; zarea@missouri.edu 23 | % Created: October, 2013 24 | % Latest Revision: January, 2015 25 | % 26 | % This product is Copyright (c) 2015 University of Missouri 27 | % All rights reserved. 28 | % 29 | % Redistribution and use in source and binary forms, with or without 30 | % modification, are permitted provided that the following conditions 31 | % are met: 32 | % 33 | % 1. Redistributions of source code must retain the above copyright 34 | % notice, this list of conditions and the following disclaimer. 35 | % 2. Redistributions in binary form must reproduce the above copyright 36 | % notice, this list of conditions and the following disclaimer in the 37 | % documentation and/or other materials provided with the distribution. 38 | % 3. Neither the name of the University nor the names of its contributors 39 | % may be used to endorse or promote products derived from this software 40 | % without specific prior written permission. 41 | % 42 | % THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF MISSOURI AND 43 | % CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 44 | % INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 45 | % MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 46 | % DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS 47 | % BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 48 | % EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 49 | % LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, 50 | % LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 51 | % HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 52 | % CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 53 | % OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 54 | % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 55 | 56 | 57 | 58 | d=size(sig_in,1); 59 | exp_ns_energy=(sig_in'*sig_in)/10^(expect_SdB/10); 60 | ns_sigma=sqrt(exp_ns_energy/d); 61 | ns_sig=ns_sigma*randn(d,1); 62 | sig_out=sig_in+ns_sig; 63 | real_ns_energy=ns_sig'*ns_sig; 64 | real_SdB=10*log10((sig_in'*sig_in)/real_ns_energy); 65 | 66 | end 67 | -------------------------------------------------------------------------------- /gen_synthetic_data_code/drchrnd.m: -------------------------------------------------------------------------------- 1 | function r = drchrnd(a,n) 2 | 3 | % This function generates random vector following Drichlet distribution 4 | 5 | % REFERENCE : 6 | % C. Jiao, A. Zare, 7 | % Functions of Multiple Instances for Learning Target Signatures,? 8 | % IEEE transactions on Geoscience and Remote Sensing, Vol. 53, No. 8, Aug. 2015, DOI: 10.1109/TGRS.2015.2406334 9 | % 10 | % SYNTAX: r = drchrnd(a,n) 11 | 12 | % Inputs: 13 | % a - parameter controlling the mean and variance of Dirichlet distribution, 1*M row vector, M is the number of variables; 14 | % n - No. of random vectors generated 15 | 16 | %Outputs: 17 | 18 | % r - output vector following Drichlet distribution, n*M row vector, M is the number of variables; 19 | 20 | % Author: Changzhe Jiao, Alina Zare 21 | % University of Missouri, Department of Electrical and Computer Engineering 22 | % Email Address: cjr25@mail.missouri.edu; zarea@missouri.edu 23 | % Created: October, 2013 24 | % Latest Revision: January, 2015 25 | % 26 | % This product is Copyright (c) 2015 University of Missouri 27 | % All rights reserved. 28 | % 29 | % Redistribution and use in source and binary forms, with or without 30 | % modification, are permitted provided that the following conditions 31 | % are met: 32 | % 33 | % 1. Redistributions of source code must retain the above copyright 34 | % notice, this list of conditions and the following disclaimer. 35 | % 2. Redistributions in binary form must reproduce the above copyright 36 | % notice, this list of conditions and the following disclaimer in the 37 | % documentation and/or other materials provided with the distribution. 38 | % 3. Neither the name of the University nor the names of its contributors 39 | % may be used to endorse or promote products derived from this software 40 | % without specific prior written permission. 41 | % 42 | % THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF MISSOURI AND 43 | % CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 44 | % INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 45 | % MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 46 | % DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS 47 | % BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 48 | % EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 49 | % LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, 50 | % LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 51 | % HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 52 | % CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 53 | % OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 54 | % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 55 | 56 | 57 | % take a sample from a dirichlet distribution 58 | M = length(a); 59 | r = gamrnd(repmat(a,n,1),1,n,M); 60 | r = r ./ repmat(sum(r,2),1,M); 61 | 62 | 63 | -------------------------------------------------------------------------------- /gen_synthetic_data_code/gen_2tar_data.m: -------------------------------------------------------------------------------- 1 | function [X,P,labels_bag,labels_point,bag_number,data] = gen_2tar_data(E_truth,params) 2 | % This function generates synthetic data set following the definition of 3 | % multiple instance learning problem using TWO targets. 4 | % Inputs: 5 | % E_Truth - array containing all spectra/endmembers [n_dim, n_samps] 6 | % params - structure containing parameters to generate synthetic data 7 | % Outputs: 8 | % X - dataset in column vectors 9 | % P - proportion set in column vectors 10 | % labels_bag - bag level label in column vectors 11 | % labels_point - instance level label in column vectors 12 | % bag_number - bag number in column vectors 13 | % data - Only provided as output if parameters.bagData = 1. Format 14 | % compatiable with MIACE and MTMIACE. Structure that contains two variables: 15 | % dataBags: bagged data 16 | % * a positive bag should have at least one positive instance in it 17 | % * a negative bag should consist of all negative instances 18 | % labels: labels for dataBags 19 | % * the labels should be a row vector with labels corresponding to the 20 | % * parameters.posLabel and parameters.negLabel where a posLabel corresponds 21 | % * to a positive bag and a negLabel corresponds to a negative bag. 22 | % * The index of the label should match the index of the bag in dataBags 23 | % ----------------------------------------------------------------------- 24 | 25 | % Setting up Variables 26 | parameters = params; 27 | TotalBags = params.num_nbags + params.num_pbags; 28 | TotalPoints = TotalBags*params.num_points; 29 | 30 | %gen_multi_tar_mixed_data for each target type 31 | parameters.E_target = params.E_target(1); 32 | parameters.bagData = 0; 33 | [X_1,P_1,labels_bag_1,labels_point_1,bag_number_1] = gen_multi_tar_mixed_data(E_truth, parameters); 34 | parameters.E_target = params.E_target(2); 35 | [X_2,P_2,labels_bag_2,labels_point_2,bag_number_2] = gen_multi_tar_mixed_data(E_truth, parameters); 36 | 37 | %concatenate data of each target type appropiately 38 | X = horzcat(X_1,X_2); 39 | P = horzcat(vertcat(P_1(1,:),zeros(1,size(P_1,2)),P_1(2:end,:)),vertcat(zeros(1,size(P_2,2)),P_2)); 40 | labels_bag = horzcat(labels_bag_1,labels_bag_2); 41 | labels_point = horzcat(labels_point_1,labels_point_2); 42 | bag_number = horzcat(bag_number_1,bag_number_2+(params.num_nbags+params.num_pbags)); 43 | 44 | if params.bagData == 1 45 | % bag the final data set 46 | for i = 1:2*(params.num_nbags+params.num_pbags) 47 | data.dataBags{i} = X(:,bag_number == i)'; 48 | data.labels(i) = unique(labels_bag(bag_number == i)); 49 | end 50 | end 51 | 52 | end -------------------------------------------------------------------------------- /gen_synthetic_data_code/gen_individual_LMM_point.m: -------------------------------------------------------------------------------- 1 | function [x,p]=gen_individual_LMM_point(E_t,E_minus,label_bag,label_point,parameters) 2 | 3 | %This function generates individual synthetic data point following the linear mixing model 4 | 5 | % REFERENCE : 6 | % C. Jiao, A. Zare, 7 | % Functions of Multiple Instances for Learning Target Signatures, 8 | % IEEE transactions on Geoscience and Remote Sensing, Vol. 53, No. 8, Aug. 2015, DOI: 10.1109/TGRS.2015.2406334 9 | % 10 | % SYNTAX : [x,p]=gen_individual_LMM_point(E_t,E_minus,label_bag,label_point,N_b,Pt_mean,sigma,expect_SdB) 11 | 12 | %Inputs: 13 | % E_T - target endemmber set 14 | % E_minus - background endmember set 15 | % label_bag - bag level label for current point 16 | % lbel_point - point level label for current point 17 | % N_b - minimal number of constituent background endmembers per point 18 | % Pt_mean - mean target proportion value 19 | % sigma - proportion variance 20 | % expect_SdB - desired SNR 21 | 22 | %Outputs: 23 | % x - per data point 24 | % p - proportion vector 25 | 26 | 27 | % Author: Changzhe Jiao, Alina Zare 28 | % University of Missouri, Department of Electrical and Computer Engineering 29 | % Email Address: cjr25@mail.missouri.edu; zarea@missouri.edu 30 | % Created: October, 2013 31 | % Latest Revision: January, 2015 32 | % 33 | % This product is Copyright (c) 2015 University of Missouri 34 | % All rights reserved. 35 | % 36 | % Redistribution and use in source and binary forms, with or without 37 | % modification, are permitted provided that the following conditions 38 | % are met: 39 | % 40 | % 1. Redistributions of source code must retain the above copyright 41 | % notice, this list of conditions and the following disclaimer. 42 | % 2. Redistributions in binary form must reproduce the above copyright 43 | % notice, this list of conditions and the following disclaimer in the 44 | % documentation and/or other materials provided with the distribution. 45 | % 3. Neither the name of the University nor the names of its contributors 46 | % may be used to endorse or promote products derived from this software 47 | % without specific prior written permission. 48 | % 49 | % THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF MISSOURI AND 50 | % CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 51 | % INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 52 | % MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 53 | % DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS 54 | % BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 55 | % EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 56 | % LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, 57 | % LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 58 | % HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 59 | % CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 60 | % OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 61 | % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 62 | 63 | % Setting up parameters 64 | N_b = parameters.N_b; 65 | Pt_mean = parameters.Pt_mean; 66 | sigma = parameters.sigma; 67 | expect_SdB = parameters.expect_SdB; 68 | T=size(E_t,2); 69 | M=size(E_minus,2); 70 | 71 | % generate a true positive target point 72 | if label_bag&&label_point 73 | t=unidrnd(T); 74 | m=unidrnd(M-(N_b-1))+(N_b-1); 75 | 76 | sq_T=randperm(T); 77 | sq_M=randperm(M); 78 | 79 | index_t=sq_T(1:t); 80 | index_m=sq_M(1:m); 81 | 82 | current_pt_mean=Pt_mean(index_t); 83 | 84 | alpha=sigma*[current_pt_mean,((1-sum(current_pt_mean))/m)*ones(1,m)]; 85 | 86 | index_all_endmember=[index_t index_m+T]; 87 | p=zeros(T+M,1); 88 | p(index_all_endmember)=drchrnd(alpha,1); 89 | 90 | current_sig=[E_t E_minus]*p; 91 | 92 | if isnan(expect_SdB) 93 | x=current_sig; 94 | else 95 | x=add_noise_to_dB(current_sig,expect_SdB); 96 | end 97 | 98 | 99 | %generate a non-target point 100 | else 101 | 102 | m=unidrnd(M-(max([N_b 1])-1))+(max([N_b 1])-1); 103 | 104 | alpha=sigma*ones(1,m); 105 | 106 | sq_M=randperm(M); 107 | index_m=sq_M(1:m)+T; 108 | 109 | p=zeros(T+M,1); 110 | p(index_m)=drchrnd(alpha,1); 111 | current_sig=[E_t E_minus]*p; 112 | 113 | if isnan(expect_SdB) 114 | x=current_sig; 115 | else 116 | x=add_noise_to_dB(current_sig,expect_SdB); 117 | end 118 | end 119 | 120 | 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /gen_synthetic_data_code/gen_multi_tar_mixed_data.m: -------------------------------------------------------------------------------- 1 | function [X,P,labels_bag,labels_point,bag_number,data] = gen_multi_tar_mixed_data(E_truth,parameters) 2 | 3 | %This function generates synthetic data set following the definition of multiple instance learning problem 4 | 5 | % REFERENCE : 6 | % C. Jiao, A. Zare, 7 | % Functions of Multiple Instances for Learning Target Signatures, 8 | % IEEE transactions on Geoscience and Remote Sensing, Vol. 53, No. 8, Aug. 2015, DOI: 10.1109/TGRS.2015.2406334 9 | % 10 | % SYNTAX : [X,P,labels_bag,labels_point]=gen_multi_tar_mixed_data(E_t,E_minus,num_pbags,num_nbags,num_points,n_tar,N_b,Pt_mean,sigma,expect_SdB) 11 | 12 | %Inputs: 13 | % E_Truth - array containing all spectra/endmembers [n_dim, n_samps] 14 | % parameters - structure containing parameters to generate synthetic data 15 | 16 | %Outputs: 17 | % X - dataset in column vectors 18 | % P - proportion set in column vectors 19 | % labels_bag - bag level label in column vectors 20 | % labels_point - instance level in column vectors 21 | % bag_number - bag number per in column vectors 22 | % data - Only provided as output if parameters.bagData = 1. Format 23 | % compatiable with MIACE and MTMIACE. Structure that contains two variables: 24 | % dataBags: bagged data 25 | % * a positive bag should have at least one positive instance in it 26 | % * a negative bag should consist of all negative instances 27 | % labels: labels for dataBags 28 | % * the labels should be a row vector with labels corresponding to the 29 | % * parameters.posLabel and parameters.negLabel where a posLabel corresponds 30 | % * to a positive bag and a negLabel corresponds to a negative bag. 31 | % * The index of the label should match the index of the bag in dataBags 32 | 33 | % Author: Changzhe Jiao, Alina Zare 34 | % University of Missouri, Department of Electrical and Computer Engineering 35 | % Email Address: cjr25@mail.missouri.edu; zarea@missouri.edu 36 | % Created: October, 2013 37 | % Latest Revision: January, 2015 38 | % 39 | % This product is Copyright (c) 2015 University of Missouri 40 | % All rights reserved. 41 | % 42 | % Redistribution and use in source and binary forms, with or without 43 | % modification, are permitted provided that the following conditions 44 | % are met: 45 | % 46 | % 1. Redistributions of source code must retain the above copyright 47 | % notice, this list of conditions and the following disclaimer. 48 | % 2. Redistributions in binary form must reproduce the above copyright 49 | % notice, this list of conditions and the following disclaimer in the 50 | % documentation and/or other materials provided with the distribution. 51 | % 3. Neither the name of the University nor the names of its contributors 52 | % may be used to endorse or promote products derived from this software 53 | % without specific prior written permission. 54 | % 55 | % THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF MISSOURI AND 56 | % CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 57 | % INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 58 | % MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 59 | % DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS 60 | % BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 61 | % EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 62 | % LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, 63 | % LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 64 | % HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 65 | % CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 66 | % OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 67 | % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 68 | 69 | % Setting up parameters for synthetic data 70 | num_pbags = parameters.num_pbags; 71 | num_nbags = parameters.num_nbags; 72 | num_points = parameters.num_points; 73 | n_tar = parameters.n_tar; 74 | E_t = E_truth(:, parameters.E_target); 75 | E_minus = E_truth(:, parameters.E_minus); 76 | 77 | % Setting up parameters for outputs 78 | X = []; 79 | P = []; 80 | labels_bag = []; 81 | labels_point = []; 82 | bag_number = []; 83 | 84 | % loop in positive bags 85 | for i=1:num_pbags 86 | 87 | % generate true positive points 88 | for j=1:n_tar 89 | temp_bag_label = 1; 90 | temp_point_label = 1; 91 | [x,p] = gen_individual_LMM_point(E_t,E_minus,temp_bag_label,temp_point_label,parameters); 92 | X(:,(i-1)*num_points+j) = x; 93 | P(:,(i-1)*num_points+j) = p; 94 | bag_number((i-1)*num_points+j) = i; 95 | labels_bag((i-1)*num_points+j) = temp_bag_label; 96 | labels_point((i-1)*num_points+j) = temp_point_label; 97 | end 98 | 99 | % generate false positive points 100 | for j=n_tar+1:num_points 101 | temp_bag_label = 1; 102 | temp_point_label = 0; 103 | [x,p] = gen_individual_LMM_point(E_t,E_minus,temp_bag_label,temp_point_label,parameters); 104 | X(:,(i-1)*num_points+j) = x; 105 | P(:,(i-1)*num_points+j) = p; 106 | bag_number((i-1)*num_points+j) = i; 107 | labels_bag((i-1)*num_points+j) = temp_bag_label; 108 | labels_point((i-1)*num_points+j) = temp_point_label; 109 | end 110 | 111 | end 112 | 113 | %loop in negative bags 114 | for i=num_pbags+1:num_pbags+num_nbags 115 | %generate background points 116 | for j=1:num_points 117 | temp_bag_label = 0; 118 | temp_point_label = 0; 119 | [x,p] = gen_individual_LMM_point(E_t,E_minus,temp_bag_label,temp_point_label,parameters); 120 | X(:,(i-1)*num_points+j) = x; 121 | P(:,(i-1)*num_points+j) = p; 122 | bag_number((i-1)*num_points+j) = i; 123 | labels_bag((i-1)*num_points+j) = temp_bag_label; 124 | labels_point((i-1)*num_points+j) = temp_point_label; 125 | end 126 | end 127 | 128 | if parameters.bagData 129 | % bag the final data set 130 | for i = 1:(parameters.num_nbags + parameters.num_pbags) 131 | data.dataBags{i} = X(:,bag_number == i)'; 132 | data.labels(i) = unique(labels_bag(bag_number == i)); 133 | end 134 | end 135 | 136 | end 137 | 138 | -------------------------------------------------------------------------------- /gen_synthetic_data_code/plotSpectra.m: -------------------------------------------------------------------------------- 1 | function [] = plotSpectra(targets, parameters) 2 | % Function that plots the endmember/spectra used for targets 3 | % if parameters variable is provided it will plot the 1-2 targets selected 4 | % versus background 5 | 6 | if istable(targets) 7 | spectra = table2array(targets(:,2:end)); 8 | wavelength = table2array(targets(:,1)); 9 | labelnames = targets.Properties.VariableNames(2:end); 10 | else 11 | spectra = targets; 12 | load('wavelength.mat'); 13 | labelnames = {}; 14 | end 15 | 16 | % Plot all targets 17 | numSamp = size(spectra,2); 18 | figure(); 19 | hold on 20 | for ii = 1:numSamp 21 | plot(wavelength,spectra(:,ii), 'LineWidth', 1.5); 22 | end 23 | axis([0.4 2.5 0 0.7]); 24 | ylabel('Reflectance'); 25 | xlabel('Wavelength (\mum)'); 26 | legend(labelnames); 27 | title('True Spectra'); 28 | hold off 29 | 30 | if nargin == 2 31 | % Plot selected targets from background 32 | spectraTarget = spectra(:,parameters.E_target); 33 | spectraBG = spectra(:,parameters.E_minus); 34 | numSampTarget = size(spectraTarget,2); 35 | numSampBG = size(spectraBG,2); 36 | figure(); 37 | hold on 38 | for ii = 1:numSampTarget 39 | plot(wavelength,spectraTarget(:,ii), 'color','k', 'LineWidth', 1.5); 40 | end 41 | for ii = 1:numSampBG 42 | plot(wavelength,spectraBG(:,ii), 'color',[0.5 0.5 0.5], 'LineWidth', 1.5); 43 | end 44 | axis([0.4 2.5 0 0.5]); 45 | ylabel('Reflectance'); 46 | xlabel('Wavelength (\mum)'); 47 | text(2.45, 0.48, 'Target','Color','k','HorizontalAlignment','right'); 48 | text(2.45, 0.46, 'Background','Color',[0.5 0.5 0.5],'HorizontalAlignment','right'); 49 | title('True Spectra'); 50 | hold off 51 | end 52 | 53 | end -------------------------------------------------------------------------------- /gen_synthetic_data_code/setParameters.m: -------------------------------------------------------------------------------- 1 | function [parameters] = setParameters() 2 | % A structure containing the parameters for generating a single target and 3 | % two target synthetic dataset. Default variables are set for single 4 | % target synthetic dataset. 5 | 6 | parameters.E_target = 1; % index of target endmember 7 | parameters.E_minus = 2:4; % index of background endmembers 8 | parameters.num_pbags = 2; % No. of positive bag 9 | parameters.num_nbags = 3; % No. of negative bag 10 | parameters.num_points = 1000; % No. of points in each bag 11 | parameters.n_tar = 250; % No. of target points in each positive bag 12 | parameters.N_b = 0; % minimum No. of background constituent background endmember in target point 13 | parameters.Pt_mean = 0.55; % mean target porportion value in target points 14 | parameters.sigma = 1; % parameter controlling variance of Dirichlet distribution 15 | parameters.expect_SdB = 10; % data noise level 16 | parameters.bagData = 1; % 0 = do not bag data, returns data as array 17 | % 1 = bag data, returns as a cell array structure 18 | end 19 | 20 | -------------------------------------------------------------------------------- /synthetic_data/E_truth.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GatorSense/Hyperspectral_Data_Simulation/d0e8bedd71201e47e990e8ae501aafec5bede45a/synthetic_data/E_truth.mat -------------------------------------------------------------------------------- /synthetic_data/highly_mixed_data_pt_03.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GatorSense/Hyperspectral_Data_Simulation/d0e8bedd71201e47e990e8ae501aafec5bede45a/synthetic_data/highly_mixed_data_pt_03.mat -------------------------------------------------------------------------------- /synthetic_data/highly_mixed_data_pt_05.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GatorSense/Hyperspectral_Data_Simulation/d0e8bedd71201e47e990e8ae501aafec5bede45a/synthetic_data/highly_mixed_data_pt_05.mat -------------------------------------------------------------------------------- /synthetic_data/highly_mixed_data_pt_07.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GatorSense/Hyperspectral_Data_Simulation/d0e8bedd71201e47e990e8ae501aafec5bede45a/synthetic_data/highly_mixed_data_pt_07.mat -------------------------------------------------------------------------------- /synthetic_data/noisy_data_SNR_10.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GatorSense/Hyperspectral_Data_Simulation/d0e8bedd71201e47e990e8ae501aafec5bede45a/synthetic_data/noisy_data_SNR_10.mat -------------------------------------------------------------------------------- /synthetic_data/noisy_data_SNR_20.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GatorSense/Hyperspectral_Data_Simulation/d0e8bedd71201e47e990e8ae501aafec5bede45a/synthetic_data/noisy_data_SNR_20.mat -------------------------------------------------------------------------------- /synthetic_data/noisy_data_SNR_30.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GatorSense/Hyperspectral_Data_Simulation/d0e8bedd71201e47e990e8ae501aafec5bede45a/synthetic_data/noisy_data_SNR_30.mat -------------------------------------------------------------------------------- /synthetic_data/noisy_data_SNR_40.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GatorSense/Hyperspectral_Data_Simulation/d0e8bedd71201e47e990e8ae501aafec5bede45a/synthetic_data/noisy_data_SNR_40.mat -------------------------------------------------------------------------------- /synthetic_data/originalData.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GatorSense/Hyperspectral_Data_Simulation/d0e8bedd71201e47e990e8ae501aafec5bede45a/synthetic_data/originalData.mat -------------------------------------------------------------------------------- /synthetic_data/random_data.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GatorSense/Hyperspectral_Data_Simulation/d0e8bedd71201e47e990e8ae501aafec5bede45a/synthetic_data/random_data.mat -------------------------------------------------------------------------------- /synthetic_data/wavelength.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GatorSense/Hyperspectral_Data_Simulation/d0e8bedd71201e47e990e8ae501aafec5bede45a/synthetic_data/wavelength.mat --------------------------------------------------------------------------------