# HG changeset patch # User Rik # Date 1381712256 25200 # Node ID a433244dd697ae58274b486798cb738d38b9b62f # Parent 7ec70c575ad64c410f18544605edf64745afe3b8 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. diff -r 7ec70c575ad6 -r a433244dd697 scripts/image/image.m --- a/scripts/image/image.m Sun Oct 13 19:57:35 2013 +0200 +++ b/scripts/image/image.m Sun Oct 13 17:57:36 2013 -0700 @@ -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