function matrix2=box2d(matrix1,n)
%function matrix2=box2d(matrix1,n)
%            2 dimensional boxcar
matrix2=boxfilt(matrix1(:),n);
matrix2=remat(matrix2,matrix1);
matrix2=matrix2';
matrix2=boxfilt(matrix2(:),n);
matrix2=remat(matrix2,matrix1');
matrix2=matrix2';
[imax,jmax]=size(matrix1);
for i=0:floor(n/2)-1;
	matrix2(1+i,:)=ones(matrix1(1,:))*nan;
	matrix2(imax-i,:)=matrix2(1,:);
	matrix2(:,1+i)=ones(matrix1(:,1))*nan;
	matrix2(:,jmax-i)=matrix2(:,1);
end
