# HG changeset patch # User carandraug # Date 1331815389 0 # Node ID c47fa2969872d2eac1b9dd8df259aaefdaebfef2 # Parent 0a3afaf0c06e6ee105700e951c78ea22d53b6fe7 iscolormap: new function to image package diff --git a/NEWS b/NEWS --- a/NEWS +++ b/NEWS @@ -18,6 +18,7 @@ iptchecknargin iptcheckstrs iptnum2ordinal + iscolormap normxcorr2 wavelength2rgb diff --git a/inst/iscolormap.m b/inst/iscolormap.m new file mode 100644 --- /dev/null +++ b/inst/iscolormap.m @@ -0,0 +1,39 @@ +## 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 . + +## -*- texinfo -*- +## @deftypefn {Function File} {} iscolormap (@var{cm}) +## Return true if @var{cm} is a colormap. +## +## A colormap is an @var{n} row by 3 column matrix. The columns contain red, +## green, and blue intensities respectively. All entries should be between 0 +## and 1 inclusive. +## +## @seealso{colormap} +## @end deftypefn + +function bool = iscolormap (cm) + + if (nargin != 1) + print_usage; + endif + + bool = false; + if (ismatrix (cm) && isnumeric (cm) && columns(cm) == 3 && + min (cm(:)) >= 0 && max (cm(:)) <= 1) + bool = true; + endif + +endfunction