leonmakise's picture
Upload 4 files
18ac00c verified
%% This is a demo code to show how to generate training and testing samples from the HSI %%
clc
clear
close all
addpath('include');
%% Step 1: generate the training and testing images from the original HSI
load('Houston2018.mat');%% Please down the Chikusei dataset (mat format) from https://www.sal.t.u-tokyo.ac.jp/hyperdata/
%% center crop this image to size 4172 x 1202
img = Houston2018;
clear Houston2018;
% normalization
img = single(img);
img = img ./ max(max(max(img)));
%% select first column as test images
[H, W, C] = size(img);
test_img_size = 256;
test_pic_num = floor(W / test_img_size);
mkdir test_Houston;
for i = 1:test_pic_num
left = (i - 1) * test_img_size + 1;
right = left + test_img_size - 1;
test = img(1:test_img_size,left:right,:);
save(strcat('./test_Houston/Houston_test_', int2str(i), '.mat'),'test');
end
%% the rest bottom for training
mkdir ('train_Houston');
img = img((test_img_size+1):end,:,:);
save('./train_Houston/Houston_train.mat', 'img');
%% Step 2: generate the testing images used in mains.py
generate_test_data;
%% Step 3: generate the training samples (patches) cropped from the training images
generate_train_data;
%% Step 4: Please manually remove 10% of the samples to the folder of evals