help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Octave vs Matlab: regionprops differences


From: Giorgio De Nunzio
Subject: Octave vs Matlab: regionprops differences
Date: Wed, 17 Jan 2018 20:36:50 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

Hi all,

please try this script in Matlab (with the image processing toolbox) and in octave (first loading the image package):

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% define a mask
BW = logical([1 1 1 0 0 0 0 0
              1 1 1 0 1 1 0 0
              1 1 1 0 1 1 0 0
              1 1 1 0 0 0 1 0
              1 1 1 0 0 0 1 0
              1 1 1 0 0 0 1 0
              1 1 1 0 0 1 1 0
              1 1 1 0 0 0 0 0]);

L = bwlabel(BW, 8);   % ,4 or ,8 (default)
s = regionprops(L, 'Perimeter', 'Eccentricity')

for j = 1:size(s)
  disp(s(j).Perimeter)
  disp(s(j).Eccentricity)
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Here is the result, with connectivity = 4 or 8, and Matlab or octave:


Connectivity = 4, Matlab:

s =

  3×1 struct array with fields:
    Eccentricity
    Perimeter

   17.2760
    0.9270
    3.5560
     0
    7.0130
    0.9315


Connectivity = 4,  octave

error: vertical dimensions mismatch (1x3 vs 1x2)
error: called from
    regionprops>rp_perimeter at line 767 column 8
    regionprops at line 412 column 26
    testOctaveVSMatlab at line 13 column 3
>>

Connectivity = 8, Matlab

s =
  2×1 struct array with fields:
    Eccentricity
    Perimeter

   17.2760
    0.9270
   13.1080
    0.9429


Connectivity = 8, octave

s =
  2x1 struct array containing the fields:
    Perimeter
    Eccentricity

 18
 0.92702
 14.243
 0.98641
>>

As you see, with 4-connectivity, octave breaks. With 8-connectivity, perimeters and eccentricities are different.

Thanks

Giorgio



---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus




reply via email to

[Prev in Thread] Current Thread [Next in Thread]