function [corners_x,corners_y]=combine_four_grids(format)

%Fred Cross June 29 2016  The Rockefeller University

%assume have 9 anchor points: 4 corners, 4 mid-edges, 1 center. matrix is 
%% draw four closed boxes with gridlines and fuse them. xcoords in fist page, ycoords in 2nd page


%all coords are x,y (i.e. column row) in each row

global ninespots;

TL=ninespots{1,1};
TM=ninespots{1,2};
TR=ninespots{1,3};

ML=ninespots{2,1};
MM=ninespots{2,2};
MR=ninespots{2,3};

BL=ninespots{3,1};
BM=ninespots{3,2};
BR=ninespots{3,3};


tl=TL;
tr=TM;
bl=ML;
br=MM;

[tl_corners_x,tl_corners_y]=get_all_corners_v2(tl,tr,bl,br,format);


  tl=TM;
  bl=MM;
  tr=TR;
  br=MR;
  
[tr_corners_x,tr_corners_y]=get_all_corners_v2(tl,tr,bl,br,format);

  tl=MM;
  bl=BM;
  tr=MR;
  br=BR;
  
[br_corners_x,br_corners_y]=get_all_corners_v2(tl,tr,bl,br,format);

 tl=ML;
  bl=BL;
  tr=MM;
  br=BM;

[bl_corners_x,bl_corners_y]=get_all_corners_v2(tl,tr,bl,br,format);

    top_x=[tl_corners_x(:,1:end-1),(tl_corners_x(:,end)+tr_corners_x(:,1))/2,...
        tr_corners_x(:,2:end)];
    
    top_y=[tl_corners_y(:,1:end-1),(tl_corners_y(:,end)+tr_corners_y(:,1))/2,...
        tr_corners_y(:,2:end)];

    bottom_x=[bl_corners_x(:,1:end-1),(bl_corners_x(:,end)+br_corners_x(:,1))/2,...
        br_corners_x(:,2:end)];
    
    bottom_y=[bl_corners_y(:,1:end-1),(bl_corners_y(:,end)+br_corners_y(:,1))/2,...
        br_corners_y(:,2:end)];
    
    corners_x=[top_x(1:end-1,:);(top_x(end,:)+bottom_x(1,:))/2;bottom_x(2:end,:)];
    corners_y=[top_y(1:end-1,:);(top_y(end,:)+bottom_y(1,:))/2;bottom_y(2:end,:)];
    
    