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

 
 

bug #61827: [octave forge] (image) regionprops.m relies on incompatible behavior of array of integers

Submitter:  Hartmut <hardy>
Submitted:  Fri 14 Jan 2022 11:30:24 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Fixed 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
   

Jump to the original submission

Mon 17 Jan 2022 07:13:28 AM UTC, comment #6: 

Thanks, this now runs fine in my 7.0.90 Octave. I think we could CLOSE this bug report now.

Hartmut <hardy>
Mon 17 Jan 2022 05:53:57 AM UTC, comment #5: 

Thanks, @Hartmut.

Fixed in http://hg.code.sf.net/p/octave/image/rev/8ecf97cc205c
as you suggested. (Though I added checking the return values of regionprops in the new test).

Avinoam Kalma <avinoam>
Group Member
Sun 16 Jan 2022 09:32:54 PM UTC, comment #4: 

I have checked Avinoams suggestions in comment #3, and it works like a charm:

  • Octave as well as Matlab really use a number of type double in the cc.NumObjects variable: "cc = bwconncom(ones(3)); class(cc.NumObjects)" gives double in Octave as well as in current Online-Matlab.


  • After this change in line 267, my code in comment #0 works fine.


  • My original image processing code, that made my find this bug, then also works fine.


That's why I would suggest the following:

  • Could you please push the suggested code change (in line 267 as described in comment #3) to the image repo, with a reference to this bug report.


  • Could you please also push my short test code (just the two code lines from comment #0) as additional BIST test to regionprops.m. (If this code runs without errors, it works fine. No need to check the return values of regionprops.)


  • Afterwards we could close this bug report.
Hartmut <hardy>
Sun 16 Jan 2022 09:00:43 AM UTC, comment #3: 

The problem is in line 267:


     cc = struct ("ImageSize", size (bw), "NumObjects", n_obj,
                   "PixelIdxList", {accumarray(bw(l_idx)(:), l_idx, [1 n_obj],
                                               @(x) {x})});


which should be:


     cc = struct ("ImageSize", size (bw), "NumObjects", double(n_obj),
                   "PixelIdxList", {accumarray(bw(l_idx)(:), l_idx, [1 n_obj],
                                               @(x) {x})});


cc.NumObjects class should be double and not uint8.

Avinoam Kalma <avinoam>
Group Member
Sun 16 Jan 2022 06:17:53 AM UTC, comment #2: 

Checking in MATLAB


>> [uint8(1); double(3200)]

ans =

  2×1 uint8 column vector

     1
   255


So the behavior in 7.0.90 is MATLAB compatible.

Weather Octave will change or not, I think that we should
change the relevant lines in regionprops.m, for example, changing


 no = cc.NumObjects;


to


 no = double(cc.NumObjects);






Avinoam Kalma <avinoam>
Group Member
Sat 15 Jan 2022 09:33:29 PM UTC, comment #1: 

To be more precise, the difference in regoinprops is with


[1:no; vec(area, 2)]


where:


no = uint8(1)
area = 3200


In 6.4.0, the result is


      1
   3200


while in 7.0.90, we get


    1
  255



Avinoam Kalma <avinoam>
Group Member
Fri 14 Jan 2022 11:30:24 PM UTC, original submission:  

I have observed that currently the function "regionprops.m" relies on an (Matlab incompatible) behavior in Octave, that maybe be will change in Octave 7 (it is already changed in Octave 7.0.90).

Here is a test code that should not error:

pkg load image
L = uint8(checkerboard);
result = regionprops(L,"Centroid");


We will probably need to wait and see how a future Octave version deals with those arrays of integer types before we can correct the image package. (see comment #14 in bug #61788).

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 group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-01-17 avinoam StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2022-01-17 avinoam StatusConfirmed Ready For Test
    2022-01-15 avinoam StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code