Herror ::hamming_distance_norm (
    Hobject Regions1,
    Hobject Regions2,
    const HTuple &Norm,
    long *Distance,
    double *Similarity
)
Herror ::hamming_distance_norm (
    Hobject Regions1,
    Hobject Regions2,
    const HTuple &Norm,
    HTuple *Distance,
    HTuple *Similarity
)
long HRegion::HammingDistanceNorm (
    const HRegionArray &Regions2,
    const HTuple &Norm,
    double *Similarity
) const
HTuple HRegionArray::HammingDistanceNorm (
    const HRegionArray &Regions2,
    const HTuple &Norm,
    HTuple *Similarity
) const

Hamming distance between two regions using normalization.

The operator ::hamming_distance_norm returns the hamming distance between two regions, i.e. the number of pixels of the regions which are different (Distance). Before calculating the different the region in Regions1 are normalized according to the regions in Regions2. The result is the number of pixels contained in one region but not in the other:

               Distance = |Norm(Regions1) intersection ~Regions2| +
                          |Regions2 intersection ~Norm(Regions1)|
The parameter Similarity describes the similarity between the two regions based on the hamming distance Distance:
             Similarity = ( 1 - Distance ) / ( |Norm(Regions1)| + |Regions2| )

The following types of normalization are available:



'center':

The region is moved so that both regions have the save center
of gravity.

If both regions are empty Similarity is set to 0. The regions with the same index from both input parameters are always compared.


Attention

In both input parameters the same number of regions must be passed.


Parameters

Regions1 (input_object)
region(-array) -> Hobject: HRegion(Array)
Regions to be examined.

Regions2 (input_object)
region(-array) -> Hobject: HRegion(Array)
Comparative regions.

Norm (input_control)
string(-array) -> HTuple.char *
Type of normalization.
Default value: 'center'
List of values: 'center'

Distance (output_control)
integer(-array) -> (HTuple.) long *
Hamming distance of two regions.
Assertion: Distance >= 0

Similarity (output_control)
real(-array) -> (HTuple.) double *
Similarity of two regions.
Assertion: (0 <= Similarity) && (Similarity <= 1)


Complexity

If F is the area of a region the mean runtime complexity is O(F).


Result

hamming_distance_norm returns the value H_MSG_TRUE if the number of objects in both parameters is the same and is not 0. The behavior in case of empty input (no input objects available) is set via the operator ::set_system('no_object_result',<Result>). The behavior in case of empty region (the region is the empty set) is set via ::set_system('empty_region_result',<Result>). If necessary an exception handling is raised.


Possible Predecessors

::threshold, ::regiongrowing, ::connection


Alternatives

::intersection, ::complement, ::area_center


See also

::hamming_change_region


Module

Region processing



Copyright © 1996-2002 MVTec Software GmbH