From: <car...@us...> - 2012-09-02 03:34:02
|
Revision: 10948 http://octave.svn.sourceforge.net/octave/?rev=10948&view=rev Author: carandraug Date: 2012-09-02 03:33:55 +0000 (Sun, 02 Sep 2012) Log Message: ----------- isrgb: use shared private functions for checks Modified Paths: -------------- trunk/octave-forge/main/image/inst/isrgb.m Modified: trunk/octave-forge/main/image/inst/isrgb.m =================================================================== --- trunk/octave-forge/main/image/inst/isrgb.m 2012-09-02 03:32:21 UTC (rev 10947) +++ trunk/octave-forge/main/image/inst/isrgb.m 2012-09-02 03:33:55 UTC (rev 10948) @@ -39,15 +39,12 @@ endif bool = false; - if (ismatrix (img) && ndims (img) == 3 && size (img, 3) == 3 && !issparse (img) && !isempty (img)) + if (!isimage (img)) + bool = false; + elseif (ndims (img) == 3 && size (img, 3) == 3) switch (class (img)) case "double" - ## to speed this up, we can look at a sample of the image first - bool = is_rgb_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_rgb_double (img); - endif + bool = ispart (@is_rgb_double, img); case {"uint8", "uint16"} bool = true; endswitch @@ -59,10 +56,6 @@ bool = all ((img(:) >= 0 & img(:) <= 1) | isnan (img(:))); endfunction -%!demo -%! isrgb(rand(1,2,3)) -%! # A 1-by-2-by-3 double matrix with elements between 0 and 1 is a RGB image. - %!# Non-matrix %!assert(isrgb("this is not a RGB image"),false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |