changeset 511:9135e5461550

isgray isbw isrgb: return false is argument is empty matrix
author carandraug
date Mon, 05 Dec 2011 04:41:59 +0000
parents 7d8494a6d8a6
children 07c981beafdf
files inst/isbw.m inst/isgray.m inst/isrgb.m
diffstat 3 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/inst/isbw.m
+++ b/inst/isbw.m
@@ -37,7 +37,7 @@
   endif
 
   ## an image cannot be a sparse matrix
-  if (!ismatrix (BW) || issparse (BW))
+  if (!ismatrix (BW) || issparse (BW) || isempty (BW))
     bool = false;
   elseif (strcmpi (logic, "logical"))
     ## this is the matlab compatible way (before they removed the function)
--- a/inst/isgray.m
+++ b/inst/isgray.m
@@ -38,7 +38,7 @@
   endif
 
   bool = false;
-  if (ismatrix (img) && ndims (img) == 2 && !issparse (img))
+  if (ismatrix (img) && ndims (img) == 2 && !issparse (img) && !isempty (img))
     switch (class (img))
       case "double"
         ## to speed this up, we can look at a sample of the image first
--- a/inst/isrgb.m
+++ b/inst/isrgb.m
@@ -39,7 +39,7 @@
   endif
 
   bool = false;
-  if (ismatrix (img) && ndims (img) == 3 && size (img, 3) == 3 && !issparse (img))
+  if (ismatrix (img) && ndims (img) == 3 && size (img, 3) == 3 && !issparse (img) && !isempty (img))
     switch (class (img))
       case "double"
         ## to speed this up, we can look at a sample of the image first