bugGNU Octave - Bugs: bug #43823, image package: potential bug in...

 
 

bug #43823: image package: potential bug in imresize.m

Submitted by:  None
Submitted on:  Sun 14 Dec 2014 10:06:52 PM UTC  
 
Category: Octave Forge PackageSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Inaccurate Result
Status: InvalidAssigned to: None
Originator Name: John SmithOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.8.1
Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 08 Dec 2016 05:41:56 PM UTC, comment #2:

No answer from OP.

Closing as invalid, according to comment #1.

Avinoam Kalma <avinoam>
Project Member
Mon 15 Dec 2014 04:43:59 PM UTC, comment #1:

Thank you for your bug report. The version of imresize you are linking too is very much out of date. Could you please compare with the latest version at

http://hg.code.sf.net/p/octave/image/file/8e61772f2fcf/inst/imresize.m

and let me know if you still have a problem there.

Carnë Draug <carandraug>
Project Member
Sun 14 Dec 2014 10:06:52 PM UTC, original submission:

There might be a bug related to the use of anti-aliasing filter in the "imresize.m" function, whose code one can see at

http://sourceforge.net/p/octave/image/ci/Octave-Forge-2006.01.28/tree/imresize.m

Consider running this function with an image of size 32x32, i.e.

img_bigger = imresize(img, [64,64], 'cubic')

or

img_smaller = imresize(img, [16,16], 'cubic')

Here 'cubic' could be 'spline', but not 'nearest'.

The problem is with the "reverse logic of the algorithm". At line 85 we have:

if (m > 1 & filter > 0)
# If the image is being enlarged and filter > 0 then
# convolve the image with a filter*filter gaussian.

...

and at line 93:

elseif (m < 1 & nargin == 4)
# If the image size is being reduced and a fourth argument
# is given, use it as a FIR filter.
...

As we have 3 arguments and the method which is not "nearest", filter is set to 11, and hence the anti-aliasing filter will be applied (wrongly) when using imresize to enlarge an image. When imresize is applied to reduce the size of the original image, there will be no anti-aliasing filtering at all since nargin==3.

This seems to be wrong: the problem with aliasing is about representing a higher resolution image in a low-resolution domain.

We need antialiasing (low pass filter) BEFORE resampling with interp2 to lower resolution, and we do not need antialiasing when upsampling with interp2 to bigger than original resolutions.

The suggestion is to reverse "m>1" on line 85 to "m<1", and similarly on line 93. The suggested change is attached in the file imresizemod.m.

P.S. Optinal matters: Consider also switching from Gaussian smoothing to fir1 filter as is done in MATLAB (might not be important at all, but to be more consistent with MATLAB and more flexible), and also "mexing" interp2 as it is currently 5-10x slower than MATLAB's equivalent already on very tiny images such as when resizing from 28x28 to 32x32.

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #32666:  imresizemod.m added by None (4KiB - text/x-objcsrc - Please verify imresize.m code logic and consider the suggested change.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by avinoam (Posted a comment)
  • -unavailable- added by avinoam
  • -unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 08 Dec 2016 05:41:56 PM UTCavinoamStatusNone=>Invalid
      Open/ClosedOpen=>Closed
    Mon 15 Dec 2014 04:43:59 PM UTCcarandraugCategoryLibraries=>Octave Forge Package
      SummaryPotential bug in imresize.m in Image toolbox=>image package: potential bug in imresize.m
    Mon 15 Dec 2014 12:07:23 PM UTCavinoamCarbon-Copy-=>Added avinoam
    Sun 14 Dec 2014 10:06:52 PM UTCNoneAttached File-=>Added imresizemod.m, #32666

    Back to the top


    Powered by Savane 3.1-cleanup1