[grid_x1,grid_x2,grid_x3,grid_x4,grid_y1,grid_y2,grid_y3,grid_y4]=splitmatrix_par(grid_x,grid_y);

function [grid_x1,grid_x2,grid_x3,grid_x4,grid_y1,grid_y2,grid_y3,grid_y4]=splitmatrix_par(grid_x,grid_y);
% This functions splits up the grid_x and the grid_y matrix of markers
% created by grid_generator.m into 4 pieces. You can now start automate_image_parinteractive.m
% started in pmode to use four cores or processors.
% After processiong all images automate_image_parinteractive.m will merge matrices to get validx
% and validy saved to the current directory.
if exist('grid_x')==0;
load('grid_x.dat');
end
if exist('grid_y')==0;
load('grid_y.dat');
end
gridx=reshape(grid_x,[],1);
gridy=reshape(grid_y,[],1);
[gridlength gridwidth]=size(gridx);
grid_x1=gridx(1:round(gridlength/4),1);
grid_x2=gridx((round(gridlength/4)+1):(round(gridlength/4)*2),1);
grid_x3=gridx((round(gridlength/4)*2+1):(round(gridlength/4)*3),1);
grid_x4=gridx((round(gridlength/4)*3+1):gridlength,1);
grid_y1=gridy(1:round(gridlength/4),1);
grid_y2=gridy((round(gridlength/4)+1):(round(gridlength/4)*2),1);
grid_y3=gridy((round(gridlength/4)*2+1):(round(gridlength/4)*3),1);
grid_y4=gridy((round(gridlength/4)*3+1):(gridlength),1);

