ARDECO: Automatic Region DEtection and COnversion

Source Code

 

The complete source-code of ARDECO and a compiled version for Windows are available as a plug-in for our Graphite software, see the Graphite page.

Some of the most important parts of the implementation are also explained here. Implementing ARDECO requires two subtle pieces of software:

The files in this directory contain a full implementation of the generic rasterizer and M-estimator code for functions of degree 0 to 3 (adding other functions bases is very easy if needed, see bivariate.h).
This source code is licensed under the GNU GPL.
 
types.h Basic typedefs, useful inline functions.
geometry.h
geometry.cpp
Point and vectors in 2d (Vec2) + operators,
Polygons in 2d, Sutherland-Hogdman re-entrant clipping.
median.h Computes the median of a set of (weight,value) pairs
matrix.h Matrix class and utilities
image.h
image.cpp
Image, memory management, RGB output.
m_estimator.h
m_estimator.cpp
M estimators (L1L2, Lp, fait, Huber, Cauchy, Geman-McClure, Welsh, Tuckey)
bivariate.h Bivariate functions (degree 1 to 3), and generic M-estimator fitting code
rasterizer.h The generic exact rasterizer
integral.h Instanciations of the rasterizer:
  • ImagePolygonIntegral
  • ImagePolygonMean
  • ImagePolygonMedian
  • ImagePolygonBarycenter
  • template ImagePolygonFitting
    computes the function that best fits a polygonal suset of an image. class FUNC can be one of those declared in "bivariate.h" Gives also access to the integrated covariance matrix and right-hand side.
test.cpp a simple example of using the generic rasterizer to draw antialiased polygons in an image
 
The generic rasterizer computes 20000 weighted barycenters per second (on a 2 GHz Pentium M) in exact mode. In approximated mode, this reaches 40000 weighted barycenters per second. However, we recommend using the exact mode, since the pixels intersected by the triangles borders are very likely to correspond to discontinuities in the image. Therefore, it is important to compute their exact contribution.
 

Compiling and running the test program

 
Compiling the sources should not be difficult.
Under Windows, just add all the source files to a project and build it.
Under Unix, use g++ *.cpp -lm -o test_rasterizer
 
As a starting point, the test program creates an image out.rgb with an antialiased triangle. This can be easily adapted to the user's need, by using the rasterizer instanciations available in integral.h.