Herror ::distance_lr (
    Hobject Region,
    const HTuple &Row1,
    const HTuple &Column1,
    const HTuple &Row2,
    const HTuple &Column2,
    double *DistanceMin,
    double *DistanceMax
)
Herror ::distance_lr (
    Hobject Region,
    const HTuple &Row1,
    const HTuple &Column1,
    const HTuple &Row2,
    const HTuple &Column2,
    HTuple *DistanceMin,
    HTuple *DistanceMax
)
HTuple HRegion::DistanceLr (
    const HTuple &Row1,
    const HTuple &Column1,
    const HTuple &Row2,
    const HTuple &Column2,
    HTuple *DistanceMax
) const

Calculate the distance between one line and one region.

The operator ::distance_lr calculates the orthogonal distance between one line and one region. As input the coordinates of 2 points that the line represent (Row1,Column1, Row2,Column2) and one region are expected. The parameters DistanceMin and DistanceMax return the result of the calculation.


Attention

Due to efficiency of ::distance_lr holes are ignored. Furthermore, if the lines intersects the region a minimal distance larger than 0.5 can be returned.


Parameters

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

Row1 (input_control)
point.y(-array) -> HTuple.double / long
Row of the first point of the line.

Column1 (input_control)
point.x(-array) -> HTuple.double / long
Column of the first point of the line.

Row2 (input_control)
point.y(-array) -> HTuple.double / long
Row of the second point of the line.

Column2 (input_control)
point.x(-array) -> HTuple.double / long
Column of the second point of the line.

DistanceMin (output_control)
number(-array) -> (HTuple.) double *
Minimal distance between the line and the region

DistanceMax (output_control)
number(-array) -> (HTuple.) double *
Maximal distance between the line and the region


Example
dev_close_window ()
read_image (Image, 'fabrik')
dev_open_window (0, 0, 512, 512, 'white', WindowHandle)
threshold (Image, Region, 180, 255)
connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 
              5000, 100000000)
dev_clear_window ()
dev_set_color ('black')
dev_display (SelectedRegions)
dev_set_color ('red')
Row1 := 100
Row2 := 400
for Col := 50 to 400 by 4
  disp_line (WindowHandle, Row1, Col+100, Row2, Col)
  distance_lr (SelectedRegions, Row1, Col+100, Row2, Col, 
               DistanceMin, DistanceMax)
endfor

Result

::distance_lr returns H_MSG_TRUE.


Alternatives

::distance_pr, ::distance_sr, ::diameter_region


See also

::hamming_distance, ::select_region_point, ::test_region_point, ::smallest_rectangle2


Module

Basic operators



Copyright © 1996-2002 MVTec Software GmbH