bugGNU Octave - Bugs: bug #37410, image.m has a wrong check for...


bug #37410: image.m has a wrong check for linearly-spaced x and y

Submitter:  Francesco Potortì <pot>
Submitted:  Thu 20 Sep 2012 11:44:33 AM UTC
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 3.6.2 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


( Jump to the original submission )

Mon 14 Oct 2013 01:09:14 AM UTC, comment #6: 

We don't necessarily need std(), but we would like something that is dimensionless and the coefficient of variation was one such measure.

Consider the following example which has small, but non-linear, spacing and would still pass your criterion.

tol = 10 * eps;
x = [1 1.5 3] * 1e-40;
dx = diff (x);
dx_maxmin = max (dx) - min(dx);
if (dx_maxmin > tol)
  disp ("non-linear");
  disp ("linear");

which displays "linear".

I think this code should work which uses the percentage change (dimensionless) from the mean delta.

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);
dymean = (max (y) - min (y)) / (numel (y) - 1);
dy = abs ((dy - dymean) / dymean);
if (any (dx > tol) || any (dy > tol))

I checked it in here http://hg.savannah.gnu.org/hgweb/octave/rev/a433244dd697.

Rik <rik5>
Project Administrator
Sat 12 Oct 2013 02:18:31 PM UTC, comment #5: 

I guess your testcase is

n = 743;
img = rand (n)*255;
x = y = linspace (0, 10.43, n);
image(x, y, img)

Why do we need std in the linearity check? Isn't something like

tol = 10 * eps;
dx = diff (x);
dy = diff (y);
dx_maxmin = max (dx) - min(dx);
dy_maxmin = max (dy) - min(dy);
if (dx_maxmin > tol || dy_maxmin > tol)

sufficient? Regards, Andy

Andreas Weber <andy1978>
Project Member
Thu 20 Sep 2012 01:50:18 PM UTC, comment #4: 

I'd like to eliminate the use of length in Octave because the definition of length (inherited from prehistoric Matlab) is weird.  So please use numel instead unless there is some specific case that actually needs the strange behavior of the length function.  And in that case, please comment why it is needed.

John W. Eaton <jwe>
Project Administrator
Thu 20 Sep 2012 01:29:14 PM UTC, comment #3: 

Yes.  This is the code as I am currently using it:

  dx = diff (x);
  dy = diff (y);
  dx = std (dx) / mean (abs (dx));
  dy = std (dy) / mean (abs (dy));
  tol = 100*eps;
  if (any (dx > length(x)*tol) || any (dy > length(y)*tol))
    warning ("Image does not map to non-linearly spaced coordinates")

The only change is in the 'if' condition.

Francesco Potortì <pot>
Thu 20 Sep 2012 01:18:12 PM UTC, comment #2: 

Did you mean:
tol = 100*length(x) * eps;

Doug Stewart <dastew>
Thu 20 Sep 2012 12:05:25 PM UTC, comment #1: 

Sorry, I meant length(x) rather than rows(x).

Francesco Potortì <pot>
Thu 20 Sep 2012 11:44:33 AM UTC, original submission:  

The check in image.m is

dx = diff (x);
dx = std (dx) / mean (abs (dx));
tol = 100*eps;
if (any (dx > tol))

but this is too strict.

I stumbled upon it with x=linspace(0,10.43,743);

I suggest to set

tol = 100*rows(x);

Francesco Potortì <pot>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by andy1978 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by dastew (Posted a comment)
  • -email is unavailable- added by pot (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.





    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-10-14 rik5 StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.9