Mercurial > hg > octave-image
changeset 254:bbbb67d744c9
Fix bug when warps go more than two times the image width out of the image frame
author | hauberg |
---|---|
date | Thu, 17 May 2007 19:13:06 +0000 |
parents | aa509c03a056 |
children | 9b5858cb424a |
files | inst/imperspectivewarp.m inst/imremap.m |
diffstat | 2 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/inst/imperspectivewarp.m +++ b/inst/imperspectivewarp.m @@ -93,7 +93,7 @@ interp = lower(interp); if (!any(strcmpi(bbox, {"loose", "crop", "same"}))) - error("imperspectivewarp: bounding box must be either 'loose' or 'crop'"); + error("imperspectivewarp: bounding box must be either 'loose', 'crop', or 'same'"); endif if (!isscalar(extrapolation_value))
--- a/inst/imremap.m +++ b/inst/imremap.m @@ -196,9 +196,15 @@ ## This version of sub2ind behaves as if the data was symmetrically padded function ind = sym_sub2ind(sz, Y, X) Y(Y<1) = 1 - Y(Y<1); - Y(Y>sz(1)) = 2*sz(1) - Y(Y>sz(1)); + while (any(Y(:)>2*sz(1))) + Y(Y>2*sz(1)) = round( Y(Y>2*sz(1))/2 ); + endwhile + Y(Y>sz(1)) = 1 + 2*sz(1) - Y(Y>sz(1)); X(X<1) = 1 - X(X<1); - X(X>sz(2)) = 2*sz(2) - X(X>sz(2)); + while (any(X(:)>2*sz(2))) + X(X>2*sz(2)) = round( X(X>2*sz(2))/2 ); + endwhile + X(X>sz(2)) = 1 + 2*sz(2) - X(X>sz(2)); ind = sub2ind(sz, Y, X); endfunction