% MATLAB code to generate the random points: % function fSegment_generate(ROI, EPSFilename, EPSSize) if nargin < 1; ROI = [0 1 0 1]; end; if nargin < 2; EPSFilename = ''; end; if nargin < 3; EPSSize = [2 2]; end; RANDSTATE=rand('state'); rand('seed',42); R=15; V=1/(2*R); n=0:1/(R+1):1; xymin=[3/8 1/4]; xymax=[7/8 5/8]; LL=1/28; LineWidth = 1; [x,y]=meshgrid(n); p = [x(:) y(:)]; o = ones(size(p,1),1); pn = min(p >= (o * xymin), [], 2) & min(p <= (o * xymax), [], 2); p(~pn,:) = p(~pn,:) + V*(rand(size(p(~pn,:)))-0.5); r = rand(size(p,1),1) >= 0.5; r(pn) = 2; pos = [p r]; fignum = gcf; clf; hold on; for i=1:size(pos,1) switch pos(i,3) case 0, h=plot(pos(i,1) + [-LL LL], pos(i,2) + [-LL LL], 'k'); case 1, h=plot(pos(i,1) + [-LL LL], pos(i,2) + [LL -LL], 'k'); case 2, h1=plot(pos(i,1) + [-LL LL]/2, pos(i,2) + [-LL LL]/2, 'k'); h2=plot(pos(i,1) + [-LL LL]/2, pos(i,2) + [LL -LL]/2, 'k'); h=[h1; h2]; end for j=1:size(h,1) set(h(j), 'LineWidth', LineWidth); end end h=plot([ROI(1) ROI(1) ROI(2) ROI(2) ROI(1)], [ROI(3) ROI(4) ROI(4) ROI(3) ROI(3)], 'k-'); for j=1:size(h,1) set(h, 'LineWidth', 2*LineWidth); end axis(ROI); axis off; hold off; rand('state',RANDSTATE); %%% %%% the second argument was nonzero, print the EPS files %%% if length(EPSFilename) > 0 set(fignum, 'PaperPosition', [0 0 EPSSize]); fprintf('Figure %d written to file %s\n',fignum,EPSFilename); print(fignum,'-deps2',EPSFilename); end