lvshape(3)

LIBRARY ROUTINE
lvshape - Performs shape analysis on images.

LIBRARY CALL
#include "vinclude.h"
int lvshape(image_type,
             image,
             typ_axe,
             typ_color,
             axis_flg,
             axis,
             outline_flg,
             outline,
             viff_flg,
             img3,
             file_flg,
             input_file,
             printdev,
             standard,
             central,
             invariant)
struct xvimage *image, **outline, **axis, **img3;
int image_type, file_flg, axis_flg, outline_flg, viff_flg;
int typ_axe, typ_color, standard, central, invariant;
char *input_file;
FILE *printdev;

INPUT

    image -- xvimage structure

    image_type -- if 0, image containing clusters or labelled objs. if 1, grey level image.

    axis_flg -- if 1, generates the image with axis representation.

    outline_flg -- if 1, generates the image with outlines representation.

    file_flg -- if 1, generates the ASCII file with objs or image information.

    input_file -- name of input file being analyzed

    printdev -- output device for printing

    print_flg -- print to printdev if set.

    standard: if 1, computes and prints standard moments.

    central: if 1, computes and prints central moments.

    invariants: if 1, computes and prints invariant moments.

OUTPUT

    image -- xvimage structure, holds the resulting image.

    axis -- xvimage structure, axis image.

    outline -- xvimage structure, outline image.

MODIFICATIONS
Ghosted by Pascal ADAM Fri Jun 15 13:38:24 MDT 1990 Modified vshape to output VIFF file format by Shirley Lee Feb/26/1991.

DESCRIPTION
lvshape performs a shape analysis on two different types of images, by extracting features like moments, area, centroids, etc.

The input "image" is a pointer to an INT xvimage that can be:

1.  A grey level image. In this particular case, the features will be computed for the entire image. Some of these features may not appear to make sense, nevertheless they will still contribute significant information to the regions.

2.  A labeled or clustered image. The grey level of a pixel in a labeled or clustered image is specifically used to assign a pixel to a particular labeled region. For a labeled image (output of vlabel ipl routine), the classes or regions are connected, however this is not true for a cluster number image (output of vquant, vkmeans or visodata). This difference can confuse a novice user, because vshape will not differentiate between connected or non-connected regions.

General Description of lvshape.

The features listed below are computed for each region or for the entire image, depending on the input image.

    - Centroid on x and y axis.

    - Variances on x and y.

    - Area or weighted area.

    - Orientation of the principal axis.

    - Eccentricity of the shape.

    - Bounded box coordinates.

Theses features are optional.

    - Standard Moments.

    - Central Moments and Normalized Central Moments.

    - Invariant Moments.

These features are provided in an optional ASCII file.

As mentioned above, the centroid coordinates of the grey level input image provides more information than the general sense of the centroid of a region.

In addition to the ASCII file, three other output files can be generated.

1.  The Axis Image. This image contains a representation of the moments of the regions contained in the input image. It can only be generated when the input image is a not a grey level image. There are two possibilities for representing the moment.

    The first one is an image containing a cross for each region. The cross center is located at the centroid of the region and the horizontal and vertical axes stop outside of the bounded box of the region.

    The second one is an image still containing a cross for each region but this time the cross is representative of the moment value in the principal axis system. The principal axis is the coordinate system in which the cross moment, m11 (cf reference for theory on moment below), is equal to zero. Therefore, this cross forms an angle (theta) with the x axis, and its length in both directions are proportional to the "length" of the shape is that direction.

2.  The Outline Image. This image contains the outlines of all the regions contained in this image. Again, this can only be generated if this input image is not a grey level image.

3.  The VIFF Image. The image contains all of the statistics. The VIFF output file has 61 (number of statistics) bands and the number of vectors in this file depends on the number of regions specified in the input image. If the statistics flags are not set, the corresponding statistics will default to zero.

For these three output images there is a final possibility, which is to assign all outlines or crosses a grey level of 255, or their previous region number. This enables the user to visualize the input image, the outline image, and the axis image using pseudo color to assign a different color to each region. This aids in interpreting the regions, and yields an artistic view of the image.

References:

1.  Vision In Man And Machine by Martin D. Levine. Chapter 10. "Shape". Page 480.

2.  Digital Image Processing by R.C. Gonzales & P. Wintz. Chapter "Representation and description". Page 418.

3.  IRE Transactions on information theory,vol IT-8,1962 "Visual Pattern Recognition by Moment Invariants" by Ming_Kuei Hu. Page 179.

SEE ALSO
vshape(1), intro(3), vipl(3), verror(3), vutils(3)

RESTRICTIONS
For the x and y representation, x represents the vertical axis and y the horizontal axis. This routine implies a lot of mathematical computation in a direct coordinate system, I didn't use the conventional x and y.

AUTHOR
Pascal ADAM, Shirley Lee

COPYRIGHT
Copyright 1991, University of New Mexico. All rights reserved.