当前位置:网站首页>Region of Halcon: generation of multiple regions (4)

Region of Halcon: generation of multiple regions (4)

2022-06-26 01:24:00 Mr anhydrous

One 、 summary

There are many concepts of some region generation , Beginners are often at a loss , If you don't learn systematically , A few years down , The thought is still vague , Doing the project feels “ Book to time side hate less ”, This article is a follow-up to the previous ones , The aim is to penetrate comprehensively and systematically , It has the effect of water dropping through the stone .

Two 、 Region based operators

2.1 Point acquisition of contour line

operator :get_region_contour(region, Rows, Columns)

Get known area region Scattered points of , Save in Rows, Columns Inside .

read_image (Image, 'f:/images/DOTS/block.jpg')
rgb1_to_gray(Image,gray)

get_image_size(gray,width,height)
* gen_rectangle1(rect,0,0,height,width)
fast_threshold (gray,rect,0, 50 , 7)
* get_region_chain(rect, Row, Column, Chain)
get_region_contour(rect, Rows, Columns)

gen_image_const(BlkImage,'byte',width,height)


for I:=0 to |Rows|-1 by 1
    tmpRow:=Rows[I]
    tmpClm:=Columns[I]
    set_grayval(BlkImage, tmpRow, tmpClm, 228)
endfor
dev_display(BlkImage)

2.2. Get the segment area

gen_region_line(regline,row1,col1,row2,col2)

Get the region of a line segment , Be careful ,regline It's an area , Not a pixel list ; To get the hash point, you need the following steps :

gen_region_line(RegionLines, 100, 50, 150, 250)
get_region_points(RegionLines, Rows, Columns)

2.3 Get the pixel tuple of the region ( See the section )

 gen_region_points(regin,rows,cos)

function : Store individual pixels as image areas .

2.4 Generate polygons

gen_region_polygon

   function : Store a polygon as an area .

gen_image_const(BlkImage,'byte',width,height)
gen_region_polygon(reg,[100,50,50,100,300,300,300,100],[50,100,200,400,400,200,50,50])

 2.5 Generate polygon solid

 gen_region_polygon_filled(region,rows,cols)

function : Store a polygon as a filled area .

gen_image_const(BlkImage,'byte',width,height)
gen_region_polygon_filled(reg,[100,50,50,100,300,300,300,100],[50,100,200,400,400,200,50,50])

 2.6 Get... From area xld

gen_contour_region_xld (reg, Contours, 'border')

reg Yes input area ,Contours It's got xld object .

gen_image_const(BlkImage,'byte',width,height)
gen_region_polygon_filled(reg,[100,50,50,100,300,300,300,100],[50,100,200,400,400,200,50,50])
gen_image_const(xldImage,'byte',width,height)
gen_contour_region_xld (reg, Contours, 'border')

2.6. Generate polygon areas

gen_region_polygon_xld

function : Create a XLD The area in the polygon .

  The following code generates the outer contour region edge .

gen_image_const(BlkImage,'byte',width,height)
gen_region_polygon_filled(reg,[100,50,50,100,300,300,300,100],[50,100,200,400,400,200,50,50])
gen_image_const(xldImage,'byte',width,height)
gen_contour_region_xld (reg, Contours, 'border')
gen_polygons_xld(Contours,Polygons , 'ramer', 1 )

gen_region_polygon_xld( Polygons,Region,  'margin')

2.7. Generate area scanlines

gen_region_runs

   function : Create an image area in scan width encoding .

2.8. Mark areas with the same gray scale

label_to_region

function : Extract the area with the same gray value in an image .

原网站

版权声明
本文为[Mr anhydrous]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206252318418977.html