changeset 11380:68c8a8c33567 octave-forge

padarray: allow string "zeros" as padvalue for consistency * other functions such as ordfilt2, ordfiltn, and medfilt2 allow the string "zeros" for matlab compatibility. Make padarray accept it to for consistency. * be case insensitive when checking options * update documentation
author carandraug
date Mon, 14 Jan 2013 00:08:28 +0000
parents 370e385e1edd
children 2440d6d0daf4
files main/image/NEWS main/image/inst/padarray.m
diffstat 2 files changed, 18 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/main/image/NEWS	Sun Jan 13 23:59:37 2013 +0000
+++ b/main/image/NEWS	Mon Jan 14 00:08:28 2013 +0000
@@ -19,6 +19,10 @@
     function has been deprecated.  If using a vector to specify the size of the
     neighborhood, the elements are no longer swapped.
 
+ ** For consistency with other functions that allow specification of padding
+    values, the function padarray now accepts the string "zeros" as a valid
+    option.
+
  ** The plot produced by `imhist' is correctly scaled on the X axis so that the
     colorbar corresponds to the actual intensity of the stems; the given
     colormarp is used on the colorbar for indexed images; and the stems no
--- a/main/image/inst/padarray.m	Sun Jan 13 23:59:37 2013 +0000
+++ b/main/image/inst/padarray.m	Mon Jan 14 00:08:28 2013 +0000
@@ -33,19 +33,19 @@
 ## values are:
 ##
 ## @table @asis
-## @item 0
+## @item 0 or "zeros" (default)
 ## Pads with 0 as described above. This is the default behaviour.
-## @item Scalar
+## @item scalar value
 ## Pads using @var{padval} as a padding value.
-## @item "Circular"
+## @item "circular"
 ## Pads with a circular repetition of elements in @var{A} (similar to
 ## tiling @var{A}).
-## @item "Replicate"
+## @item "replicate"
 ## Pads replicating values of @var{A} which are at the border of the
 ## array.
-## @item "Symmetric"
+## @item "symmetric"
 ## Pads with a mirror reflection of @var{A}.
-## @item "Reflect"
+## @item "reflect"
 ## Same as "symmetric", but the borders are not used in the padding.
 ## @end table
 ##
@@ -53,14 +53,14 @@
 ## direction of the pad. Possible values are:
 ##
 ## @table @asis
-## @item "Both"
+## @item "both"
 ## For each dimension it pads before the first element the number
 ## of elements defined by @var{padsize} and the same number again after
 ## the last element. This is the default value.
-## @item "Pre"
+## @item "pre"
 ## For each dimension it pads before the first element the number of
 ## elements defined by @var{padsize}.
-## @item "Post"
+## @item "post"
 ## For each dimension it pads after the last element the number of
 ## elements defined by @var{padsize}.
 ## @end table
@@ -99,6 +99,10 @@
       ps = ds;
       ps(dim) = s;                       # padding size
 
+      if (strcmpi (padval, "zeros"))
+        padval = 0;
+      endif
+
       if (ischar(padval))
         # Init a "index all" cell array. All cases need it.
         idx = cell(1, length(ds));
@@ -106,7 +110,7 @@
           idx{i} = 1:ds(i);
         endfor
 
-        switch (padval)
+        switch (tolower (padval))
           case ("circular")
             complete = 0;
             D = B;