bugGNU Octave - Bugs: bug #46392, image package -...

 
 

bug #46392: image package - regionprops(bw,'Perimeter') gives incorrect result

Submitted by:  Hartmut <hardy>
Submitted on:  Fri 06 Nov 2015 08:21:06 PM UTC  
 
Category: Octave Forge PackageSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: 4.0.0Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Thu 07 Jul 2016 06:26:11 PM UTC, comment #4:

regionprops is already working. It's just that some properties haven't been converted yet. I have done so for Perimeter today http://hg.code.sf.net/p/octave/image/rev/db54e8cb5f9b

Carnë Draug <carandraug>
Project Member
Tue 05 Jul 2016 08:02:53 PM UTC, comment #3:

Sorry, but I suspect that in the near future I won't find any time to make regionprops.m work again.

Hartmut <hardy>
Fri 24 Jun 2016 10:39:50 PM UTC, comment #2:

I have pushed your patch http://hg.code.sf.net/p/octave/image/rev/a0405f2664f4

However, as you have noticed yourself, the current version of regionprops is a work in progress (unfortunately, a much more slow progress than I initially hoped for). The purpose of this work is to vectorize the computations of the properties which were just too slow. What this means is that the computations for Perimeter will have to be rewritten anyway.

Take a look on how regionprops has been written now if you are interested in making it work for the next release of the image package. I hope the comments are quite explicit how the code is supposed to work but I will be happy to clear up anything.

Carnë Draug <carandraug>
Project Member
Fri 06 Nov 2015 08:39:19 PM UTC, comment #1:

Here is a PATCH to fix this issue. It works as described before.

Since the current version of regionprops.m in the repo is not functional for the 'diameter' property, I could not test my final patch. But the (few) code lines to properly calculate the diameter value as well as the code of the new test where themselfs tested somehow, and should also be Matlab compatible.

(file #35403)

Hartmut <hardy>
Fri 06 Nov 2015 08:21:06 PM UTC, original submission:

This happens with Octave 4.0.0 and the current image package 2.4.1 (as well as the current repo tip of the image package). Here is a little script to show the behavior:

The results of Octave are: area = 31397 and perim = 564 .
The results of Matlab R2013b are: area = 31397 and perim = 658.4407 .

The "correct" result of the perimeter of a circle of radius 100.5 is perim = 631.46 . This is much closer to the Matlab approximation value than to the current Octave return value.

I think I understand the difference and will be able to fix it: Octave only counts the plain number of pixels that form the boundary. This results in a too small result at positions where two boundary pixels are only connected diagonally. Octave will currently calculate the length at this position to be 1 (as for any other pixels as well). But a better approximation for the distancy between to diagonally connected pixels is sqrt(2).

I will try to soon prepare a patch for this.

Hartmut <hardy>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #35403:  regionprops_diameter.patch added by hardy (1KiB - text/x-diff)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -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 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 24 Jun 2016 10:39:58 PM UTCcarandraugStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Fri 06 Nov 2015 08:39:19 PM UTChardyAttached File-=>Added regionprops_diameter.patch, #35403

    Back to the top


    Powered by Savane 3.1-cleanup1