PARA=struct('east_min',1653166,'east_max',1655165,'north_min',7367489,...
    'north_max',7370488,'n_rows',3000,'n_cols',2000,'r',10);
east_min=1653166;
east_max=1655165;
north_min=7367489;
north_max=7370488;
min_target=35;
rad=10;
n_rows=3000;
n_cols=2000;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% r=7;    %Window size = 2*r+1
thresh_1=0.25;  %pixels with intensity smaller than thresh_1 
                %will be set to 0 directly
theta=0:15:180;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dim=(2*r+1)^2;
nb_targ=2;
PA=[1653166 1655165 7367489 7370488 3000 2000 r];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%average filter
nh=5;
h=ones(nh,nh)/(nh^2);
nborder=round((nh-1)/2);




% reference order the paper used
refm1=[3 4 5 3 4 5             %(ref 1)
      4 5 2 4 5 2
      5 2 3 5 2 3
      2 3 4 2 3 4];

% other references
refm2=[4 5 3 4 5 3             %(ref 2)
      5 2 4 5 2 4
      2 3 5 2 3 5
      3 4 2 3 4 2];
refm3=[5 3 4 5 3 4               %(ref 3)
      2 4 5 2 4 5
      3 5 2 3 5 2
      4 2 3 4 2 3];

mis=3; pas=5;

refm=refm1;
Learning_MV;
weight1=WEIGHT;
xtarg1=xtarg;
xback1=xback;
x_targ1=x1;
x_back1=x2;
fn=sprintf('learned_wnd%d_ref1.mat',2*r+1);
save(fn,'weight1','xtarg1','xback1','x_targ1','x_back1');

refm=refm2;
Learning_MV;
weight2=WEIGHT;
xtarg2=xtarg;
xback2=xback;
x_targ2=x1;
x_back2=x2;
fn=sprintf('learned_wnd%d_ref2.mat',2*r+1);
save(fn,'weight2','xtarg2','xback2','x_targ2','x_back2');

refm=refm3;
Learning_MV;
weight3=WEIGHT;
xtarg3=xtarg;
xback3=xback;
x_targ3=x1;
x_back3=x2;
fn=sprintf('learned_wnd%d_ref3.mat',2*r+1);
save(fn,'weight3','xtarg3','xback3','x_targ3','x_back3');