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

 
 

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

Submitter:  Hartmut <hardy>
Submitted:  Mon 15 Aug 2016 09:26:02 PM UTC
 
Category:  Octave Forge Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

( Jump to the original submission )

Tue 25 Apr 2017 12:18:29 AM UTC, 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 17 Aug 2016 11:34:59 AM UTC, comment #5: 

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

marker = ones(3,3,3,3)
mask = marker;
mask(2,2,2,2) = 0
im = imreconstruct(marker, mask)
% result: no error message, im == mask, class(im) == double

Hartmut <hardy>
Tue 16 Aug 2016 10:47:49 PM UTC, 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 16 Aug 2016 07:23:38 PM UTC, comment #3: 

Here are some results from Matlab 2014b:

marker = true(3)
mask = logical([1 1 1; 1 0 1; 1 1 1])
im = imreconstruct(marker, mask)
% result: no error message, im == mask, class(im) == logical

marker = ones(3)
mask = [1 1 1; 1 0 1; 1 1 1]
im = imreconstruct(marker, mask)
% result: no error message, im == mask, class(im) == double

marker = ones(3,3,3)
mask = marker;
mask(2,2,2) = 0
im = imreconstruct(marker, mask)
% result: no error message, im == mask, class(im) == double

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 16 Aug 2016 05:55:58 AM UTC, comment #2: 

With Matlab 2015a

>> imreconstruct (ones (3), [1 1 1; 1 0 1; 1 1 1])

ans =

     1     1     1
     1     0     1
     1     1     1

Avinoam Kalma <avinoam>
Project Member
Mon 15 Aug 2016 09:59:16 PM UTC, 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:

>> imreconstruct (ones (3), [1 1 1; 1 0 1; 1 1 1])
??? Error using ==> imreconstructmex
MARKER pixels must be <= MASK pixels.

Error in ==> imreconstruct at 77
  im = imreconstructmex(marker,mask);

Can you test this in a more recent Matlab version?

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

Here is a little example to show the behavior:

clear, close all
pkg load image

marker = true(3)
mask = logical([1 1 1; 1 0 1; 1 1 1])

im = imreconstruct(marker, mask)

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 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 avinoam (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 project members can vote.

     

     

     

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-04-25 carandraug StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top


    Powered by Savane 3.9