distance_ps ( : : Row, Column, Row1, Column1, Row2, Column2 : DistanceMin, DistanceMax )

Calculate the distances between a point and a line segment.

The operator distance_ps calculates the minimum and maximum distance between a point (Row,Column) and a line segment which is represented by the start point (Row1,Column1) and the end point (Row2,Column2). DistanceMax is the maximum distance between the point and the end points of the line segment. DistanceMin is identical to distance_pl in the case that the point is ``between'' the two endpoints. Otherwise, the minimum distance to one of the end points is used.


Parameters

Row (input_control)
point.y(-array) -> real / integer
Row coordinate of the first point.

Column (input_control)
point.x(-array) -> real / integer
Column coordinate of the first point.

Row1 (input_control)
point.y(-array) -> real / integer
Row coordinate of the first point of the line segment.

Column1 (input_control)
point.x(-array) -> real / integer
Column coordinate of the first point of the line segment.

Row2 (input_control)
point.y(-array) -> real / integer
Row coordinate of the second point of the line segment.

Column2 (input_control)
point.x(-array) -> real / integer
Column coordinate of the second point of the line segment.

DistanceMin (output_control)
number(-array) -> real
Minimum distance between the point and the line segment.

DistanceMax (output_control)
number(-array) -> real
Maximum distance between the point and the line segment.


Example
read_image (Image, 'mreut')
dev_open_window (0, 0, 512, 512, 'white', WindowHandle)
dev_display (Image)
dev_set_color ('black')
threshold (Image, Region, 180, 255)
dev_clear_window ()
dev_display (Region)
connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and',
              10000, 100000000)
get_region_contour (SelectedRegions, Rows, Columns)
RowLine1 := 400
ColLine1 := 50
RowLine2 := 50
ColLine2 := 450
NumberTuple := |Rows|
dev_set_color ('red')
disp_line (WindowHandle, RowLine1, ColLine1, RowLine2, ColLine2)
dev_set_color ('green')
for i := 1 to NumberTuple by 10
  disp_line (WindowHandle, Rows[i], Columns[i]-2, Rows[i], Columns[i]+2)
  disp_line (WindowHandle, Rows[i]-2, Columns[i], Rows[i]+2, Columns[i])
  distance_ps (Rows[i], Columns[i], RowLine1, ColLine1, RowLine2, ColLine2,
               DistanceMin, DistanceMax)
endfor

Result

distance_ps returns 2 (H_MSG_TRUE).


Parallelization Information

distance_ps is reentrant and processed without parallelization.


Alternatives

distance_pl


See also

distance_pp, distance_pr


Module

Foundation



Copyright © 1996-2008 MVTec Software GmbH