Next: , Previous: , Up: Guile-CV   [Contents][Index]


3.2.5 Features

The Guile-CV procedures and methods related to image features.

Procedures

im-features
Procedure: im-features image l-image [#:n-label #f]

Returns a list of features, one list for each labeled object - including the backgroud - in ascending order.

Notes: (a) image can either be an RGB or a GRAY image; (b) l-image is the ‘corresponding’ labeled image; (c) when used, the #:n-label optional keyword argument must be total number of label values used in l-image, as returned by im-label and im-label-all.

The GRAY feature list values are:

area

The labeled object area in pixel

left top right bottom

The coordinates of the ‘bounding box’ labeled object9

mean-x mean-y

Also sometimes called the ‘centroid’, these are the average of the x and y coordinates of all of the pixels in the labeled object. These two coordinate values are floating points, representing the ‘mathematical position’ of the mean x and y values of the labeled object

min max mean std-dev

The minimum, maximum, mean and standard gray deviaton labeled object values

major-ev-x major-ev-y minor-ev-x minor-ev-y

Respectively the major and minor eigen vectors x and y normalized coordinates10: (= (sqrt (+ (expt x 2) (expt y 2))) 1)

major-axis minor-axis

Respectively the major and minor eigen values, optimized so that they actually correspond to major and minor radius of the ellipse covering the same area as the particle itself

angle

The angle of the major eigen vector axis, in degrees in the trigonometirc circle reference system

center-mass-x center-mass-y

The center of mass x and y coordinates

perimeter

The labeled object perimeter in pixels

skewness kurtosis

Respectively the skewness and the kurtosis of the labeled object

circularity aspect-ratio roundness

Respectively the circularity (/ (* 4 %pi area) (expt perimeter 2)), the aspect ratio (/ major-axis minor-axis) and the roundness (/ minor-axis major-axis) of the labeled object

The RGB feature list values are:

area

The labeled object area in pixel

left top right bottom

The coordinates of the labeled object (the corresponding GRAY feature footnote applies here too of course)

mean-x mean-y

Also sometimes called the ‘centroid’, these are the average of the x and y coordinates of all of the (red green blue) pixels in the labeled object. These two coordinate values are floating points, representing the ‘mathematical position’ of the mean x and y values of tha labeled object

min-r min-g min-b max-r max-g max-b mean-r mean-g mean-b std-dev-r std-dev-g std-dev-b

The minimum, maximum, mean and standard deviaton labeled object values of the red, green and blue channels

major-axis minor-axis

Respectively the major and minor eigen values, optimized so that they actually correspond to major and minor radius of the ellipse covering the same area as the particle itself

angle

The angle of the major eigen vector axis, in degrees in the trigonometirc circle reference system

center-mass-x center-mass-y

The center of mass x and y coordinates

perimeter

The labeled object perimeter in pixels

skewness-r skewness-g skewness-b kurtosis-r kurtosis-g kurtosis-b

Respectively the skewness and the kurtosis labeled object values of the red, green and blue channels

circularity aspect-ratio roundness

Respectively the circularity (/ (* 4 %pi area) (expt perimeter 2)), the aspect ratio (/ major-axis minor-axis) and the roundness (/ minor-axis major-axis) of the labeled object

Though we did not make it public, Guile-CV has an internal feature display procedure that you might be interested to (re)use, so here is an example of a GRAY feature list display:

scheme@(guile-user)> ,use (cv)
scheme@(guile-user)> (im-load "pp-17-bf.png")
$2 = (85 95 3 (#f32(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 …) …))
scheme@(guile-user)> (im-rgb->gray $2)
$3 = (85 95 1 (#f32(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 # …)))
$4 = (0.0 251.0 128.3132714138286 8075)
scheme@(guile-user)> (im-threshold $3 136)
$5 = (85 95 1 (#f32(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 # …)))
scheme@(guile-user)> (im-label $5)
$6 = (85 95 1 (#f32(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 # …)))
$7 = 2
scheme@(guile-user)> (im-features $2 $6)
$8 = ((3782 0 0 84 94 43.19196319580078 45.657588958740234 0.0 # …) …)
scheme@(guile-user)> ((@@ (cv features) f-display) (match $8 ((bg a) a)))

                          area : 4293 (pixels)
         left top right bottom : 0 0 84 94
                 mean-x mean-y :  40.94992  48.18262
        min (red, green, blue) : 137.00000 136.00000 135.00000
        max (red, green, blue) : 255.00000 250.00000 250.00000
       mean (red, green, blue) : 236.13417 232.84999 232.84207
  std. dev. (red, green, blue) :  20.23275  19.41402  19.84854
                 major ev x, y :   0.22202   0.97504
                 minor ev x, y :   0.97504  -0.22202
             major, minor axis :  39.86419  34.27900 (radius)
                         angle :  77.17241 (degrees)
           center of mass x, y :  40.73749  48.28692
                     perimeter : 367.74725
   skewness (red, green, blue) :  -2.90164  -2.99066  -2.91777
   kurtosis (red, green, blue) :   8.53371   9.05482   8.61162
                   circularity :   0.39891
                  aspect ratio :   1.16293
                     roundness :   0.85989

As we mentioned above, f-diplay is defined in the (cv features) module, but it is not exported: in Guile, calling none exported procedure (which should not be ‘abused’) is done using the syntax @@ module-name binding-name, which in this example translates to (@@ (cv features) f-display).


Footnotes

(9)

Note that when passed to im-crop, right and bottom must be increased by 1: (im-crop image left top (+ right 1) (+ bottom 1)).

(10)

Note that Vigra calculates and returns these values in the image coordinate system, where the y-axis is ‘flipped’ compared to the trigonometric circle ‘traditional’ representation. Guile-CV however transforms and returns these values using the trigonometric circle reference system.


Next: , Previous: , Up: Guile-CV   [Contents][Index]