bugGNU Octave - Bugs: bug #50188, [octave forge] (image) poly2mask...


bug #50188: [octave forge] (image) poly2mask does incompatible rounding

Submitted by:  Hartmut <hardy>
Submitted on:  Mon 30 Jan 2017 08:07:25 PM UTC  
Category:  Octave Forge Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  dev Operating System:  Any

Add a New Comment(Rich Markup)

You are not logged in

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


Mon 30 Jan 2017 11:37:53 PM UTC, comment #1:

There is an (still imperfect) fix for this bug in patch #9244 (inside the function rp_convex_image). It might be a starting point to generate a proper solution for this bug.

Hartmut <hardy>
Mon 30 Jan 2017 08:07:25 PM UTC, original submission:

This happens with the current image-2.6.1 package and Octave 4.2.0.

The current Octave implementation of poly2mask.m rounds its polygon input values to the nearest integer (and correctly says so in its documentation).

In contrast, the Matlab implementation of poly2mask.m also uses fractional input values, and does some 5-by-5 subsampling of pixels. See the Matlab documentation: https://de.mathworks.com/help/images/ref/poly2mask.html#f6-465457

As a result the output values between the Octave and the Matlab version of poly2mask are different.

Here is some typical code that shows the difference, and can be used for implementing an improved version of Octave's poly2mask:

The current output of Octave is:

(I hit this bug while implementing a new feature in regionprops.m. I will probably work around this bug in regionprops, to not introduce more dependencies of patches. This means that a future fix to this bug could have a look what's been done in regionprops.m for the 'ConvexImage' calculation.)

Hartmut <hardy>


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

Attach Files:

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 jwe (Updated the item)
  • -email is unavailable- added by hardy (Submitted the item)
  • -email is unavailable- added by hardy (add people to cc who care about the image package)
  • -email is unavailable- added by hardy (add people to cc who care about the image package)

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

    Only project members can vote.




    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-02-26 mtmiller Release4.2.0 => dev
    2017-08-12 jwe Summaryimage package: poly2mask does incompatible rounding => [octave forge] (image) poly2mask does incompatible rounding
    2017-01-30 hardy Carbon-Copy- => Added avinoam
        Carbon-Copy- => Added carandraug

    Back to the top

    Powered by Savane 3.4