function code = generate_code(data)
%
% generate_code.m for EE368 project, Spring 2006
%
% Embed 83 bits of data in the 2-D code marker
%   data: 1-by-83, composed of 0's and 1's
%   code marker: 11-by-11, composed of 0's and 1's
%         0 and 1 correspond to white and black dots respectively

code = [ ...
    1 0 2 2 2 2 2 2 2 0 1; ...
    0 0 2 2 2 2 2 2 2 0 0; ...
    2 2 2 2 2 2 2 2 2 0 1; ...
    2 2 2 2 2 2 2 2 2 0 1; ...
    2 2 2 2 2 2 2 2 2 0 1; ...
    2 2 2 2 2 2 2 2 2 0 1; ...
    2 2 2 2 2 2 2 2 2 0 1; ...
    2 2 2 2 2 2 2 2 2 0 1; ...
    2 2 2 2 2 2 2 2 2 0 1; ...
    0 0 2 2 2 0 0 0 0 0 0; ...
    1 0 2 2 2 0 1 1 1 1 1];

code(find(code==2)) = data;
figure; imagesc(~code); colormap gray; axis equal; axis off;