# HG changeset patch # User carandraug # Date 1346557300 0 # Node ID cad86b82d447f4d992a3f97f00c651cdd5ec5bba # Parent 96b49bbc07cd739aed27aa97e86697cf90cc1b54 is_double_image: new private function to check if an image of class double is valid diff --git a/inst/isgray.m b/inst/isgray.m --- a/inst/isgray.m +++ b/inst/isgray.m @@ -43,7 +43,7 @@ elseif (ndims (img) == 2) switch (class (img)) case "double" - bool = ispart (@is_gray_double, img); + bool = ispart (@is_double_image, img); case {"uint8", "uint16"} bool = true; endswitch @@ -51,10 +51,6 @@ endfunction -function bool = is_gray_double (img) - bool = all ((img(:) >= 0 & img(:) <= 1) | isnan (img(:))); -endfunction - %!shared a %! a = rand (100); %!assert (isgray (a), true); diff --git a/inst/isrgb.m b/inst/isrgb.m --- a/inst/isrgb.m +++ b/inst/isrgb.m @@ -44,7 +44,7 @@ elseif (ndims (img) == 3 && size (img, 3) == 3) switch (class (img)) case "double" - bool = ispart (@is_rgb_double, img); + bool = ispart (@is_double_image, img); case {"uint8", "uint16"} bool = true; endswitch @@ -52,10 +52,6 @@ endfunction -function bool = is_rgb_double (img) - bool = all ((img(:) >= 0 & img(:) <= 1) | isnan (img(:))); -endfunction - %!# Non-matrix %!assert(isrgb("this is not a RGB image"),false); diff --git a/inst/private/is_double_image.m b/inst/private/is_double_image.m new file mode 100644 --- /dev/null +++ b/inst/private/is_double_image.m @@ -0,0 +1,21 @@ +## Copyright (C) 2012 Carnë Draug +## +## 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 . + +## simple check used by some functions. Images of the double class must have +## all their values between 0 and 1 or be NaN + +function bool = is_double_image (img) + bool = all ((img(:) >= 0 & img(:) <= 1) | isnan (img(:))); +endfunction