Mercurial > hg > octave-image
changeset 289:73730d5494de
input checking and minor compatibility fix
author | hauberg |
---|---|
date | Wed, 19 Mar 2008 22:51:49 +0000 |
parents | 97079f84b901 |
children | 2a2825ef29b9 |
files | inst/colfilt.m |
diffstat | 1 files changed, 22 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/inst/colfilt.m +++ b/inst/colfilt.m @@ -11,9 +11,6 @@ ## placed back into the subblock from whence it came. @var{A} is processed ## in chunks of size @var{m} x @var{n}. ## -## The present version requires [@var{m}, @var{n}], but for compatibility it should -## be optional. Use colfilt(@var{A},[@var{r}, @var{c}], size(@var{A}),...) -## ## The present version requires that [@var{m}, @var{n}] divide size(@var{A}), but for ## compatibility it should work even if [@var{m}, @var{n}] does not divide @var{A}. Use ## the following instead: @@ -32,8 +29,28 @@ ## Author: Paul Kienzle <pkienzle@users.sf.net> function B = colfilt(A,filtsize,blksize,blktype,f,varargin) - - [m,n]=size(A); + ## Input checking + real_nargin = nargin - length(varargin); + if (real_nargin < 4) + error("colfilt: not enough input arguments"); + endif + if (ischar(blksize)) + varargin = {f, varargin{:}}; + f = blktype; + blktype = blksize; + blksize = size(A); + elseif (real_nargin < 5) + error("colfilt: not enough input arguments"); + endif + if (!ismatrix(A) || ndims(A) != 2) + error("colfilt: first input argument must be a matrix"); + endif + if (!isvector(filtsize) || numel(filtsize) != 2) + error("colfilt: second input argument must be a 2-vector"); + endif + + ## Compute! + [m,n] = size(A); r = filtsize(1); c = filtsize(2); mblock = blksize(1);