bugGNU Octave - Bugs: bug #46774, image package: im2col produces...

 
 

bug #46774: image package: im2col produces different results compared with Matlab

Submitted by:  Luis Mendo <lmendo>
Submitted on:  Tue 29 Dec 2015 12:24:49 PM UTC  
 
Category: Octave Forge PackageSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: Luis MendoOpen/Closed: Closed
Release: otherOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Wed 10 Feb 2016 08:41:59 PM UTC, comment #3:

Thanks for your feedback, Carnë.

I found these bugs because I was deliberately testing corner cases. I'm designing a code-golf language based on Matlab (see this link if curious: https://esolangs.org/wiki/MATL). The compiler (or rather transpiler) produces Matlab code, meant to be compatible with Octave as well. When I introduce a function (in this case, the equivalent to `im2col`), I try to test corner cases to see if it works well, and specially to detect different behaviour when running the compiled code on Matlab and on Octave.

Yes, it seems Matlab collapses all dimensions beyond the first. I'm not sure that can be considered a bug, though.

Luis Mendo <lmendo>
Sun 07 Feb 2016 11:11:28 PM UTC, comment #2:

Just curious, did you found these bug by accident or do you have code that relies on these Matlab corner cases?

In short, I fixed issue (2) for Matlab compatibility. However, I will not change (1) and (3) since they are required to support images of N dimensions. Either Matlab does not support images with higher number of dimensions or there's a bug on their code. If you have an account with Mathworks, could you fill a bug report with them?

== (1) Multidimensional arrays. ==

Octave's im2col handles N dimensional input. Matlab does not throw an error but its output is obviously incorrect. I'm guessing that either Matlab's im2col is not meant to use with arrays with more than 2 dimensions, or it has a bug.

Can you please fill a bug report against Matlab? I have seen this happening before, so my guess is that somewhere in their code they do "[rows, cols] = size (image)" and then actually use it, forgetting that columns becomes the cumulative product of all other dimensions.

== (2) Block size exceeds input array size ==

The fix for this was just removing that input check and to automatically becomes Matlab compatible. Unfortunately, there is a bug in Octave which prevents automatic broadcasting with dimensions of length zero https://savannah.gnu.org/bugs/?47085 so I had to regress back to use bsxfun. Anyway, It is fixed here

http://hg.code.sf.net/p/octave/image/rev/0fc684589226

== (3) Block size exceeds input array size in dimension greater than 2 with 'distinct' option ==

If it is not possible to make complete blocks of the image, then it is treated as if padded with zeros. This seems to be the same for Matlab. I don't know why Matlab does not do the same for the other dimensions but considering the other bugs you're reporting, I'm guessing it's really not coded to support more dimensions.

Note that Octave does support more dimensions which Matlab does not at all and fixing this would impact on that.

Carnë Draug <carandraug>
Project Member
Thu 14 Jan 2016 03:15:29 PM UTC, comment #1:

I have attached a function that intercepts `im2col` to reproduce Matlab's behaviour

Luis Mendo <lmendo>
Tue 29 Dec 2015 12:24:49 PM UTC, original submission:

Some of these are admittedly corner cases, but the output is different.

(1) Multidimensional arrays. Example code:

Octave output:

Matlab output:

My interpretation is that Matlab collapses all dimensions beyond the first. Specifically, this reproduces Matlab's output in Octave (and in Matlab):

(2) Block size exceeds input array size. Example code:

Octave output: gives error:

Matlab output:

(3) Block size exceeds input array size in dimension greater than 2 with 'distinct' option. Example code:

Octave output:

Matlab output: gives error:

Luis Mendo <lmendo>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #36030:  im2col_comp.m added by lmendo (207B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by lmendo (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
    Sun 07 Feb 2016 11:11:56 PM UTCcarandraugStatusNone=>Fixed
      Open/ClosedOpen=>Closed
      Release4.0.0=>other
      Operating SystemMicrosoft Windows=>Any
      Summaryim2col produces different results compared with Matlab=>image package: im2col produces different results compared with Matlab
    Thu 14 Jan 2016 03:14:25 PM UTClmendoAttached File-=>Added im2col_comp.m, #36030

    Back to the top


    Powered by Savane 3.1-cleanup1