Herror ::connection (
    Hobject Region,
    Hobject *ConnectedRegions
)
HRegionArray HRegion::Connection (
    void
) const
HRegionArray HRegionArray::Connection (
    void
) const

Compute connected components of a region.

::connection determines the connected components of the input regions given in Region. The neighborhood used for this can be set via ::set_system('neighborhood',<4/8>) The default is 8-neighborhood, which is useful for determining the connected components of the foreground. The inverse operator of ::connection is ::union1.


Parameters

Region (input_object)
region(-array) -> Hobject: HRegion(Array)
Input region.

ConnectedRegions (output_object)
region-array -> Hobject * : HRegionArray
Connected components.


Example
#include  <iostream.h>
#include  "HalconCpp.h"

int main (int argc, char *argv[])
{
  HImage   image (argv[1]);
  HWindow  w;
  w.SetColored(12);
  HRegion Light = image >= 128;
  Light.Display(w);
  HRegionArray Many = Light.Connection();
  cout << "Nummber of regions after threshold = " << Many.Num();
  Many.Display(w);
}

Complexity

Let F be the area of the input region and N be the number of generated connected components. Then the runtime complexity is O(F * N).


Result

::connection always returns the value H_MSG_TRUE. The behavior in case of empty input (no regions given) can be set via ::set_system('no_object_result',<Result>) and the behavior in case of an empty input region via ::set_system('empty_region_result',<Result>). If necessary, an exception handling is raised.


Possible Predecessors

::auto_threshold, ::threshold, ::dyn_threshold, ::erosion1


Possible Successors

::select_shape, ::select_gray, ::shape_trans, ::set_colored, ::dilation1, ::count_obj, ::reduce_domain, ::add_channels


Alternatives

::background_seg


See also

::set_system, ::union1


Module

Region processing



Copyright © 1996-2002 MVTec Software GmbH