bugGNU Octave - Bugs: bug #48794, image package: imreconstruct...


bug #48794: image package: imreconstruct should clip marker > mask

Submitted by:  Hartmut <hardy>
Submitted on:  Mon Aug 15 21:26:02 2016  
Category: Octave Forge PackageSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: Any

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

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


(Jump to the original submission Jump to the original submission)

Tue Apr 25 00:18:29 2017, comment #6:

Thank you for the report and testing. Fixed with the changed proposed in comment #1 http://hg.code.sf.net/p/octave/image/rev/4957d5743185 I just added two more tests. Not having to check the whole image for that condition should also make it faster.

Carnë Draug <carandraug>
Project Member
Wed Aug 17 11:34:59 2016, comment #5:

4d images also work fine in Matlab (V2014b):

Hartmut <hardy>
Tue Aug 16 22:47:49 2016, comment #4:

The version I mentioned below that caused an error was 2010b.

I think it's enough to skip the input check to have this work. But the algorithm is complex, I read and implement it a long time ago, and I want to check better if I can really do so with images that trigger all parts of the algorithm.

> Yes, the Matlab version of imreconstruct does also accept 3D data. Despite their documentation saying differently.

Only up to 3D?

Carnë Draug <carandraug>
Project Member
Tue Aug 16 19:23:38 2016, comment #3:

Here are some results from Matlab 2014b:

My conclusions are:

  • There must have been a change in Matlab behavior between your Matlab version (what version is this?) and todays (R2014b and R2015a) version. Nowadays they DO the clipping if marker > mask, as their documentation says. (For logical inputs as well as class double inputs.)
  • Yes, the Matlab version of imreconstruct does also accept 3D data. Despite their documentation saying differently.
Hartmut <hardy>
Tue Aug 16 05:55:58 2016, comment #2:

With Matlab 2015a

Avinoam Kalma <avinoam>
Project Member
Mon Aug 15 21:59:16 2016, comment #1:

I only needed to comment out the code that makes the check to get the results you wanted. See https://bitbucket.org/carandraug/octave-image/commits/2c4e414f727c8edc87246172ba1821d04ae3791e

But I'm not sure it and need more testing if there's any assumption in the algorithm about it (I'd prefer to avoid having to actually modify the raw data -- although there's another step that already makes a copy so maybe it's not a big deal).

Note that the Matlab documentation also says that the image needs to be 2D which is not true. Testing in Matlab, I actually get the error about marker being higher than mask if I use non-logical:

Can you test this in a more recent Matlab version?

Carnë Draug <carandraug>
Project Member
Mon Aug 15 21:26:02 2016, original submission:

Here is a little example to show the behavior:
This throws an error "imreconstruct: MARKER must be less or equal than MASK" in the current image package (version 2.4.1 and image dev version).

According to the Matlab help in http://de.mathworks.com/help/images/ref/imreconstruct.html the imreconstruct should instead clip the values where marker > mask to the corresponding mask value.

Hartmut <hardy>


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

Attach File(s):

No files currently attached


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 hardy (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 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue Apr 25 00:18:29 2017carandraugStatusNone=>Fixed

    Back to the top

    Powered by Savane 3.1-cleanup1