1. 程式人生 > >halcon影象旋轉

halcon影象旋轉

read_image(Image, '1.bmp')
rgb1_to_gray (Image, ImageGray)
get_image_size (ImageGray, Width, Height)
*/////////////////////////////////////////標定

*/////////////////////////////////////////旋轉
gen_disc_se(SE,'byte', 20,20, 0)
gray_tophat (ImageGray, SE, ImageTopHat)
threshold(ImageTopHat, Region8, 10, 240)
intensity( Region8, ImageTopHat, Mean, Deviation)
opening_rectangle1(Region8, RegionOpeningn, 20
, 1) connection(RegionOpeningn, ConnectedRegionsn) select_shape(ConnectedRegionsn, ConnectedRegionsn, 'width', 'and', 1000, 99999) elliptic_axis(ConnectedRegionsn, Ra, Rb, Phi) Long:=|Phi| add:=0 for i := 0 to Long-1 by 1 add:=add+Phi[i] endfor average:=-(add/Long)/3.14*180 rotate_image (Image, Image, average, 'constant'
)