Use of polar coordinates

Round pictures are converted into rectangles to facilitate character recognition and key area extraction.

 

Corresponding operator in halcon

(1) Polar expansion: polar_trans_image_ext(Image: PolarTransImage: Row, Column, AngleStart, AngleEnd, RadiusStart, RadiusEnd, Width, Height, Interpolation : )

(2) Inverse polar transformation: polar_trans_image_INv (PolarImage: XYTransImage: Row, Column, AngleStart, AngleEnd, RadiusStart, RadiusEnd, Width, Height, Interpolation : )

Where Row and Column are the coordinates of the center Row and Column of the ring respectively, AngleStart and AngleEnd are the starting and ending angles, RadiusStart and RadiusEnd are the starting and ending radius angles, Width and Height are the Width and Height of the output image.

(3) Inverse transformation of point coordinates: polar_trans_contour_XLD_INV (PolarContour: XYTransContour: Row, Column, AngleStart, AngleEnd, RadiusStart, RadiusEnd, WidthIn, HeightIn, Width, Height : )

 

I wrote the case

dev_close_window () dev_open_window (0, 0, 512, 512, 'black', WindowHandle) read_image (Image, PNG) get_image_size (Image, Width, Height) draw_circle (WindowHandle, Row1, Column1, Radius) gen_circle (WindowHandle, Row1, Column1) Row1, Column1, Radius) reduce_domain (Image, Circle, ImageReduced) PI:=3.1415926 * counterclockwise, from 0 degrees to 360 degrees, turn one circle polar_trans_ext (PolarTransImage, Row1, Column1, 0, 2*PI, 0, Radius, Width, Height, 'nearest_neighbor') write_image (PolarTransImage, 'jpeg 100', 0, 'd:\\1.jpg') * length and width must be the length and width of the original image, otherwise the size is too small, the image is easy to exceed, resulting in a black, can not see the conversion result polar_trans_image_INv (PolarTransImage, XYTransImage, Row1, Column1, 0, 2*PI, 0, Radius, Width, Height, 'nearest_neighbor') write_image (XYTransImage, 'jpeg 100', 0, The original coordinate of Contour is based on polar coordinate system, we transfer it to Cartesian coordinate system gen_Contour_Polygon_xld (Contour, [155.568, 137.404, 30], [47.4712, 116.479, 260]) XLD_INV ( Width, Height, Width, Height) stop()Copy the code

Before the conversion:

After the transformation:

Inverse transformation: will return to the original

 

The official routine

ocr_cd_print_polar_trans.hdev

create_shape_model_xld.hdev

circular_barcode.hdev

 

reference

Blog.csdn.net/qq_32939413…

www.pianshen.com/article/394…