DGtal
0.9.4beta

In this example, we show how to use the GridCurve object, which is key to analyze digital curves.
Using the Z2i shortcut, you can merely declare it as follows:
You can load your grid curve from a text file that contains the coordinates of some points (each coordinate separated by a white space and one point per line).
For instance, the file smallSquare.dat used above contains:
Using the STL file stream, you can initialize your grid curve from the file data as follows:
DGtal::Board2D is a nice way of displaying many 2D objects. See Board2D: a stream mechanism for displaying 2D digital objects for further details.
Using the stream mechanism of DGtal::Board2D, you can write your grid curve in a vectorgraphics file (here in postscript, but xfig, svg, pdf are other available formats).
Here is a png conversion of the resulting image:
A same digital curve may be viewed in very different ways: either as an alternating sequence of cells, or as a sequence of points, or as a sequence of codes, and so one. Moreover, some processing algorithms require a specific type of elements: either 4connected points, 8connected points, grid edges, and so one. That is why the GridCurve object provides many ranges, i.e. objects that provides services to iterate over a sequence of elements.
For instance, if you have to (or want to) work with 8connected digital curves, you can get the grid curve inner points as follows:
If you have to (or want to) work with separating algorithms, you can get the grid curve incident points as follows:
See GridCurve for the exhaustive list of available ranges and their basic usage. See Analysis of onedimensional discrete structures for a general introduction about digital curves analysis.
Here are the basic includes:
In order to use the drawing mechanism, you have to include: