Halcon判断一个点是否在某个区域

* Index of all regions containing a given pixel
* 
read_image (Image, 'fabrik')
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowID)
dev_set_color ('white')
dev_set_draw ('fill')
* Segment an image using regiongrowing
regiongrowing (Image, Regions, 1, 1, 3, 400)
Button := 1
dev_set_color ('red')
while (Button == 1)
    * Click with the mouse on the region to be selected
    * Quit the loop with the right mouse button
    get_mbutton (WindowID, Row, Column, Button)
    get_region_index (Regions, Row, Column, Index)
    if (Index != [])
        select_obj (Regions, ObjectSelected, Index)
    endif
endwhile
* 
* This example program shows how to use select_xld_point.
* 
* Color code:
* red - test point
* white - contours, selected
* dim gray - contours, not selected
* 
* 
* 
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
* 
* 
* 
PointRow := 100.0
PointCol := 100.0
gen_contour_polygon_xld (Contours, [50,50,150,150,50], [50,150,150,50,50])
gen_contour_polygon_xld (Contour2, [50,50,150,150,50], [200,300,300,200,200])
concat_obj (Contours, Contour2, Contours)
select_xld_point (Contours, SelectedContours, PointRow, PointCol)
gen_cross_contour_xld (Cross, PointRow, PointCol, 6, 0.785398)
dev_clear_window ()
dev_set_color ('dim gray')
dev_display (Contours)
dev_set_color ('white')
dev_display (SelectedContours)
dev_set_color ('red')
dev_display (Cross)
stop ()
* 
* 
* 
* Contours that are not closed will be closed automatically.
* Therefore, the selection for the open contours is exactly
* the same as in the previous example.
* 
PointRow := 100.0
PointCol := 100.0
gen_contour_polygon_xld (Contours, [50,50,150,150], [50,150,150,50])
gen_contour_polygon_xld (Contour2, [50,50,150,150], [200,300,300,200])
concat_obj (Contours, Contour2, Contours)
select_xld_point (Contours, SelectedContours, PointRow, PointCol)
gen_cross_contour_xld (Cross, PointRow, PointCol, 6, 0.785398)
dev_clear_window ()
dev_set_color ('dim gray')
dev_display (Contours)
dev_set_color ('white')
dev_display (SelectedContours)
dev_set_color ('red')
dev_display (Cross)
stop ()
* 
* 
* 
* Intersecting line segments may cause holes in a polygon. Note that
* line segments in real world applications will practically never intersect.
* 
PointRow := 200.0
PointCol := 200.0
gen_contour_polygon_xld (Contours, [50,50,250,250,150,150,350,350,50], [50,250,250,150,150,350,350,50,50])
select_xld_point (Contours, SelectedContours, PointRow, PointCol)
gen_cross_contour_xld (Cross, PointRow, PointCol, 6, 0.785398)
dev_clear_window ()
dev_set_color ('dim gray')
dev_display (Contours)
dev_set_color ('white')
dev_display (SelectedContours)
dev_set_color ('red')
dev_display (Cross)
stop ()
* 
* 
* 
* Points lying directly on one of the contour's line segments
* cannot be classified reliably.
* 
PointRow := 200.0
PointCol := 200.0
gen_contour_polygon_xld (Contours, [150,150,250,250,150], [100,200,200,100,100])
gen_contour_polygon_xld (Contour2, [100,100,200,200,100], [150,250,250,150,150])
concat_obj (Contours, Contour2, Contours)
gen_contour_polygon_xld (Contour3, [150,150,250,250,150], [200,300,300,200,200])
concat_obj (Contours, Contour3, Contours)
gen_contour_polygon_xld (Contour4, [200,200,300,300,200], [150,250,250,150,150])
concat_obj (Contours, Contour4, Contours)
select_xld_point (Contours, SelectedContours, PointRow, PointCol)
gen_cross_contour_xld (Cross, PointRow, PointCol, 6, 0.785398)
dev_clear_window ()
dev_set_color ('dim gray')
dev_display (Contours)
dev_set_color ('white')
dev_display (SelectedContours)
dev_set_color ('red')
dev_display (Cross)

你可能感兴趣的:(Halcon实战)