A method for calculating the symmetry center of an image

By selecting the ROI rectangular area in the image and calculating the intersection points of the axis of symmetry, the problems of low efficiency and low accuracy of image symmetry center calculation in the prior art are solved, and efficient and accurate image symmetry center calculation is achieved.

CN119169074BActive Publication Date: 2025-03-04SHENZHEN RUIYANG JINGSHI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411661625.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-20
Publication Date
2025-03-04
Estimated Expiration
2044-11-20

AI Technical Summary

Technical Problem

The prior art uses low computing efficiency and low accuracy when calculating the center point of a symmetrical product in an image, especially when real-time matching of product design drawings is required.

Method used

After real-time acquisition of images, select the ROI rectangular area containing the center of the image, and calculate the axis of symmetry in the x-axis direction and the y-direction respectively, and determine the center point of the image using the intersection of the two axes of symmetry.

Benefits of technology

It effectively improves the efficiency and accuracy of image symmetric center calculation, and realizes the ability to match the calculation product image center in real time in the automated production process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119169074B_ABST
    Figure CN119169074B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for calculating the symmetry center of an image, comprising the following steps: S1, collecting an image; S2, selecting a rectangular ROI region containing a symmetrical pattern in the image; S3, calculating the axis of symmetry in the ROI rectangular region about the y-axis direction; S4, calculating the axis of symmetry in the ROI rectangular region about the x-axis direction; S5, calculating the symmetry center of the image: according to the axis of symmetry in the ROI region about the y-axis direction obtained in step S3 and the axis of symmetry in the ROI region about the x-axis direction obtained in step S4, the intersection of the two axes of symmetry is calculated as the symmetry center of the image. After acquiring an image through real-time acquisition, the present invention selects a rectangular ROI region containing the center of the image, calculates the axes of symmetry in the x-axis direction and the y-axis direction respectively therein, and then uses the intersection of the two axes of symmetry to determine the center point of the image, thereby effectively improving the calculation efficiency and accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of algorithms, and in particular to a method for calculating an image symmetry center. Background Art

[0002] In machine vision testing, measurement or inspection, it is necessary to find the center point of the symmetrical figure in the image captured by the camera to facilitate the positioning of subsequent product inspections and the determination of the relationship between the measurement data and the center point. In some positioning applications, it is necessary to calculate the center point of symmetrical products to guide the robot to grasp the center of the product, or to assemble so that the center points can correspond, so as to quickly calculate the center point of the symmetrical product in the image, which is the core process in the automated visual guidance system.

[0003] The current method for determining the center point of a product is to use the design drawing of the product, find its center point on the design drawing, convert the design drawing into an image, and then calculate the symmetry center of the image. In actual application, this calculation method needs to find the center point on the design drawing and then convert it to the center of the image. It needs to match the design drawings of each product in real time, and the calculation efficiency is low. In addition, the conversion error is large in the process of converting the design drawing into the product image. Summary of the invention

[0004] The technical problem to be solved by the present invention is to address the deficiencies of the above-mentioned prior art and to provide a method for calculating the image symmetry center by acquiring an image through real-time acquisition, selecting a ROI rectangular area containing the image center, calculating the symmetry axes in the x-axis direction and the y-axis direction respectively therein, and then determining the image center point using the intersection of the two symmetry axes, thereby effectively improving the calculation efficiency and accuracy.

[0005] The technical solution adopted by the present invention is as follows: a method for calculating the symmetry center of an image, comprising the following steps:

[0006] S1. Image acquisition: After the camera captures the image of the product to be tested, the image information is transmitted to the industrial computer;

[0007] S2, select the ROI rectangular area containing the symmetrical pattern in the image: select the ROI rectangular area containing the symmetrical pattern in the image acquired after step S1 as the calibration area for calculation;

[0008] S3, calculate the symmetry axis about the y-axis in the ROI rectangular area: select the counting axis x=n in the ROI rectangular area selected in step S2, and search and extract the image areas on the left and right sides of the counting axis x=n respectively, compare the images on both sides, take the image with the smaller width as the superimposed image, and calculate the similarity after superimposing the images on the left and right sides; repeat this cycle, calculate the similarities corresponding to different counting axes x=n column by column in the ROI rectangular area, and take the counting axis x=n corresponding to the maximum similarity as the symmetry axis of the ROI rectangular area about the y-axis;

[0009] S4, calculating the symmetry axis about the x-axis in the ROI rectangular area: selecting the counting axis y=m in the ROI rectangular area selected in step S2, and searching and extracting the image areas on both sides of the counting axis y=m respectively, comparing the images on both sides, taking the image with the smaller height as the superimposed image, and superimposing the images on the upper and lower sides to calculate the similarity; repeating in this way, calculating the similarities corresponding to different counting axes y=m row by row in the ROI rectangular area, and taking the counting axis y=m corresponding to the maximum similarity as the symmetry axis of the ROI rectangular area about the x-axis;

[0010] S5. Calculate the symmetry center of the image: According to the symmetry axis of the ROI region about the y-axis direction obtained in step S3 and the symmetry axis of the ROI region about the x-axis direction obtained in step S4, calculate the intersection of the two symmetry axes as the symmetry center of the image.

[0011] Preferably, the ROI rectangular area in step S2 is the calculated calibration area of ​​the image collected in step S1, and the width of the ROI rectangular area is w, and the height is h.

[0012] Preferably, the starting position of the counting axis x=n selected in step S3 is the leftmost axis of the ROI rectangular area. During the counting process, the pixel of the image is taken as 1 counting unit, x=n+1 is taken column by column, and n takes values ​​from 0 to w-2 until the coverage area of ​​the ROI rectangular area is completed; while taking the counting axis column by column, the similarity S(n) corresponding to each counting axis is recorded; S(n) is the similarity corresponding to x=n.

[0013] Preferably, when determining the image sizes on the left and right sides of the counting axis x=n in step S3, the determination is made based on the size of n; when n<w / 2, the image on the left side of the counting axis is taken as the superimposed image; when n≥w / 2, the image on the right side of the counting axis is taken as the superimposed image.

[0014] Preferably, after the superimposed image is selected in step S3, the counting axis x=n is used as the folding center line, the superimposed image on the left or right is flipped and transformed, and then the similarity of the two superimposed images before and after flipping is calculated.

[0015] Preferably, the starting position of the counting axis y=m selected in step S4 is the uppermost axis of the ROI rectangular area. During the counting process, the pixel of the image is taken as the unit, y=m-1 is taken row by row, and the value of m ranges from h-1 to 2, and the coverage area of ​​the ROI rectangular area is taken; while taking the counting axis row by row, the similarity S(m) corresponding to each counting axis is recorded; S(m) is the similarity corresponding to y=m.

[0016] Preferably, when determining the image sizes on the left and right sides of the counting axis y=m in step S4, the determination is made based on the size of m; when m<h / 2, the image on the lower side of the counting axis is taken as the superimposed image; when m≥h / 2, the image on the upper side of the counting axis is taken as the superimposed image.

[0017] Preferably, after the superimposed image is selected in step S4, the counting axis y=m is used as the folding center line, the superimposed image on the upper side or the lower side is flipped and pixel values ​​are converted, and then the similarity of the two superimposed images before and after flipping is calculated.

[0018] Preferably, the calculation formula for the flip pixel value conversion of the superimposed image along the counting axis x=n is: x,y =src x,rows-y-1 The calculation formula for the flip pixel value conversion of the superimposed image along the counting axis y=m is dst x,y =src cols-x-1,y , where src is the pixel value of the image before flipping, dst is the pixel value of the image after flipping; x and y are the corresponding coordinate values; rows is the height of the flipped superimposed image, and cols is the width of the flipped superimposed image.

[0019] Preferably, the calculation formula of the similarity is:

[0020] ;

[0021] in,

[0022] ;

[0023] ;

[0024] T(x, y) represents the pixel value with coordinates (x, y) on the left or upper image; I(x, y) represents the pixel value with coordinates (x, y) on the right or lower image, the value range of x is (0, (w-1)), the value range of y is (0, (h-1)); w is the width of the ROI rectangular area, and h is the height of the ROI rectangular area.

[0025] The beneficial effects of the present invention are:

[0026] In view of the defects and shortcomings of the prior art, the present invention independently developed and designed a method for calculating the image symmetry center by acquiring an image through real-time acquisition, selecting a ROI rectangular area containing the center of the image, calculating the symmetry axes in the x-axis and y-direction respectively within the area, and then determining the center point of the image using the intersection of the two symmetry axes, thereby effectively improving the calculation efficiency and accuracy.

[0027] The present invention aims to provide a calculation method for visually guiding the positioning of product centers in an automated production process, so as to realize real-time matching and calculation of product image centers in the production process, and effectively improve the positioning calculation efficiency and the center positioning calculation accuracy compared with traditional positioning methods; specifically, the present invention can form a captured image after capturing the image of the product in real time through a CCD camera; by selecting an ROI rectangular area including the image symmetry center on the captured image as a subsequent calculation area, the selection principle is that the image symmetry center needs to be included, and in the actual selection process, the image size can be selected according to the calculation accuracy requirements, such as the width is w and the height is h; after selecting the ROI rectangular area, first select the counting axis x=n therein, the starting counting axis can select the leftmost vertical line of the ROI rectangular area, and then extract images of a certain width to the left and right sides with the counting axis as the center, and when the counting axis is n<w / 2, take the left side of the counting axis as the superimposed image; when n ≥ w / 2, the image on the right side of the counting axis is taken as the superimposed image, that is, the image with a smaller width is taken as the subsequent similarity calculation image; then the superimposed image is flipped and converted for pixel value calculation, and finally the pixel similarity of the left and right images is calculated to obtain the similarity S (n) corresponding to x = n; then the similarities corresponding to x = n + 1 to x = n + w are calculated column by column, and the maximum value is taken from the calculated similarities to determine the counting axis corresponding to the maximum similarity as the vertical symmetry axis of the ROI rectangular area; similarly, the principle of determining the horizontal symmetry axis of the ROI rectangular area is similar to the above process, first taking the counting axis y = m at the top of the ROI rectangular area as the starting axis, and after calculating the similarity of each row row by row, the axis corresponding to the maximum similarity is taken as the horizontal symmetry axis of the ROI rectangular area; finally, the intersection between the vertical symmetry axis and the horizontal symmetry axis obtained by calculation is taken as the midpoint of the image. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 It is a principle block diagram of the present invention.

[0029] Figure 2 This is a schematic diagram of selecting a rectangular ROI area in the present invention.

[0030] Figure 3 A schematic diagram of the counting axis x=n is taken for the present invention.

[0031] Figure 4 One of the superimposed image schematic diagrams is selected for determination of the present invention.

[0032] Figure 5 The second schematic diagram of the superimposed image is selected for determination of the present invention.

[0033] Figure 6 This is one of the schematic diagrams of the flipping of the superimposed images according to the present invention.

[0034] Figure 7 This is one of the schematic diagrams of the flipping of the superimposed images according to the present invention.

[0035] Figure 8 It is a schematic diagram of the symmetry center of the image collected by the present invention. DETAILED DESCRIPTION

[0036] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0037] It should be noted that all directional indications such as up, down, left, right, front, back, etc. in the embodiments of the present invention are only used to explain the relative position relationship, movement status, etc. between the components in a certain specific posture. If the specific posture changes, the directional indication will also change accordingly.

[0038] In the present invention, unless otherwise clearly specified and limited, the terms "connection", "fixation", etc. should be understood in a broad sense. For example, "connection" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0039] like Figure 1 As shown, a method for calculating the symmetry center of an image includes the following steps:

[0040] S1. Image acquisition: After the camera captures the image of the product to be tested, the image information is transmitted to the industrial computer;

[0041] S2, select the ROI rectangular area containing the symmetrical pattern in the image: select the ROI rectangular area containing the symmetrical pattern in the image acquired after step S1 as the calibration area for calculation;

[0042] S3, calculate the symmetry axis about the y-axis in the ROI rectangular area: select the counting axis x=n in the ROI rectangular area selected in step S2, and search and extract the image areas on the left and right sides of the counting axis x=n respectively, compare the images on both sides, take the image with the smaller width as the superimposed image, and calculate the similarity after superimposing the images on the left and right sides; repeat this cycle, calculate the similarities corresponding to different counting axes x=n column by column in the ROI rectangular area, and take the counting axis x=n corresponding to the maximum similarity as the symmetry axis of the ROI rectangular area about the y-axis;

[0043] S4, calculating the symmetry axis about the x-axis in the ROI rectangular area: selecting the counting axis y=m in the ROI rectangular area selected in step S2, and searching and extracting the image areas on both sides of the counting axis y=m respectively, comparing the images on both sides, taking the image with the smaller height as the superimposed image, and superimposing the images on the upper and lower sides to calculate the similarity; repeating in this way, calculating the similarities corresponding to different counting axes y=m row by row in the ROI rectangular area, and taking the counting axis y=m corresponding to the maximum similarity as the symmetry axis of the ROI rectangular area about the x-axis;

[0044] S5. Calculate the symmetry center of the image: According to the symmetry axis of the ROI region about the y-axis direction obtained in step S3 and the symmetry axis of the ROI region about the x-axis direction obtained in step S4, calculate the intersection of the two symmetry axes as the symmetry center of the image.

[0045] like Figure 2 As shown, as an embodiment of the present invention, the ROI rectangular area in step S2 of the present invention is the calculation and calibration area of ​​the image collected in step S1, and the width of the ROI rectangular area is w, and the height is h.

[0046] like Figure 3 As shown, as an embodiment of the present invention, the starting position of the counting axis x=n selected in step S3 of the present invention is the leftmost axis of the ROI rectangular area. During the counting process, the pixel of the image is taken as 1 counting unit, and x=n+1 is taken column by column, and n takes values ​​from 0 to w-2, and the coverage area of ​​the ROI rectangular area is taken; while taking the counting axis column by column, the similarity S(n) corresponding to each counting axis is recorded; the S(n) is the similarity corresponding to x=n.

[0047] like Figure 4 As shown, as an embodiment of the present invention, the present invention is preferred, when determining the image sizes on the left and right sides of the counting axis x=n in step S3, the determination is made based on the size of n; when n<w / 2, the image on the left side of the counting axis is taken as the superimposed image; when n≥w / 2, the image on the right side of the counting axis is taken as the superimposed image.

[0048] In step S3, after the superimposed image is selected, the counting axis x=n is used as the folding center line, and the superimposed image on the left or right is flipped and transformed, and then the similarity of the two superimposed images before and after flipping is calculated.

[0049] like Figure 5 As shown, as an embodiment of the present invention, the starting position of the counting axis y=m selected in step S4 of the present invention is the uppermost axis of the ROI rectangular area. During the counting process, the pixel of the image is taken as the unit, y=m-1 is taken row by row, and the value of m ranges from h-1 to 2, and the coverage area of ​​the ROI rectangular area is taken; while taking the counting axis row by row, the similarity S(m) corresponding to each counting axis is recorded; the S(m) is the similarity corresponding to y=m.

[0050] When determining the image sizes on the left and right sides of the counting axis y=m in step S4, the determination is made based on the size of m; when m<h / 2, the image on the lower side of the counting axis is taken as the superimposed image; when m≥h / 2, the image on the upper side of the counting axis is taken as the superimposed image.

[0051] In step S4, after the superimposed image is selected, the counting axis y=m is used as the folding center line, and the superimposed image on the upper side or the lower side is flipped and pixel values ​​are converted, and then the similarity of the two superimposed images before and after flipping is calculated.

[0052] like Figure 6 to Figure 7 As shown in the figure, they are schematic diagrams of flipping and transforming the superimposed image along the vertical direction and the horizontal direction, respectively. The calculation formula for flipping pixel value conversion of the superimposed image along the counting axis x=n direction of the present invention is dst x,y =src x,rows-y-1 The calculation formula for the flip pixel value conversion of the superimposed image along the counting axis y=m is dst x,y =src cols-x-1,y , where src is the pixel value of the image before flipping, dst is the pixel value of the image after flipping; x and y are the corresponding coordinate values; rows is the height of the flipped superimposed image, and cols is the width of the flipped superimposed image.

[0053] Furthermore, the present invention designs a method for calculating the image symmetry center by selecting a ROI rectangular area containing the image center after acquiring an image through real-time acquisition, and then calculating the symmetry axes in the x-axis direction and the y-axis direction respectively, and then using the intersection of the two symmetry axes to determine the image center point, thereby effectively improving the calculation efficiency and accuracy. The present invention aims to provide a calculation method for visually guiding the positioning of the product center in an automated production process, so as to achieve real-time matching and calculation of the product image center in the production process, and effectively improve the positioning calculation efficiency and the center positioning calculation accuracy compared to the traditional positioning method; specifically, the present invention can form a captured image after capturing the image of the captured product in real time through a CCD camera; by selecting the ROI rectangular area including the image symmetry center on the captured image as the subsequent calculation area, the principle of the selection is that the image symmetry center needs to be included, and the image size can be selected according to the calculation accuracy requirements in the actual selection process, such as the width is w and the height is h; after selecting the ROI rectangular area, first select the counting axis x=n in it, and the starting counting axis can select the leftmost vertical line of the ROI rectangular area, and then extract a certain width of image to the left and right with the counting axis as the center, and when the counting axis is n<w / 2, take the left side of the counting axis as the superimposed image; when n ≥ w / 2, the image on the right side of the counting axis is taken as the superimposed image, that is, the image with a smaller width is taken as the subsequent similarity calculation image; then the superimposed image is flipped and converted for pixel value calculation, and finally the pixel similarity of the left and right images is calculated to obtain the similarity S (n) corresponding to x = n; then the similarities corresponding to x = n + 1 to x = n + w are calculated column by column, and the maximum value is taken from the calculated similarities to determine the counting axis corresponding to the maximum similarity as the vertical symmetry axis of the ROI rectangular area; similarly, the principle of determining the horizontal symmetry axis of the ROI rectangular area is similar to the above process, first taking the counting axis y = m at the top of the ROI rectangular area as the starting axis, and after calculating the similarity of each row row by row, the axis corresponding to the maximum similarity is taken as the horizontal symmetry axis of the ROI rectangular area; finally, the intersection between the vertical symmetry axis and the horizontal symmetry axis obtained by calculation is taken as the midpoint of the image. Example 1

[0054] The calculation formula of the similarity S(n) of the present invention is:

[0055] ;

[0056] in,

[0057] ;

[0058] ;

[0059] The above formula is a normalized correlation coefficient calculation method, which can eliminate the influence of illumination and noise and has stronger robustness. The essence of the calculation method is to subtract the grayscale average value of the image from the grayscale pixel value of each position of the image. For two superimposed images, the image average is first taken, and the grayscale values ​​of the two images are multiplied after the coordinates are processed. Then, the product of all pixels is accumulated. Therefore, a larger number indicates a higher similarity between the two images. The denominator of the formula is a normalization operation. The final similarity value is between 0 and 1. A similarity of 1 indicates complete consistency, which can be judged as the maximum value. The counting axis corresponding to this value is the symmetry axis.

[0060] Calculation example: Take the width w as 900 and the height h as 700;

[0061] (1) Calculate the vertical axis of symmetry

[0062] The value range of n is [180, 720];

[0063] The calculation result corresponding to the similarity calculation value S(n):

[0064] -0.066,-0.064,-0.062,-0.059,-0.057,-0.055,-0.053,-0.052,-0.050,-0.049,-0.047,-0.045,-0.041,-0.038,-0.034,-0.031,-0.028,-0.025,-0.022,-0.019,-0.016,-0.014,-0.011,-0.007,-0.004,0.000,0.004,0.008,0.011,0.014,0.017,0.020,0.023,0.025,0.028,0.030,0.034,0.037,0.040,0.043,0.046,0.049,0.051,0.053,0.056,0.058,0.061,0.064,0.067,0.070,0.074,0.077,0.080,0.083,0.085,0.086,0.089,0.091,0.094,0.097,0.100,0.103,0.106,0.109,0.112,0.113,0.115,0.116,0.118,0.120,0.122,0.125,0.128,0.131,0.134,0.137,0.139,0.140,0.141,0.142,0.143,0.145,0.147,0.150,0.153,0.157,0.159,0.161,0.162,0.163,0.165,0.166,0.167,0.170,0.173,0.176,0.180,0.183,0.185,0.186,0.187,0.188,0.189,0.190,0.191,0.193,0.197,0.200,0.203,0.205,0.207,0.208,0.208,0.209,0.210,0.211,0.213,0.215,0.219,0.222,0.225,0.227,0.228,0.229,0.229,0.230,0.230,0.231,0.232,0.235,0.238,0.242,0.245,0.248,0.250,0.252,0.253,0.253,0.254,0.254,0.256,0.258,0.261,0.264,0.268,0.269,0.268,0.265,0.261,0.256,0.250,0.246,0.243,0.243,0.245,0.248,0.252,0.255,0.257,0.257,0.256,0.253,0.250,0.247,0.246,0.246,0.246,0.246,0.246,0.246,0.247,0.249,0.252,0.258,0.266,0.274,0.282,0.287,0.288,0.286,0.281,0.274,0.268,0.264,0.262,0.263,0.268,0.274,0.281,0.288,0.293,0.298,0.302,0.306,0.310,0.313,0.314,0.315,0.311,0.299,0.279,0.254,0.231,0.215,0.206,0.205,0.209,0.217,0.225,0.233,0.240,0.245,0.248,0.251,0.258,0.270,0.288,0.312,0.336,0.361,0.381,0.391,0.397,0.409,0.433,0.471,0.521,0.585,0.658,0.735,0.806,0.853,0.860,0.825,0.768,0.707,0.647,0.590,0.539,0.495,0.457,0.424,0.393,0.359,0.322,0.289,0.264,0.247,0.237,0.234,0.233,0.233,0.230,0.225,0.216,0.206,0.197,0.189,0.184,0.182,0.185,0.192,0.204,0.218,0.232,0.246,0.257,0.266,0.272,0.275,0.277,0.276,0.270,0.262,0.251,0.239,0.227,0.216,0.207,0.202,0.202,0.206,0.212,0.221,0.228,0.235,0.240,0.242,0.242,0.241,0.239,0.236,0.231,0.224,0.216,0.207,0.199,0.191,0.187,0.186,0.191,0.199,0.208,0.217,0.224,0.228,0.229,0.226,0.221,0.213,0.205,0.197,0.190,0.184,0.180,0.178,0.178,0.180,0.184,0.191,0.198,0.205,0.211,0.215,0.217,0.216,0.213,0.207,0.200,0.194,0.187,0.183,0.180,0.178,0.178,0.179,0.181,0.183,0.186,0.190,0.193,0.195,0.196,0.196,0.194,0.191,0.188,0.185,0.180,0.176,0.173,0.171,0.170,0.169,0.168,0.167,0.165,0.164,0.163,0.162,0.160,0.159,0.158,0.158,0.157,0.156,0.155,0.153,0.151,0.148,0.146,0.143,0.142,0.140,0.138,0.137,0.135,0.134,0.133,0.132,0.131,0.129,0.127,0.125,0.123,0.121,0.119,0.118,0.116,0.115,0.114,0.113,0.111,0.109,0.106,0.104,0.102,0.100,0.098,0.097,0.095,0.093,0.091,0.089,0.087,0.085,0.083,0.080,0.079,0.077,0.076,0.074,0.072,0.069,0.067,0.065,0.063,0.061,0.058,0.056,0.055,0.053,0.051,0.049,0.047,0.045,0.043,0.040,0.037,0.034,0.032,0.031,0.029,0.027,0.025,0.024,0.022,0.019,0.016,0.012,0.008,0.006,0.004,0.003,0.001,-0.000,-0.002,-0.003,-0.005,-0.008,-0.012,-0.015,-0.017,-0.018,-0.019,-0.020,-0.021,-0.021,-0.023,-0.024,-0.026,-0.028,-0.029,-0.031,-0.031,-0.032,-0.032,-0.031,-0.028,-0.018,-0.005,0.009,0.023,0.036,0.051,0.064,0.078,0.092,0.106,0.120,0.134,0.149,0.163,0.178,0.194,0.209,0.224,0.239,0.254,0.266,0.272, 0.266, 0.250, 0.232, 0.213, 0.195, 0.176, 0.157, 0.137, 0.117, 0.096, 0.075, 0.054, 0.032, 0.011, -0.010, -0.030, -0.046, -0.061, -0.074, -0.087, -0.098, -0.105, -0.107, -0.104, -0. .098, -0.091, -0.083, -0.074, -0.066, -0.057, -0.049, -0.040, -0.032, -0.023, -0.014, -0.005, 0.004, 0.010, 0.015, 0.017, 0.018, 0.018, 0.017, 0.016, 0.016, 0.015, 0.014, 0.013, .

[0065] The maximum S(n) is S(412)=0.86.

[0066] (2) Calculate the horizontal axis of symmetry

[0067] The value range of m is [140,560];

[0068] The similarity calculation value of S(m) is

[0069] -0.022,-0.020,-0.017,-0.012,-0.008,-0.003,0.004,0.011,0.017,0.020,0.022,0.025,0.028,0.031,0.033,0.035,0.036,0.037,0.040,0.045,0.050,0.053,0.058,0.064,0.069,0.074,0.077,0.079,0.080,0.081,0.083,0.085,0.088,0.090,0.093,0.095,0.098,0.100,0.104,0.107,0.111,0.116,0.120,0.124,0.127,0.130,0.132,0.133,0.133,0.132,0.133,0.134,0.136,0.138,0.141,0.145,0.149,0.155,0.160,0.163,0.165,0.166,0.166,0.167,0.167,0.168,0.168,0.169,0.171,0.174,0.176,0.179,0.182,0.184,0.187,0.190,0.193,0.195,0.196,0.198,0.201,0.203,0.205,0.207,0.208,0.208,0.208,0.207,0.207,0.207,0.208,0.211,0.215,0.220,0.225,0.230,0.234,0.236,0.236,0.235,0.233,0.231,0.229,0.228,0.228,0.229,0.231,0.235,0.240,0.246,0.251,0.255,0.258,0.259,0.259,0.257,0.256,0.254,0.253,0.252,0.252,0.253,0.253,0.255,0.258,0.261,0.264,0.268,0.272,0.276,0.279,0.281,0.281,0.281,0.280,0.278,0.276,0.275,0.274,0.273,0.273,0.274,0.276,0.280,0.285,0.291,0.297,0.303,0.307,0.310,0.311,0.310,0.305,0.298,0.289,0.282,0.278,0.276,0.277,0.280,0.286,0.296,0.308,0.318,0.323,0.322,0.316,0.306,0.295,0.284,0.273,0.263,0.255,0.250,0.250,0.254,0.263,0.276,0.290,0.303,0.313,0.318,0.316,0.306,0.287,0.262,0.237,0.217,0.203,0.197,0.194,0.195,0.199,0.204,0.210,0.218,0.232,0.254,0.280,0.305,0.327,0.343,0.353,0.356,0.353,0.346,0.338,0.335,0.348,0.381,0.438,0.518,0.611,0.701,0.774,0.819,0.810,0.754,0.664,0.565,0.478,0.412,0.360,0.326,0.322,0.349,0.383,0.416,0.437,0.434,0.405,0.355,0.294,0.235,0.186,0.153,0.141,0.148,0.166,0.191,0.219,0.248,0.275,0.297,0.315,0.328,0.336,0.338,0.337,0.333,0.328,0.321,0.316,0.313,0.312,0.312,0.313,0.318,0.325,0.335,0.343,0.348,0.350,0.347,0.342,0.333,0.322,0.308,0.296,0.286,0.280,0.277,0.279,0.284,0.293,0.302,0.310,0.317,0.320,0.320,0.315,0.307,0.297,0.287,0.279,0.273,0.270,0.269,0.271,0.275,0.279,0.282,0.284,0.285,0.286,0.286,0.285,0.283,0.280,0.276,0.271,0.267,0.264,0.262,0.260,0.258,0.257,0.256,0.256,0.256,0.257,0.258,0.259,0.260,0.261,0.261,0.259,0.255,0.251,0.246,0.242,0.237,0.233,0.229,0.228,0.229,0.231,0.234,0.237,0.240,0.241,0.240,0.236,0.231,0.225,0.220,0.216,0.213,0.210,0.208,0.206,0.207,0.208,0.209,0.210,0.210,0.209,0.208,0.207,0.206,0.204,0.202,0.198,0.1 93,0.188,0.185,0.182,0.180,0.177,0.175,0.176,0.178,0.179,0.180,0.179,0.177,0.174,0.171,0.167,0.163,0.158,0.155,0.152,0.150,0.147,0.14 5,0.143,0.141,0.140,0.140,0.140,0.139,0.138,0.137,0.135,0.132,0.128,0.123,0.117,0.113,0.109,0.107,0.106,0.104,0.103,0.102,0.101,0.099 ,0.096,0.093,0.090,0.087,0.084,0.082,0.079,0.075,0.070,0.064,0.059,0.055,0.051,0.048,0.045,0.043,0.043,0.044,0.044,0.041,0.037,0.031.

[0070] The maximum S(m) value is S(355)=0.819.

[0071] The symmetry center in the selected R0I image is (412, 355);

[0072] like Figure 8 As shown, the final symmetry center is the intersection of x=412 and y=355.

[0073] The embodiments of the present invention are only to introduce its specific implementation methods and are not intended to limit its protection scope. The technicians in this industry can make some modifications inspired by this embodiment, so any equivalent changes or modifications made according to the scope of the patent of the present invention are within the scope of the patent claims of the present invention.

Claims

1. A method for calculating the symmetry center of an image, characterized in that: The steps include: S1. Image acquisition: After the camera captures the image of the product to be tested, the image information is transmitted to the industrial computer; S2, select the ROI rectangular area containing the symmetrical pattern in the image: select the ROI rectangular area containing the symmetrical pattern in the image acquired after step S1 as the calibration area for calculation; S3, calculate the symmetry axis about the y-axis in the ROI rectangular area: select the counting axis x=n in the ROI rectangular area selected in step S2, and search and extract the image areas on the left and right sides of the counting axis x=n respectively, compare the images on both sides, take the image with the smaller width as the superimposed image, and calculate the similarity after superimposing the images on the left and right sides; repeat this cycle, calculate the similarities corresponding to different counting axes x=n column by column in the ROI rectangular area, and take the counting axis x=n corresponding to the maximum similarity as the symmetry axis of the ROI rectangular area about the y-axis; S4, calculating the symmetry axis about the x-axis in the ROI rectangular area: selecting the counting axis y=m in the ROI rectangular area selected in step S2, and searching and extracting the image areas on both sides of the counting axis y=m respectively, comparing the images on both sides, taking the image with the smaller height as the superimposed image, and superimposing the images on the upper and lower sides to calculate the similarity; repeating in this way, calculating the similarities corresponding to different counting axes y=m row by row in the ROI rectangular area, and taking the counting axis y=m corresponding to the maximum similarity as the symmetry axis of the ROI rectangular area about the x-axis; S5, calculating the symmetry center of the image: according to the symmetry axis of the ROI region about the y-axis direction obtained in step S3 and the symmetry axis of the ROI region about the x-axis direction obtained in step S4, the intersection of the two symmetry axes is calculated as the symmetry center of the image; The ROI rectangular area in step S2 is the calculated calibration area of ​​the image collected in step S1, and the width and height of the ROI rectangular area are w and h, respectively. The starting position of the counting axis x=n selected in step S3 is the leftmost axis of the ROI rectangular area. During the counting process, the pixel of the image is taken as 1 counting unit, and x=n+1 is taken column by column, and n takes values ​​from 0 to w-2, and the coverage area of ​​the ROI rectangular area is taken; while taking the counting axis column by column, the similarity S(n) corresponding to each counting axis is recorded; S(n) is the similarity corresponding to x=n; When determining the image sizes on the left and right sides of the counting axis x=n in step S3, the determination is made based on the size of n; when n<w / 2, the image on the left side of the counting axis is taken as the superimposed image; when n≥w / 2, the image on the right side of the counting axis is taken as the superimposed image.

2. The method for calculating the image symmetry center according to claim 1, characterized in that: In the step S3, after the superimposed image is selected, the counting axis x=n is used as the folding center line, and the superimposed image on the left or right is flipped and transformed, and then the similarity of the two superimposed images before and after flipping is calculated.

3. The method for calculating the image symmetry center according to claim 1, characterized in that: The starting position of the counting axis y=m selected in the step S4 is the uppermost axis of the ROI rectangular area. During the counting process, the pixel of the image is taken as the unit, y=m-1 is taken row by row, and the value of m ranges from h-1 to 2, and the coverage area of ​​the ROI rectangular area is taken; while taking the counting axis row by row, the similarity S(m) corresponding to each counting axis is recorded; S(m) is the similarity corresponding to y=m.

4. The method for calculating the image symmetry center according to claim 3, characterized in that: When determining the image sizes on the left and right sides of the counting axis y=m in step S4, the determination is made based on the size of m; when m<h / 2, the image on the lower side of the counting axis is taken as the superimposed image; when m≥h / 2, the image on the upper side of the counting axis is taken as the superimposed image.

5. The method for calculating the image symmetry center according to claim 4, characterized in that: In the step S4, after the superimposed image is selected, the counting axis y=m is used as the folding center line, and the superimposed image on the upper side or the lower side is flipped and pixel values ​​are converted, and then the similarity of the two superimposed images before and after flipping is calculated.

6. The method for calculating the image symmetry center according to claim 2 or 3, characterized in that: The calculation formula for the flip pixel value conversion of the superimposed image along the counting axis x=n is dst x,y =src x,rows-y-1 The calculation formula for the flip pixel value conversion of the superimposed image along the counting axis y=m is dst x,y =src cols-x-1,y , where src is the pixel value of the image before flipping, dst is the pixel value of the image after flipping; x and y are the corresponding coordinate values; rows is the height of the flipped superimposed image, and cols is the width of the flipped superimposed image.

7. The method for calculating the image symmetry center according to claim 1, characterized in that: The calculation formula of the similarity is: ; in, ; ; T(x, y) represents the pixel value with coordinates (x, y) on the left or upper image; I(x, y) represents the pixel value with coordinates (x, y) on the right or lower image, the value range of x is (0, (w-1)), the value range of y is (0, (h-1)); w is the width of the ROI rectangular area, and h is the height of the ROI rectangular area.

Citation Information

Patent Citations

  • Method of determining ROI (Region of Interest) in interventional image

    CN106557767A

  • Systems and methods for automatic symmetry identification and for quantification of asymmetry for analytic, diagnostic and therapeutic purposes

    US20080021502A1