Holes Construction
A hole is a set of connected pixels that are entirely surrounded by a parent object (4 or 8 pixels depending on the connexity mode).
A hole has no child. Objects inside a hole are considered as separate objects.
EObject and EHole classes both derive from ECodedElement, so objects and holes are managed in the same way and share the same functions.
Encoding the white layer (3 objects and 3 holes)
Encoding the black layer (4 objects and 3 holes)
- Declare a new ECodedImage2 object.
- Declare an EImageEncoder and, if applicable, select and setup the appropriate segmenter, and choose the appropriate layer(s) to encode.
- Setup an output image.
- Encode the image.
- Declare a helper function to draw the runs. A helper function (see also section Object Construction/Working at the Run Level) draws the runs in an output image, using, for example, a given color. This function can be shared for objects and holes.
- Draw the objects and their holes in the output image. It is necessary to iterate over the objects of the chosen layer.
- The helper function draws the runs of each object (DrawRuns) using a specific color.
- The holes are iterated over the current object, and their runs are drawn.
- Each hole of an object is drawn with a different color computed in the global function (GetFadedColor) which returns a color that depends upon the hole index, for example a gradation of red to green colors.
Raw image (left) Building of objects and all holes (right)