changeset 11372:6ea8cf72b7aa octave-forge

imresize/imremap: do not parse interpolation methods, leave it to interp2 (already expands available methods)
author carandraug
date Fri, 11 Jan 2013 08:55:30 +0000
parents 3d395f5b2908
children e0b85689330f
files main/image/NEWS main/image/inst/@strel/reflect.m main/image/inst/imremap.m main/image/inst/imresize.m
diffstat 4 files changed, 26 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/main/image/NEWS	Fri Jan 11 08:14:46 2013 +0000
+++ b/main/image/NEWS	Fri Jan 11 08:55:30 2013 +0000
@@ -47,9 +47,12 @@
  ** The performance of `imresize()' has been greatly improved when using the
     nearest neighbor method for N or 1/N scale factors (e.g.: 2, 50, 1/4, 1/7).
 
- ** The `imresize' function will now accept any interpolation method available
-    in `interp2()'.  At the moment, means that the `spline' method is new.  The
-    `triangle' method has also been added (same as the `linear' method).
+ ** The `imresize' function will now accept any interpolation method from
+    `interp2()' thus extending the available methods to `spline' and `pchip'.
+     The `triangle' method has also been added (same as the `linear' method).
+
+ ** The `imremap' function will now accept any interpolation method from
+    `interp2()' thus extending the available methods to `pchip'.
 
 Summary of important user-visible changes for image 2.0.0:
 -------------------------------------------------------------------
--- a/main/image/inst/@strel/reflect.m	Fri Jan 11 08:14:46 2013 +0000
+++ b/main/image/inst/@strel/reflect.m	Fri Jan 11 08:55:30 2013 +0000
@@ -48,7 +48,3 @@
   rotate = @(x) reshape (x(end:-1:1), size (x));
   se     = strel ("arbitrary", rotate (nhood), rotate (height));
 endfunction
-
-
-
-
--- a/main/image/inst/imremap.m	Fri Jan 11 08:14:46 2013 +0000
+++ b/main/image/inst/imremap.m	Fri Jan 11 08:55:30 2013 +0000
@@ -28,18 +28,11 @@
 ## by interpolation. Note that the image @var{im} is expressed in a (X, Y)-coordinate
 ## system and not a (row, column) system.
 ##
-## The argument @var{interp} selects the used interpolation method, and most be one
-## of the following strings
-## @table @code
-## @item "nearest"
-## Nearest neighbor interpolation.
-## @item "linear"
-## @itemx "bilinear"
-## Bilinear interpolation. This is the default behavior.
-## @item "cubic"
-## @itemx "bicubic"
-## Bicubic interpolation.
-## @end table
+## The optional argument @var{interp} defines the interpolation method to be
+## used.  All methods supported by @code{interp2} can be used.  In
+## addition, the methods @code{bicubic} (same as @code{cubic}), and
+## @code{bilinear} (same as @code{linear}) are supported for @sc{matlab}
+## compatibility.  By default, the @code{linear} method is used.
 ##
 ## All values of the result that fall outside the original image will
 ## be set to @var{extrapval}. For images of class @code{double} @var{extrapval}
@@ -51,7 +44,7 @@
 ## @seealso{imperspectivewarp, imrotate, imresize, imshear, interp2}
 ## @end deftypefn
 
-function [warped, valid] = imremap(im, XI, YI, interp = "bilinear", extrapval = NA)
+function [warped, valid] = imremap(im, XI, YI, interp = "linear", extrapval = NA)
   ## Check input
   if (nargin < 3)
     print_usage();
@@ -66,13 +59,14 @@
     error("imremap: XI and YI must be matrices of the same size");
   endif
   
-  if (!any(strcmpi(interp, {"nearest", "linear", "bilinear", "cubic", "bicubic", "spline"})))
-    error("imremap: unsupported interpolation method");
-  endif
-  if (any(strcmpi(interp, {"bilinear", "bicubic"})))
-    interp = interp(3:end); # Remove "bi"
-  endif
-  interp = lower(interp);
+  ## Handle the interp argument. We do not check for the actual value. We leave
+  ## that to interp2 so we don't have to keep updating this when interp2
+  ## gets new methods
+  interp = tolower (interp);
+  switch interp
+    case "bicubic",   interp = "cubic";
+    case "bilinear",  interp = "linear";
+  endswitch
   
   if (!isscalar(extrapval))
     error("imremap: extrapolation value must be a scalar");
--- a/main/image/inst/imresize.m	Fri Jan 11 08:14:46 2013 +0000
+++ b/main/image/inst/imresize.m	Fri Jan 11 08:55:30 2013 +0000
@@ -33,9 +33,11 @@
 ## @end group
 ## @end example
 ##
-## The optional argument @var{method} defines the method to use for the
-## interpolation.  All methods supported by @code{interp2} can be used.  In
-## addition, the following methods can be used for @sc{matlab} compatibility:
+## The optional argument @var{method} defines the interpolation method to be
+## used.  All methods supported by @code{interp2} can be used.  In
+## addition, the methods @code{bicubic} (same as @code{cubic}), @code{bilinear}
+## and @code{triangle} (both, the same as @code{linear}) are supported for
+## @sc{matlab} compatibility.  By default, the @code{cubic} method is used.
 ##
 ## @table @asis
 ## @item bicubic (default)
@@ -51,7 +53,7 @@
 ## @seealso{imremap, imrotate, interp2}
 ## @end deftypefn
 
-function im = imresize (im, scale, method = "bicubic")
+function im = imresize (im, scale, method = "cubic")
   if (nargin < 2 || nargin > 3)
     print_usage
   elseif (! isimage (im) || (! isrgb (im) && ! isgray (im)))