Segmentation is a complex task, and the number of functors in the CVR-Lib that deal with segmentation grows.
.. A few extra-notes are required.
There are two sorts of segmentation functors. Traditional "complete" algorithms and "blocks", with which you can build your own segmentation approach. There are also tools to convert the results from one representation to another.
The complete algorithms are:
- Threshold segmentation. Used to separate background from object (two-classes segmentation). You give a "window" for pixel values that should be recognized as object. The rest will be background. Some algorithms can choose automatically the threshold values. (see cvr::thresholdSegmentation, cvr::optimalThresholding)
- Watershed segmentation. This sort of algorithms are widely used. Several implementations can be chosen using the functor parameters (see cvr::watershedSegmentation)
- Comaniciu's Mean-Shift algorithm is also implemented. With it you can choose between quantization, oversegmentation and undersegmentation. (see cvr::meanShiftSegmentation)
- Region growing for a two-classes segmentation problem can also be found here (see cvr::regionGrowing)
There are several blocks, that can be used as part of a more complex segmentation approach.
- A statistical background model per pixel can detect a continuous background from a moving object or objects. (see cvr::backgroundModel)
- A pre-segmentation approach is implemented, which finds regions using color quantization and marks as background the colors most used at the border in cvr::csPresegmentation.
- Similar to the pre-segmentation is the cvr::kMeansSegmentation, but here no background is identified, only the color quantization and (optionally) the smoothing stages are done.
- cvr::whiteningSegmentation uses the kMeansSegmentation to segment the original image and a transformed one, and combines the results of both.
- Given a list of area points, where each object (or region) is represented by an cvr::areaPoints object, it is possible to generate a so called similarity matrix using the cvr::similarityMatrix functor. Here a similarity measure will be generated for all adjacent objects.
- With a similarity matrix it is possible to merge similar regions using the cvr::regionMerge functor.
Segmentation algorithms produce usually so called "masks", i.e. channels, where each pixel contains a label value. These masks can be considered for two classes problems, where only values of zero and not-zero will be differentiated, and "labeled" masks, where each value is considered as a different object. To extract the position of each single object in the image in an efficient way the functor
cvr::objectsFromMask should be used. Sometimes the
cvr::fastRelabeling functor provides all functionality required for this task.
The cvr::boundingBox functor can use one of the pointLists extracted with cvr::objectsFromMask to produce a new image with only one object.
It is useful sometimes to generate a color image, where each label found in the segmentation is replaced by its mean color, producing an color quantized image. Here, the functors cvr::usePalette and cvr::computePalette are helpful.