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: the background always comes first (since it is labeled 0).

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 the total number of labeled objects from l-image.

The GRAY feature list values are:

area

The labeled object area in pixel

left top right bottom

The coordinates of the ‘bounding box’ labeled object7

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 coordinates8: (= (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)> (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.0 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 = 1
scheme@(guile-user)> (im-features $3 $6)
$8 = ((3780 0 0 84 94 43.19735336303711 45.65052795410156 0.0 # # …) #)
scheme@(guile-user)> ((@@ (cv features) f-display) (match $8 ((bg a) a)))

                     area : 4295 (pixels)
    left top right bottom : 0 0 84 94
            mean-x mean-y :  40.94622  48.18766
             min max mean : 137.00000 251.00000 233.94669
       standard deviation :  19.80314
            major ev x, y :   0.22270   0.97489
            minor ev x, y :   0.97489  -0.22270
        major, minor axis :  39.87575  34.28503 (radius)
                    angle :  77.13236 (degrees)
      center of mass x, y :  40.94622  48.18766
                perimeter : 367.74725
                 skewness :  -2.94312
                 kurtosis :   8.75887
              circularity :   0.39909
             aspect ratio :   1.16307
                roundness :   0.85980

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

(7)

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

(8)

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]