function maxima = getMaxima (harrisResponse, neighborhood, responseTreshold, mask)
  if (nargin < 2) neighborhood = 1; end;
  if (nargin < 3) responseTreshold = 0.001; end;
  if (nargin < 4) mask = ones (size (harrisResponse)); end;

  ignoredImageBorder = 10;
  if (ignoredImageBorder <= neighborhood) ignoredImageBorder = neighborhood + 1; end;

%  assert (size (harrisResponse, 1) == size (mask, 1) & size (harrisResponse, 2) == size (mask, 2));

  maxima = [];
  [yIndices, xIndices] = find (harrisResponse >= responseTreshold & mask);
  i = (yIndices > ignoredImageBorder & yIndices < size (harrisResponse, 1) - ignoredImageBorder & xIndices > ignoredImageBorder & xIndices < size (harrisResponse, 2) - ignoredImageBorder);
  yIndices = yIndices (i);
  xIndices = xIndices (i);

  for i = 1 : length (yIndices)
      y = yIndices (i);
      x = xIndices (i);

      ring = harrisResponse (y - neighborhood : y + neighborhood, x - neighborhood : x + neighborhood);
      ring (1 + neighborhood, 1 + neighborhood) = 0;
      if harrisResponse (y, x) > max (max (ring))
          maxima = [ maxima; x, y, harrisResponse(y, x)];
      end;
  end;

  maxima = abs (sortrows ([maxima(:,1:2) -maxima(:,3)], 3));

return