Monday, 15 February 2010

image - How to draw repeating straight lines with specific radius and angle in matlab? -



image - How to draw repeating straight lines with specific radius and angle in matlab? -

suppose draw image following:

where pixel values refined 0 black , white 1. these line drawn specific radius , angles

now create 80 x 160 matrix texturematrix = zeros(80,160);

then want alter particular elements 1 according lines conditions how create them repeatedly specific distance apart each others effectively? lot everyone!

this might not looking for, generating such image done plotting set of lines, follows:

% grid sizes m = 6; n = 5; % line length , angle len = 1; theta = .1*pi; [a,b] = meshgrid(1:m,1:n); x = reshape([a(:),a(:)+len*cos(theta),nan(numel(a),1)]',[],1); y = reshape([b(:),b(:)+len*sin(theta),nan(numel(b),1)]',[],1); h = figure(); plot(x,y,'k', 'linewidth', 2);

but has nil texture matrix. so, build matrix of desired size:

set(gca, 'position',[0 0 1 1], 'units','normalized', 'ytick',[], 'xtick',[]); frame = frame2im(getframe(h),[0 0 1 1]); im = imresize(frame,[80 160]); m = ~(im(2:end,2:end,1)==255);

image matlab plot

No comments:

Post a Comment