Mercurial > hg > octave-nkf
changeset 17648:a433244dd697
image.m: Implement better check for linearity (bug #37410)
* scripts/image/image.m: Use the percentage change from the average spacing as
a unitless measure for linearity. If it deviates by more than 1%, print a
warning.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 13 Oct 2013 17:57:36 -0700 |
parents | 7ec70c575ad6 |
children | a09511ebf7ef |
files | scripts/image/image.m |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/image/image.m +++ b/scripts/image/image.m @@ -121,12 +121,13 @@ if (numel (x) > 2 && numel (y) > 2) ## Test data for non-linear spacing which is unsupported - ## FIXME: Need a better check on linearity - tol = 100*eps; + tol = .01; # 1% tolerance. FIXME: this value was chosen without thought. dx = diff (x); + dxmean = (max (x) - min (x)) / (numel (x) - 1); + dx = abs ((dx - dxmean) / dxmean); dy = diff (y); - dx = std (dx) / mean (abs (dx)); - dy = std (dy) / mean (abs (dy)); + dymean = (max (y) - min (y)) / (numel (y) - 1); + dy = abs ((dy - dymean) / dymean); if (any (dx > tol) || any (dy > tol)) warning ("image: non-linear X, Y data is ignored. IMG will be shown with linear mapping"); endif