bugGNU Octave - Bugs: bug #50797, uint8 RGB images trigger...

 
 

bug #50797: uint8 RGB images trigger conversion error

Submitter:  Pantxo Diribarne <pantxo>
Submitted:  Thu 13 Apr 2017 03:22:16 PM UTC
   
 
Category:  Plotting Severity:  4 - Important
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 24 Apr 2017 01:18:39 PM UTC, comment #5: 

I pushed the patch here:
http://hg.savannah.gnu.org/hgweb/octave/rev/39045e50ea45

Closing report as fixed

Pantxo Diribarne <pantxo>
Group Member
Sun 23 Apr 2017 08:10:41 PM UTC, comment #4: 

The attached patch fixes the issue for me.

(file #40477)

Pantxo Diribarne <pantxo>
Group Member
Sun 23 Apr 2017 06:11:19 PM UTC, comment #3: 

I don't think we want to handle this in image.m since we want the original cdata to be stored in the image object, not a converted value. I mean the following test should pass (as it does in 4.2):


im = uint8 (rand (10,10,3)*128);
hi = image (im)
assert (get (hi, "cdata"), im)


Pantxo Diribarne <pantxo>
Group Member
Fri 21 Apr 2017 09:46:04 PM UTC, comment #2: 

I get the same behavior reported error on the dev branch as well.

The actual error is generated in libinterp/octave-value/ov-intx.h.


  Matrix
  matrix_value (bool = false) const
  {
    Matrix retval;
    dim_vector dv = dims ();
    if (dv.ndims () > 2)
      error ("invalid conversion of %s to Matrix", type_name ().c_str ());

    retval = Matrix (dv(0), dv(1));
    double *vec = retval.fortran_vec ();
    octave_idx_type nel = matrix.numel ();
    for (octave_idx_type i = 0; i < nel; i++)
      vec[i] = matrix(i).double_value ();

    return retval;
  }


Somewhere in the code we are using object.matrix_value ().  The issue is probably that the code expects to see a 2-D color data matrix at that point rather than a 3-D RGB value.  I'm not sure whether the conversion is expected to happen in C++ or in the m-file image.m.

Rik <rik5>
Group administrator
Fri 14 Apr 2017 07:53:55 AM UTC, comment #1: 

Confirmed with hg_id 62320e943696.

The error comes from line 198 in image.m


  h = __go_image__ (hax, "cdata", img, "xdata", xdata, "ydata", ydata,
                         "cdatamapping", "direct", varargin{:});


which has not been changed from 4.2.1 to 4.3.0+, so the
error is deeper, in graphics.cc

Avinoam Kalma <avinoam>
Group Member
Thu 13 Apr 2017 03:22:16 PM UTC, original submission:  

The following code leads to an error in the current default branch while it works as expected in 4.2.x


image (uint8 (rand (10,10,3)*128))
## -> error: invalid conversion of uint8 matrix to Matrix


Pantxo Diribarne <pantxo>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #40477:  ndarray.patch added by pantxo (797B - text/x-patch)

 

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 avinoam (Posted a comment)
  • -email is unavailable- added by pantxo (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
    2017-04-24 pantxo Open/ClosedOpen Closed
    2017-04-24 pantxo StatusPatch Submitted Fixed
    2017-04-23 pantxo Attached File- Added ndarray.patch, #40477
        StatusConfirmed Patch Submitted
    2017-04-14 avinoam StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code