Contour length of a region.
The operator contlength calculates the total length of the contour (sum of all connection components of the region) for each region of Regions. The distance between two neighbouring contour points parallel to the coordinate axes is rated 1, the distance in the diagonal is rated sqrt(2). If more than one region is passed the numerical values of the contour length are stored in a tuple, the position of a value in the tuple corresponding to the position of the region in the input tuple. In case of an empty region the operator contlength returns the value 0.
The contour of holes is not calculated.
Regions (input_object) |
region(-array) -> object |
Region(s) to be examined. |
ContLength (output_control) |
real(-array) -> real |
Contour length of the input region(s). | |
Assertion: ContLength >= 0 |
#include#include "HCPP.H" int main (int argc, char *argv[]) { if (argc < 2) { cout << "Usage: " << argv[0] << " <# of regions> " << endl; return (-1); } HWindow w; HRegionArray reg; int NumOfElements = atoi (argv[1]); cout << "Draw " << NumOfElements << " regions " << endl; for (int i=0; i < NumOfElements; i++) { reg[i] = w.DrawRegion (); } Tuple circ = reg.Circularity (); Tuple cont = reg.Contlength (); for (i = 0; i < NumOfElements; i++) { cout << "Circularity of " << i+1 << ". region = " << circ[i].D(); cout << "\t\t Contour Length of" << i+1 << ". region = " << cont[i].D() << endl; } w.Click (); return(0); }
The operator contlength returns the value TRUE if the input is not empty. The behavior in case of empty input (no input regions available) is set via the operator set_system(::'no_object_result',<Result>:). If necessary an exception is raised.
threshold__, regiongrowing__, connection