/usr/share/octave/packages/image-2.4.1/imregionalmin.m is in octave-image 2.4.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | ## Copyright (C) 2014 Carnë Draug <carandraug@octave.org>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 3 of the
## License, or (at your option) any later version.
##
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, see
## <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
## @deftypefn {Function File} {} imregionalmin (@var{img})
## @deftypefnx {Function File} {} imregionalmin (@var{img}, @var{conn})
## Compute regional minima.
##
## Returns a logical matrix, same size as the input @var{img}, with the
## regional minima.
##
## The optional argument @var{conn}, defines the connectivity. It can
## be a scalar value or a boolean matrix (see @code{conndef} for details).
## Defaults to @code{conndef (ndims (@var{img}), "maximal")}
##
## Regional minima should not be mistaken with local minima. Local minima
## are pixels whose value is less or equal to all of its neighbors.
## A regional minima is the connected component of pixels whose values are
## all less than the neighborhood of the minima (the connected component,
## not its individual pixels).
## All pixels belonging to a regional minima are local minima, but the
## inverse is not true.
##
## @seealso{imreconstruct, imregionalmax}
## @end deftypefn
function bw = imregionalmin (img, conn)
if (nargin < 1 || nargin > 2)
print_usage ();
endif
if (nargin < 2)
conn = conndef (ndims (img), "maximal");
else
conn = conndef (conn);
endif
if (isfloat (img))
img = - img;
else
img = imcomplement (img);
endif
if (islogical (img))
bw = img;
else
## we could probably still make this more efficient
recon = imreconstruct (img, img + 1, conn);
bw = (recon == img);
endif
endfunction
%!test
%! a = [
%! 7 3 9 3 10 3
%! 4 2 3 10 1 3
%! 1 4 6 9 4 10
%! 8 7 9 3 4 8
%! 5 9 3 3 8 9
%! 3 6 9 4 1 10];
%!
%! a4 = logical ([
%! 0 0 0 1 0 0
%! 0 1 0 0 1 0
%! 1 0 0 0 0 0
%! 0 0 0 1 0 0
%! 0 0 1 1 0 0
%! 1 0 0 0 1 0]);
%! assert (imregionalmin (a, 4), a4)
%! assert (imregionalmin (uint8 (a), 4), a4)
%! assert (imregionalmin (int8 (a), 4), a4)
%!
%! a8 = logical ([
%! 0 0 0 0 0 0
%! 0 0 0 0 1 0
%! 1 0 0 0 0 0
%! 0 0 0 0 0 0
%! 0 0 0 0 0 0
%! 1 0 0 0 1 0]);
%! assert (imregionalmin (a), a8)
%! assert (imregionalmin (a, 8), a8)
%! assert (imregionalmin (uint8 (a), 8), a8)
%! assert (imregionalmin (int8 (a), 8), a8)
%!test
%! a = [
%! 4 8 5 -1 8 7
%! -1 4 0 7 1 1
%! 6 1 2 6 7 0
%! 6 1 5 -2 5 9
%! 1 4 -1 0 0 2
%! 4 6 1 0 7 1];
%!
%! a4 = logical ([
%! 0 0 0 1 0 0
%! 1 0 1 0 0 0
%! 0 1 0 0 0 1
%! 0 1 0 1 0 0
%! 1 0 1 0 0 0
%! 0 0 0 0 0 1]);
%! assert (imregionalmin (a, 4), a4)
%! assert (imregionalmin (int8 (a), 4), a4)
%!
%! a8 = logical ([
%! 0 0 0 1 0 0
%! 1 0 0 0 0 0
%! 0 0 0 0 0 1
%! 0 0 0 1 0 0
%! 0 0 0 0 0 0
%! 0 0 0 0 0 0]);
%! assert (imregionalmin (a), a8)
%! assert (imregionalmin (a, 8), a8)
%! assert (imregionalmin (int8 (a), 8), a8)
|