From: <car...@us...> - 2011-12-05 04:41:06
|
Revision: 9270 http://octave.svn.sourceforge.net/octave/?rev=9270&view=rev Author: carandraug Date: 2011-12-05 04:40:59 +0000 (Mon, 05 Dec 2011) Log Message: ----------- isind: * big rewrite of function based on code from isgray * now returns false if argument is empty matrix * improved help text * upgrade license to GPLv3+ Modified Paths: -------------- trunk/octave-forge/main/image/inst/isind.m Modified: trunk/octave-forge/main/image/inst/isind.m =================================================================== --- trunk/octave-forge/main/image/inst/isind.m 2011-12-05 04:20:50 UTC (rev 9269) +++ trunk/octave-forge/main/image/inst/isind.m 2011-12-05 04:40:59 UTC (rev 9270) @@ -1,8 +1,9 @@ -## Copyright (C) 2000 Kai Habel +## Copyright (C) 2000 Kai Habel <kai...@gm...> +## Copyright (C) 2011 Carnë Draug <car...@gm...> ## ## 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 2 of the License, or +## 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, @@ -14,26 +15,49 @@ ## along with this program; if not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} @var{bool}= isind (@var{X}) -## Returns true for an index image. All index values must -## be intergers and greater than or equal to 1. +## @deftypefn {Function File} @var{bool} = isind (@var{img}) +## Return true if @var{img} is a RGB image. +## +## A variable is considereed to be an indexed image if it is 2-dimensional, +## non-sparse matrix and: +## @itemize @bullet +## @item is of class double and all values are integers greater than or equal to 1; +## @item is of class uint8 or uint16. +## @end itemize +## +## Note that indexed time-series image have 4 dimensions (NxMx1xtime) but +## isind will still return false. +## @seealso{isbw, isgray, isrgb} ## @end deftypefn -## Author: Kai Habel <kai...@gm...> -## Date: 20/03/2000 +function bool = isind (img) -function ret = isind (X) + if (nargin != 1) + print_usage; + endif - if nargin != 1 - usage ("isind(X)"); + bool = false; + if (ismatrix (img) && ndims (img) == 2 && !issparse (img) && isreal (img) && !isempty (img)) + switch (class (img)) + case "double" + ## to speed this up, we can look at a sample of the image first + bool = is_ind_double (img(1:ceil (rows (img) /100), 1:ceil (columns (img) /100))); + if (bool) + ## sample was true, we better make sure it's real + bool = is_ind_double (img); + endif + case {"uint8", "uint16"} + bool = true; + endswitch endif - ret = isreal (X) && length (size (X)) == 2 ... - && all ( X(:) == floor (X(:)) ) && all ( X(:) >= 1 ); +endfunction +function bool = is_ind_double (img) + bool = all (img(:) == fix (img(:))) && all (img(:) >= 1); endfunction -%!assert(isind([])) +%!fail(isind([])) ## should fail for empty matrix %!assert(isind(1:10)) %!assert(!isind(0:10)) %!assert(isind(1)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-04-11 14:57:41
|
Revision: 10190 http://octave.svn.sourceforge.net/octave/?rev=10190&view=rev Author: carandraug Date: 2012-04-11 14:57:31 +0000 (Wed, 11 Apr 2012) Log Message: ----------- isind: fix small mistake on help text Modified Paths: -------------- trunk/octave-forge/main/image/inst/isind.m Modified: trunk/octave-forge/main/image/inst/isind.m =================================================================== --- trunk/octave-forge/main/image/inst/isind.m 2012-04-11 14:08:27 UTC (rev 10189) +++ trunk/octave-forge/main/image/inst/isind.m 2012-04-11 14:57:31 UTC (rev 10190) @@ -16,7 +16,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} @var{bool} = isind (@var{img}) -## Return true if @var{img} is a RGB image. +## Return true if @var{img} is an indexed image. ## ## A variable is considereed to be an indexed image if it is 2-dimensional, ## non-sparse matrix and: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-09-02 02:44:29
|
Revision: 10944 http://octave.svn.sourceforge.net/octave/?rev=10944&view=rev Author: carandraug Date: 2012-09-02 02:44:23 +0000 (Sun, 02 Sep 2012) Log Message: ----------- isind: use shared private functions for checks Modified Paths: -------------- trunk/octave-forge/main/image/inst/isind.m Modified: trunk/octave-forge/main/image/inst/isind.m =================================================================== --- trunk/octave-forge/main/image/inst/isind.m 2012-09-02 02:37:12 UTC (rev 10943) +++ trunk/octave-forge/main/image/inst/isind.m 2012-09-02 02:44:23 UTC (rev 10944) @@ -37,15 +37,12 @@ endif bool = false; - if (ismatrix (img) && ndims (img) == 2 && !issparse (img) && isreal (img) && !isempty (img)) + if (!isimage (img)) + bool = false; + elseif (ndims (img) == 2 && isreal (img)) switch (class (img)) case "double" - ## to speed this up, we can look at a sample of the image first - bool = is_ind_double (img(1:ceil (rows (img) /100), 1:ceil (columns (img) /100))); - if (bool) - ## sample was true, we better make sure it's real - bool = is_ind_double (img); - endif + bool = ispart (@is_ind_double, img); case {"uint8", "uint16"} bool = true; endswitch This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-09-02 02:48:36
|
Revision: 10945 http://octave.svn.sourceforge.net/octave/?rev=10945&view=rev Author: carandraug Date: 2012-09-02 02:48:30 +0000 (Sun, 02 Sep 2012) Log Message: ----------- isind: use builtin function isindex Modified Paths: -------------- trunk/octave-forge/main/image/inst/isind.m Modified: trunk/octave-forge/main/image/inst/isind.m =================================================================== --- trunk/octave-forge/main/image/inst/isind.m 2012-09-02 02:44:23 UTC (rev 10944) +++ trunk/octave-forge/main/image/inst/isind.m 2012-09-02 02:48:30 UTC (rev 10945) @@ -42,7 +42,7 @@ elseif (ndims (img) == 2 && isreal (img)) switch (class (img)) case "double" - bool = ispart (@is_ind_double, img); + bool = isindex (img); case {"uint8", "uint16"} bool = true; endswitch @@ -50,10 +50,6 @@ endfunction -function bool = is_ind_double (img) - bool = all (img(:) == fix (img(:))) && all (img(:) >= 1); -endfunction - %!fail(isind([])) ## should fail for empty matrix %!assert(isind(1:10)) %!assert(!isind(0:10)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-09-02 03:32:27
|
Revision: 10947 http://octave.svn.sourceforge.net/octave/?rev=10947&view=rev Author: carandraug Date: 2012-09-02 03:32:21 +0000 (Sun, 02 Sep 2012) Log Message: ----------- isind: also check part first for speedup Modified Paths: -------------- trunk/octave-forge/main/image/inst/isind.m Modified: trunk/octave-forge/main/image/inst/isind.m =================================================================== --- trunk/octave-forge/main/image/inst/isind.m 2012-09-02 03:17:47 UTC (rev 10946) +++ trunk/octave-forge/main/image/inst/isind.m 2012-09-02 03:32:21 UTC (rev 10947) @@ -42,7 +42,7 @@ elseif (ndims (img) == 2) switch (class (img)) case "double" - bool = isindex (img); + bool = ispart (@isindex, img); case {"uint8", "uint16"} bool = true; endswitch This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |