[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #41674] image package: temporary arrays in imr

From: Ian Journeaux
Subject: [Octave-bug-tracker] [bug #41674] image package: temporary arrays in imresize are doubles
Date: Thu, 27 Feb 2014 17:07:06 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36

Follow-up Comment #4, bug #41674 (project octave):

I am not sure your proposal works since it is virtually guaranteed that 

all(XD == double(single(XD))) 

will not be true due to differences in precision. 

I believe you have to factor in what would be an acceptable tolerance for the
difference. You can do that with a relative tolerance or an absolute
tolerance. My preference is an absolute tolerance but I have the definition
for the relative tolerance comparison in case it is useful. 

Also my choice of 1e-6 as a tolerance might not be appropriate. 

Since you are creating grid coordinates for an interpolation, how many
significant digits are required for an accurate interpolation?

If valid, it might be applicable to other places where meshgrid is used as a
method of reducing the memory footprint.

I have tested this and it seems to work correctly and is more robust than my
original proposal.

        XD = linspace (1, inCols, outCols);
        YD = linspace (1, inRows, outRows);
        XDs = single(XD);
        YDs = single(YD);
%# absolute tolerance equality
        isequalAbs = @(x,y,tol) (abs(x-y) <= tol );
%# relative tolerance equality
        isequalRel = @(x,y,tol) ( abs(x-y) <= ( tol*max(abs(x),abs(y)) + eps) );

        if(all(isequalAbs(XD, XDs, 1e-6)) && all(isequalAbs(YD, YDs, 1e-6))) 
                XD = XDs;
                YD = YDs;
        clear XDs YDs
        [XI, YI] = meshgrid (XD, YD);
        im = imremap (im, XI, YI, method);


Reply to this item at:


  Message sent via/by Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]