Explanation: define an identity matrix with diagonal 1, which is multiplied by any matrix equal to the original matrix itself.
hom_mat2d_translate (HomMat2DIdentity, Tx, Ty, HomMat2DTranslate)
Function: add translation to anti fire transformation matrix
Hommat2d (input parameter): affine transformation matrix
TX (input parameter): the distance to translate along the x axis
Ty (input parameter): the distance to translate along the y axis
Hommat2dtranslate (output parameter): output transformation matrix
##Image preprocessing part #1 image translation, rotation, scaling, affine transformation, projection transformation read_image(Image,'E:/C/Halcon/1.jpg') hom_mat2d_identity (HomMat2DIdentity) hom_mat2d_translate(HomMat2DIdentity,300,500,HomMat2DIdentity) affine_trans_image (Image, ImageAffineTrans, HomMat2DIdentity, 'constant', 'false') #rotate hom_mat2d_identity (HomMat2DIdentity) hom_mat2d_rotate (HomMat2DIdentity, 0.78, 300, 300, HomMat2DRotate) affine_trans_image (Image, ImageAffineTrans, HomMat2DRotate, 'constant', 'false') #zoom hom_mat2d_identity (HomMat2DIdentity) hom_mat2d_scale (HomMat2DIdentity, 0.5, 0.5, 0, 0, HomMat2DScale) affine_trans_image (Image, ImageAffineTrans, HomMat2DScale, 'constant', 'false')
The region of interest is extracted to reduce the amount of calculation. In image matching, you can define templates. It's an area.
In halcon, ROI needs two steps to complete. The first step is to delimit the area and the second step is to cut out the area.
There are two ways to divide areas. The first is to use the create ROI of the interface, and various block diagrams can be selected. The second is to use the operator: gen_rectangle et al.
Cut out the region, because we only drew the region in the image, but did not cut it out. Use the operator reduce_domain. You can understand this operator as ROI, that is, the scope of the image. The establishment of ROI reduces the scope of the original whole image to ROI, that is, the scope of the area we specify is reduced, so there is the origin of the operator name.
3, Image enhancement
Histogram equalization, contrast enhancement, out of focus image processing
Starting from the gray image, a gray histogram of 0-255 is established to count the times of each gray value. Then the histogram is equalized to make the gray value distribution of pixels more uniform, so as to enhance the brightness of the image.
#Histogram equalization read_image(Image,'E:/C/Halcon/1.jpg') rgb1_to_gray(Image,GrayImage) equ_histo_image(GrayImage,ImageEquHisto) gray_histo(Image,Image,AbsoluteHisto1,RelativeHisto1) gray_histo(ImageEquHisto,ImageEquHisto,AbsoluteHisto2,RelativeHisto2) gen_region_histo(H1,AbsoluteHisto1,255,5,1) gen_region_histo(H2,AbsoluteHisto2,255,400,1)
equ_histo_image: histogram equalization (including two steps: gray conversion histogram and histogram equalization)
gray_histo: convert to histogram
gen_region_histo: display histogram
Enhance contrast: enhance the edges and details of the image to make it more obvious. emphasize function
read_image(Image,'E:/C/Halcon/1.jpg') emphasize(Image,ImageEm,10,10,1.5) dev_display(ImageEm)
Processing out of focus images: images with inaccurate focus may be blurred, and sharpening operation shall be considered. Some impact is formed at the edge of the highlight to enhance the edge of the image.
read_image(Image,'E:/C/Halcon/1.jpg') shock_filter(Image,ImageEm,0.5,20,'canny',2.5) dev_display(ImageEm)