Tutorial 6 . Contours

Date: May 12, 2020, 5:53 p.m. | 

Tutorial 6 describes how eli application reads objects contours and how contours can be display on picture. Tutorial explains contours parameters. Eli application uses contours parameters for objects description program. Execution of object description program founds object on cameras, pictures or videos.

Find contours, draw contours

Tutorial picture

Contours parameters

Next part of this tutorial explains contours parameters. Those parameters is using during object description programs. It is mathematical description of contours. Results of this mathematical description are using in object description programs.

Bounding Rectangle

Bounding rectangle is rectangle around all object. Bounding rectangle has 4 parameters:

Tutorial picture

Contour area and perimeter

Contour area is number of all pixels in the object represented by contour
Perimeter is length of contour over object

Tutorial picture

Minimal area rectangle

It is minimal rectangle over all object. Rectangle also describe rotation of object Minimal area rectangle has 5 parameters:

Tutorial picture

Minimal enclosing circle

It is minimal circle over all object. Minimal enclosing circle has 5 parameters:

Tutorial picture

Fit ellipse

It is minimal ellipse over all object. Ellipse also describe rotation of object fit ellipse has 5 parameters:

Tutorial picture

Moments

There are four types of moments which are calculated on contours. It is Spatial moments,Central moments, Normalized cetral moments and Hu moments
The first three moments are calculated up to the 3rd order. There are 2 picture which helps explain moments calculation. There are two different object on each picture
On the picture is same object with various position:

Object A

Tutorial picture

Object B

Tutorial picture

Spatial moments

Spatial moments are calculated according follow formulla:

Tutorial picture

Table bellow show spatial moments on both objects on picture above
(0 0)(1 0)(0 1)(1 1)(2 0)(0 2)(3 0)(2 1)(1 2)(0 3)
ObjA 317737.54.99666e+065.62435e+061.53457e+091.46495e+091.84454e+094.45672e+114.3586e+114.88249e+116.23745e+11
ObjA 49929.55.07865e+062.87129e+061.46919e+092.60054e+098.64829e+081.33311e+127.52635e+114.42781e+112.69793e+11
ObjA 117759.51.93094e+064.24407e+064.63406e+082.19388e+081.12349e+092.57921e+105.29516e+101.235e+113.19615e+11
ObjA 217759.55.68349e+062.28613e+067.29661e+081.92813e+093.0373e+086.88084e+112.47358e+119.65996e+104.14146e+10
ObjB 1316650.54.5397e+064.74617e+061.2621e+091.27477e+091.39666e+093.67914e+113.45878e+113.62496e+114.23443e+11
ObjB 1481883.73339e+061.88459e+068.60065e+081.70432e+094.51198e+087.78961e+113.92987e+112.06124e+111.11892e+11
ObjB 11165491.40598e+063.5126e+063.01685e+081.27815e+088.17047e+081.22805e+102.77511e+107.10363e+102.03854e+11
ObjB 12165544.89893e+061.73768e+065.10946e+081.52135e+091.90774e+084.92481e+111.57984e+115.5699e+102.17828e+10

Spatial moments is raw moments. It used for calculation other types of moments
Spatial moments (0,0) is same value as contour area. If you look on the formulla it is just count of pixels

Central moments

Central moments are calculated according follow formula:

Tutorial picture

Central moments use the mass center calculated from spatial moments. Central moments (0,0) is same as a spatial moments (0,0), central moments (1,0) (0,1) is zero
Table bellow show central moments on both objects on the picture above.
(2 0)(1 1)(0 2)(3 0)(2 1)(1 2)(0 3)
ObjA 35.73947e+07-4.98137e+076.11254e+076.57369e+08-5.94336e+082.32032e+089.91759e+07
ObjA 42.96483e+066057083.45458e+07-2.75378e+072.28825e+079.63112e+07-2.66864e+08
ObjA 19.44212e+061.95917e+061.09269e+08-1.14698e+089.73089e+074.08835e+08-1.09688e+09
ObjA 21.09269e+08-1.95917e+069.44212e+061.09688e+094.08835e+08-9.73089e+07-1.14698e+08
ObjB 133.70346e+07-3.19304e+074.37821e+071.58183e+08-7.96574e+07-9.66333e+073.68412e+08
ObjB 142.04315e+067698371.74324e+07-5719251.09706e+074.17462e+071.76256e+07
ObjB 118.36398e+063.25848e+067.14823e+073677506.82476e+072.37686e+088.72112e+07
ObjB 127.15813e+07-3.29803e+068.36821e+06-1.09078e+082.38701e+08-6.55965e+07227269

Normalized Central moments

Normalized Central moments are calculated according follow formulla:

Tutorial picture

Normalized central moments use central moments which is devided with contour area powered according (i,j) . Normalized Central moments (0,0) is 1, normalized central moments (1,0) (0,1) is zero
Table bellow show central moments on both objects on the picture above.
(2 0)(1 1)(0 2)(3 0)(2 1)(1 2)(0 3)
ObjA 30.182426-0.158330.1942840.0156884-0.01418410.005537530.00236687
ObjA 40.03007080.00614340.350381-0.002802920.002329080.00980298-0.0271626
ObjA 10.0299370.006211690.346444-0.002728840.002315130.00972683-0.0260964
ObjA 20.346444-0.006211690.0299370.02609640.00972683-0.00231513-0.00272884
ObjB 130.133583-0.1151730.1579220.00442172-0.00222668-0.002701210.0102983
ObjB 140.0304750.01148270.260016-9.42746e-050.001808360.006881330.00290535
ObjB 110.030540.01189790.2610091.04381e-050.001937130.006746440.00247539
ObjB 120.261212-0.01203510.030537-0.003093710.00677011-0.001860476.44588e-06

HU moments

HU moments are calculated according follow formulla:

Tutorial picture

Hu moments are calculated from Normalized central moments. There are 7 HU moments. The first six moments are invariant to the image scale,rotation and reflection. The seventh one is invariant only to the image scale, rotation. Sign of seventh is changed according reflection.
HU0HU1HU2HU3HU4HU5HU6
ObjA 30.376710.1004150.002018580.0005901866.42718e-070.00015517-4.33658e-08
ObjA 40.3804520.1027490.002203820.0006657058.04458e-070.000177569-5.48277e-08
ObjA 10.3763810.1003310.002109970.0006145226.96882e-070.000159366-6.33078e-08
ObjA 20.3763810.1003310.002109970.0006145226.96882e-070.000159366-6.33078e-08
ObjB 130.2915050.05365140.0004451486.8111e-053.56325e-09-4.88411e-061.13119e-08
ObjB 140.2904910.05321660.0004364246.82831e-054.27595e-09-4.00399e-061.09847e-08
ObjB 110.2915490.05368210.0004203376.51257e-053.473e-09-4.61593e-061.02002e-08
ObjB 120.2917490.05379050.0004184377.04657e-055.20806e-09-3.31515e-061.09217e-08


Leave comments:


Comments: