From: <car...@us...> - 2011-12-05 03:59:50
|
Revision: 9267 http://octave.svn.sourceforge.net/octave/?rev=9267&view=rev Author: carandraug Date: 2011-12-05 03:59:44 +0000 (Mon, 05 Dec 2011) Log Message: ----------- isbw: check sample of image first to speed up computation Modified Paths: -------------- trunk/octave-forge/main/image/inst/isbw.m Modified: trunk/octave-forge/main/image/inst/isbw.m =================================================================== --- trunk/octave-forge/main/image/inst/isbw.m 2011-12-05 01:22:06 UTC (rev 9266) +++ trunk/octave-forge/main/image/inst/isbw.m 2011-12-05 03:59:44 UTC (rev 9267) @@ -44,7 +44,7 @@ bool = islogical (BW); ## the following block is just temporary to keep backwards compatibility - if (!islogical (BW) && all (all ((BW == 1) + (BW == 0)))) + if (!islogical (BW) && is_bw_nonlogical (BW)) persistent warned = false; if (! warned) warned = true; @@ -56,7 +56,16 @@ ## end of temporary block for backwards compatibility elseif (strcmpi (logic, "non-logical")) - bool = all (all ((BW == 1) + (BW == 0))); + ## to speed this up, we can look at a sample of the image first + bool = is_bw_nonlogical (BW(1:ceil (rows (BW) /100), 1:ceil (columns (BW) /100))); + if (bool) + ## sample was true, we better make sure it's real + bool = is_bw_nonlogical (BW); + endif endif endfunction + +function bool = is_bw_nonlogical (BW) + bool = all (all ((BW == 1) + (BW == 0))); +endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |