CN116503462A - Method and system for quickly extracting circle center of circular spot - Google Patents

Method and system for quickly extracting circle center of circular spot Download PDF

Info

Publication number
CN116503462A
CN116503462A CN202310520586.3A CN202310520586A CN116503462A CN 116503462 A CN116503462 A CN 116503462A CN 202310520586 A CN202310520586 A CN 202310520586A CN 116503462 A CN116503462 A CN 116503462A
Authority
CN
China
Prior art keywords
spot
image
contour
edge
circular spot
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310520586.3A
Other languages
Chinese (zh)
Inventor
李成
龚成
刘玉宝
杨柳
袁超飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
WUHAN POWER3D TECHNOLOGY Ltd
Original Assignee
WUHAN POWER3D TECHNOLOGY Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by WUHAN POWER3D TECHNOLOGY Ltd filed Critical WUHAN POWER3D TECHNOLOGY Ltd
Priority to CN202310520586.3A priority Critical patent/CN116503462A/en
Publication of CN116503462A publication Critical patent/CN116503462A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/12Edge-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30172Centreline of tubular or elongated structure
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Abstract

The invention discloses a method and a system for quickly extracting the circle center of a circular spot, wherein the method comprises the following steps: collecting a circular spot image, and performing downsampling treatment and pretreatment on the circular spot image; extracting the whole pixels of the edges of the preprocessed circular spot image by a Canny operator to obtain edge contours; setting a spot target contour screening rule, and screening out a spot contour conforming to the spot target contour screening rule from the edge contour; performing edge sub-pixel extraction on the screened spot outline by adopting polynomial fitting; and carrying out ellipse fitting on the extracted edge sub-pixels, and calculating the center position of the circular spot. The invention reduces the size of the image by downsampling the image, improves the speed of extracting and calculating the center coordinates, calculates the accurate spot contour by using the edge whole pixel extraction and edge sub-pixel extraction methods, and simultaneously utilizes the circular spot characteristics to carry out contour screening, thereby improving the accuracy of extracting the center of the circular spot, and being applicable to real-time detection and recognition systems.

Description

Method and system for quickly extracting circle center of circular spot
Technical Field
The invention belongs to the technical field of vision measurement, and particularly relates to a method and a system for quickly extracting the center of a circular spot.
Background
Circles have incomparable advantages over other geometries (e.g., straight, square) in computer image processing: the circle is insensitive to threshold segmentation, when the segmented threshold is changed, the edge points of the circle are correspondingly scaled, but the circle center obtained by the scaled edge points is changed very little, which cannot be achieved by graphs such as straight lines, squares and the like. Therefore, in the vision measurement system, the spot image formed by the small round object is often selected as the characteristic to participate in calculation, for example, in the calibration process, the spot image formed by the dot array is used for camera calibration; in the depth image matching process, point cloud matching registration under different visual angles is carried out by using circular spot images attached to the surface of an object; in a photogrammetry system, a global precision control field is constructed by using a circular spot image; the recognition and center positioning of the circular spots directly affect the precision and accuracy of the measurement system.
In order to ensure the accuracy of the measurement system, it is often required in practice that the circle center extraction accuracy of the circular spots in the image is at the sub-pixel level. The traditional method for extracting the edges of the round spot sub-pixels mainly comprises an edge fitting method, an interpolation method and a moment method.
The precondition of the edge fitting method is that the characteristic of the measured object meets the preset function form, the proper function model is selected, curve fitting is carried out according to the position of the pixel where the edge is located in the image and gray value information, then continuous functions obtained by fitting are derived, and the position where the point with the maximum derivative value is located corresponds to the sub-pixel position of the edge. Common fitting methods include polynomial fitting and least squares fitting. The essence of the polynomial fitting method is that a function approximation method is used for obtaining a function formula which accords with the gray level distribution characteristics of the image edge, and the sub-pixel position is calculated through the existing edge coordinates; the least square fitting method fits the edge vector based on the least square criterion, the more the pixel points involved in the fitting are, the closer the obtained fitting result is to the actual edge distribution on the image, the more accurate the final sub-pixel positioning result is, but the larger the calculated amount is, and the longer the running time is. The invention patent with publication number of CN104318555A discloses a method for accurately positioning a center projection point in a target image, which is characterized in that the center projection point is determined by geometric constraint through fitting an elliptic equation and establishing an elliptic circumscribed triangle, but the accuracy of the method for detecting the edge of the pixel level is not high, and the actual measurement requirement cannot be met.
The interpolation principle is that the gradient of the pixel position of the edge in the image takes an extreme value, the second derivative crosses the zero point, and several sampling points are taken in a small neighborhood taking the pixel-level edge point as the center for interpolation, the resolution of the input image is improved through interpolation, and the sub-pixel positioning of the edge is realized. Common interpolation methods can be classified into nearest neighbor interpolation and bilinear interpolation. The nearest interpolation method is to simply assign values to the areas, but the gray values of the interpolated images are still discontinuous, and serrated edges are easy to form in the images; the bilinear interpolation method has better processing effect, belongs to polynomial interpolation, can improve the defect of the nearest interpolation method, and has better gray continuity in the obtained image. When the image is noisy, the interpolation node is susceptible to noise interference, resulting in inaccurate measurement results.
The principle of the moment method for sub-pixel positioning of the edge is that in digital image processing, the moment is used as one of statistical feature quantities of a digital image gray level histogram and contains image edge model parameters. The moment has rotation invariance, and the image characteristics can be prevented from being influenced by geometric changes, so that the moment characteristics of the object before and after imaging are kept unchanged. From a mathematical point of view, the moment can be regarded as a transformation of the original image function in a new coordinate space, i.e. the moment can uniquely represent any one of the piecewise continuous bounded functions. Based on the principle of moment invariance, the moment characteristics of an ideal edge model can be assumed to be consistent with the moment characteristics of the edges of an actual image, and parameters of edge characteristics in a target image can be obtained through the consistency solution. Among the methods commonly used in the moment are a space moment method and a Zernike moment method, wherein the Zernike moment method is developed on the basis of the theory of the space moment, and the problem that redundant information can be generated by the original space moment method is improved in the calculation process. However, the moment method involves multiple times of power operation in calculation, so that the calculation amount is large and the time consumption is long.
The camera usually collects the circular spot image and has the interferences of disordered background, poor imaging quality, partial reflection and the like, which makes it difficult to directly extract the edge and the center of the circular spot from the image. In order to overcome the influence of interference factors, the prior art firstly carries out smoothing processing on the image, and then can further carry out the extraction calculation of the circular speckle correlation. The traditional circular detection method is most commonly used by using the circular Hough transformation, but the method needs to vote and record each boundary point by point, has long calculation time, occupies a large amount of memory of a computer, and is not suitable for being used in a real-time detection system.
In summary, how to realize the rapid and accurate extraction of the circle center of the circular spot is an urgent problem to be solved.
Disclosure of Invention
In view of the above, the invention provides a method and a system for rapidly extracting the center of a circular spot, which are used for solving the problem of low extraction speed of the center of the circular spot.
The invention discloses a method for quickly extracting the center of a circular spot, which comprises the following steps:
collecting a circular spot image, and performing downsampling treatment and pretreatment on the circular spot image;
extracting the whole pixels of the edges of the preprocessed circular spot image by a Canny operator to obtain edge contours;
setting a spot target contour screening rule, and screening out a spot contour conforming to the spot target contour screening rule from the edge contour;
performing edge sub-pixel extraction on the screened spot outline by adopting polynomial fitting;
and carrying out ellipse fitting on the extracted edge sub-pixels, and calculating the center position of the circular spot.
On the basis of the above technical solution, preferably, the downsampling and preprocessing the circular speckle image specifically includes:
selecting a sampling coefficient alpha according to the resolution ratio W.times.H of the circular spot image and the pixel size occupied by the spot, wherein alpha is more than 0 and less than or equal to 1, and the pixel relationship between the downsampled image and the original image is as follows:
i s =round(i*α)
j s =round(j*α)
wherein I (I, j) is the pixel point before downsampling, I s (i s ,j s ) For the pixel point after downsampling, i is more than or equal to 0 s <round(H*α),0≤j s < round (, α), the round () function is to round the input parameters.
On the basis of the above technical solution, preferably, the extracting the whole pixel of the edge of the preprocessed circular spot image by the Canny operator, to obtain the edge contour specifically includes:
calculating pixel gradient values of the circular spot image to obtain a gradient value image;
the maximum threshold value in the Canny operator is obtained by adopting an OTSU method on the gradient value image, and the minimum threshold value of the Canny operator is set to be half of the maximum threshold value;
and extracting edge integer pixels of the circular spot image based on the maximum threshold and the minimum threshold of the Canny operator.
On the basis of the above technical solution, preferably, the set spot target contour screening rule specifically includes:
(1) is a closed contour;
(2) the outline size is within a set range;
(3) the inner gray values of the contour are larger than the outer gray values of the contour.
Based on the above technical solution, preferably, the internal gray value I in And an external gray value I out The calculation is as follows:
I in =(I s (x 1 ,y min +1)+I s (x max -1,y 2 )+I s (x 2 ,y max -1)+I s (x min +1,y 1 ))/4
I out =(I s (x 1 ,y min -1)+I s (x max +1,y 2 )+I s (x 2 ,y max +1)+I s (x min -1,y 1 ))/4
let the coordinates of the outline point of the outline of the spot be (x i ,y i ),i=0,1,2…N,I s (. Cndot.) is the gray value of the pixel at the corresponding coordinate, N is the total number of contour points, (x) min ,y 1 )、(x max ,y 2 ) Respectively, when x is in each spot contour i Minimum time coordinate sum x i Coordinates at maximum, (x) 1 ,y min )、(x 2 ,y max ) Respectively when y i Minimum time coordinate sum y i Coordinates at maximum.
On the basis of the above technical solution, preferably, the performing edge sub-pixel extraction on the screened speckle profile by using polynomial fitting specifically includes:
let the fitting model of polynomial fitting be:
f(x,y)=k 1 +k 2 x+k 3 y+k 4 x 2 +k 5 xy+k 6 y 2 +k 7 x 3 +k 8 x 2 y+k 9 xy 2 +k 10 y 3
wherein k is j As polynomial coefficients, j=1, 2, …,10, determined by fitting region pixel gray scale;
assuming that points in the edge gradient direction θ are expressed as x=ρcos θ, y=ρsin θ, ρ is the corresponding point arc length, the center point of the fitting region (x 0 ,y 0 ) The second derivative in the θ direction is:
f″ θ (x 0 ,y 0 )=6(k 7 sin 3 θ+k 8 sin 2 θcosθ+k 9 sinθcos 2 θ+k 10 cos 3 θ)ρ+2(k 4 sin 2 θ+k 5 sinθcosθ+k 6 cos 2 θ)
let the second derivative f θ (x 0 ,y 0 ) =0, solving for ρ, resulting in a subpixel coordinate position of the edge point of (x 0 +ρcosθ,y 0 +ρsinθ)。
On the basis of the above technical solution, preferably, after the ellipse fitting is performed on the extracted edge sub-pixels, the method further includes:
setting an ellipse fitting error threshold value, and reserving the circle center of which the fitting error is smaller than the error threshold value;
setting the ratio range of the major axis to the minor axis of the ellipse, and reserving the circle center of the ratio of the major axis to the minor axis in the set ratio range.
The invention discloses a method for quickly extracting the center of a circular spot, which comprises the following steps:
and a pretreatment module: the method comprises the steps of acquiring a circular spot image, and carrying out downsampling treatment and preprocessing on the circular spot image;
and a contour extraction module: the method comprises the steps of performing edge whole pixel extraction on a preprocessed circular spot image through a Canny operator to obtain an edge contour;
a sub-pixel extraction module: the method comprises the steps of setting a spot target contour screening rule, and screening out spot contours conforming to the spot target contour screening rule from edge contours; performing edge sub-pixel extraction on the screened spot outline by adopting polynomial fitting;
the circle center calculating module: and the method is used for carrying out ellipse fitting on the extracted edge sub-pixels to calculate the center position of the circular spot.
In a third aspect of the present invention, an electronic device is disclosed, comprising: at least one processor, at least one memory, a communication interface, and a bus;
the processor, the memory and the communication interface complete communication with each other through the bus;
the memory stores program instructions executable by the processor which the processor invokes to implement the method according to the first aspect of the invention.
In a fourth aspect of the invention, a computer-readable storage medium is disclosed, storing computer instructions that cause a computer to implement the method according to the first aspect of the invention.
Compared with the prior art, the invention has the following beneficial effects:
1) According to the invention, the size of the image is reduced by downsampling the image, the accurate spot contour is calculated by utilizing the edge integral pixel extraction and edge sub-pixel extraction methods, and meanwhile, contour screening is performed by utilizing the circular spot characteristics, so that the speed of circle center coordinate extraction and calculation is effectively improved, and the method can be suitable for a real-time detection and identification system;
2) According to the invention, the contour screening rule is set, so that the spot contour which is closed in contour and proper in contour size and has larger gray value in the contour than the gray value in the contour is selected, the background noise contour is removed, the interference point and the point with poor quality are removed, and the accuracy of extracting the edge contour of the circular spot image is improved;
3) According to the invention, the edge sub-pixel extraction is carried out by fitting the edge image by using a cubic polynomial, the sub-pixel coordinate position of the edge point is accurately calculated, and the subdivision of the round spot edge pixel basic unit is realized, so that the spot detection precision is improved, and the actual measurement requirement is met.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for quickly extracting the center of a circular spot;
FIG. 2 is a schematic representation of a simulated generated circular blob image;
FIG. 3 is a schematic view of a downsampled circular speckle image;
FIG. 4 is a schematic view of a circular speckle image after image preprocessing;
FIG. 5 is a schematic diagram of edge integer pixel extraction results;
FIG. 6 is a schematic diagram of an edge profile screening result;
FIG. 7 is a graph showing the result of sub-pixel centering;
fig. 8 is a schematic diagram of a spot center extraction result in an original image.
Detailed Description
The following description of the embodiments of the present invention will clearly and fully describe the technical aspects of the embodiments of the present invention, and it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, are intended to fall within the scope of the present invention.
Referring to fig. 1, the invention provides a method for rapidly extracting the center of a circular spot, which comprises the following steps:
s1, image downsampling processing.
And acquiring a circular spot image, and performing downsampling processing on the circular spot image.
Specifically, a proper sampling coefficient alpha is selected according to the resolution ratio W.times.H of the circular spot image and the pixel size occupied by the spot, wherein alpha is more than 0 and less than or equal to 1, and the setting of the sampling coefficient ensures that the spot contour pixels after downsampling are not less than twenty pixels. The pixel relationship between the downsampled image and the original image is:
i s =round(i*α)
j s =round(j*α)
wherein I (I, j) is the pixel point before downsampling, I s (i s ,j s ) For the pixel point after downsampling, i is more than or equal to 0 s <round(H*α),0≤j s < round (, α), the round () function is a rounding operation after rounding the input parameters.
Fig. 2 shows a simulated generation of a circular speckle image with a resolution of 800 x 800, which has been subjected to noise addition and blurring, and the downsampling factor α=0.5 is set, the resulting downsampled image being shown in fig. 3. The comparison shows that the data volume after downsampling is one fourth of the data volume before downsampling, so that the image calculation time is greatly shortened.
S2, image preprocessing.
The circular speckle image collected by the measurement system often has noise interference, which affects the image quality. In order to restrain noise influence, the invention adopts a Gaussian image filtering method to carry out image preprocessing. The gaussian filtering is a process of performing weighted average on the whole image, the value of each pixel point is obtained by performing weighted average on the pixel point and other pixel values in the neighborhood, and the expression of a gaussian kernel function h (x, y) is as follows:
wherein (x, y) is a coordinate value with the center of the kernel as the origin of coordinates, sigma is a standard deviation, and the smoothing effect of the image is obvious when sigma is larger. And carrying out convolution calculation on the template generated by the Gaussian kernel function and each pixel in the image to obtain a preprocessed image. The image after preprocessing the downsampled image of fig. 3 is shown in fig. 4.
S3, extracting the whole edge pixels.
The boundary of the circular spot contour is the place with more severe gray value change, and the invention extracts the whole pixel of the edge of the preprocessed circular spot image by the Canny operator to obtain the edge contour. However, how to set the threshold value parameter in the Canny operator is a technical difficulty, so the invention obtains a gradient value image by calculating the pixel gradient value of the circular spot image, and obtains the threshold value in the Canny operator by adopting an OTSU method for the gradient value image.
Specifically, convolution kernel H for calculating x-axis direction and y-axis direction respectively x 、H y By convolution kernel H x Performing convolution calculation with the image to obtain gradient G along the x-direction x From convolution kernel H y Performing convolution calculation with the image to obtain gradient G along y direction y From G x And G y The gradient image G is synthesized, and the corresponding calculation formula is as follows:
G x =H x *I s
G y =H y *I s
G=|G x |+|G y |
the invention adopts an OTSU (Otsu method-maximum inter-class variance method) method to solve the threshold value of a Canny operator, wherein the maximum threshold value T is a segmentation threshold value of an image foreground and a background, and the proportion of the foreground points to the image is w 0 Average gray level u 0 The background point is w 1 Average gray level u 1 If the total average gray level of the image is u, the calculation formula of the average gray level u is:
u=w 0 ×u 0 +w 1 ×u 1
the variance of the foreground and background images is g, and the calculation formula of g is:
g=w 0 ×(u 0 -u) 2 +w 1 ×(u 1 -u) 2
the simultaneous preparation method comprises the following steps:
when the variance g is maximum, the foreground and background differences are considered to be maximum, the gray value at the moment is the optimal threshold, the maximum threshold T of the Canny operator is set as half of the maximum threshold, and the whole pixel edge of the circular spot image is extracted based on the maximum threshold and the minimum threshold of the Canny operator. The whole pixel edge extraction result of the preprocessed image of fig. 4 is shown in fig. 5.
S4, edge contour screening.
The edges obtained by whole pixel extraction not only have the outline of the spot, but also contain a plurality of background noise outlines, so that the outlines need to be screened regularly, and the target outlines of the spot are selected from the edge outlines in the step S3. According to the method, the spot target contour screening rule is set, the spot contour which is closed in contour, proper in contour size and larger in contour inner gray value than contour outer gray value is screened out from the edge contour, interference points and points with poor quality are eliminated, and the accuracy of extracting the edge contour of the circular spot image is improved.
Specifically, the set spot target contour screening rule is as follows:
(1) is a closed contour. The specific implementation process for judging whether the contour is closed is as follows: traversing each pixel I in the image s (i s ,j s ) If I s (i s ,j s ) > 0, saving the coordinate values into a Array of numbers, and storing I s (i s ,j s ) Setting the gray scale of (2) to zero; pair I s (i s ,j s ) And (3) carrying out the same judgment operation on each point in the eight adjacent areas, and storing the coordinate values of the corresponding points into the Array. If the first point coordinate and the last point coordinate of the Array are I s (i s ,j s ) The contour is considered a closed contour, which is preserved, otherwise discarded.
(2) The contour size is within a set range. The specific implementation process for judging the size of the outline is as follows: and counting the number of pixels forming each contour, if the number of the contour points exceeds the set minimum and maximum ranges, considering that the contour size is not satisfactory, and discarding the contour, and only keeping the contour with the number of the contour points between the minimum and maximum ranges.
(3) The inner gray values of the contour are larger than the outer gray values of the contour. The inner gray value of the normal spot outline is larger than the outer gray value of the outline, and if the inner gray value of the outline is smaller than or equal to the outer gray value, the outline is eliminated. The specific implementation process for calculating the inner and outer gray values of the outline is as follows: for each contour, each contour point coordinate (x i ,y i ),i=0,1,2…N,I s (. Cndot.) is the gray value of the pixel at the corresponding coordinate, N is the total number of contour points, and the current x in each spot contour is calculated i Coordinates of the smallest time (x min ,y 1 ) And x i Coordinates at maximum (x max ,y 2 ) And when y i Minimum ofCoordinates of time (x 1 ,y min ) And y i Coordinates at maximum (x 2 ,y max )。
Calculating the internal gray value I from the above coordinates in And an external gray value I out
I in =(I s (x 1 ,y min +1)+I s (x max -1,y 2 )+I s (x 2 ,y max -1)+I s (x min +1,y 1 ))/4
I out =(I s (x 1 ,y min -1)+I s (x max +1,y 2 )+I s (x 2 ,y max +1)+I s (x min -1,y 1 ))/4
Only reserve I in >I out A corresponding profile. The result of the edge contour screening of the edge contour shown in fig. 5 is shown in fig. 6, and comparing fig. 5 and fig. 6 can know that the contour screening of the present invention can better filter irrelevant points. Through the edge contour screening, the accuracy of spot target contour recognition is improved, the calculation amount of the subsequent circle center coordinate extraction can be further reduced, and the circle center extraction speed is improved.
S5, extracting edge sub-pixels.
The edge extraction method in step S4 belongs to pixel-level edge detection, and the accuracy is not high, and the actual measurement requirement cannot be met, so that the pixel basic unit needs to be subdivided, and the spot detection accuracy is improved. The invention adopts polynomial fitting to extract edge sub-pixels of the screened spot outline. Let the fitting model of polynomial fitting be:
f(x,y)=k 1 +k 2 x+k 3 y+k 4 x 2 +k 5 xy+k 6 y 2 +k 7 x 3 +k 8 x 2 y+k 9 xy 2 +k 10 y 3
wherein k is j As polynomial coefficients, j=1, 2, …,10 is determined by fitting the region pixel gray scale.
The derivation of f (x, y) is:
continuing to calculate the second derivative is:
assuming that points in the edge gradient direction θ are represented as x=ρcos θ, y=ρsin θ, ρ is the corresponding point arc length, the speckle profile fits the region center point (x 0 ,y 0 ) The second derivative in the θ direction is:
f″ θ (x 0 ,y 0 )=6(k 7 sin 3 θ+k 8 sin 2 θcosθ+k 9 sinθcos 2 θ+k 10 cos 3 θ)ρ+2(k 4 sin 2 θ+k 5 sinθcosθ+k 6 cos 2 θ)
let the second derivative f θ (x 0 ,y 0 ) =0, solving for ρ, resulting in a subpixel coordinate position of the edge point of (x 0 +ρcosθ,y 0 +ρsin θ). In this way, the edge sub-pixels of the circular spot are found.
S6, positioning the center of the sub-pixel.
The circular spot image approximates to a plane ellipse shape, the invention utilizes the extracted edge sub-pixels to carry out ellipse fitting, the coefficient of an ellipse equation is obtained through least square fitting, and the center position of the circular spot is calculated according to the obtained equation coefficient.
The general equation for a plane ellipse is:
x 2 +2Bxy+Cy 2 +2Dx+2Ey+F=0
five parameters B, C, D, E, F of the ellipse equation are found by least squares fitting, the center coordinates (x c ,y c ) The method comprises the following steps:
the "+" of the center of a circular blob in FIG. 7 represents the sub-pixel centered position of each circular blob.
S7, screening the edge contours of the sub-pixels.
Some spots in the circular spot image are seriously deformed or missing due to imaging quality or acquisition angles, and the ellipse obtained by direct fitting has a great error, so that the fitted contour needs to be further screened. The invention sets an ellipse fitting error threshold value, and reserves the circle center of which the fitting error is smaller than the error threshold value; meanwhile, a ratio range of a long axis to a short axis of the ellipse is set, and a circle center of the ratio of the long axis to the short axis in the set ratio range is reserved.
S8, coordinate conversion.
The center coordinates of the spots calculated in step S7 are coordinates after image downsampling, and need to be further converted into the original image, and the conversion formula is as follows:
X=x c
Y=y c
wherein (x) c ,y c ) Is the center coordinates of the spots after the downsampling of the image, (X, Y) is the center coordinates of the spots in the original image, and alpha is the downsampling coefficient. The "+" of the center of the circular spot in FIG. 7 indicates the location of the center of the extracted spot in the original image.
The invention reduces the size of the image by downsampling the image, effectively improves the speed of extracting and calculating the center coordinates, calculates the accurate spot contour by using the edge whole pixel extraction and edge sub-pixel extraction methods, and simultaneously screens the contour by using the circular spot characteristics, thereby improving the accuracy of extracting the center of the circular spot, and being applicable to real-time detection and identification systems with higher requirements on real-time performance and accuracy.
Corresponding to the embodiment of the method, the invention also provides a system for quickly extracting the circle center of the circular spot, which comprises the following steps:
and a pretreatment module: the method comprises the steps of acquiring a circular spot image, and carrying out downsampling treatment and preprocessing on the circular spot image;
and a contour extraction module: the method comprises the steps of performing edge whole pixel extraction on a preprocessed circular spot image through a Canny operator to obtain an edge contour;
a sub-pixel extraction module: the method comprises the steps of setting a spot target contour screening rule, and screening out spot contours conforming to the spot target contour screening rule from edge contours; performing edge sub-pixel extraction on the screened spot outline by adopting polynomial fitting;
the circle center calculating module: and the method is used for carrying out ellipse fitting on the extracted edge sub-pixels to calculate the center position of the circular spot.
The system embodiments and the method embodiments are in one-to-one correspondence, and the brief description of the system embodiments is just to refer to the method embodiments.
The invention also discloses an electronic device, comprising: at least one processor, at least one memory, a communication interface, and a bus; the processor, the memory and the communication interface complete communication with each other through the bus; the memory stores program instructions executable by the processor that the processor invokes to implement the aforementioned methods of the present invention.
The invention also discloses a computer readable storage medium storing computer instructions for causing a computer to implement all or part of the steps of the methods of the embodiments of the invention. The storage medium includes: a usb disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The system embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, i.e., may be distributed over a plurality of network elements. One of ordinary skill in the art may select some or all of the modules according to actual needs without performing any inventive effort to achieve the objectives of the present embodiment.
The foregoing description of the preferred embodiments of the invention is not intended to be limiting, but rather is intended to cover all modifications, equivalents, alternatives, and improvements that fall within the spirit and scope of the invention.

Claims (10)

1. A method for quickly extracting the center of a circular spot is characterized by comprising the following steps:
collecting a circular spot image, and performing downsampling treatment and pretreatment on the circular spot image;
extracting the whole pixels of the edges of the preprocessed circular spot image by a Canny operator to obtain edge contours;
setting a spot target contour screening rule, and screening out a spot contour conforming to the spot target contour screening rule from the edge contour;
performing edge sub-pixel extraction on the screened spot outline by adopting polynomial fitting;
and carrying out ellipse fitting on the extracted edge sub-pixels, and calculating the center position of the circular spot.
2. The method for quickly extracting the center of a circular spot according to claim 1, wherein the downsampling the circular spot image specifically comprises:
selecting a sampling coefficient alpha according to the resolution ratio W.times.H of the circular spot image and the pixel size occupied by the spot, wherein alpha is more than 0 and less than or equal to 1, and the pixel relationship between the downsampled image and the original image is as follows:
i s =round(i*α)
j s =round(j*α)
wherein I (I, j) is the pixel point before downsampling, I s (i s ,j s ) For the pixel point after downsampling, i is more than or equal to 0 s <round(H*α),0≤j s < round (, α), the round () function is to round the input parameters.
3. The method for quickly extracting the center of a circular spot according to claim 2, wherein the extracting the whole pixel of the edge of the preprocessed circular spot image by the Canny operator to obtain the edge contour specifically comprises:
calculating pixel gradient values of the circular spot image to obtain a gradient value image;
the maximum threshold value in the Canny operator is obtained by adopting an OTSU method on the gradient value image, and the minimum threshold value of the Canny operator is set to be half of the maximum threshold value;
and extracting edge integer pixels of the circular spot image based on the maximum threshold and the minimum threshold of the Canny operator.
4. The method for quickly extracting the center of a circular spot according to claim 1, wherein the set spot target contour screening rule specifically includes:
(1) is a closed contour;
(2) the outline size is within a set range;
(3) the inner gray values of the contour are larger than the outer gray values of the contour.
5. The method for rapidly extracting a circle center of a circular spot according to claim 4, wherein the internal gray value I in And an external gray value I out The calculation is as follows:
I in =(I s (x 1 ,y min +1)+I s (x max -1,y 2 )+I s (x 2 ,y max -1)+I s (x min +1,y 1 ))/4
I out =(I s (x 1 ,y min -1)+I s (x max +1,y 2 )+I s (x 2 ,y max +1)+I s (x min -1,y 1 ))/4
let the coordinates of the outline point of the outline of the spot be (x i ,y i ),i=0,1,2…N,I s (. Cndot.) is the gray value of the pixel at the corresponding coordinate, N is the total number of contour points, (x) min ,y 1 )、(x max ,y 2 ) Respectively, when x is in each spot contour i Minimum time coordinate sum x i Coordinates at maximum, (x) 1 ,y min )、(x 2 ,y max ) Respectively when y i Minimum time coordinate sum y i Coordinates at maximum.
6. The method for quickly extracting the center of a circular spot according to claim 1, wherein the step of performing edge sub-pixel extraction on the screened spot profile by using polynomial fitting specifically comprises:
let the fitting model of polynomial fitting be:
f(x,y)=k 1 +k 2 x+k 3 y+k 4 x 2 +k 5 xy+k 6 y 2 +k 7 x 3 +k 8 x 2 y+k 9 xy 2 +k 10 y 3
where f (x, y) is a cubic polynomial, (x, y) represents subpixel coordinates, k j For the third order polynomial coefficients, j=1, 2, …,10, determined by the fitting region pixel gray scale;
assuming that points in the edge gradient direction θ are expressed as x=ρcos θ, y=ρsin θ, ρ is the corresponding point arc length, the center point of the fitting region (x 0 ,y 0 ) The second derivative in the θ direction is:
f″ θ (x 0 ,y 0 )=6(k 7 sin 3 θ+k 8 sin 2 θcosθ+k 9 sinθcos 2 θ+k 10 cos 3 θ)ρ+2(k 4 sin 2 θ+k 5 sinθcosθ+k 6 cos 2 θ)
let the second derivative f θ (x 0 ,y 0 ) =0, solving for ρ, resulting in a subpixel coordinate position of the edge point of (x 0 +ρcosθ,y 0 +ρsinθ)。
7. The method for quickly extracting the center of a circular spot according to claim 6, wherein after the ellipse fitting is performed on the extracted edge sub-pixels, further comprises:
setting an ellipse fitting error threshold value, and reserving the circle center of which the fitting error is smaller than the error threshold value;
setting the ratio range of the major axis to the minor axis of the ellipse, and reserving the circle center of the ratio of the major axis to the minor axis in the set ratio range.
8. A rapid extraction system for the center of a circular spot, the system comprising:
and a pretreatment module: the method comprises the steps of acquiring a circular spot image, and carrying out downsampling treatment and preprocessing on the circular spot image;
and a contour extraction module: the method comprises the steps of performing edge whole pixel extraction on a preprocessed circular spot image through a Canny operator to obtain an edge contour;
a sub-pixel extraction module: the method comprises the steps of setting a spot target contour screening rule, and screening out spot contours conforming to the spot target contour screening rule from edge contours; performing edge sub-pixel extraction on the screened spot outline by adopting polynomial fitting;
the circle center calculating module: and the method is used for carrying out ellipse fitting on the extracted edge sub-pixels to calculate the center position of the circular spot.
9. An electronic device, comprising: at least one processor, at least one memory, a communication interface, and a bus;
the processor, the memory and the communication interface complete communication with each other through the bus;
the memory stores program instructions executable by the processor, the processor invoking the program instructions to implement the method of any of claims 1-7.
10. A computer readable storage medium storing computer instructions for causing a computer to implement the method of any one of claims 1 to 7.
CN202310520586.3A 2023-05-10 2023-05-10 Method and system for quickly extracting circle center of circular spot Pending CN116503462A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310520586.3A CN116503462A (en) 2023-05-10 2023-05-10 Method and system for quickly extracting circle center of circular spot

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310520586.3A CN116503462A (en) 2023-05-10 2023-05-10 Method and system for quickly extracting circle center of circular spot

Publications (1)

Publication Number Publication Date
CN116503462A true CN116503462A (en) 2023-07-28

Family

ID=87321430

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310520586.3A Pending CN116503462A (en) 2023-05-10 2023-05-10 Method and system for quickly extracting circle center of circular spot

Country Status (1)

Country Link
CN (1) CN116503462A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117236247A (en) * 2023-11-16 2023-12-15 零壹半导体技术(常州)有限公司 Signal shielding wire generation method for chip test
CN117495851A (en) * 2023-12-29 2024-02-02 陕西中医药大学 Image contour processing-based water environment microorganism detection method

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117236247A (en) * 2023-11-16 2023-12-15 零壹半导体技术(常州)有限公司 Signal shielding wire generation method for chip test
CN117236247B (en) * 2023-11-16 2024-01-23 零壹半导体技术(常州)有限公司 Signal shielding wire generation method for chip test
CN117495851A (en) * 2023-12-29 2024-02-02 陕西中医药大学 Image contour processing-based water environment microorganism detection method
CN117495851B (en) * 2023-12-29 2024-04-05 陕西中医药大学 Image contour processing-based water environment microorganism detection method

Similar Documents

Publication Publication Date Title
CN110866924B (en) Line structured light center line extraction method and storage medium
CN108921176B (en) Pointer instrument positioning and identifying method based on machine vision
CN107301661B (en) High-resolution remote sensing image registration method based on edge point features
CN116503462A (en) Method and system for quickly extracting circle center of circular spot
CN107507208B (en) Image feature point extraction method based on curvature estimation on contour
CN109903319B (en) Multi-resolution-based fast iteration closest point registration algorithm
CN110706293B (en) SURF feature matching-based electronic component positioning and detecting method
CN111354047B (en) Computer vision-based camera module positioning method and system
CN111415376B (en) Automobile glass subpixel contour extraction method and automobile glass detection method
CN111311618A (en) Circular arc workpiece matching and positioning method based on high-precision geometric primitive extraction
CN115096206A (en) Part size high-precision measurement method based on machine vision
CN106340010A (en) Corner detection method based on second-order contour difference
CN116664559A (en) Machine vision-based memory bank damage rapid detection method
CN112085675A (en) Depth image denoising method, foreground segmentation method and human motion monitoring method
CN114612412A (en) Processing method of three-dimensional point cloud data, application of processing method, electronic device and storage medium
CN112801141B (en) Heterogeneous image matching method based on template matching and twin neural network optimization
CN113223074A (en) Underwater laser stripe center extraction method
CN112435272A (en) High-voltage transmission line connected domain removing method based on image contour analysis
CN114882095B (en) Object height online measurement method based on contour matching
CN114742849A (en) Leveling instrument distance measuring method based on image enhancement
CN109949245B (en) Cross laser detection positioning method and device, storage medium and computer equipment
CN113902667A (en) Thread turning identification method and system for machine vision
CN109272540B (en) SFR automatic extraction and analysis method of image of graphic card
CN111798506A (en) Image processing method, control method, terminal and computer readable storage medium
CN117670916B (en) Coating edge detection method based on deep learning

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination