Gold bar detection point selection method and system

CN122550602APending Publication Date: 2026-08-11CHANGCHUN GOLD RES INST
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-14
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0003]现有根据传统边缘检测的金条定位方法,在复杂光照、背景干扰及金条自身不规则断面的现实条件下,边缘提取能力不足,导致无法稳定、精确地获取金条轮廓,进而直接影响后续所有环节(定位、检测点选择)的准确性与可靠性

Benefits of technology

在本发明的技术方案中,通过对原始图像进行预处理,有效降低了复杂光照和背景干扰带来的噪声影响,为后续的边缘检测奠定了良好基础。在此基础上进行边缘检测,并结合亚像素级非极大值抑制处理,能够精确地定位边缘点,极大地提高了边缘定位的精度。随后对抑制处理后的边缘进行连接,形成连续边缘线段,这一步骤克服了金条不规则断面可能导致的边缘断裂问题,使得边缘信息更加完整和连贯。接着从连续边缘线段中筛选出金条的目标轮廓并确定其位置,确保了轮廓提取的准确性和稳定性,避免了非目标轮廓的干扰。最后根据目标轮廓在其界定的区域内选取测试点,为后续的无损纯度分析等检测环节提供了精准的位置基准,从而有效提升了智能黄金回收终端整体检测流程的准确性与可靠性,推动了贵金属回收行业智能化升级的标准化水平。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122550602A_ABST
    Figure CN122550602A_ABST
Patent Text Reader

Abstract

This application provides a method and system for selecting gold bar detection points, belonging to the field of image processing. The method includes: acquiring an original image containing gold bars; preprocessing the original image to obtain a preprocessed image; performing edge detection on the preprocessed image to obtain edge detection results; performing sub-pixel-level non-maximum suppression processing on the edge detection results; connecting the suppressed edges to form continuous edge segments; selecting the target contour of the gold bar from the continuous edge segments and determining its position; and selecting a test point within the defined area of ​​the target contour. This invention can effectively cope with complex lighting, background interference, and irregular cross-sections of gold bars, significantly improving the stability and accuracy of gold bar contour extraction, thereby ensuring the accuracy and reliability of detection point selection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, specifically to a method and system for selecting gold bar detection points. Background Technology

[0002] With the intelligent upgrading of the precious metal recycling industry, intelligent gold recycling terminals are gradually becoming more widespread due to their efficient and standardized recycling model. One of the core functions of this type of terminal is to use a vision system to accurately locate the gold bar placed inside the terminal and automatically determine the optimal detection point on its surface (especially the cut surface) for subsequent non-destructive purity analysis and other tests. The accuracy of this positioning and point selection process directly determines the accuracy and reliability of the entire recycling and testing process.

[0003] Existing gold bar positioning methods based on traditional edge detection are insufficient in edge extraction under real-world conditions such as complex lighting, background interference, and the irregular cross-section of the gold bar itself. This results in the inability to stably and accurately obtain the gold bar outline, which in turn directly affects the accuracy and reliability of all subsequent steps (positioning, detection point selection). Summary of the Invention

[0004] In view of the technical problems existing in the background art, this application provides a method and system for selecting gold bar detection points. The method can effectively cope with the real conditions such as complex lighting, background interference and irregular cross-section of gold bars, significantly improve the stability and accuracy of gold bar contour extraction, and thus ensure the accuracy and reliability of detection point selection. It provides a precise position benchmark for subsequent detection steps such as non-destructive purity analysis of gold bars, which is conducive to improving the overall detection efficiency and standardization level of intelligent gold recycling terminals.

[0005] In a first aspect, the present invention proposes a method for selecting detection points for gold bars, comprising: Obtain the original image containing the gold bars; The original image is preprocessed to obtain a preprocessed image; Edge detection is performed on the preprocessed image to obtain the edge detection results; Subpixel-level nonmaximum suppression processing is applied to the edge detection results; Connect the suppressed edges to form continuous edge segments; The target outline of the gold bar is selected from continuous edge segments, and its location is determined; Based on the target profile, select a test point within its defined area.

[0006] Furthermore, the steps of preprocessing the original image to obtain a preprocessed image include: The original image is converted to the target color space and the color component images are extracted. Illumination normalization is performed on the color component image; Adaptive binarization is performed on the image after illumination normalization. Noise reduction is performed on the binarized image.

[0007] Furthermore, the steps of converting the original image to the target color space and extracting the color component images include: Convert the original image to the HSV color space; Extract the H component image from the HSV color space.

[0008] Further, the illumination normalization process includes: Divide the color component image into multiple non-overlapping sub-blocks; Calculate the grayscale histogram for each sub-block, and allocate the number of pixels in the grayscale histogram that exceed a preset threshold to other grayscale levels; Each processed sub-block is merged using bilinear interpolation.

[0009] Further adaptive binarization processing includes: For each pixel in the image after illumination normalization, the binarization threshold is dynamically calculated based on its local gray mean, local gray standard deviation and the global maximum standard deviation of the image. The grayscale value of each pixel is compared with its corresponding dynamic threshold to generate a binary image, where pixels with a value higher than or equal to the threshold are marked as the first background, and pixels with a value lower than the threshold are marked as the second background; and / or, Noise reduction processing includes bilateral filtering.

[0010] Furthermore, the steps for performing edge detection on the preprocessed image to obtain the edge detection results include: The gradient of the image is calculated using at least two edge detection operators in different directions; The gradient values ​​of corresponding pixels in each directional gradient map are fused to obtain the edge detection result.

[0011] Further, sub-pixel-level nonmaximum suppression processing includes: The gradient direction of each pixel is determined based on the edge detection results; Interpolate along the gradient direction at the sub-pixel level to find local extrema of the gradient. Only edge points at local extreme points are retained to obtain the suppressed edges.

[0012] Further steps in selecting the target outline of the gold bar from continuous edge segments include: Calculate the area, aspect ratio, and convexity of each closed contour in a continuous edge segment, and filter out the target contour according to a preset range.

[0013] Furthermore, the step of selecting a test point within the defined area based on the target contour includes: Calculate the curvature of the sampling points on the target contour and the gradient change in the gradient map; Candidate points are selected based on curvature threshold and gradient mutation threshold; The position range of candidate points is constrained based on the prior length information of the gold bar; From all candidate points that satisfy the constraints, select the point with the largest product of curvature and gradient change as the test point.

[0014] Secondly, the present invention also proposes a gold bar detection point selection system, comprising: The image acquisition module is used to acquire the original image containing the gold bar; The preprocessing module is used to preprocess the original image to obtain a preprocessed image; The edge detection module is used to perform edge detection on the preprocessed image to obtain the edge detection results; The subpixel-level suppression processing module is used to perform subpixel-level non-maximum suppression processing on the edge detection results; The edge connection module is used to connect the suppressed edges to form continuous edge segments; The contour determination module is used to filter out the target contour of the gold bar from continuous edge segments and determine its position; The test point selection module is used to select a test point within the defined area based on the target contour.

[0015] The beneficial effects of this invention are: In the technical solution of this invention, preprocessing the original image effectively reduces the noise impact caused by complex lighting and background interference, laying a solid foundation for subsequent edge detection. Edge detection is then performed on this basis, combined with sub-pixel-level non-maximum suppression processing, enabling precise edge point localization and significantly improving edge positioning accuracy. Subsequently, the suppressed edges are connected to form continuous edge segments. This step overcomes the edge breakage problem that may be caused by irregular cross-sections of gold bars, making the edge information more complete and coherent. Next, the target contour of the gold bar is selected from the continuous edge segments, and its position is determined, ensuring the accuracy and stability of contour extraction and avoiding interference from non-target contours. Finally, test points are selected within the defined area based on the target contour, providing precise positional benchmarks for subsequent non-destructive purity analysis and other detection steps. This effectively improves the accuracy and reliability of the overall detection process of the intelligent gold recycling terminal and promotes the standardization of intelligent upgrading in the precious metal recycling industry.

[0016] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description

[0017] To more clearly illustrate the technical solutions of this application, the accompanying drawings used in this application will be briefly described below. Obviously, the drawings described below are merely some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without any creative effort.

[0018] Figure 1 This is a flowchart illustrating the first method for selecting gold bar detection points according to an embodiment of the present invention. Figure 2 This is a flowchart illustrating the second method for selecting gold bar detection points provided in an embodiment of the present invention. Figure 3 This is a flowchart illustrating the third method for selecting gold bar detection points provided in an embodiment of the present invention. Figure 4 This is a flowchart illustrating the fourth method for selecting gold bar detection points provided in an embodiment of the present invention. Figure 5 This is a flowchart illustrating the fifth method for selecting gold bar detection points provided in this embodiment of the invention. Figure 6 This is a flowchart illustrating the sixth method for selecting gold bar detection points provided in this embodiment of the invention. Figure 7 This is a flowchart illustrating the seventh method for selecting gold bar detection points provided in this embodiment of the invention. Figure 8 This is a flowchart illustrating the eighth method for selecting gold bar detection points provided in this embodiment of the invention. Figure 9 This is a flowchart illustrating the ninth method for selecting gold bar detection points provided in this embodiment of the invention. Detailed Implementation

[0019] The embodiments of the technical solution of this application will now be described in detail with reference to the accompanying drawings. These embodiments are only used to more clearly illustrate the technical solution of this application and are therefore merely examples, and should not be used to limit the scope of protection of this application.

[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application; the terms “comprising” and “having”, and any variations thereof, in the specification, claims, and foregoing description of the drawings are intended to cover non-exclusive inclusion.

[0021] In the description of the embodiments of this application, technical terms such as "first" and "second" are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly specifying the number, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly defined.

[0022] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in each place in the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0023] In the description of the embodiments in this application, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship.

[0024] In the description of the embodiments of this application, the term "multiple" refers to two or more (including two), similarly, "multiple sets" refers to two or more (including two sets), and "multiple pieces" refers to two or more (including two pieces).

[0025] In the description of the embodiments of this application, the technical terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," "clockwise," "counterclockwise," "axial," "radial," and "circumferential" indicate the orientation or positional relationship based on the accompanying drawings. They are only for the convenience of describing the embodiments of this application and simplifying the description, and are not intended to indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the embodiments of this application.

[0026] In the description of the embodiments of this application, unless otherwise expressly specified and limited, technical terms such as "installation," "connection," "joining," and "fixing" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. For those skilled in the art, the specific meaning of the above terms in the embodiments of this application can be understood according to the specific circumstances.

[0027] Visit Figure 1 In a first aspect, the present invention proposes a method for selecting detection points for gold bars, comprising: Step S101: Obtain the original image containing the gold bar; Step S102: Preprocess the original image to obtain a preprocessed image; Step S103: Perform edge detection on the preprocessed image to obtain the edge detection results; Step S104: Perform sub-pixel-level non-maximum suppression processing on the edge detection results; Step S105: Connect the edges after suppression processing to form continuous edge segments; Step S106: Select the target outline of the gold bar from the continuous edge segments and determine its position; Step S107: Select a test point within the defined area based on the target contour.

[0028] In the technical solution of this invention, preprocessing the original image effectively reduces the noise impact caused by complex lighting and background interference, laying a solid foundation for subsequent edge detection. Edge detection is then performed on this basis, combined with sub-pixel-level non-maximum suppression processing, enabling precise edge point localization and significantly improving edge positioning accuracy. Subsequently, the suppressed edges are connected to form continuous edge segments. This step overcomes the edge breakage problem that may be caused by irregular cross-sections of gold bars, making the edge information more complete and coherent. Next, the target contour of the gold bar is selected from the continuous edge segments, and its position is determined, ensuring the accuracy and stability of contour extraction and avoiding interference from non-target contours. Finally, test points are selected within the defined area based on the target contour, providing precise positional benchmarks for subsequent non-destructive purity analysis and other detection steps. This effectively improves the accuracy and reliability of the overall detection process of the intelligent gold recycling terminal and promotes the standardization of intelligent upgrading in the precious metal recycling industry.

[0029] It is understood that the raw image in step S101 refers to the unprocessed visual data containing gold bars, directly acquired by an image acquisition module (such as a high-definition industrial camera). This raw image may contain complex background information, uneven lighting, and detailed features of the gold bars themselves, such as texture, reflection, and cut surfaces. This raw image is the fundamental input for all subsequent image processing and analysis steps, and its quality (such as resolution, sharpness, and lighting conditions) directly affects the preprocessing and subsequent processing results.

[0030] Understandably, preprocessing refers to a series of targeted image enhancement and noise suppression operations performed on the original image. The aim is to eliminate or reduce the interference of complex environmental factors (such as changes in lighting, cluttered background textures, sensor noise, etc.) on the gold bar contour extraction, highlight the effective features of the gold bar target area, and provide high-quality image data for subsequent edge detection.

[0031] Understandably, preprocessing can be achieved in various ways, such as spatial geometric transformations (e.g., scaling, cropping, rotation) to unify dimensions or increase data diversity; color and contrast adjustments (e.g., grayscale, normalization, histogram equalization) to standardize input or enhance features; image enhancement techniques (e.g., adding noise, random color dithering, advanced blending methods) to improve model generalization by simulating real-world variations; and filtering and denoising (e.g., Gaussian filtering, median filtering) to eliminate noise interference. In practical applications, these methods are typically combined into a workflow depending on the specific task.

[0032] Visit Figure 2 In some embodiments, step S102 includes: Step S201: Convert the original image to the target color space and extract the color component images: Step S202: Perform illumination normalization processing on the color component image: Step S203: Perform adaptive binarization on the image after illumination normalization: Step S204: Perform noise reduction processing on the binarized image.

[0033] In this embodiment, by converting the original image to the target color space and extracting the color component images, the differences between the gold bars and the background in specific color dimensions can be highlighted, providing more discriminative image data for subsequent processing. Illumination normalization processing effectively eliminates local brightness differences in the image caused by uneven illumination, making the overall grayscale distribution of the image more balanced and avoiding interference from excessively bright or dark areas on feature extraction. Adaptive binarization processing, by dynamically calculating the threshold of each pixel, can more accurately separate the foreground and background areas of the gold bars under complex background and lighting conditions. Compared with fixed threshold binarization, it is more adaptable to local grayscale changes in the image. Denoising processing further removes isolated noise points and small interference contours that may be introduced during binarization, allowing subsequent edge detection to focus on the true edge information of the gold bars, thereby improving the overall quality of the preprocessed image and providing a foundation for accurately extracting the gold bar contours.

[0034] It is understandable that color component extraction from images can be achieved in various ways. For example, standard color components can be directly obtained by calling OpenCV library functions for color space conversion and channel separation; color components can be generated or verified by performing mathematical operations on pixels according to conversion formulas; and deep learning models can learn from images and output task-related abstract feature representations, which are often presented in the form of single-channel feature maps. The specific implementation method needs to be selected based on the actual task requirements, environmental conditions, and resource constraints.

[0035] Visit Figure 3 In some embodiments, step S201 includes: Step S301: Convert the original image to the HSV color space; Step S302: Extract the H component image from the HSV color space.

[0036] In this embodiment, by converting the original image to the HSV color space, the image's brightness (V component) and color information (H and S components) can be separated, effectively reducing the impact of illumination changes on color perception. Since the H component (hue) of gold bars in the HSV color space has a relatively stable range, extracting the H component image can highlight the hue difference between the gold bars and the background. For example, gold bars typically exhibit a specific golden hue, while the background may contain other colors or complex textures. The H component image can more clearly distinguish the gold bar area from the background area, providing more targeted input data for subsequent illumination normalization and binarization processing, thereby improving the accuracy and robustness of preprocessing.

[0037] It's important to note that the gold hue of gold bars exhibits a stable range in the H component, typically between 20° and 60°. This range effectively separates the gold bars from the background, covering the hue of most common gold bars (such as pure gold and 24K gold). By setting upper and lower thresholds for the H component (e.g., a lower limit of 20° and an upper limit of 60°), pixel areas in the image that match the hue characteristics of gold bars can be initially filtered out. Background pixels that clearly do not belong to the gold bar hue (such as low H-value areas in dark backgrounds, or interference areas of other hues like red or blue) can be initially excluded. This allows for the initial localization of the gold bar target in the color dimension, narrowing the scope of focus for subsequent processing steps such as illumination normalization and reducing interference from irrelevant background information.

[0038] Specifically, in one embodiment, the acquired RGB color raw image (pixel values ​​represented as...) Convert to HSV color space and extract the H component image. The gold bar and background are initially separated. The conversion formula is as follows: In the formula, R is the value of the red channel; G is the value for the green channel; B is the value for the blue channel; H stands for hue, which indicates the type of color (such as red, yellow, green, and blue). S represents saturation, and V represents brightness.

[0039] Understandably, illumination normalization can be achieved in various ways. For example, algorithms based on Retinex theory model an image as the product of reflection and illumination components, enhancing image detail and consistency by estimating and removing the illumination component. Adaptive histogram equalization divides the image into blocks and performs contrast-limited histogram equalization, improving overall contrast while suppressing local over-enhancement and noise amplification. Gamma correction adjusts the overall brightness distribution by performing a non-linear transformation on image intensity to improve visual perception or adapt to display characteristics. In practical processing, appropriate preprocessing methods can be selected based on the specific pattern of image illumination unevenness, the reflective characteristics of the gold bar surface, and subsequent processing requirements, thus providing a more reliable image foundation for subsequent edge detection and contour extraction.

[0040] Visit Figure 4 In some embodiments, step S202 includes: Step S401: Divide the color component image into multiple non-overlapping sub-blocks; Step S402: Calculate the grayscale histogram of each sub-block and allocate the number of pixels in the grayscale histogram that exceed a preset threshold to other grayscale levels. Step S403: Merge each processed sub-block using bilinear interpolation.

[0041] In this embodiment, by dividing the color component image into multiple non-overlapping sub-blocks, the uneven illumination problem of the overall image can be decomposed into local sub-block illumination adjustments. This allows each sub-block to be processed independently according to its own illumination characteristics, avoiding the problem of some areas being too bright or too dark that may occur due to global processing. The grayscale histogram of each sub-block is calculated, and the number of pixels exceeding a preset threshold is distributed to other grayscale levels to avoid over-amplifying noise. The processed sub-blocks are then merged using bilinear interpolation, weakening overly bright areas caused by reflections and overly dark areas caused by shadows, resulting in a more balanced overall grayscale distribution of the image and clearly revealing the texture details of the gold bar surface.

[0042] Specifically, in one embodiment, the color component image is... The CLAHE algorithm is applied for local contrast enhancement, dividing the image into sections. There are 3 non-overlapping sub-blocks, each with a size of 1. .

[0043] For each sub-block, a grayscale histogram is calculated, and a contrast threshold (T=20) is set to distribute pixel values ​​exceeding the threshold evenly to other grayscale levels. The sub-blocks are then stitched together using bilinear interpolation to obtain an illumination-normalized image. .

[0044] Understandably, adaptive binarization can be implemented in various ways, such as threshold calculation methods based on local pixel neighborhoods. For example, the NiBlack algorithm dynamically determines the threshold by calculating the mean and standard deviation of the neighborhood around each pixel, making it suitable for images with uneven lighting. The Sauvola algorithm introduces dynamic coefficients based on the NiBlack algorithm, further optimizing threshold selection in low-contrast regions. The Bernsen algorithm determines the threshold by comparing the average of the maximum and minimum gray values ​​within the pixel neighborhood, exhibiting good adaptability to different contrast regions. In practical applications, a suitable adaptive binarization algorithm can be selected based on the specific characteristics of the gold bar image (such as surface reflectivity and background complexity) to achieve accurate separation of the foreground and background of the gold bar.

[0045] Visit Figure 5 In some embodiments, step S203 includes: Step S501: For each pixel in the image after illumination normalization, dynamically calculate the binarization threshold based on its local gray mean, local gray standard deviation and the global maximum standard deviation of the image. Step S502: Compare the gray value of each pixel with its corresponding dynamic threshold to generate a binary image, wherein pixels that are higher than or equal to the threshold are marked as the first background and pixels that are lower than the threshold are marked as the second background.

[0046] In this embodiment, by dynamically calculating the binarization threshold by combining the local gray-level mean, local gray-level standard deviation, and the global maximum standard deviation of the image, the local gray-level characteristics and overall gray-level distribution features of different regions of the image can be fully considered, making the threshold determination more targeted and adaptable. Compared with fixed thresholds or threshold calculation methods that rely solely on local information, this approach can not only effectively handle local gray-level fluctuations on the gold bar surface caused by reflection and texture differences, but also constrain the local threshold through the global maximum standard deviation, avoiding excessive influence of extreme local gray-level values ​​on the threshold calculation. This allows for more accurate separation of the gold bar foreground and background under complex lighting and background conditions. After comparing the gray-level value of each pixel with its corresponding dynamic threshold, a binary image is generated. Pixels higher than or equal to the threshold are marked as the first background, and pixels lower than the threshold are marked as the second background. This binarization method clearly highlights the outline of the gold bar from the complex background, providing a high-contrast image foundation for subsequent edge detection and contour extraction, and effectively reducing interference from non-target areas in subsequent processing.

[0047] Specifically, in one embodiment, the image after illumination normalization (e.g.) Binarization is performed, and the threshold for each pixel is dynamically determined: in, for The average gray value of the local window centered on [the value]. Standard deviation of grayscale within the window is the global maximum standard deviation of the image, and k is the correction coefficient. The binarization result is: In the formula, Indicates the background of gold bars. Indicates the background of the tray.

[0048] It is understandable that noise reduction can be achieved in various ways, such as morphological operations (e.g., opening and closing operations) to eliminate small noise points, smooth contour edges, or fill holes within contours; connected component analysis, by marking and filtering connected regions whose area, perimeter, and other features meet preset conditions, can remove isolated noise blocks with excessively small areas; region growing methods start from seed points and merge pixels to form regions according to similarity criteria, effectively distinguishing target regions from noise regions. In practical applications, single or combined noise reduction methods are usually selected based on the type of noise (e.g., Gaussian noise, impulse noise, etc.) and the specific characteristics of the image, in order to remove noise interference to the maximum extent while preserving the key contour information of the gold bar. In some embodiments, the noise reduction process includes: performing morphological opening operations on the binarized image; performing morphological closing operations on the image after opening operations; and performing connected component analysis on the image after closing operations to filter connected regions with an area greater than a preset area threshold. In this embodiment, morphological opening operation processing (erosion followed by dilation) can effectively remove small isolated noise points and fine interference burrs in the binarized image, while basically maintaining the shape of the main outline of the gold bar. Morphological closing operation processing (dilation followed by erosion) can fill in the tiny holes and depressions on the edges of the outline that may exist inside the gold bar, making the outline smoother and more complete. Connected region analysis calculates the area of ​​each connected region and filters out connected regions with an area greater than a preset area threshold. This can further eliminate small noise regions that may still remain after opening and closing operations, ensuring that the main connected regions of the gold bar are retained. This significantly improves the signal-to-noise ratio of the preprocessed image and lays a solid foundation for the subsequent accurate extraction of the gold bar's edges and outline.

[0049] In some embodiments, noise reduction processing includes bilateral filtering.

[0050] In this embodiment, bilateral filtering is used for noise reduction, which effectively suppresses noise while preserving the edge details of the gold bar to the greatest extent. The core principle of bilateral filtering is that its weight calculation considers not only the spatial distance between pixels (such as the spatial domain weight of Gaussian filtering) but also the similarity of pixel gray values ​​(range domain weight). For gold bar images, the edge regions are often accompanied by significant gray value jumps, while noise usually manifests as isolated gray value anomalies. When calculating the output value of a pixel, bilateral filtering assigns higher weights to pixels that are spatially close and have gray values ​​similar to the center pixel, and lower weights to pixels that are spatially far away or have large gray value differences (such as pixels on both sides of the edge or noise points). This characteristic allows bilateral filtering to smooth noise in uniform areas within the image without blurring the edge contours of the gold bar, avoiding the edge information loss problem that may occur during the noise reduction process of traditional methods such as Gaussian filtering.

[0051] Specifically, in one embodiment, bilateral filtering is used instead of traditional Gaussian blurring to preserve the gold bar edges while suppressing noise. The filtering formula is as follows: In the formula, The filtering window is centered at (x, y); Gaussian function in the spatial domain: d is the spatial distance. Options 3-5.

[0052] Gaussian function for grayscale: d represents the grayscale difference. 20-30 is an option.

[0053] Normalization coefficients: It is understandable that edge detection can be achieved in various ways. For example, the Canny edge detection algorithm achieves high-precision edge extraction through multi-stage processing (Gaussian filtering for noise reduction, calculation of gradient magnitude and direction, non-maximum suppression for edge refinement, dual threshold detection, and edge connection), effectively suppressing noise while preserving clear edge contours. The Sobel operator calculates the gradients of the image in the horizontal and vertical directions to obtain the intensity and direction information of the edges, and is characterized by its simple computation and low sensitivity to noise. The Prewitt operator is similar to the Sobel operator, but uses an average filtering kernel, resulting in a more uniform response to edges. The Laplacian operator detects edges based on the zero-crossing points of the second derivative, is sensitive to abrupt changes in grayscale but is easily affected by noise. In practical applications, a suitable edge detection algorithm can be selected based on the edge characteristics of the gold bar image (such as whether it is continuous or whether there are burrs), the noise level, and the required edge positioning accuracy to accurately extract the contour edges of the gold bar.

[0054] Visit Figure 6 In some embodiments, step S103 includes: Step S601: Calculate the gradient of the image using at least two edge detection operators in different directions; Step S602: Fuse the gradient values ​​of the corresponding pixels in each directional gradient map to obtain the edge detection result.

[0055] In this embodiment, by using edge detection operators in at least two different directions to calculate the gradient of the image, the grayscale variation information of the gold bar edge in different directions can be captured more comprehensively. The edge of the gold bar may exhibit various orientations such as horizontal, vertical, 45-degree, and 135-degree. A single-directional edge detection operator is often only sensitive to edge responses in a specific direction, easily missing edge details in other directions. By combining edge detection operators in at least two different directions, the gradient values ​​of corresponding pixels in each direction's gradient map are fused. For example, by taking the maximum value of the gradient values ​​in each direction, the square root of the sum of squares, or a weighted sum, the edge responses in each direction can be integrated, resulting in an edge detection result that contains more edge details and responds well to edges in different orientations. Compared with single-directional operators, this multi-directional gradient fusion method can effectively reduce edge detection omissions, especially for fine texture edges that may exist on the gold bar surface or irregular edges caused by casting or processing, which can be detected more accurately, providing more complete and reliable edge information for subsequent contour extraction and detection point selection.

[0056] Specifically, in one embodiment, the Scharr operator is used to calculate the gradients in the horizontal (0°) and vertical (90°) directions: In the formula, This represents the convolution operation. The filtered image after bilateral filtering is shown above. , This operator is a 3×3 convolution kernel used to extract the horizontal gray-level change rate of the image, mainly responding to vertical edges; The coefficients in column 1, -3, -10, and -3, indicate that negative weighting is applied to the left-hand pixels of a local region of the image. The coefficients 3, 10, and 3 in column 3 indicate that positive weighting is applied to the right-side pixels of a local region of the image. All coefficients in the middle column are 0, indicating that they do not participate in the weighting of the center column and only highlight the difference in gray levels between the left and right sides; The intermediate row coefficient ±10 is the main weight, used to strengthen the true gradient in the horizontal direction; the up and down row coefficients ±3 are the auxiliary weights, used to smooth noise and suppress single-point mutation interference.

[0057] The Prewitt operator is used to calculate the gradients at 45° and 135°: In the formula, This represents the convolution operation. The filtered image after bilateral filtering is shown above. .

[0058] The 3×3 convolution kernel is used to detect inclined edges at 45° and 135° angles to the horizontal direction; The upper right corner of the matrix is ​​assigned a positive weight, which means that the upper right pixels in the local area of ​​the image are given a positive weight; the lower left corner of the matrix is ​​assigned a negative weight, which means that the lower left pixels in the local area of ​​the image are given a negative weight. The center position coefficient is 0, and it is only used to highlight the grayscale difference in the diagonal direction; (-1, 0, 1) represents the weight values, which reduces computational complexity while ensuring the accuracy of gradient calculation.

[0059] The fused gradient map is obtained by taking the maximum value of the gradient maps in the four directions. The formula is as follows: Understandably, subpixel-level nonmaximum suppression (NVPS) can be implemented in various ways. For example, methods based on quadratic interpolation fit the grayscale values ​​of adjacent pixels along the gradient direction using a quadratic function to find the precise peak position of the gradient magnitude. Centroid-based methods calculate subpixel coordinates by weighting the gradient magnitudes of adjacent pixels along the gradient direction, utilizing the distribution characteristics of grayscale values ​​to improve positioning accuracy. Polynomial interpolation methods construct high-order polynomial models to fit grayscale changes near the edge, thereby achieving subpixel-level edge positioning. In practical applications, a suitable subpixel-level NNVPS method can be selected based on the continuity of the edge, the smoothness of the gradient change, and the computational efficiency requirements, to ensure both edge positioning accuracy and real-time performance.

[0060] Visit Figure 7 In some embodiments, step S104 includes: Step S701: Determine the gradient direction of each pixel based on the edge detection results; Step S702: Perform interpolation at the sub-pixel level along the gradient direction to find local extreme points of the gradient; Step S703: Only retain the edge points at the local extreme points to obtain the suppressed edges.

[0061] In this embodiment, by determining the gradient direction of each pixel based on the edge detection results, interpolation is performed along this gradient direction at the sub-pixel level, enabling more accurate local extrema of the gradient. Specifically, for each candidate edge point in the edge detection results, its gradient direction is first determined (e.g., 0°, 45°, 90°, 135°, or more refined angle divisions), and then the gradient magnitudes of two adjacent pixels in this direction are selected. By performing quadratic function interpolation fitting on the gradient magnitudes of these three points (the current pixel and its two neighboring pixels in the gradient direction), a quadratic function model about the positional offset is constructed, and the location of the extremum point of this quadratic function is solved. The x-coordinate of this extremum point is the sub-pixel level edge position. Only edge points at the local extrema points of the gradient obtained through interpolation are retained, while edge points at non-maximum points are suppressed, thereby refining the original pixel-level edge contour to the sub-pixel level, significantly improving the accuracy of edge localization, and providing higher-resolution edge base data for subsequent contour fitting and accurate selection of detection points. This processing method effectively avoids edge positioning errors and jagged effects that may be caused by traditional pixel-level non-maximum suppression, making the extracted gold bar edges smoother, more continuous, and more precisely positioned.

[0062] Specifically, in one embodiment, the edge detection results (e.g., fused gradient maps) are processed. ), calculate the gradient direction for each pixel. It is then quantized into 8 directions, along the gradient direction. Get the current pixel Neighboring pixels on both sides and The precise location of the gradient maximum is calculated using quadratic interpolation. :set up , , The interpolation function is Solving for the extreme points yields the results. The corresponding sub-pixel offset; if If the maximum value is within the interpolation interval, then retain it. If a pixel is used as an edge point, it is otherwise suppressed to obtain a sub-pixel level edge map. (i.e., the edges after suppression processing).

[0063] In some embodiments, the step of connecting the suppressed edges to form continuous edge segments includes: setting a dual threshold. , Based on the gradient plot mean, dynamic adjustment can be achieved. ). Filtering strong edge point sets. and weak edge point set ;by The point in the middle is the seed, and the search is performed within the 8-neighborhood. If the gradient direction of a weak edge point and a seed point forms an angle... If a point is determined to be on the same edge, it is included in the edge until no new points are added; after connecting, a complete edge map is obtained. (i.e., continuous edge segments).

[0064] Visit Figure 8 In some embodiments, step S106 includes: Step S801: Calculate the area, aspect ratio, and convexity of each closed contour in the continuous edge line segment, and select the target contour according to the preset range.

[0065] In this embodiment, by calculating the area, aspect ratio, and convexity of each closed contour in a continuous edge segment, and filtering the target contour according to a preset range, the contour region where the gold bar is located can be accurately located. Specifically, the area calculation is achieved by counting the number of pixels contained in the closed contour. As a detection object with fixed specifications, the projected area of ​​the gold bar in the image usually falls within a relatively stable preset range. The aspect ratio is calculated by first determining the minimum bounding rectangle of the closed contour using the minimum bounding rectangle algorithm. As an approximately cuboid structure, the aspect ratio of the gold bar at a standard shooting angle usually conforms to a specific range. The convexity calculation is achieved by determining whether the closed contour is a convex polygon. By setting a convexity threshold, contours that conform to the shape characteristics of the gold bar can be further filtered out. In practical applications, combining the three feature parameters of area, aspect ratio, and convexity for filtering can accurately identify the target contour of the gold bar, providing a reliable contour basis for the selection of subsequent detection points.

[0066] Specifically, in one embodiment, for continuous edge segments (e.g.) An 8-pass contour extraction algorithm was used to obtain all closed contours. For each contour Calculate and filter based on the following features: area Aspect Ratio : Calculate the length of the minimum bounding rectangle of the profile Hekuan ,satisfy convexity Calculate the area of ​​the convex hull of the contour With contour area ratio ,satisfy The outline that meets the above characteristics is retained as the gold bar outline. (i.e., the target contour), the center coordinates of its smallest bounding rectangle and rotation angle This refers to the position and orientation of the gold bars.

[0067] It is understandable that step S107 can be implemented in various ways. For example, intelligent selection of detection points can be achieved through neural network model training. A large number of precious metal image samples containing different specifications, surface features, and defects can be trained using a pre-learning deep learning algorithm, enabling the neural network model to autonomously learn the optimal distribution pattern of detection points on the precious metal surface and adaptively output the coordinates of the detection points based on the actual morphological characteristics of the precious metal (such as surface texture, potential defect areas, geometric center, etc.). Alternatively, standardized selection of detection points can be achieved through a preset rule base. For example, based on the geometric parameters of the precious metal contour (such as length, width, center position), a set of detection points can be generated according to rules such as equal-spaced grid division, priority given to key feature points (such as corners, center, and edge midpoints), or focused coverage of defect-sensitive areas. In practical applications, appropriate detection point selection methods can be selected based on the accuracy requirements of the detection scenario, detection efficiency needs, and individual differences of precious metals to ensure that the detection points can fully cover the key areas of the precious metal surface, providing accurate sampling locations for subsequent component analysis and defect detection.

[0068] Visit Figure 9 In some embodiments, step S107 includes: Step S901: Calculate the curvature of the sampling points on the target contour and the gradient change in the gradient map; Step S902: Filter candidate points based on curvature threshold and gradient mutation threshold; Step S903: Constrain the position range of candidate points based on the prior length information of the gold bar; Step S904: From all candidate points that satisfy the constraints, select the point with the largest product of curvature and gradient change as the test point.

[0069] In this embodiment, by comprehensively considering multi-dimensional features such as the curvature, gradient change, and prior length information of the gold bar sampling points on the target contour, accurate selection of gold bar detection points can be achieved. Reasonable curvature and gradient abruptness thresholds are set, and sampling points with curvature values ​​greater than the curvature threshold and gradient change values ​​greater than the gradient abruptness threshold are selected as candidate points. The location range of the candidate points is constrained by combining the prior length information of the gold bar. For all candidate points that meet the above constraints, the product of their curvature value and gradient change value is calculated. This product comprehensively reflects the bending characteristics and grayscale change characteristics of the candidate point. The larger the product, the more likely the point is to be a key detection location on the gold bar surface. The point with the largest product is selected as the final test point. This multi-feature fusion selection method can effectively eliminate interference factors, accurately capture representative detection areas on the gold bar surface, and provide accurate location basis for subsequent gold bar quality inspection.

[0070] Specifically, in one embodiment, the target contour (e.g., the contour of a gold bar) is... Sampling is performed at equal arc length intervals to obtain a sampling point sequence. ,in ; Calculate the curvature of each sampling point : In the formula, , It is a first-order difference (approximately the first-order derivative). , It is a second-order difference (approximately a second-order derivative).

[0071] In curvature ( For the region (where the curvature threshold is defined), calculate the first-order difference of the gradient map. ,reserve ( This is the gradient mutation threshold, which can be selected. Points are selected as candidate detection points based on the length of the gold bar. The detection points are limited to both ends of the contour. and Within the interval, the final value is taken from the interval. The largest point is selected as the optimal detection point.

[0072] Secondly, this invention also proposes a gold bar detection point selection system, including an image acquisition module, a preprocessing module, an edge detection module, a subpixel-level suppression processing module, an edge connection module, a contour determination module, and a test point selection module. The image acquisition module acquires an original image containing the gold bar; the preprocessing module preprocesses the original image to obtain a preprocessed image; the edge detection module performs edge detection on the preprocessed image to obtain edge detection results; the subpixel-level suppression processing module performs subpixel-level non-maximum suppression processing on the edge detection results; the edge connection module connects the suppressed edges to form continuous edge segments; the contour determination module selects the target contour of the gold bar from the continuous edge segments and determines its position; the test point selection module selects a test point within the defined area of ​​the target contour.

[0073] It is understandable that this gold bar detection point selection system has all the beneficial effects of the aforementioned gold bar detection point selection method, and will not be elaborated further here.

[0074] It should be noted that this application is not limited to the above-described embodiments. The above embodiments are merely examples, and any embodiments with the same structure and effect as the technical concept within the scope of this application are included in the technical scope of this application. Furthermore, without departing from the spirit of this application, all kinds of modifications that can be conceived by those skilled in the art to the embodiments, and other ways of constructing by combining some of the constituent elements of the embodiments, are also included in the scope of this application.

Claims

1. A method for selecting detection points for gold bars, characterized in that, include: Obtain the original image containing the gold bars; The original image is preprocessed to obtain a preprocessed image; Edge detection is performed on the preprocessed image to obtain the edge detection results; The edge detection results are subjected to subpixel-level nonmaximum suppression processing; Connect the suppressed edges to form continuous edge segments; The target outline of the gold bar is selected from the continuous edge segments, and its position is determined; Based on the target contour, select a test point within the area it defines.

2. The method for selecting gold bar detection points according to claim 1, characterized in that, The step of preprocessing the original image to obtain a preprocessed image includes: The original image is converted to the target color space and the color component image is extracted. The color component image is subjected to illumination normalization processing; Adaptive binarization is performed on the image after illumination normalization. Noise reduction is performed on the binarized image.

3. The method for selecting gold bar detection points according to claim 2, characterized in that, The steps of converting the original image to the target color space and extracting the color component image include: Convert the original image to the HSV color space; Extract the H component image from the HSV color space.

4. The method for selecting gold bar detection points according to claim 2, characterized in that, The illumination normalization process includes: The color component image is divided into multiple non-overlapping sub-blocks; Calculate the grayscale histogram for each sub-block, and allocate the number of pixels in the grayscale histogram that exceed a preset threshold to other grayscale levels; Each of the processed sub-blocks is then merged using bilinear interpolation.

5. The method for selecting gold bar detection points according to claim 2, characterized in that, The adaptive binarization process includes: For each pixel in the image after illumination normalization, the binarization threshold is dynamically calculated based on its local gray mean, local gray standard deviation and the global maximum standard deviation of the image. The grayscale value of each pixel is compared with its corresponding dynamic threshold to generate a binary image, where pixels with a value higher than or equal to the threshold are marked as the first background, and pixels with a value lower than the threshold are marked as the second background; and / or, The noise reduction process includes bilateral filtering.

6. The method for selecting gold bar detection points according to claim 1, characterized in that, The step of performing edge detection on the preprocessed image to obtain the edge detection result includes: The gradient of the image is calculated using at least two edge detection operators in different directions; The gradient values ​​of corresponding pixels in each directional gradient map are fused to obtain the edge detection result.

7. The method for selecting gold bar detection points according to claim 1, characterized in that, The sub-pixel-level non-maximum suppression processing includes: The gradient direction of each pixel is determined based on the edge detection results; Interpolate along the gradient direction at the sub-pixel level to find local extrema of the gradient. Only the edge points at the local extreme points are retained to obtain the edge after suppression processing.

8. The method for selecting gold bar detection points according to claim 1, characterized in that, The step of selecting the target outline of the gold bar from the continuous edge segments includes: Calculate the area, aspect ratio, and convexity of each closed contour in the continuous edge segments, and filter out the target contours according to a preset range.

9. The method for selecting gold bar detection points according to claim 1, characterized in that, The step of selecting a test point within the area defined by the target contour includes: Calculate the curvature of the sampling points on the target contour and the gradient change in the gradient map; Candidate points are selected based on curvature threshold and gradient mutation threshold; The position range of candidate points is constrained based on the prior length information of the gold bar; From all candidate points that satisfy the constraints, select the point with the largest product of curvature and gradient change as the test point.

10. A gold bar detection point selection system, characterized in that, include: The image acquisition module is used to acquire the original image containing the gold bar; A preprocessing module is used to preprocess the original image to obtain a preprocessed image; An edge detection module is used to perform edge detection on the preprocessed image to obtain edge detection results; A subpixel-level suppression processing module is used to perform subpixel-level non-maximum suppression processing on the edge detection results; The edge connection module is used to connect the suppressed edges to form continuous edge segments; The contour determination module is used to filter out the target contour of the gold bar from the continuous edge segments and determine its position; The test point selection module is used to select a test point within the area defined by the target contour.