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


bug #51724: [octave forge] (image) imregionalmax misbehaves on float images

Submitted by:  Hartmut <hardy>
Submitted on:  Thu 10 Aug 2017 06:23:10 PM UTC  
Category: Octave Forge PackageSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: ConfirmedAssigned to: None
Originator Name: Open/Closed: Open
Release: otherOperating System: Any

Add a New Comment(Rich Markup)

You are not logged in

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


Mon 14 Aug 2017 08:40:54 PM UTC, comment #3:

Reading the explanation in https://www.mathworks.com/help/images/understanding-morphological-reconstruction.html, is seems that using img+1 suppresses all maxima which
are less than 1 level above their neighborhood, which is correct for grayscale integer images,
but not for double/float image. Using Hartmut suggestion, what about this fix:

Avinoam Kalma <avinoam>
Project Member
Sun 13 Aug 2017 06:09:19 PM UTC, comment #2:

Confirmed. I also see that the line

is wrong in this case.

Avinoam Kalma <avinoam>
Project Member
Thu 10 Aug 2017 06:24:48 PM UTC, comment #1:

added people to cc

Hartmut <hardy>
Thu 10 Aug 2017 06:23:10 PM UTC, original submission:

Here is how to reproduce the behavior:

There are several problems with this:

  • The output of imregionalmax (for float input images) depends on the absolute size of the input. This should not happen.
  • The output of imregionalmax is not the same as Matlab's output (which is 4).

This happens with current Octave (4.2.1) and image package release (2.6.1).

The underlying function imreconstruct seems to NOT be the problem. Because when I run the Octave code of imregionalmax.m (at least the essential code line) under Matlab (and thus use the Matlab implementation of imreconstruct), then the wrong results (3 and 1) stay.

To me it seems that the current code of imregionalmax (i.e. "recon = imreconstruct (img, img + 1)") is only ment to be applied to integer valued input images.

Maybe a possibility to calculate the same thing for float input images would be "recon = imreconstruct (img, img + eps (im))". This little change made the result of the above script Matlab compatible for me (i.e. 4 in both cases, and also the same index positions in Armax and Brmax as in Matlab).

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 jwe (Updated the item)
  • -unavailable- added by hardy (add people who care about the image package)
  • -unavailable- added by hardy (add people who care about the image package)
  • -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 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 13 Aug 2017 06:10:18 PM UTCavinoamStatusNone=>Confirmed
    Sat 12 Aug 2017 12:47:48 AM UTCjweSummaryimage package: imregionalmax misbehaves on float images=>[octave forge] (image) imregionalmax misbehaves on float images
    Thu 10 Aug 2017 06:24:48 PM UTChardyCarbon-Copy-=>Added avinoam
      Carbon-Copy-=>Added carandraug

    Back to the top

    Powered by Savane 3.1-cleanup1