%% demo LORSAL_MLL_AS: Hyperspectral segmentation  for the AVIRIS Indian
%% Pines dataset 

close all
clear all
clc

% load the training set
load AVIRIS_Indiana_16class
load imgreal;

img = ToVector(img);
img = img';

% discard noisy bands  
img([104:108 150:163 220],:) =[];
trainall = trainall';

% randomly select the training set
indexes=train_test_random_new(trainall(2,:),10,160);  
train = trainall(:,indexes);
% the remaining samples used as the  test set
test = trainall;
test(:,indexes)=[];

% load the ground truth image
open('AVIRISindian16classtrue.fig')
mycmap = get(figure(1),'Colormap');

% arrange the image struct
img = struct('im',img,'size',[145 145],'mycolormap',mycmap);

% arrange the AL_sampling struct
AL_method = 'MBT';
candidate = test;
U = 100;
u = 20;
AL_sampling = struct('AL_method',AL_method,'candidate',candidate,'U',U,'u',u);

% implement 
[class_results,seg_results] = LORSAL_MLL_AS(img,train,test,[],[],[],AL_sampling);
