function len = plen2( im, base, center, step );

%
% len = plen2( im, base, center, step )
%
% Calculates the lengths in of the binary
% image im with center of mass m in the directions of
% n*step starting from the first base
% direction and going through all the angles which
% are in the distance of step from each other from
% 0 to 2*pi
% in the orthonormal base.
%

b = base(1:2,1);
imsiz = size(im);
cnt = round(2*pi/step)-1;
len = zeros(1,cnt+1);

for i=0:cnt,
  angle = i*step;
  n = 0;
  place = round(center);
  u = [ cos(angle)*b(1)-sin(angle)*b(2); ...
        sin(angle)*b(1)+cos(angle)*b(2) ];
  while ( im(place(1),place(2)) ~= 0 ) & ( place(1) <= imsiz(1) ) ...
          & ( place(2) <= imsiz(2) ),
    n=n+1;
    place = round(center+n*u);
    if (place(1) > imsiz(1)) | (place(1) < 1),
      break;
    end
    if (place(2) > imsiz(2)) | (place(2) < 1),
      break;
    end
  end
  len(1,i+1) = n;
end
