function x = findMaxima (image, nMaxima, minDist)
% x = findMaxima (image, nMaxima, minDist)
%
% funkce pro nalezeni nekolika maxim v obrazku, 
% pricemz zadna dve nesmi mit k sobe blize nez minDist

s = sort (image(:));
i = length (s);
n = 0;
found = zeros (nMaxima,2);

while i > 0 & n < nMaxima
   [y, x] = find (image == s(i));
   for f = 1 : length (y);
      ok = 1;
      for m = 1 : n
         if sum ((found(m,:) - [y(f) x(f)]).^2) < minDist^2
            ok = 0;
         end;
      end;
      if ok
         n = n + 1;
         found(n,:) = [y(f) x(f)];
      end;
   end;
   i = i - 1;
end;

x = found (1:n, 1:2);