Skip to content

Main concepts of DGtal

troussil edited this page Jan 26, 2012 · 4 revisions

Description

The core of DGtal is built on a small set of concepts:

  • The concept space (CSpace) describes digital spaces of arbitrary dimension, with user-chosen integer types (CInteger). One available model of this concept is SpaceND, which defines fundamental types associated to a digital space like the type of point or vector lying in this space, etc. The point (or vector) is besides the key geometrical element of many components of the library (hierarchy of concepts of points to do).

  • The concept of value (CValue) describes a very abstract type that is default constructible, assignable, copiable, and equally comparable.

  • Sets and Images: There are concepts for the unbounded (i) and bounded (ii) cases :

    • (i)

      • The concept of image (CImage) merely describes a mapping between points and values. Models must at least provide a point and a value as inner types and a reading service, ie. an operator () that takes a point as argument and returns a value.
      • Sets can be implicitly defined through images. Such sets are called point predicates. CImplicitPointPredicate is a refinement of CImage whose values are less-than comparable. Its models must provide a method threshold () that returns a comparable value saying how to convert models of CImplicitPointPredicate into simple point predicates, verifying the concept CPointPredicate, which is simply a refinement of CImage whose values are boolean.
    • (ii)

      • The concept CBoundable gather types having a method domain () that can return a (reference on a) domain.
      • Being a refinement of CBoundable, the concepts of domain and set (CDomain and CDigitalSet (CSet ?), which is a refinement of CDomain) describe bounded sets of points, of known size, that can be enumerated from a lower bound to a upper bound. The difference is that the former is not-mutable, basically used to bound the space part where the computations have to be performed, while the latter is mutable (insertion/deletion of a point is available). A key model of domain is HyperRectDomain. It used to bound usual digital images. Models of sets are DigitalSetBySTLVector or DigitalSetBySTLSet.
        Note that at some time, a digital set (mutable) can be converted into a domain (not mutable) for having a domain of arbitrary shape.
        Moreover, since points either belong to or not belong to a given set of points, there are adapters of domains (DomainPredicate), or sets (SetPredicate), which are models of point predicate.
      • Lastly, the concept of image container is a refinement of CBoundable and CImage that provides extra services, especially writing a value associated to a point with the method setValue.
        Different models are available: ImageContainerBySTLVector, ImageContainerBySTLMap, mageContainerByITKImage, ImageContainerByHashTree. Moreover, thresholding is the basic way of getting point predicates (or sets) from an image whose values are comparable because, given a threshold, the image trivially defines an implicit point predicate bounded by a (hyper)-rectangular domain.

In order to kept algorithms as generic as possible, models of different concepts are required according to the operations that are performed:

  • a simple membership test only requires a model of CPointPredicate
  • visiting the points of a set requires a model of CDomain
  • insertion/deletion of points require a model of CSet
  • reading (resp. writing) values associated to a given point requires a model of CImage (resp. CImageContainer).

Changes in shapes

  • To write CImplicitPointPredicate and implement a generic adapter of models of implicit point predicate that is a model of point predicate (inspired by Point2ShapePredicate)
  • CDigitalOrientedShape becomes CImplicitPointPredicate
  • CDigitalBoundedShape is replaced by CBoundable
  • CEuclideanX can be removed: Euclidean shapes (implicitBall for instance) should be templated by a model of point (instead of space) and should be a model of CImplicitPointPredicate. When used with GaussDigitizer in order to generate digital shapes, the chosen type of point should be a model of RealPoint provided by SpaceND. GaussDigitizer, templated by a model of space and a model of CImplicitPointPredicate, can check if the type of point provided by the model of CImplicitPointPredicate is the same that the type of RealPoint provided by the model of CSpace. GaussDigitizer is itself a model of CImplicitPointPredicate, but such as the inner type Point is equal to the inner type Point of its model of CSpace.

Changes in images

ImageBySTLMap should be both a model of CImageContainer and CDigitalSet and should have a default value (which can be given as an argument at construction, being 0 by default) for points being in the domain but that are not stored in the map.

Possible change

Renaming concepts could help in making them more abstract and more understandable for the beginner or the non-specialist. For instance:

  • Space, Point

  • Image

  • ThresholdableImage (instead of ImplicitPointPredicate)

  • BinaryImage (instead of PointPredicate)

  • NotMutableSet (instead of Domain)

  • MutableSet (instead of DigitalSet)

  • ImageContainer (or ContainableImage or StorableImage)

Note that we could rename these concepts without changing the name of the models: for instance, the term HyperRectDomain makes sense because it names a type whose instances bound the computation domain for image processing algorithms.