bugGNU Octave - Bugs: bug #47879, image package: imerode and...

 
 

bug #47879: image package: imerode and imdilate sets elements to Inf when SE is zero

Submitter:  Artur Wegele <art645>
Submitted:  Mon 09 May 2016 12:05:37 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * other Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 10 May 2016 05:42:53 PM UTC, comment #2: 

I added several new test cases to imdilate and imerode.

http://hg.code.sf.net/p/octave/image/rev/e959fc1c7b0a

Some of them were failing but I have now push other changes so that they all pass and works coherently, i.e., when erosion or dilation get an empty set, they return that type maximum and minimum value. This should happen if SE is both an empty or blank, and also in cases where all of the SE would be outside the image (different cases in the code but mathematically need to behave the same).

From Artur Wegele via email:

> Should the function throw an exception, when the structuring element has a 0 overlapping with the image as in my case?
>
> I think the result is undefined same as if we divide 0/0. I expect imerode to deliver only values found in the source image. If there is no overlapping, then it can't work correctly.


If you are worried about this cases while at the same create unusual shaped SE, you can use the "valid" option of imerode.

---

I'm closing as invalid since after looking more into literature, Inf and -Inf can be considered correct valid. See http://stackoverflow.com/a/37117842/1609556

Carnë Draug <carandraug>
Group Member
Mon 09 May 2016 06:49:16 PM UTC, comment #1: 

I originally asked the reporter to report it here since I thought it was a bug. I'm not so sure anymore. The issue can be generalized by using a SE of zero:


octave> imerode (zeros (3), 0)
ans =

   Inf   Inf   Inf
   Inf   Inf   Inf
   Inf   Inf   Inf


While searching the web, I found a post on stackoverflow asking why this odd result. I have compiled my thoughts on that answer here http://stackoverflow.com/a/37117842/1609556

This seems to boil down about finding min of an empty set, or whether erosion should compute min or infimum (same for imdilation). I would appreciate comments on this but I'm currently leaning towards actually being the correct answer (but I will be the first to admit to code it by accident).

Carnë Draug <carandraug>
Group Member
Mon 09 May 2016 12:05:37 PM UTC, original submission:  

imerode sets the last pixel in the image to 1 in this.
Reproducable with the attached script ImErodeBug.m.

I expect imerode only to change pixel from 1 to 0, never from 0 to 1.

Artur Wegele <art645>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #37108:  img.png added by art645 (77B - image/png)
file #37109:  result.png added by art645 (76B - image/png)
file #37110:  strEl.png added by art645 (71B - image/png)
file #37111:  ImErodeBug.m added by art645 (148B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by art645 (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 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-05-10 carandraug CategoryOctave Package Octave Function
        StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed
        Release4.0.0 other
        Operating SystemMicrosoft Windows Any
    2016-05-09 carandraug Summaryimerode Sets a bit to 1/Inf, when the center of the strel is 0 image package: imerode and imdilate sets elements to Inf when SE is zero
    2016-05-09 rik5 Carbon-CopyRemoved 72865 -
    2016-05-09 rik5 CategoryOctave Function Octave Package
    2016-05-09 art645 Attached File- Added img.png, #37108
        Attached File- Added result.png, #37109
        Attached File- Added strEl.png, #37110
        Attached File- Added ImErodeBug.m, #37111

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code