Mercurial > hg > octave-image
changeset 692:df1ce9178886
strel:
* @strel/getneighbors: fix typo on filename
* @strel/getneighbors: use nnz, not sum
* @strel/reflect: always reflect height to prevent future bugs
if case we decide to keep the height
* @strel/display: use printf when there's no FID
author | carandraug |
---|---|
date | Wed, 19 Dec 2012 11:12:20 +0000 (2012-12-19) |
parents | 199c5cf48f51 |
children | f33550d36273 |
files | inst/@strel/display.m inst/@strel/getneighbors.m inst/@strel/getneightbors.m inst/@strel/reflect.m |
diffstat | 4 files changed, 46 insertions(+), 47 deletions(-) [+] |
line wrap: on
line diff
--- a/inst/@strel/display.m +++ b/inst/@strel/display.m @@ -22,8 +22,7 @@ function display (SE) - % Some elaborations - P = sum(SE.nhood(:) == 1); + P = nnz (SE.nhood); if (SE.flat) flatstr = "Flat"; else @@ -35,14 +34,16 @@ plural_p = ""; endif - % Output - fprintf ("%s = \n", inputname(1)); - fprintf (" %s strel object with %d neighbor%s\n\n", flatstr, P, plural_p); - fprintf (" Neighborhood:\n"); + ## FIXME using inputname won't work when SE is a field in a struct or in a + ## cell array. Not only won't get the correct name sometimes, it may + ## also mess up the display of nested structures. + printf ("%s = \n", inputname (1)); + printf (" %s STREL object with %d neighbor%s\n\n", flatstr, P, plural_p); + printf (" Neighborhood:\n"); display (SE.nhood); if (!SE.flat) - fprintf (" Height:\n"); + printf (" Height:\n"); display (SE.height); endif -endfunction \ No newline at end of file +endfunction
new file mode 100644 --- /dev/null +++ b/inst/@strel/getneighbors.m @@ -0,0 +1,34 @@ +## Copyright (C) 2012 Roberto Metere <roberto@metere.it> +## +## 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} {[@var{offsets}, @var{heights}] =} getneighbors (@var{SE}) +## For each neighbor in structuring element, return the relative position and height. +## +## If P is the number of neighbors in SE, @var{offsets} are relative position +## from the center of the structuring element to them, of which heights are +## stored in corresponding columns of the array @var{heights}. +## @var{offsets} is an array with P rows and 2 columns, the first for the row +## offset, the second for the column offset. +## +## @seealso{getnhood, getheight, strel} +## @end deftypefn + +function [offsets, heights] = getneighbors (SE) + + error ("getneighbors: not yet implemented"); + P = nnz (SE.nhood); + +endfunction
deleted file mode 100644 --- a/inst/@strel/getneightbors.m +++ /dev/null @@ -1,34 +0,0 @@ -## Copyright (C) 2012 Roberto Metere <roberto@metere.it> -## -## 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} {[@var{offsets}, @var{heights}] =} getneighbors (@var{SE}) -## For each neighbor in structuring element, return the relative position and height. -## -## If P is the number of neighbors in SE, @var{offsets} are relative position -## from the center of the structuring element to them, of which heights are -## stored in corresponding columns of the array @var{heights}. -## @var{offsets} is an array with P rows and 2 columns, the first for the row -## offset, the second for the column offset. -## -## @seealso{getnhood, getheight, strel} -## @end deftypefn - -function [offsets, heights] = getneighbors (SE) - - error ("getneighbors: not yet implemented"); - P = sum(SE.nhood(:) == 1); - -endfunction \ No newline at end of file
--- a/inst/@strel/reflect.m +++ b/inst/@strel/reflect.m @@ -27,9 +27,7 @@ function SE2 = reflect (SE) SE2 = SE; - SE2.nhood = rotdim(SE.nhood, 2); - if (!SE2.flat) - SE2.height = rotdim(SE.height, 2); - endif + SE2.nhood = rotdim (SE.nhood, 2); + SE2.height = rotdim (SE.height, 2); -endfunction \ No newline at end of file +endfunction