function out = MakeChessBoard( x, y, N )

[nr,nc] = size( x );
out = zeros( nr, nc );

nnr = floor( nr/N );
nnc = floor( nc/N );

out = x;
rr = 0;
for r = 1:N:nr-N,
    rr = rr + 1;
    for c = 1:2*N:nc-N,
        if rem( rr, 2 )
           out( min(nr,r:r+N), min(nc,c:c+N) ) = y( min(nr,r:r+N), min(nc,c:c+N) );
        else
           out( min(nr,r:r+N), min(c+N:c+2*N,nc) ) = y( r:r+N, min(c+N:c+2*N,nc) );
        end
    end
end

% imshow( out, [] );

