bugGNU Octave - Bugs: bug #57528, imread always fails when Octave...

 
 

bug #57528: imread always fails when Octave was started with the "--traditional" option

Submitter:  Hartmut <hardy>
Submitted:  Fri 03 Jan 2020 04:52:44 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 04 Jan 2020 09:37:36 PM UTC, comment #6: 

Thanks for the fast patch!
I have compiled current dec Octave (hg id: f658d41003e4) including the patch mentioned in comment #5 and can confirm that the originally reported buggy behavior is now FIXED. I tested under linux, and only the procedure described in comment #0.

Hartmut <hardy>
Fri 03 Jan 2020 11:32:42 PM UTC, comment #5: 

I crafted a solution by adding an else if block to construct a Range object from a vector/array object.


  else if (region.is_matrix_type ())
    {
      NDArray array = region.array_value ();
      double base = array(0);
      double limit = array(array.numel () - 1);
      double incr = array(1) - base;
      output = Range (base, limit, incr);
    }


This seems to work with the test code in this report so I checked it in here https://hg.savannah.gnu.org/hgweb/octave/rev/1a06fa2fe13a.

Marking as Ready for Test.

Rik <rik5>
Group administrator
Fri 03 Jan 2020 10:58:20 PM UTC, comment #4: 

Thanks for the hint.  The code in question is at line 149 of _magick_read_.cc


// We need this in case one of the sides of the image being read has
// width 1.  In those cases, the type will come as scalar instead of range
// since that's the behavior of the colon operator (1:1:1 will be a scalar,
// not a range).
static Range
get_region_range (const octave_value& region)
{
  Range output;
  if (region.is_range ())
    output = region.range_value ();
  else if (region.is_scalar_type ())
    {
      double value = region.scalar_value ();
      output = Range (value, value);
    }
  else
    error ("__magick_read__: unknown datatype for Region option");

  return output;
}




Rik <rik5>
Group administrator
Fri 03 Jan 2020 10:23:32 PM UTC, comment #3: 

The relevant option is "disable_range (true)" when running Octave with --traditional. With this option set to true, a range expression like 1:10 expands to a full matrix. But the imread function internally seems to be depending on a range object being passed down into the lower layers, see the function get_region_range in libinterp/corefcn/__magick_read__.cc.

Mike Miller <mtmiller>
Group Member
Fri 03 Jan 2020 09:38:18 PM UTC, comment #2: 

Tracking this down a bit, the file scripts/image/private/__imread__.m is the last point in the debug stack which is still an m-file.  The line where the error is generated is


  [varargout{1:nargout}] = __magick_read__ (filename, options);


I used the debugger to inspect filename and options variables when octave was started with --traditional and without.  The variables are the same, so the problem lies in the C++ code somewhere.


Rik <rik5>
Group administrator
Fri 03 Jan 2020 07:52:20 PM UTC, comment #1: 

Confirmed.  It is still present on the dev release which is about to become 6.1.

Rik <rik5>
Group administrator
Fri 03 Jan 2020 04:52:44 PM UTC, original submission:  

I have copied this presumably buggy behavior from the mailing list: https://octave.1599824.n4.nabble.com/imread-fails-with-unknown-datatype-for-Region-option-error-td4692399.html

I can reproduce the behavior, here is how to do it:

  • create an image file somewhere, e.g. "test.png" (it seems to happen with any image file)
  • start Octave from the commandline with the traditional option: "./octave --traditional"
  • (Set the Octave variable "filename" to the full filename of your image file from above.)
  • try to use imread to load this image file: "im = imread(filename);"


Here is the error message I then get using Octave 5.1.0 on linux:


>> im = imread(filename)
error: __magick_read__: unknown datatype for Region option
error: called from
    __imread__ at line 131 column 26
    imageIO at line 118 column 28
    imread at line 106 column 33


Using the imread command in the very same Octave installation, just without the --traditional option, works fine.

Hartmut <hardy>

 

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

Attach Files:
   
   
Comment:
   

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 hardy (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 group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-01-05 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2020-01-03 rik5 StatusConfirmed Ready For Test
    2020-01-03 rik5 StatusNone Confirmed
        Release5.1.0 dev

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code