Mercurial > hg > octave-image
changeset 887:33c44c229f74
use 0 for extrapolation value for better Matlab compatibility
* imperspectivewarp.m, imremap.m, imrotate.m: Set default for
extrapolation value to 0 instead of NA.
* NEWS: Note change.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 22 Apr 2014 12:53:04 -0400 |
parents | a0c42a32c6c4 |
children | ea45a8e63169 |
files | NEWS inst/imperspectivewarp.m inst/imremap.m inst/imrotate.m |
diffstat | 4 files changed, 15 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS +++ b/NEWS @@ -21,6 +21,10 @@ im2bw + ** For better compatibility with Matlab, the imrotate, imremap, and + imperspectivewarp functions now use 0 instead of NA for the default + extrapolation value. + ** Deprecated functions. The following functions were deprecated in image 2.2.0 and have been
--- a/inst/imperspectivewarp.m +++ b/inst/imperspectivewarp.m @@ -41,8 +41,7 @@ ## @end table ## ## 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} -## defaults to @code{NA} and for other classes it defaults to 0. +## be set to @var{extrapval}. The default value of @var{extrapval} is 0. ## ## The optional output @var{valid} is a matrix of the same size as @var{warped} ## that contains the value 1 in pixels where @var{warped} contains an interpolated @@ -50,7 +49,7 @@ ## @seealso{imremap, imrotate, imresize, imshear, interp2} ## @end deftypefn -function [warped, valid] = imperspectivewarp(im, P, interp = "linear", bbox = "loose", extrapolation_value = NA) +function [warped, valid] = imperspectivewarp(im, P, interp = "linear", bbox = "loose", extrapolation_value = 0) if (nargin < 2 || nargin > 5) print_usage ();
--- a/inst/imremap.m +++ b/inst/imremap.m @@ -37,8 +37,7 @@ ## @code{linear}) are also supported. ## ## 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} -## defaults to @code{NA} and for other classes it defaults to 0. +## be set to @var{extrapval}. The default value of @var{extrapval} is 0. ## ## The optional output @var{valid} is a matrix of the same size as @var{warped} ## that contains the value 1 in pixels where @var{warped} contains an interpolated @@ -46,7 +45,7 @@ ## @seealso{imperspectivewarp, imrotate, imresize, imshear, interp2} ## @end deftypefn -function [warped, valid] = imremap(im, XI, YI, interp = "linear", extrapval = NA) +function [warped, valid] = imremap(im, XI, YI, interp = "linear", extrapval = 0) if (nargin < 3 || nargin > 5) print_usage (); @@ -63,10 +62,10 @@ ## Interpolate if (size (im, 3) == 1) # Gray - warped = grayinterp(im, XI, YI, interp, NA); + warped = grayinterp(im, XI, YI, interp, 0); else # rgb image for i = 3:-1:1 - warped(:,:,i) = grayinterp(im(:,:,i), XI, YI, interp, NA); + warped(:,:,i) = grayinterp(im(:,:,i), XI, YI, interp, 0); endfor endif valid = !isna(warped); @@ -79,9 +78,9 @@ function [warped, valid] = grayinterp(im, XI, YI, interp, extrapval) if (strcmp(interp, "cubic")) - warped = graybicubic(double(im), XI, YI, NA); + warped = graybicubic(double(im), XI, YI, 0); else - warped = interp2(double(im), XI, YI, interp, NA); + warped = interp2(double(im), XI, YI, interp, 0); endif valid = !isna(warped); warped(!valid) = extrapval; @@ -97,7 +96,7 @@ ## @seealso{interp2} ## @end deftypefn -function ZI = graybicubic (Z, XI, YI, extrapval = NA) +function ZI = graybicubic (Z, XI, YI, extrapval = 0) ## Allocate output [X, Y] = meshgrid(1:columns(Z), 1:rows(Z));
--- a/inst/imrotate.m +++ b/inst/imrotate.m @@ -41,8 +41,7 @@ ## @end itemize ## ## @var{extrapval} sets the value used for extrapolation. The default value -## is @code{NA} for images represented using doubles, and 0 otherwise. -## This argument is ignored of Fourier interpolation is used. +## is 0. This argument is ignored of Fourier interpolation is used. ## ## Output parameters: ## @@ -57,7 +56,7 @@ ## not available if Fourier interpolation is used. ## @end deftypefn -function [imgPost, H, valid] = imrotate (imgPre, thetaDeg, interp = "nearest", bbox = "loose", extrapval = NA) +function [imgPost, H, valid] = imrotate (imgPre, thetaDeg, interp = "nearest", bbox = "loose", extrapval = 0) if (nargin < 2 || nargin > 5) print_usage ();