[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #52933] [octave-forge] (image) regionprops Per
From: |
Hartmut |
Subject: |
[Octave-bug-tracker] [bug #52933] [octave-forge] (image) regionprops Perimeter returns Matlab incompatible results |
Date: |
Thu, 8 Feb 2018 14:56:43 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0 |
Follow-up Comment #12, bug #52933 (project octave):
Here is some code that I used to test the new Matlab (R2017b) results with:
clear, close all, clc
% assumption: perim = even*0.980 + odd*1.406 - corners*0.091
format compact
I = zeros(5);
I(3,3)=1
props=regionprops(I,'Perimeter');
perim=props.Perimeter
perim_ML = 0
even=0; odd=0; corners=-(perim-even*0.980-odd*1.406)/0.091
corners_ML=0
I = zeros(5);
I(3,3:4)=1
props=regionprops(I,'Perimeter');
perim=props.Perimeter
perim_ML = 1.96
even=2; odd=0; corners=-(perim-even*0.980-odd*1.406)/0.091
corners_ML=0
I = zeros(5);
I(3:4,3)=1
props=regionprops(I,'Perimeter');
perim=props.Perimeter
perim_ML = 1.96
even=2; odd=0; corners=-(perim-even*0.980-odd*1.406)/0.091
corners_ML=0
I = zeros(5);
I(3,3)=1; I(4,4)=1
props=regionprops(I,'Perimeter');
perim=props.Perimeter
perim_ML = 2.812
even=0; odd=2; corners=-(perim-even*0.980-odd*1.406)/0.091
corners_ML=0
I = zeros(5);
I(3,4)=1; I(4,3)=1
props=regionprops(I,'Perimeter');
perim=props.Perimeter
perim_ML = 2.812
even=0; odd=2; corners=-(perim-even*0.980-odd*1.406)/0.091
corners_ML=0
I = zeros(5);
I(3:4,3:4)=1
props=regionprops(I,'Perimeter');
perim=props.Perimeter
perim_ML = 3.556
even=4; odd=0; corners=-(perim-even*0.980-odd*1.406)/0.091
corners_ML=4
I = zeros(5);
I(3:4,3:4)=1; I(4,5)=1
props=regionprops(I,'Perimeter');
perim=props.Perimeter
perim_ML = 4.962
even=4; odd=1; corners=-(perim-even*0.980-odd*1.406)/0.091
corners_ML = 4
I = zeros(5);
I(3:4,3:4)=1; I(5,5)=1
props=regionprops(I,'Perimeter');
perim=props.Perimeter
perim_ML = 6.277
even=4; odd=2; corners=-(perim-even*0.980-odd*1.406)/0.091
corners_ML = 5
I = zeros(5);
I(2,3)=1; I(3,2:4)=1; I(4,3)=1
props=regionprops(I,'Perimeter');
perim=props.Perimeter
perim_ML = 5.624
even=0; odd=4; corners=-(perim-even*0.980-odd*1.406)/0.091
corners_ML = 0
I = zeros(5);
I(2,3)=1; I(3,2:4)=1; I(4,3)=1; I(5,3)=1
props=regionprops(I,'Perimeter');
perim=props.Perimeter
perim_ML = 7.402
even=2; odd=4; corners=-(perim-even*0.980-odd*1.406)/0.091
corners_ML = 2
I = zeros(5);
I(2,3)=1; I(3,2:4)=1; I(4,3)=1; I(5,4)=1
props=regionprops(I,'Perimeter');
perim=props.Perimeter
perim_ML = 8.436
even=0; odd=6; corners=-(perim-even*0.980-odd*1.406)/0.091
corners_ML = 0
I = zeros(5);
I(2,1:4)=1; I(3,4)=1
props=regionprops(I,'Perimeter');
perim=props.Perimeter
perim_ML = 7.013
even=6; odd=1; corners=-(perim-even*0.980-odd*1.406)/0.091
corners_ML = 3
Here are my conclusions:
* The three used coefficients seem to be right (0.980, 1.406, -0.091).
* The calculation of odd and even values seem to also be right (at least for
my test images above).
* The calculation of the corners value seems to be incompatible. Matlab seems
to do the following:
** corners of 90° are counted, but only when they are aligned with the
coordinate system.
** corners of 135° are counted
** corners of 45° are counted
** NO other types of corners are counted, especially not "spikes" of 360°
(aligned with axes or not), and 90° cornes that are tilted (by 45°) with
regard to the axes.
@Avinoam: Do you have a good idea how to mimic this behavior (of counting
"corners") on your code suggestion?
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?52933>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #52933] [octave-forge] (image) regionprops Perimeter returns Matlab incompatible results,
Hartmut <=