Workpiece metal surface character recognition method based on image segmentation
By employing a total variational regularization decomposition and a light-topology hybrid seed data generation method, the problems of optical environment and texture interference in character recognition on the surface of metal workpieces are solved, achieving efficient character recognition and surface defect assessment.
Patent Information
- Application Number
- CN202610142519.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-02
- Publication Date
- 2026-05-12
AI Technical Summary
Character recognition on the surface of metal workpieces faces challenges from the optical environment and texture interference of high-gloss material surfaces. Traditional methods struggle to distinguish between background noise and character signals, leading to fluctuations in recognition rate.
The image is decoupled into material intrinsic properties and illumination components by total variational regularization decomposition, generating an illumination confidence field map. Combined with morphological reconstruction operation, light-topology hybrid seed data is generated. Geodesic morphological reconstruction is used to repair reflective broken characters and suppress background noise.
It improves the signal-to-noise ratio of character recognition, ensures the integrity and connectivity of character topology, reduces the artifact generation rate, and can quantify physical defects on the workpiece surface and abnormal ambient lighting conditions in real time.
Smart Images

Figure CN122024252A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, specifically to a method for recognizing text on the metal surface of a workpiece based on image segmentation. Background Technology
[0002] With the rapid development of computer vision and intelligent chip interaction technologies, image analysis-based non-contact recognition technologies have been widely applied in precision manufacturing, medical device traceability, and high-end industrial control. In these scenarios, accurately reading characters from object surfaces through image recognition and analysis is a key step in achieving full lifecycle data interaction and traceability. However, unlike conventional OCR scenarios on paper or diffuse reflective surfaces, character recognition on high-gloss surfaces such as metals and ceramics faces extremely stringent challenges due to optical environments and texture interference.
[0003] In existing technologies, character recognition on the surface of metal workpieces faces significant technical bottlenecks. The high-frequency textures generated by the inherent brushing, sandblasting, or grinding processes on metal surfaces highly overlap with the strokes of characters etched by dot-matrix or laser etching in the frequency domain, making it difficult for traditional gradient operator-based edge detection algorithms to distinguish between background noise and character signals.
[0004] The complex and variable lighting environment in industrial settings can create strong specular reflections (highlights) or shadows on highly reflective surfaces, causing visual breaks in the character topology on the imaging sensor. Although a recognition method based on deep learning and Retinex enhancement, as proposed in patent document CN117275010A, processes the image through filtering and template matching, such physical model-based enhancement methods often suffer from a "noise amplification effect," meaning that while removing uneven lighting, they incorrectly enhance background texture noise. Traditional morphological segmentation methods, while able to suppress texture, lack effective connectivity seeds when faced with character stroke breaks caused by strong reflections, making it impossible to complete correct morphological reconstruction, resulting in fluctuations in recognition rate under extreme conditions.
[0005] To address the aforementioned challenges, this invention proposes an adaptive image analysis strategy based on "light-topology coupling." Unlike data-driven models that solely rely on deep neural networks or image enhancement models that solely rely on physical models, this invention constructs a "geodesic seed generator weighted by illumination confidence." This method decouples the image into intrinsic material properties and illumination components through total variational regularization decomposition, and transforms the gradient statistical characteristics of the illumination components into a spatial confidence field, thereby dynamically guiding the generation of seeds for morphological reconstruction. This achieves a shift from "globally consistent processing" to "locally adaptive weighting," aiming to "heal" characters broken by reflections using physical layer information while simultaneously "suppressing" high-frequency background noise using topological layer information. Summary of the Invention
[0006] The purpose of this invention is to provide a method for recognizing text on the metal surface of a workpiece based on image segmentation, so as to solve the problems mentioned in the background art.
[0007] To achieve the above objectives, the present invention provides the following technical solution:
[0008] A method for recognizing text on the metal surface of a workpiece based on image segmentation, comprising the following steps:
[0009] S1: Acquire single-frame grayscale image data characterizing the optical properties of the workpiece surface;
[0010] S2: Perform total variational regularization decomposition on the single-frame grayscale image data to separate and generate intrinsic reflectivity distribution data characterizing the inherent properties of the material, and illumination component distribution data characterizing ambient light and specular reflection intensity.
[0011] S3: Based on the local gradient statistical characteristics of the illumination component distribution data, an illumination confidence field mapping map is generated, and the illumination confidence field mapping map is used as a spatial weighting factor to perform weighted fusion of morphological erosion features and skeleton connectivity features derived from the intrinsic reflectance distribution data, thereby generating a light-topology hybrid seed data.
[0012] S4: Using the intrinsic reflectivity distribution data as a morphological mask and the light-topology hybrid seed data as a morphological marker, perform geodesic morphological reconstruction operation to generate character-enhanced structural data that characterizes the background texture noise that has been filtered out and the reflective breakage defects that have been repaired.
[0013] S5: Perform binarization and pattern matching processing on the character enhancement structure data, and output the final character recognition result data.
[0014] Compared with the prior art, the beneficial effects of the present invention are:
[0015] By employing total variational regularization decomposition (S2) and introducing an adaptive weighted energy functional model incorporating texture activity analysis, the original image is separated into "intrinsic reflectivity," representing the inherent properties of the material, and "illuminance component," representing environmental disturbances. Regularization constraints are used to smooth the illumination field while preserving the sharpness of character edges, physically eliminating the influence of specular reflection and shadows on character structure, and improving the signal-to-noise ratio of the algorithm under complex lighting conditions.
[0016] An illumination confidence field mapping mechanism (S3) was constructed and used as a spatial weighting factor to generate a "light-topology hybrid seed". By combining it with geodesic morphological reconstruction operations (S4), "growth repair" is mainly performed using topological skeleton connectivity in regions with low illumination confidence (highlight breaks), while "noise suppression" is mainly performed using morphological erosion features in regions with high illumination confidence. This mechanism effectively overcomes the technical difficulty of existing morphological methods in handling reflective broken characters, ensuring the integrity and connectivity of the character's topological structure and reducing the artifact generation rate.
[0017] Before outputting the recognition results, a surface quality assessment and system self-diagnosis process (S5) is introduced. By comparing the local texture disorder index based on the gray-level co-occurrence matrix and the illumination hysteresis comparison logic, this solution can not only recognize characters, but also quantitatively assess the degree of physical defects (severe corrosion) on the workpiece surface and the abnormal state of ambient lighting in real time. This avoids forced recognition and false alarms under unavailable operating conditions, and improves the overall system's adaptability to industrial environments and operational safety. Attached Figure Description
[0018] Figure 1 This is a schematic diagram illustrating the main process principle of a workpiece metal surface text recognition method based on image segmentation.
[0019] Figure 2 This is a roadmap illustrating the principle of generating light-topology hybrid seed data in this invention.
[0020] Figure 3 Verification diagram of iterative convergence characteristics and dynamic truncation of the geodesic reconstruction algorithm;
[0021] Figure 4 This is a roadmap illustrating the principle of generating character recognition result data in this invention. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0023] It is understood that the terms “first,” “second,” etc., used in this application may be used herein to describe various elements, but unless otherwise stated, these elements are not limited by these terms. These terms are used only to distinguish one element from another.
[0024] Example 1:
[0025] Please see Figures 1 to 4 The present invention provides a technical solution:
[0026] A method for recognizing text on the metal surface of a workpiece based on image segmentation includes the following steps:
[0027] S1: Acquire single-frame grayscale image data characterizing the optical properties of the workpiece surface;
[0028] S2: Perform total variational regularization decomposition on the single-frame grayscale image data to separate and generate intrinsic reflectivity distribution data characterizing the inherent properties of the material, and illumination component distribution data characterizing ambient light and specular reflection intensity.
[0029] S3: Based on the local gradient statistical characteristics of the illumination component distribution data, an illumination confidence field mapping map is generated, and the illumination confidence field mapping map is used as a spatial weighting factor to perform weighted fusion of morphological erosion features and skeleton connectivity features derived from the intrinsic reflectance distribution data, thereby generating a light-topology hybrid seed data.
[0030] S4: Using the intrinsic reflectivity distribution data as a morphological mask and the light-topology hybrid seed data as a morphological marker, perform geodesic morphological reconstruction operation to generate character-enhanced structural data that characterizes the background texture noise that has been filtered out and the reflective breakage defects that have been repaired.
[0031] S5: Perform binarization and pattern matching processing on the character enhancement structure data, and output the final character recognition result data.
[0032] Step S1 is further defined as follows: In step S1, acquiring single-frame grayscale image data characterizing the optical properties of the workpiece surface includes: receiving a raw two-dimensional array signal from an image sensor, and performing linear demosaicing and grayscale mapping processing on the raw two-dimensional array signal to generate the single-frame grayscale image data with linear photometric response characteristics, wherein the pixel value of each pixel in the single-frame grayscale image data is proportional to the physical radiance of the workpiece surface at that location.
[0033] Further defining step S2: In step S2, performing the total variational regularization decomposition operation includes: constructing an energy functional model containing a data fidelity term, a total variational sparse term for reflectance, and an illumination smoothing term; iteratively solving the energy functional model using the alternating direction multiplier method, and calculating the two components that minimize the energy functional model, which are defined as the intrinsic reflectance distribution data and the illumination component distribution data, respectively.
[0034] Further specifying, in step S2, an energy functional model is constructed that includes a data fidelity term, a total variational sparse term for reflectivity, and an illumination smoothing term, further comprising:
[0035] Perform local texture activity analysis step: Perform local variance statistical operation on the single frame grayscale image data to generate a texture activity distribution map that characterizes the richness of local details in the image;
[0036] Perform the regularization weight dynamic mapping step: Based on the texture activity distribution map, generate independent adaptive regularization weight coefficients for each pixel position in the image through a preset inverse proportional mapping function;
[0037] The weighted energy functional construction step is performed by applying the adaptive regularization weight coefficients pixel by pixel to the total variational sparse term of reflectivity, thereby enhancing the smoothness constraint in flat regions and reducing the smoothness constraint in texture-rich regions.
[0038] Step S3 is further defined as follows: In step S3, a light-topology hybrid seed data is generated, which includes the following sub-steps:
[0039] Sub-step 3.1: Calculate the gradient magnitude field of the illumination component distribution data, and transform the gradient magnitude field into the illumination confidence field mapping map with values ranging from 0 to 1 through the negative exponential mapping function, wherein the larger the gradient magnitude, the lower the corresponding confidence value;
[0040] Sub-step 3.2: Perform morphological corrosion operation on the intrinsic reflectivity distribution data to generate basic corrosion feature data;
[0041] Sub-step 3.3: Perform topological skeleton extraction operation on the intrinsic reflectance distribution data to generate skeleton connectivity feature data;
[0042] Sub-step 3.4: For each pixel location in the image, using the value of the illumination confidence field map as the first weight and the complement of the value of the illumination confidence field map as the second weight, linearly weighted summation is performed on the basic erosion feature data and the skeleton connectivity feature data to generate the light-topology hybrid seed data.
[0043] Further specifying, in sub-step 3.1 of step S3, a light confidence field mapping map is calculated and generated, specifically including:
[0044] The structure tensor construction step is performed as follows: For each pixel position of the illumination component distribution data, a positive semidefinite structure tensor matrix is constructed based on the horizontal and vertical gradients in its neighborhood.
[0045] The coherence index calculation steps are as follows: perform eigenvalue decomposition on the structure tensor matrix to obtain the principal eigenvalues and secondary eigenvalues, and calculate the square of the difference between the principal eigenvalues and the secondary eigenvalues to generate the local structure coherence index.
[0046] The confidence mapping step is as follows: obtain the preset illumination confidence attenuation rate parameter, calculate the product of the local structure coherence index and the illumination confidence attenuation rate parameter, and perform a negative exponential operation on the product to generate the illumination confidence field mapping map.
[0047] Further specifying, in step S3, the morphological corrosion features and skeleton connectivity features derived from the intrinsic reflectivity distribution data are weighted and fused, specifically including:
[0048] Configure a disk-shaped structural element with a preset pixel value, and use this disk-shaped structural element to perform morphological erosion on the intrinsic reflectance distribution data to generate basic erosion feature data;
[0049] Extract the center line of the single pixel width of the intrinsic reflectance distribution data to generate skeleton connectivity feature data;
[0050] For each pixel location, the value of the illumination confidence field map is used as the first weight, and the difference between the value of the illumination confidence field map and 1 is used as the second weight. A linear weighted sum is then performed on the basic erosion feature data and the skeleton connectivity feature data to generate the light-topology hybrid seed data.
[0051] The following are specific implementation instructions for the above content:
[0052] The specific implementation details of sub-step 3.1 "Calculate the gradient magnitude field" in step S3 are as follows:
[0053] The following defined logical steps are performed to accurately distinguish between structural edges (including shadow boundaries) and cluttered noise: Specifically, the illumination component distribution data output from step S2 is acquired. The horizontal Sobel operator is applied to this data to generate horizontal gradient data; simultaneously, the vertical Sobel operator is applied to generate vertical gradient data. For each pixel location in the image, the following intermediate operations are performed:
[0054] The first component of the data is obtained by squaring the horizontal gradient data; the second component of the data is obtained by squaring the vertical gradient data; and the third component of the data is obtained by multiplying the horizontal gradient data and the vertical gradient data.
[0055] For the first, second, and third components of the data, Gaussian kernel-based convolutional smoothing operations are performed. This smoothing operation introduces neighborhood information, transforming the gradient information of a single point into structural information of the region. For each pixel location, based on the smoothed three components, the eigenvalues of the structure tensor matrix are analyzed. The specific logic is as follows:
[0056] The trace of the matrix is obtained by summing the smoothed first and second components. The determinant of the matrix is then calculated by multiplying the smoothed first component by the second component and subtracting the square of the third component. Based on the trace and determinant, two non-negative eigenvalues are calculated using root-finding logic, defined as the principal eigenvalue (representing the gradient strength in the principal direction) and the secondary eigenvalue (representing the gradient strength in the orthogonal direction). The square of the difference between the principal and secondary eigenvalues is calculated. This result is defined as the "local structure coherence index." When the image region contains isotropic noise, the principal and secondary eigenvalues are approximately equal, and the coherence index approaches zero. When a clear linear structure exists (e.g., shadow edges), the principal eigenvalue is greater than the secondary eigenvalue, and the coherence index increases. This logic fundamentally solves the defect of traditional gradient operators in distinguishing between strong noise and weak edges.
[0057] In this embodiment, the following core control parameters are defined in an abstract way:
[0058] The linear response reference coefficient is denoted as : The gamma correction value used to characterize the photoelectric conversion properties of image data. Specifically, it is determined by performing the following photoelectric response calibration procedure: Construct a controlled optical test environment containing a uniformly diffused light source (integrating sphere light source) with adjustable brightness and a high-precision luminance meter certified by national metrology standards. Fix the image acquisition module used to perform this method at the light source outlet. Gradually adjust the light source brightness from 0 nits to the upper limit of the acquisition module's saturation brightness, setting at least 20 uniformly distributed test nodes. At each test node, record the luminance meter reading (as the physical true value). Simultaneously, the acquisition module is triggered to acquire a frame of RAW format image and calculate the average pixel value of the central region of the image (as a measurement value). Establish a photoelectric response model: The collected data Perform linear regression analysis in the logarithmic domain. Calculate the regression slope as the current system Gamma value. If this calculated value deviates from 1.0 by more than ±0.02, generate a backward lookup table (LUT) or apply an exponential correction operation to force the overall system response curve to be corrected. The state.
[0059] k8 is defined as the photoelectric conversion gain coefficient, used to characterize the overall photoelectric sensitivity of the image acquisition module under specific exposure and gain settings, i.e., the basic proportional constant for mapping physical brightness to digital pixel values. In this embodiment, for an 8-bit camera with an output grayscale level of 0-255, under standard exposure with a saturation brightness of approximately 300 nits, the typical value of k8 is approximately 0.85. Considering the differences in bit depth (12-bit or 16-bit) and exposure parameters of different sensors, the effective general range of k8 is set between 0.1 and 50.0. Its specific value is determined by the data pairing during the calibration process. Automatic calculation and determination of the intercept when performing linear regression analysis in the logarithmic domain.
[0060] Basic regularization strength factor (denoted as ): A benchmark value representing the sparsity constraint strength imposed by the total variation model on the reflectivity component in a standard flat region. Specifically, it is determined through the following standardized calibration process, aiming to balance "denoising capability" and "texture preservation capability"; using the image acquisition module of this embodiment, capture a standard uniform grayscale card (example 18% neutral grayscale card). Ensure the lighting environment is uniform and stable. Acquire a frame of the original image of the grayscale card. Select the central region of the image (100×100 pixels), calculate the standard deviation of the pixel values within this region, and define this standard deviation as the "system inherent noise benchmark (…)". A test image sequence containing stripe patterns with different spatial frequencies is constructed to characterize the texture. Gaussian white noise is artificially added to this test image sequence, with an intensity equal to the "system intrinsic noise baseline" determined above. The test range of the regularization intensity factor is set (from 0.01 to 1.0, in steps of 0.05). For each test value, the total variation decomposition operation in step S2 is performed to separate the reflectance component. The "peak signal-to-noise ratio (PSNR)" between the reflectance component and the noise-free original stripe pattern is calculated. The test value that maximizes the PSNR is selected and determined as the "base regularization intensity factor" of the current system. Under the typical industrial camera configuration of this embodiment (SNR of 40dB), after the above calibration, the preferred value of the base regularization intensity factor is determined to be 0.15. This value is at the critical balance point between "oversmoothing leading to stripe blurring" and "undersmoothing leading to noise residue".
[0061] Texture sensitivity adjustment coefficient (denoted as) ): This is a hyperparameter used to control the degree of response of the adaptive regularization mechanism to local texture changes in the image. Specifically, it is determined by using adaptive determination logic based on "texture dynamic range"; specifically, the "texture activity distribution map" generated in step S2 is obtained. The distribution of all non-zero pixel values in this texture activity distribution map is statistically analyzed, and its 95th percentile value is calculated and defined as the "effective maximum texture intensity". The design goal is that at the "effective maximum texture intensity", the regularization weight should decay to 10% of the base value. Based on the inverse proportional mapping function logic, the equation is constructed as follows: Where WLf represents the effective maximum texture intensity; solving this equation derives... The calculation logic: By Dynamically bound to the statistical distribution (95th percentile) of the current image, it achieves "zero-sample adaptation" for workpieces with different surface roughness, obtaining optimal denoising-edge preservation balance on both smooth and rough surfaces without manual intervention. The larger the texture sensitivity adjustment coefficient, the more drastic the attenuation of regularization intensity in textured regions, thus preserving more details.
[0062] Illumination confidence attenuation rate (denoted as) ): An exponential parameter used to control the rate at which the illumination confidence decreases with the degree of change in illumination. Specifically, it is used to adjust the "sensitive area" of the fusion mechanism, determining the level of illumination gradient at which the algorithm begins to abandon physical features and switch to topological features. The illumination confidence decay rate is specifically determined as follows: In this embodiment, the "gradient half-life" rule is used for setting; the "half-confidence gradient threshold" is defined as a specific gradient intensity: when the local gradient (or coherence index) of the illumination component reaches this intensity, the confidence in the illumination quality of that region drops to exactly 0.5.
[0063] Based on the typical highly reflective edge characteristics in the application scenario, a "half-confidence gradient threshold" is preset (in this embodiment, it is set to a gradient value of 50 in 8-bit grayscale space). Based on the mathematical properties of the negative exponential mapping function, the natural logarithm operation is performed: the natural logarithm is calculated. The value is equal to -0.693. Dividing -0.693 by the preset "half-confidence gradient threshold" and taking the absolute value of the quotient is the final value of the "illuminance confidence attenuation rate". This method calculates the illuminance confidence attenuation rate. This is transformed into a "half-life" control quantity with intuitive physical meaning, which can intuitively adjust the sensitivity of the algorithm according to the intensity of reflection in actual working conditions, without the need for blind parameter search.
[0064] In this embodiment, the acquisition and application of all parameters are embedded in specific data flow steps. When the method starts, it accesses a preset local storage path and reads a structured spreadsheet file. The file is parsed to extract the specific values of the "basic regularization intensity factor", "texture sensitivity adjustment coefficient", and "illuminance confidence decay rate", and these values are loaded into memory variables as global constants for subsequent calculation processes.
[0065] Furthermore, an anisotropy confidence assessment mechanism based on the structural tensor: using only gradient magnitude. This is used to measure the drasticness of changes in illumination. Simple gradients cannot distinguish between "random noise" and "regular shadow boundaries." This method introduces "structural tensor coherence analysis logic": specifically defining the horizontal gradient of the illumination component L as... The vertical gradient is .
[0066] Construct a structure tensor matrix for each point And Gaussian smoothing is applied to each element of the matrix.
[0067] Computing the structure tensor matrix Two eigenvalues and ; Define local structural coherence. When encountering random noise, ,but The confidence level remains high (indicating no misleading effect from noise); only when encountering true shadow boundaries or highlight bands does the confidence level remain high. ,but Only when the value is high does the confidence level decrease significantly.
[0068] 2.0) Further, for step S1, acquire single-frame grayscale image data with linear photometric response: In this step, the aim is to construct an original data field that conforms to the "physical superposition principle". Start the image acquisition process, controlling the industrial area array sensor (configured in Bayer array mode) to acquire the original two-dimensional array signal of the workpiece surface at a preset exposure time. Perform linear demosaic processing. Use a bilinear interpolation algorithm to convert the RAW data into three-channel RGB data. During this process, disable the built-in Gamma correction, automatic white balance, and sharpening functions in the sensor ISP, or apply an inverse Gamma curve (setting the Gamma value to the reciprocal of 2.2) to ensure that the RGB values maintain a linear relationship with the photon flux. Then, perform physical brightness mapping processing. Use brightness weighting logic that conforms to the characteristics of human vision to accurately reflect the radiant brightness of the metal surface. Specifically, the red channel component R, green channel component G, and blue channel component B are obtained; R is multiplied by a weighting coefficient of 0.299, G by a weighting coefficient of 0.587, and B by a weighting coefficient of 0.114; the sum of these three products is calculated and assigned as the grayscale value of the corresponding pixel in the single-frame grayscale image data. This embodiment uses a specific RGB weighting to maximize the signal-to-noise ratio while preserving the contrast between rust (reddish-brown) and scratches (highlights or shadows) on the metal surface.
[0069] Before outputting single-frame grayscale image data, global normalization must be performed to ensure the accuracy of subsequent physical decomposition models and parameters. and The numerical stability of the image is determined by dividing each pixel value of a single-frame grayscale image by the maximum value corresponding to the sensor bit depth (255 for 8-bit images and 4095 for 12-bit images), mapping it to double-precision floating-point data with a strict range of [0.0, 1.0]. The total variation operation in step S2 and the tensor calculation in step S3 must be performed based on this normalized floating-point data.
[0070] 2.1) Step S2: Perform adaptive total variation regularization decomposition operation:
[0071] In this step, the principle of energy functional minimization is used to decouple a single-frame grayscale image into "intrinsic reflectance" and "illuminance component". To address the issue that traditional globally uniform regularization weights cannot simultaneously handle noise reduction in flat regions and preservation of edge details, this step introduces a spatially adaptive regularization weight generation mechanism. The specific execution flow is as follows:
[0072] Read the base regularization strength factor from the external configuration file. In this embodiment, the value is preferably set to 0.15 (based on the signal-to-noise ratio calibration of a standard 18% neutral grayscale card); the texture sensitivity adjustment coefficient is then read. The preferred setting is 0.05; the illumination smoothing constraint factor is set (denoted as...). Given the physically gradual change of the light component, it is set to 10 times the base factor, i.e. .
[0073] Local variance calculation is performed on the single-frame grayscale image data output in step S1. The specific dimensions are defined as follows: A sliding window traverses the image for each pixel; for each pixel position... The statistical variance of pixel grayscale values within the 8-neighborhood covered by the window is calculated to generate a texture activity distribution map. Minimal variance values characterize flat background areas, while significantly increased variance values characterize character edges or high-frequency texture areas.
[0074] Based on the aforementioned texture activity distribution map, a dynamic inverse proportional mapping logic based on local variance is used to map the location of each pixel in the image. Generate independent adaptive regularization weight coefficients (denoted as...) The calculation formula is as follows:
[0075] ;in, This represents the texture activity value at that location (indicating local variance). This mechanism utilizes the inverse proportional function property... Larger character edges or areas with rich textures will automatically decrease. The value of [value] is adjusted to reduce the smoothing effect and prevent character strokes from being mistakenly erased as noise; conversely, [the value] is adjusted to reduce the smoothing effect. A smaller, flat background region is used, with higher weight coefficients to enhance denoising. The resulting weight map will serve as the spatial adaptive constraint benchmark for subsequent energy functional construction.
[0076] 2.2) Based on the above configuration, a multi-objective optimization energy functional model is constructed. Logically, this model seeks the optimal decomposition result by minimizing the weighted sum of the following three physical constraint terms:
[0077] The first constraint (data fidelity constraint): Based on the principles of physical imaging, this constraint limits the pointwise product of the "intrinsic reflectance data" and the "illuminance component data" to make it numerically approximate the input "single-frame grayscale image data". This constraint aims to ensure that the two decomposed components can reconstruct the original observed image during resynthesis, preventing the decomposition result from deviating from physical reality.
[0078] The second constraint (weighted reflectivity sparsity constraint): This term, based on total variation theory, imposes a sparsity penalty on the spatial gradient field of the intrinsic reflectivity data. Its core logic lies in: using the aforementioned generated adaptive regularization weight coefficients to spatially modulate this constraint; applying a high-intensity sparsity penalty in flat image regions, forcing the gradient to tend towards zero, thereby eliminating random noise; and reducing the sparsity penalty in textured image regions, allowing the gradient to retain non-zero values, thus protecting character edges from blurring.
[0079] The third constraint (lighting smoothness constraint): This constraint applies a smoothness penalty to the spatial gradient of the "lighting component data" based on the spatially gradual variation characteristics of ambient lighting. This constraint forces the lighting components to maintain a continuous and smooth transition across the entire image, prohibiting the appearance of high-frequency abrupt details, thereby forcing high-frequency textures and edge information in the image to be retained only in the reflectance component.
[0080] 2.3) Since the above model contains nonlinear and non-smooth terms, this embodiment adopts the Alternating Direction Multiplier Method (ADMM) to decompose the complex global optimization problem into two independently executable sub-steps, and performs iterative iterations. The intrinsic reflectivity data and illumination component data are initialized as the input image; the Lagrange multipliers (dual variables) are initialized as a zero matrix; the ADMM penalty parameter is set ( The empirical value is 2.0, which has been experimentally verified to ensure that the algorithm converges within a finite number of iterations. In each iteration, the following logical actions are executed sequentially:
[0081] Sub-step A3: Solving for intrinsic reflectance data while keeping the illumination components and Lagrange multipliers unchanged, solve for the near-end mapping operator containing the weighted total variation term, i.e., perform "soft thresholding" on the reflectance components. The specific execution logic is as follows:
[0082] Calculate the gradient field of the current image residual. Compare each value in the gradient field with the corresponding "adaptive regularization weight coefficient". If the gradient magnitude at a certain location is less than the adaptive regularization weight coefficient, the gradient is determined to be caused by noise, and its value is forcibly set to zero; if the gradient magnitude at a certain location is greater than the adaptive regularization weight coefficient, the gradient is determined to be caused by a true edge, and its value is subtracted by one weight unit towards zero. Reconstruct the reflectivity data using the shrunken gradient field. This step achieves the removal of background noise while preserving the character stroke structure on the workpiece surface.
[0083] Sub-step B3: Solving for the illumination component data. With the reflectivity component and Lagrange multipliers unchanged, the illumination components are updated. Since the illumination components are constrained by the smoothness of the entire image, solving them in the spatial domain involves extremely computationally expensive convolution operations. Therefore, this embodiment performs the following "frequency domain transformation solution" logic:
[0084] Frequency domain transformation: Using the two-dimensional Fast Fourier Transform (FFT), the current image data and difference operators are transformed from the spatial domain to the frequency domain.
[0085] Spectral division: In the frequency domain, the complex spatial convolution operation is transformed into a simple element-by-element division operation using the convolution theorem. Based on the least squares principle, the optimal illumination component spectrum is directly calculated in the frequency domain.
[0086] Inverse Transform Reconstruction: Using the two-dimensional inverse fast Fourier transform (IFFT), the calculated spectrum is restored to the spatial domain illumination component data. This frequency domain solution logic avoids large-scale matrix inversion operations, improving the algorithm's computational speed by several orders of magnitude.
[0087] Sub-step C3: Dual variable update and convergence criterion: Update the Lagrange multipliers based on the constraint residuals, that is, multiply the current residual term by the penalty parameter and accumulate it into the dual variable. Calculate the relative error between the two iterations. When this error is less than a preset threshold ( When the iteration stops, the final intrinsic reflectance distribution data and illumination component distribution data are output.
[0088] 3) Step S3, generating light-topology hybrid seed data: In this step, the method uses "coherence confidence" to dynamically fuse physical and geometric features.
[0089] Sub-step 3.1, generating an illumination confidence field mapping map: acquiring illumination component distribution data and calculating its horizontal gradient. with vertical gradient .calculate , and Perform Gaussian smoothing on the three original tensor components respectively. The standard deviation of the Gaussian kernel ( The smoothing factor is set to 1.5, and the window size is 5×5. This smoothing step introduces neighborhood information, ensuring the tensor matrix is full rank, thus enabling effective resolution of local geometry. The final 2×2 structure tensor matrix is constructed using the three smoothed components. Eigenvalue decomposition is then performed on the structure tensor matrix to obtain the principal eigenvalues. and secondary eigenvalues Perform subtraction. The square of the result yields a local structure coherence index characterizing the strength of local illumination structure. The preset illumination confidence attenuation rate is then read. (In this embodiment, the value is set to 0.04, determined by the half-confidence gradient threshold rule.) For each pixel, the local structure coherence index and the illumination confidence attenuation rate are calculated. The product of the product and the negative exponent of the product are calculated to generate an illumination confidence field mapping map with values in the interval [0,1].
[0090] In step S3, the process of generating light-topology hybrid seed data specifically includes the following detailed sub-steps:
[0091] Sub-step 3.2, basic corrosion characteristic data (denoted as...) Generation of intrinsic reflectivity data: Morphological erosion is performed on the intrinsic reflectivity distribution data to suppress high-frequency noise and obtain smooth underlying structure information. The specific implementation process is as follows:
[0092] Define a two-dimensional morphological structural element. In this embodiment, the key configuration is to use a disk-shaped structural element. The radius of this disk-shaped structural element is set to 2 pixels. This radius value is chosen based on the statistical analysis of common background noise on the surface of the workpiece to be inspected. Since the average size of common isolated noise (salt-and-pepper noise or fine dust) is about 1 to 2 pixels, a disk structure with a radius of 2 pixels can cover and contain these noise areas, ensuring that subsequent etching operations can effectively remove these isolated noises while preserving the edge morphology of large characters or defects to the greatest extent. Using intrinsic reflectance distribution data (denoted as R1) as the input image, the image is traversed using the aforementioned disk-shaped structural element. For each pixel position in the image... The formula for calculating the minimum pixel grayscale value within the neighborhood covered by the structuring element is as follows: ; where (u,v) are the relative coordinates of the structuring element relative to the center pixel (x,y) within its coverage area.
[0093] In order to connect with the illumination confidence field (value) in subsequent steps Numerical matching is performed, and the results are normalized. The final image data is defined as the basic erosion feature value, denoted as . .
[0094] Sub-step 3.3, skeleton connectivity feature data (denoted as...) Generation of the intrinsic reflectance distribution data: Topological feature extraction is performed on the intrinsic reflectance distribution data to extract the central skeleton of the target texture, preventing structural breaks in low-light areas. The specific implementation process is as follows: The intrinsic reflectance distribution data R1 is segmented. In this embodiment, the Otsu's method is used to automatically calculate the global optimal threshold T1. The image is traversed, and pixels with gray values greater than the global optimal threshold T1 are marked as foreground (logical values). Pixels with grayscale values less than or equal to the global optimal threshold T1 are marked as background (logical value). This generates a binary image. .
[0095] For binary images The Zhang-Suen parallel thinning algorithm is applied. This algorithm consists of two iterative sub-steps, repeatedly removing pixels from the edges of the binary image that satisfy specific connectivity conditions until the image no longer changes. After iterative convergence, the texture of the original width is thinned to a centerline of single pixel width, while preserving the connectivity of the original topological structure. Since the thinned skeleton map only contains logical values... and To achieve energy amplitudes comparable to the base erosion features in subsequent weighted calculations, amplitude mapping is performed on the skeleton map. This involves mapping the pixels (logical values) on the skeleton... Assigning a value to AND The same maximum dynamic range value (if) If it's a normalized floating-point number, assign a value of 1.0; if it's an 8-bit grayscale number, assign a value of 255. The background pixel remains unchanged. The final image data is defined as the skeleton connectivity feature value, denoted as... .
[0096] Sub-step 3.4 generates light-topology hybrid seed data (denoted as...). For each pixel location in the image, a linear weighted fusion based on illumination confidence is performed. The specific computation logic and parameter descriptions are as follows:
[0097] Traversing every coordinate position in the image spatial domain Execute the following formula:
[0098] ;in This indicates the pixel index position in the image matrix. y is the column index of the image, and y is the row index of the image. This index constrains the multiplication and addition in the formula to be pixel-by-pixel operations, rather than matrix multiplication. This represents the numerical value of the final light-topology hybrid seed data generated at index position (x, y). This data set combines the smoothing properties of the erosion features with the topological properties of the skeleton features. This represents the illumination confidence value at index position (x, y). This value originates from the mapping map generated in the previous steps and ranges from [0, 1]. It serves as the first weight; a larger value indicates better illumination conditions at that position and more reliable data. This represents the base corrosion feature value at index position (x,y). This represents the complement of the illumination confidence value at index position (x, y). This value serves as the second weight; a larger value indicates worse illumination conditions at that position (including shadows or reflections), requiring reliance on topological priors. This represents the skeleton connectivity feature value at index position (x, y). In a uniformly illuminated region ( It mainly retains the corrosion characteristics with strong noise resistance, effectively filtering out background noise; in shadow or reflective areas ( It automatically switches to a skeleton feature with extremely strong fracture resistance, forcibly connecting the texture structure that is broken due to uneven lighting, thereby achieving the preservation of character structure in all scenes.
[0099] Further, step S4 is defined as follows: In step S4, the geodesic morphological reconstruction operation is performed based on a morphological reconstruction algorithm. Under the numerical height constraint defined by the intrinsic reflectance distribution data, the optical-topological hybrid seed data is driven to undergo iterative conditional dilation until the pixel values of all connected regions no longer change. This preserves the image structure that is spatially connected to the optical-topological hybrid seed data, while suppressing non-connected texture noise.
[0100] Further specifying, in step S4, performing the iterative conditional expansion specifically includes:
[0101] Obtain the preset reconstruction stability threshold and the number of stable cycles;
[0102] Entering the iteration loop, in each iteration, the light-topology hybrid seed data is dilated and numerically truncated using the intrinsic reflectivity distribution data to generate updated light-topology hybrid seed data;
[0103] Calculate the total pixel change between the updated light-topology hybrid seed data and the original light-topology hybrid seed data;
[0104] Establish a stability counter. If the total pixel change is less than the reconstruction stability threshold, increase the value of the stability counter; otherwise, reset the stability counter.
[0105] The iteration loop terminates only when the value of the stability counter reaches the number of stable periods.
[0106] For step S5, further specify: before outputting the final character recognition result data in step S5, a surface quality assessment and system self-diagnosis process is also included:
[0107] Calculate the difference image data between the intrinsic reflectance distribution data and the character enhancement structure data;
[0108] Based on the local variance statistics of the differential image data, a surface quality assessment index characterizing the degree of physical defects on the workpiece surface is generated.
[0109] Simultaneously, the global average illumination value of the illumination confidence field map is calculated. When the global average illumination value is lower than a preset safety threshold, a status alarm signal indicating abnormal ambient lighting or sensor occlusion is generated.
[0110] Further specifying, in step S5, surface quality assessment indicators characterizing the degree of physical defects on the workpiece surface are generated, specifically including:
[0111] Calculate the difference image data between the intrinsic reflectance distribution data and the character enhancement structure data;
[0112] The differential image data is divided into multiple local windows. For each local window, a gray-level co-occurrence matrix is constructed and normalized to obtain a probability matrix.
[0113] For each non-zero element in the probability matrix, calculate the product of the element's value and the natural logarithm of the element's value, and sum all the negative values of the products to generate a local texture disorder index.
[0114] Calculate the peak value or the proportion of exceeding the limit of the local texture disorder index for all local windows, and use it as the surface quality evaluation index.
[0115] Further specifying, in step S5, generating a status alarm signal indicating abnormal ambient light or sensor obstruction specifically includes:
[0116] Obtain a preset light warning trigger threshold and a light recovery reset threshold, wherein the value of the light recovery reset threshold is greater than the value of the light warning trigger threshold;
[0117] Calculate the global average illumination value of the illumination confidence field map and read the currently recorded alarm status identifier;
[0118] If the alarm status indicator indicates a non-alarm state and the global average illumination value is lower than the illumination warning trigger threshold, the status alarm signal is generated and the alarm status indicator is updated to an alarm state.
[0119] If the alarm status indicator indicates an alarm status and the global average illumination value is higher than the illumination recovery reset threshold, the status alarm signal is deactivated and the alarm status indicator is updated to a non-alarm status.
[0120] If the global average illumination value is between the illumination warning trigger threshold and the illumination recovery reset threshold, the current state of the alarm status identifier and the status alarm signal remains unchanged.
[0121] The following is a detailed description of the implementation of the above content:
[0122] In this embodiment, the following core control parameters are defined, and the following key control parameters are read from a preset external structured configuration file:
[0123] Reconstruction stability threshold (denoted as) This parameter represents the maximum perturbation allowed when the image state has reached a "steady state" during geodesic growth. It is determined using a dynamic noise floor calibration method based on the current imaging environment to ensure that the parameter value filters noise while preserving weak character end signals.
[0124] With the aperture of the imaging module closed or the ambient light source turned off, under completely dark conditions, the image sensor continuously acquires N2 frames (N2=50 in this embodiment) of dark current images. For each pixel position in the image array, the standard deviation of its pixel value in the N2 frames is calculated, thereby generating a "temporal noise distribution map". The arithmetic mean of all pixel values in the temporal noise distribution map is calculated and defined as "system reference noise intensity (…)". Based on Gaussian distribution 3 The criterion sets the reconstruction stability threshold to three times the system's baseline noise intensity (characterized by...). This method ensures that a structure is considered valid only when the grayscale variation of a pixel is statistically significantly greater than the fluctuation range of random thermal noise (confidence level > 99.7%), thus guaranteeing the authenticity of the algorithm's convergence at the physical level.
[0125] Stable number of periods (denoted as) This parameter is used to confirm the reliability of iterative convergence and prevent premature interruption of reconstruction due to accidental stagnation in a single iteration. In this embodiment, the parameter is set to 3. This means that only when the change in three consecutive iterations is less than [a certain value] will the reconstruction be completed. Only then is the reconstruction considered complete.
[0126] To address the issues of "under-reconstruction" (stroke breakage) or "over-reconstruction" (waste of computational resources) that may result from fixed-number iterations in existing technologies, this step introduces a "dynamic residual feedback truncation mechanism." Traditional morphological reconstruction typically iterates to "zero change" or a fixed number of iterations. In industrial settings, due to the presence of image sensor noise, achieving mathematically "zero change" is extremely difficult, leading to a large amount of meaningless computation in the final stage. This method considers "intrinsic reflectivity distribution data" (Mask) as the upper limit of topological potential energy and "light-topological hybrid seed data" (Marker) as the potential energy injection source. During iteration, the rate of potential energy propagation is monitored in real time and represented as the pixel change rate. When the propagation rate is lower than the system's inherent noise level (due to...), the algorithm stops the iteration. (Definition) and maintain for a certain period of time (by) When the definition is reached, a mandatory determination is made that the physical structure has been restored, and computational resources are cut off. This mechanism ensures that the connected components of a character can be completely healed across the reflective breakpoint, while keeping the algorithm's time complexity within the effective information propagation cycle.
[0127] The above content can be summarized and explained as follows:
[0128] For the iterative reconstruction loop, perform the following operations sequentially in each iteration:
[0129] Perform grayscale dilation on the current labeled image. Specifically, using a structuring element with a preset connectivity (8-neighborhood), update the value of each pixel to the maximum value within its neighborhood, obtaining an "intermediate dilation result." Perform a pixel-by-pixel comparison between the intermediate dilation result and the mask image. For each pixel location, select the smaller value of the two as the new value for that location, thereby generating the "updated labeled image." This step forces the numerical growth to be confined within the physical envelope of the material's intrinsic reflectivity. Perform a difference operation between the updated labeled image and the labeled image before this iteration. Specifically, calculate the absolute value of the difference between pixel values at corresponding locations in the two images, sum the absolute values across all locations in the entire image, and divide by the total number of pixels in the image to obtain a scalar value, defined as the global average residual.
[0130] The global average residual is compared with the reconstruction stability threshold. Compare them.
[0131] Branch 1: If the global average residual is less than the reconstruction stability threshold, increment the stability counter by 1.
[0132] Branch 2: If the global average residual is greater than or equal to the reconstruction stability threshold, then reset the stability counter to 0.
[0133] Determine whether the stability counter has reached the preset number of stable periods. If yes, terminate the iteration loop and output the current labeled image as "character enhancement structure data"; this data represents the complete character shape after background texture noise has been filtered out and reflective breakage defects have been repaired. If no, return to execute the next iteration.
[0134] Specifically, during the geodesic morphological reconstruction operation, the processor uses the light-topology hybrid seed data as the initial marker image, denoted as... The intrinsic reflectance distribution data is used as a mask image, denoted as... Both sets of data are configured as two-dimensional digital matrices stored in the electronic device's memory, with each element corresponding to the grayscale response value of a physical pixel in the image sensor array. To achieve physically controlled growth, this embodiment employs the following discrete iterative model to drive the pixel value updates:
[0135] The iterative process continues until the preset physical steady-state condition is met. In the... In each iteration cycle, the absolute value of the difference between corresponding pixel values in the two images is calculated. Then, the sum of the absolute values across all positions in the entire image is divided by the total number of pixels in the image to obtain a scalar value, defined as the global average residual. . ;
[0136] symbol and : respectively represent the first Second and third Intermediate digital image data generated in the next iteration.
[0137] All dimensional constraints A two-dimensional matrix, where W and H are the horizontal and vertical resolutions of the image sensor, respectively.
[0138] B3 defines the isotropic operator for the pixel energy propagation path. In this embodiment, a preferred one is... A matrix of all 1s (8-connected neighborhood) represents the energy that can diffuse to its 8 physical neighbors. This embodiment is not limited to... Alternatively, it can be adopted. Or a cross-shaped structural element. Symbol (Euclidean dilation): Represents morphological dilation operation. Specifically, it refers to any pixel position in the image. Update its value to the maximum pixel value within the neighborhood covered by structuring element B3. (Symbol) (Point-to-point minimum): Represents a pixel-by-pixel truncation operation. Physically, it forces the energy of the grown pixels to be limited by the mask. Within the defined intrinsic reflectivity envelope of the material, the algorithm is prevented from generating artifacts that do not exist. A scalar value characterizing the growth rate of the character structure. In the preferred configuration of this embodiment, the number of stable periods... In this embodiment, a threshold of 3 is preferred, meaning that the iteration terminates only when the residuals of three consecutive iterations are all below the threshold. The actual range can be an integer [2, 10]. For 8-bit grayscale images (pixel values 0-255): Reconstruction stability threshold Value range: [0.5, 5.0]; preferred value: 1.2;
[0139] Reconstruction stability threshold A lower bound of 0.5 indicates that the average change per pixel is only 0.5 gray levels. This is a stringent convergence condition, representing an image that is almost completely static. Setting it too low will result in too many iterations, wasting computational resources.
[0140] Reconstruction stability threshold Maximum value 5.0: This means the process will stop when the average change reaches 5.0 gray levels. Setting it too high may result in incomplete reconstruction, and the process may end prematurely before the characters are fully filled.
[0141] This embodiment reconstructs the stability threshold. The preferred value is 1.2, which is slightly higher than the sensor's thermal noise level (0.8-1.0 gray level), ensuring that the voids are filled without idling at the noise level.
[0142] For global average residual The dynamic range of change; during the iteration process. It is a variable that monotonically decreases over time: in the early stages of iteration ( ): Larger, with values ranging from Between. At this moment, the inflation operation is rapidly filling the large holes inside the character.
[0143] Late iteration phase (convergence phase): It will decay rapidly and approach its maximum. The algorithm terminates when it falls below the set threshold of 1.2.
[0144] It should be noted that the above threshold range is based on 8-bit images (0-255). When applied to 12-bit (0-4095) or 16-bit (0-65535) high dynamic range images, the reconstruction stability threshold... The image should be scaled linearly according to its bit depth. For example, for a 16-bit image, the threshold range should be adjusted to [128, 1280].
[0145] For step S5, binarization, recognition, and system self-diagnosis are performed:
[0146] A local texture disorder index is defined to characterize the randomness of residual textures in a difference image. It is used to distinguish between regular character edge residues and random physical rust / scratches. It is determined by calculating the entropy value based on the gray-level co-occurrence matrix (GLCM) of the image blocks. The input data is the "difference image data" calculated in step S5 (denoted as...). )".
[0147] The following defined logical steps are performed to quantify the degree of physical defects on the workpiece surface: Acquire differential image data. Linearly compress the pixel grayscale range of the differential image data to a smaller level (in this embodiment, from 0-255 to 0-16 levels) to generate "quantized differential data". Define a 16×16 sliding window on the quantized differential data. For each sliding window, construct a grayscale co-occurrence matrix. Specifically, count the occurrences of all pixel pairs within the window that satisfy spatial positional relationships (horizontally adjacent and 1 pixel apart), fill the corresponding coordinates in the matrix, and normalize the matrix so that the sum of all elements equals 1, thus obtaining a "normalized co-occurrence probability matrix". Iterate through each element value in the normalized co-occurrence probability matrix. For each non-zero element, perform the following operation: multiply the element value by its natural logarithm and accumulate the product in a temporary variable. After iteration, take the negative of the temporary variable (multiply by -1) to obtain the "local texture disorder index" of the sliding window.
[0148] The peak value or excess proportion of the local texture disorder index for all local windows is calculated as the surface quality evaluation index, specifically in the following two directions:
[0149] The first approach is to take the maximum value of the peak representation, specifically extracting the maximum value among the local texture disorder indices of all local windows, as the surface quality evaluation index.
[0150] The second approach is to statistically analyze the proportion of out-of-limit values. Specifically, this involves calculating the percentage of windows whose values exceed the preset "local defect warning line" among all local texture disorder indicators, which serves as a surface quality assessment indicator.
[0151] Specifically, to quantify the physical defects on the workpiece surface, the processing unit constructs a normalized gray-level co-occurrence matrix (GLCM) for each local sliding window of the differential image data and calculates the Shannon entropy accordingly. This process includes the following data transformation steps:
[0152] Gray-level quantization compression is performed to reduce random noise introduced by sparse matrix calculations. The processor applies the following mapping function to transform the original gray-level data... Mapped to low-bit-depth quantized data :
[0153] Construct a multi-directional fusion-based accumulative GLCM to capture isotropic rust textures on the workpiece surface. Define a set of displacement vectors. , respectively corresponding Four directions. For a size of The local window, its cumulative GLCM matrix elements in The calculation is as follows: ;in This indicates an indicator function. It is a logical conditional operator. It takes the value 1 when the condition within the parentheses is true, and 0 otherwise. It represents a condition that satisfies a specific grayscale pair. and spatial relationships Frequency statistics are performed on the pixel pairs. When the logical condition within parentheses (the quantized grayscale values of the pixel pairs are respectively equal to...) is met... and When the condition is true, the function takes the value 1; when the condition is false, it takes the value 0. In the summation formula, this is equivalent to counting pixel pairs that satisfy a specific gray-level co-occurrence relationship. This is based on the normalized probability matrix. Calculate the local texture disorder index of the window. : ;
[0154] parameter The quantization grayscale level is a dimensional constraint parameter of the GLCM matrix, which directly determines the computational complexity. In this embodiment, a value of 16 is preferred. This value achieves the best balance between preserving sufficient texture details and suppressing sensor noise. The actual application range is the integer [8, 32].
[0155] parameter The sliding window size is the spatial neighborhood size for texture feature statistics. In this embodiment, it is preferably 16 pixels. The actual range is [8, 64] pixels. (Symbol) It is a numerical stability constant: a very small positive number used to prevent mathematical singularities from occurring in logarithmic operations. In this embodiment, it is preferably... .
[0156] This is the defect judgment threshold: a critical value used to distinguish between regular character edges (low entropy) and disordered physical defects (high entropy). For 16-level grayscale quantization, this threshold is preferably set to 2.5. When When the region is found to have a physical defect, this solution utilizes the sensitivity of entropy to disorder to solve the technical problem that traditional variance-based methods cannot distinguish between "sharp character edges (high variance but ordered)" and "rust noise (high variance and disorder)," thereby reducing the false alarm rate.
[0157] Light warning trigger threshold (denoted as) ); used to define the lower limit critical point for determining whether the ambient light is severely insufficient or the sensor is blocked.
[0158] Light restoration reset threshold (denoted as) This is used to define the upper limit critical point at which the ambient light has returned to normal and the alarm has been cleared, introducing a hysteresis interval to prevent alarm jitter.
[0159] Light warning trigger threshold Reset threshold for illumination recovery The following dual-modal distribution analysis procedure was used to determine:
[0160] Construct a reference dataset. Subset A1 contains 1000 images acquired under "standard compliant lighting" conditions; subset B1 contains 1000 images acquired under abnormal conditions such as "light occlusion, light source aging, or strong interference." Calculate the global average illumination value of the illumination confidence field map for each image in subsets A1 and B1. Calculate the probability density function of the global average illumination value for subsets A1 and B1 respectively. Set a lighting warning trigger threshold. Set to the 99th percentile value of the probability distribution curve of subset B1 (abnormal group). This means that 99% of abnormal cases will be below this value, ensuring no cases are missed.
[0161] Reset the threshold to restore illumination. Set to the 1% quantile value of the probability distribution curve of subset A1 (normal group). This indicates that 99% of normal cases will have values higher than this, ensuring no false alarms. Verification. Is it greater than Furthermore, the difference between the two values should not be less than 0.05. If this condition is not met, it indicates that the confidence generation algorithm in step S3 needs to be optimized to improve the discriminative power. In this embodiment, the illumination recovery reset threshold is set to 0.35. It constructs a "dead zone" with a width of 0.05 to ensure that only a clear improvement in illumination can eliminate the alarm. The illumination warning trigger threshold is set to 0.3; defined... ,in The preset minimum safety hysteresis is 0.05 to ensure the physical existence of the logic reset range. This width can cover the ±5% light intensity jitter caused by general industrial power supply fluctuations.
[0162] Furthermore, traditional OCR processes only output text, lacking explanation for recognition failures. Traditional illumination detection often results in frequent false alarms due to critical flickering caused by a single threshold. This embodiment utilizes the "Top-Hat transform" characteristic of morphological reconstruction to extract a difference image that includes the background filtered out by the algorithm. This method calculates its "local texture disorder" and introduces a gray-level co-occurrence matrix (GLCM) to capture the spatial correlation between pixels. If the calculated texture entropy is too high, it indicates a cluttered background (severe corrosion); in this case, even if characters are recognized, the workpiece surface quality should be marked as unqualified.
[0163] When monitoring the confidence level of illumination, the Schmitt trigger model from control theory is introduced, and a hysteresis loop is constructed using a dual threshold, which fundamentally eliminates alarm noise in the critical state.
[0164] The state determination model for setting up hysteresis comparison logic: This logic is a refinement of the logic in step S5 for the action of "generating a state alarm signal indicating abnormal ambient light or sensor occlusion".
[0165] The input data is the "global average illumination value" of the illumination confidence field map generated in step S3. ")" and the current "alarm status indicator ( (Boolean value).
[0166] To prevent alarm flashing caused by critical fluctuations in lighting conditions, the following state machine logic is executed:
[0167] Logical Branch 1 (Currently in Normal State): Obtain the current alarm status indicator. If the current status indicates "Normal (No Alarm)", then compare the real-time calculated global average illuminance value with the previously determined illuminance warning trigger threshold. The comparison is performed. The trigger state is reversed only when the global average illuminance is less than the illuminance warning trigger threshold, the alarm status is updated to "abnormal", and the alarm signal output interface is immediately activated; otherwise, the current state remains unchanged.
[0168] Logical Branch 2 (Currently in an Abnormal State): If the current alarm status indicator is "Abnormal (Alarm Present)", then the real-time calculated global average illuminance value will be compared with the previously determined illuminance recovery reset threshold. A comparison is performed. The state is flipped only when the global average illuminance is significantly greater than the illuminance recovery reset threshold, updating the alarm status flag to "normal" and immediately revoking the activation command of the alarm signal output interface; otherwise, the current state remains unchanged.
[0169] The updated alarm status identifier and corresponding hardware control signals (including lighting a red LED) are output. This mechanism can not only read text, but also evaluate workpiece quality (rust detection) and sense its own health (light / occlusion detection), improving robustness in industrial settings. This embodiment abstracts the hysteresis comparison logic as a finite state machine, and its state transition truth table is shown below:
[0170] Table 1: State Machine Logic Table
[0171] Current state (St) Input: Global average illumination value ( ) The state at the next moment (St+1) Action output Normal (OK) Normal (OK) Remain silent Normal (OK) Alarm Trigger alarm signal Alarm Normal (OK) Alarm signal cancellation Alarm Alarm Keep the alarm running
[0172] The above logic constructs an interval on the numerical axis. In this embodiment, the range is [0.30, 0.35]. When the light intensity decreases from the normal value (0.5), even if it drops to 0.32 (entering the range), it remains "normal" until it falls below 0.30 before triggering an alarm.
[0173] When the illumination level recovers from the abnormal value (0.1), even if it rises to 0.32 (entering the range), the alarm remains active until it exceeds 0.35. This design effectively filters out light source flicker interference caused by voltage fluctuations in industrial environments by utilizing the dead zone, avoiding frequent malfunctions of relays or alarm lights. Specifically, to eliminate light source flicker interference caused by voltage fluctuations in industrial environments, the system's self-diagnostic process uses a Schmitt trigger model to perform hysteresis control on the illumination status. The processing unit maintains an alarm status flag in a Boolean state variable stored in a register. And based on the real-time calculated global average illuminance value Execute the following state transition logic:
[0174] The transition from normal to alarm state occurs only when the current alarm state is indicated. The indicator is set to "Normal (False)," and the real-time monitored global average illuminance value is... Falling below the light warning trigger threshold At that time, the processing unit triggers a state flip, and... Update to "Alarm (True)" and simultaneously send a high-level drive signal to the external PLC or alarm indicator.
[0175] Reset from alarm to normal state: Only when the current alarm state is indicated. The indicator is set to "Alert (True)," and the global average illuminance value is monitored in real time. Rebounded to above the light recovery reset threshold When the processing unit triggers a state reset, it will... Update to "Normal (False)" and cancel the drive signal.
[0176] Dead zone preservation: when the global average illumination value In the range During this period, the processing unit ignores the light fluctuation and forcibly maintains the light level. The current state remains unchanged.
[0177] The following is a detailed explanation of the implementation of the above content:
[0178] Local texture disorder index based on gray-level co-occurrence matrix (GLCM) Calculations and their applications in surface quality assessment and defect decoupling.
[0179] Local texture disorder index It is a non-negative real number whose theoretical range is determined by the number of quantized gray levels. Decision, scope In this embodiment, the following settings are provided. Under these conditions, the theoretical maximum value is approximately 5.54.
[0180] when When approaching a minimum: This indicates that the pixel texture within the local window exhibits high uniformity or completely regular periodicity. Physically, this corresponds to a "specular reflection area" or "single background area" on the workpiece surface, or possibly to character entities with extremely thick strokes and uniform internal structure. In this case, it is determined that the region does not have high-frequency physical defects, and the signal-to-noise ratio of OCR recognition is at its theoretical extreme, resulting in the highest confidence level.
[0181] when When the value approaches a maximum: This indicates that the pixel grayscale distribution within the local window exhibits the greatest degree of randomness. Physically, this corresponds to severe "isotropic corrosion," "sandblasting noise," or "high-frequency random scratches." This state means that the character structure information has been completely obscured by physical defects, and even the geodesic reconstruction in step S4 cannot recover a valid topology. This trend directly indicates the physically unusable state of the workpiece surface, triggering a scrap rejection mechanism.
[0182] In response to the impact The key input parameters for the output are analyzed as follows:
[0183] GLCM displacement vector set ( ) includes multiple directions ( The fusion calculation of the values is positively correlated with the stability of the final entropy value. Real physical defects (rust spots) are isotropic, while character strokes have a specific directionality. By accumulating the co-occurrence matrices of the four directions, the interference of character stroke direction on the entropy value is eliminated, enhancing the sensitivity to disordered noise. This design ensures that the algorithm does not mistakenly identify "tilted character strokes" as "disordered noise," thereby reducing the false alarm rate for italic characters or rotated workpieces, supporting the technical effect of "highly robust defect decoupling" in this invention.
[0184] Gray quantization level The value of is positively correlated with the calculated entropy resolution, but negatively correlated with the noise immunity. If For an excessively large 256 levels, the inherent thermal noise of the sensor can cause sparsity in the co-occurrence matrix, artificially inflating the entropy value; if If the level is too low (e.g., 4), subtle rust patterns will be merged and quantified, leading to missed detections. This embodiment is preferred. It is a balance point calculated based on the physical constraints of the signal-to-noise ratio (SNR) of industrial cameras, ensuring that only values exceeding the sensor's noise floor are considered. Only texture changes within a certain range are recorded in GLCM, thus achieving "physical noise filtering defined by the algorithm".
[0185] Furthermore, this embodiment is configured within a digital twin model of an automated optical inspection (AOI) production line for high-speed stamping parts. Typical operating conditions during continuous production are simulated, including light fluctuations, scratches caused by mechanical vibration, and corrosion defects inherent in the material itself. Parameters are set as follows: reconstruction stability threshold. Light warning / Reset threshold Defect judgment threshold GLCM quantization levels ;
[0186] To verify the efficiency advantage of the "dynamic residual feedback truncation mechanism" of this invention, a "traditional morphological reconstruction algorithm" was set up as a control group. The control group did not use a reconstruction stability threshold. Instead, it iterates until the image pixels no longer change. See Table 2 below for details:
[0187] Table 2: Calculation Examples of System Response and Efficiency Comparison under Different Environmental Disturbances
[0188] Scene Number Scene Description Surface physical texture features Number of iterations in this application Traditional iteration cycle number Alarm status indicator Local texture disorder peak System decision results Case 1 Standard operating conditions - perfect surface 0.55 (Strong) Smooth, with only clear characters 12 (Quick Truncation) 18 False (Normal) 0.85 (Low) PASS (Quality Qualified) Case 2 Sudden drop in light - entering the dead zone 0.32 (Low to Medium) Smooth, without defects 14 (Normal truncation) 20 False (Initially normal) 0.88 (Low) PASS (Interference prevention effective) Case 3 Illumination anomaly - trigger threshold 0.28(< ) There is slight dark noise in the background. 25 (Noise Suppression) 42 False → True 1.10 (Chinese) ALARM (Abnormal Lighting) Case 4 Light Recovery - Dead Zone Test 0.33(> ) There is slight dark noise in the background. 18 (Normal truncation) 26 True (Initial Alarm) 1.05 (Medium) ALARM (Delayed Activation) Case 5 Strong light spots + minor scratches 0.60 (overexposed) Localized highlights, intermittent scratches 35 (Deep Repair) 48 False (Normal) 1.95(< ) PASS (S4 repair successful) Case 6 Severe corrosion interference 0.45 (normal) Dense isotropic pockmarks 8 (Early circuit breaker) 150+ (failed to converge) False (Normal) 4.25(> ) REJECT (physical defect)
[0189] The above data, through multi-dimensional comparison, quantitatively verifies the beneficial effects of this invention in three aspects: "efficiency improvement," "defect decoupling," and "robust control."
[0190] The peak value of local texture disorder is denoted as The number of iteration cycles in this application is denoted as . The traditional iteration cycle number is denoted as ;
[0191] Comparison table and In the standard operating condition (Case 1), the traditional algorithm requires 18 iterations to reach mathematical stability, while this application, through dynamic truncation based on noise floor, determines physical convergence on the 12th iteration. The computational efficiency improvement rate is (18-12) / 18. 33.3%. Under harsh operating conditions (Case 3), due to increased sensor noise, traditional algorithms require a surge in iterations to 42 times in pursuit of meaningless "zero change"; while this application identifies residuals lower than... The calculation stopped on the 25th iteration. The efficiency improvement rate was (42-25) / 42. 40.5%.
[0192] Data evidence of the high sensitivity of texture entropy in identifying defect properties: a comparison of Case 5 (scratch interference) and Case 6 (rust interference). Output value. Although Case 5 has obvious physical scratches, its local texture disorder is due to the directionality (order) of the scratches. With a value of only 1.95, it is correctly identified as "repairable surface fluctuation".
[0193] In Case 6, the corrosion exhibits an isotropic random distribution (highly disordered), leading to It surged to 4.25.
[0194] Compared to scratch interference, the index values under corrosion interference were improved. 118%. This significant difference in signal-to-noise ratio (>100%) demonstrates that the indicator can accurately distinguish between "regular geometric defects" and "random material defects," effectively solving the technical problem that existing variance statistics methods are prone to confusing the two and causing false alarms.
[0195] Data evidence of the hysteresis robustness of illumination state management: Comparison of Case 2 and Case 4. The input illumination values for the two scenes are extremely close (0.32 and 0.33), and both fall within the preset dead zone [0.30, 0.35].
[0196] Case 2, with an initial state of "False," ignored the slight decrease in illumination and maintained the "PASS" state, thus avoiding false alarms. Case 4, with an initial state of "True," ignored the slight increase in illumination and maintained the "ALARM" state, preventing frequent fluctuations in the alarm signal. This data confirms that the introduction of the Schmidt triggering model provides the control loop with anti-interference capabilities under critical conditions, ensuring the determinism and stability of alarm signals in industrial settings.
[0197] Furthermore, based on the "local texture disorder index" calculated in the previous steps... This embodiment establishes three practical application ranges for this continuous risk assessment parameter by pre-calibrating the OCR recognition rate of samples covering different surface qualities, and configures corresponding differentiated processing logic:
[0198] Interval 1: Trusted Reconstruction Interval The upper threshold (2.0) of this range is determined by statistics from the "End Point of the OCR Recognition Rate Platform Zone". When At this point, the first derivative of the OCR recognition error rate is close to 0, indicating that the entropy value of the background texture is within the range of "morphological noise" that can be completely suppressed by the geodesic reconstruction algorithm described in step S4, and the character structure has not been substantially damaged. The endpoint of the OCR recognition rate plateau indicates that, without additional special processing (without triggering secondary enhancement), a preset high-precision recognition rate (accuracy) can be maintained. The maximum noise tolerance limit is determined by the processor. The corresponding processing operation is that the processor determines that the current workpiece is in a "safe state", directly adopts the "character-enhanced structure data" output by step S4 as the final result, executes the subsequent OCR recognition process, and marks the workpiece surface quality as "excellent (A4 level)".
[0199] Interval 2: Conditional Enhancement Interval The upper threshold of 2.5 in this interval is determined by the "linear growth zone of the entropy-false recognition rate curve". Within this interval, physical defects (including minor scratches or oil stains) begin to interfere with the connectivity of character strokes, leading to a risk of local breakage in the basic reconstruction of step S4, but not yet reaching the information theory limit of complete unrecognizableness. The corresponding processing operation is that the processor automatically triggers a "secondary enhancement mode". Specifically, the control loop calls a more aggressive morphological closing operation kernel, changing its size from the default... Dynamically expand to The output of step S4 is then subjected to supplementary smoothing connection processing. After processing, OCR recognition is performed, and the workpiece surface quality is marked as "Good (B4 grade)".
[0200] Interval 3: Physically defective and abandoned interval. This threshold corresponds to the "engineering approximation point of the Shannon limit." Statistical calibration data shows that when the local entropy value exceeds 2.5, the effective information content (signal-to-noise ratio) in the image has fallen below the minimum number of bits required for OCR feature extraction, and the recognition error rate rises exponentially to over 90%, rendering further processing pointless. The corresponding processing operation is to avoid unnecessary computational waste; the processor immediately terminates subsequent OCR recognition processes and image enhancement attempts, directly generates and outputs a "surface quality NG" alarm signal, and drives the production line actuator to remove the workpiece. In the industrial application scenario of this embodiment, the minimum number of bits is 5.2 bits.
[0201] Further explanation: Figure 1 This diagram illustrates the core processing logic of this invention for recognizing characters on the surface of metal workpieces with complex textures and reflective properties. The metal workpiece shown on the left / top of the diagram is the object of this method, and its surface carries pin-type or laser-etched character markings. The flowchart in the diagram corresponds sequentially to the four key processing stages of this invention:
[0202] The first block diagram, “Total Variation Decomposition and Decoupling”, corresponds to steps S1 and S2 of the present invention. It indicates that after the original image is acquired, the image is separated into an intrinsic reflectivity component that characterizes the inherent properties of the material and an illumination component that characterizes environmental interference through total variation regularization operation.
[0203] The second block diagram, “Light-Topological Seed Generation,” corresponds to step S3 of this invention. It indicates that this scheme utilizes the gradient statistical characteristics of the illumination component to construct an illumination confidence field, and uses this field to perform spatial weighted fusion of morphological erosion features and skeleton connectivity features to generate hybrid seed data.
[0204] The third block diagram, “Geodetic Morphological Reconstruction,” corresponds to step S4 of the present invention. It indicates that a controlled morphological reconstruction operation is performed using intrinsic reflectivity data as a mask and mixed seed data as a marker to physically repair the broken structure of the character and suppress background noise.
[0205] The fourth block diagram, “Character Recognition and Diagnosis,” corresponds to step S5 of this invention. It represents the binarization recognition of the reconstructed enhanced structure, combined with surface quality evaluation indicators, to output the final result and system status alarm.
[0206] Figure 3 This is a schematic diagram illustrating the results of a numerical verification experiment performed on "Step S4: Geodesic Morphological Reconstruction Calculation" in one embodiment of the present invention. This numerical verification aims to test the present invention under preset standardized boundary conditions (i.e., Quantization series and Theoretical response characteristics under threshold configuration. Figure 3 In the diagram, the horizontal axis represents the number of iteration cycles (…). The vertical axis represents the number of iterations in which the algorithm performs the expansion and truncation operations; the vertical axis represents the "global average residual" calculated based on the residual calculation formula described in this invention. The graph is displayed using a logarithmic scale. The gray solid line represents the baseline convergence trajectory of the existing technology (without dynamic truncation), the blue solid line represents the optimized trajectory of the present invention after adopting the dynamic residual feedback truncation mechanism, and the red dashed line represents the preset reconstruction stability threshold.
[0207] like Figure 3 As shown, the numerical calculation results clearly reveal the difference between the present invention and existing technologies in terms of convergence behavior. This mathematically proves that the "dynamic residual feedback truncation mechanism" proposed in this invention can effectively eliminate invalid calculations. Specifically, in the early stages of iteration (e.g., k < 12), the two curves coincide, indicating that the present invention preserves the physical growth characteristics of morphological reconstruction; when the global average residual ( When the curve of this invention (blue) first falls below the "reconstruction stability threshold" shown by the red dashed line and maintains a stable period, it immediately terminates at k=12 (corresponding to the data of Case 1 in Table 1), while the prior art (gray), in pursuit of mathematical zero change, continues to extend to k=18 or even further. This "iterative truncation" phenomenon directly confirms that by introducing a stability counter and threshold judgment, it is possible to reduce redundant iteration steps by more than 30% while ensuring that the physical structure has been restored (residuals are as low as the noise floor level).
[0208] Furthermore, this verification was built on a general-purpose numerical computing environment (MATLAB / Python NumPy). This environment was chosen to verify the logical closed-loop performance and numerical stability of the geodesic morphology reconstruction algorithm described in step S4 within a deterministic computational framework, rather than relying on hardware-specific physical experiments. For quantitative evaluation, the actual workpiece image was abstracted into a two-dimensional discrete matrix model. Core state representation: The system state is represented by variables... (The labeled image matrix) is represented. This variable is defined in memory as a two-dimensional grayscale matrix, the dimensions of which correspond to the pixel resolution of the industrial camera. State updates strictly follow iterative logic: Each iteration includes a morphological dilation operator and a pixel-wise minimum truncation, accompanied by a global average residual. Real-time calculation.
[0209] A standardized input set covering typical application scenarios was constructed:
[0210] Benchmark / Steady-state test vectors (for scenario Case 1): Configure input parameters Furthermore, there is no strong interference. This vector is intended to verify that the algorithm can converge quickly and trigger the truncation mechanism under standard operating conditions.
[0211] Boundary / Stress Test Vector (corresponding to Scenario Case 6): Configure input parameters with high-frequency random noise (simulating severe corrosion). This configuration constitutes the logical boundary for verifying the algorithm under the signal-to-noise ratio limit, and verifies the discriminative power of the entropy index in step S5.
[0212] For the above input, execute the complete computation path of "iteration-decision-truncation" and output deterministic verification data (number of iteration cycles). With the final entropy value ).
[0213] This verification uses the "number of iteration cycles ( ")" and "Local texture disorder index ( ")" is used as the core evaluation indicator. The defined logic follows: the algorithm satisfies the termination condition. The loop count during the time.
[0214] The value quantifies the time complexity optimization contribution of the "dynamic truncation mechanism" in the theoretical sense of computational complexity. In an information theory sense, the value quantifies the sensitivity of "entropy detection" to disordered noise.
[0215] Verification data shows that the present invention The value (12) is significantly smaller than the benchmark value (18), and Peak values are observed at the defects. This theoretically directly characterizes the extent to which the proposed solution eliminates computational redundancy and its ability to decouple from artifact interference.
[0216] The computational logic involved in this application can be constructed using algorithms such as regression analysis in machine learning, establishing a mathematical model by analyzing the inherent trends and interrelationships of the collected parameters. This process can be implemented using specialized computational tools (such as Python's Scikit-learn library or the R language environment). Throughout all calculations, to eliminate the influence of different physical dimensions and ensure that data is compared and analyzed on the same scale, the input parameters in each formula are dimensionless. The dimensionless techniques used include, but are not limited to, max-min normalization or Z-score standardization.
[0217] The algorithm of this invention is implemented as a Python script. Before executing the core logic, the program first executes a data loading module (e.g., using the widely used pandas library in Python) configured to read the aforementioned spreadsheet file and load its contents into the program's working memory (e.g., a DataFrame data structure). Subsequent algorithm steps will directly query and retrieve the required configuration parameters from this in-memory data structure.
[0218] It should be emphasized that the foregoing embodiments are merely illustrative of preferred implementations of the present invention and are not intended to limit the scope of protection of the present invention. This application also provides a computer-readable storage medium having computer program instructions stored thereon.
Claims
1. A method for recognizing text on the metal surface of a workpiece based on image segmentation, characterized in that, The specific steps include: S1: Acquire single-frame grayscale image data characterizing the optical properties of the workpiece surface; S2: Perform total variational regularization decomposition on the single-frame grayscale image data to separate and generate intrinsic reflectivity distribution data characterizing the inherent properties of the material, and illumination component distribution data characterizing ambient light and specular reflection intensity. S3: Based on the local gradient statistical characteristics of the illumination component distribution data, an illumination confidence field mapping map is generated, and the illumination confidence field mapping map is used as a spatial weighting factor to perform weighted fusion of morphological erosion features and skeleton connectivity features derived from the intrinsic reflectance distribution data, thereby generating a light-topology hybrid seed data. S4: Using the intrinsic reflectivity distribution data as a morphological mask and the light-topology hybrid seed data as a morphological marker, perform geodesic morphological reconstruction operation to generate character-enhanced structural data that characterizes the background texture noise that has been filtered out and the reflective breakage defects that have been repaired. S5: Perform binarization and pattern matching processing on the character enhancement structure data, and output the final character recognition result data.
2. The method for recognizing text on the metal surface of a workpiece based on image segmentation according to claim 1, characterized in that: In step S1, single-frame grayscale image data characterizing the optical properties of the workpiece surface is acquired, including: The system receives raw two-dimensional array signals from an image sensor and performs linear demosaicing and grayscale mapping processing on the raw two-dimensional array signals to generate single-frame grayscale image data with linear photometric response characteristics. The pixel value of each pixel in the single-frame grayscale image data is proportional to the physical radiance of the workpiece surface at that location.
3. The method for recognizing text on the metal surface of a workpiece based on image segmentation according to claim 2, characterized in that: In step S2, performing the total variational regularization decomposition operation includes: An energy functional model is constructed, which includes a data fidelity term, a total variational sparse term for reflectance, and an illumination smoothing term. The energy functional model is solved iteratively by the alternating direction multiplier method, and the two components that minimize the energy functional model are calculated and defined as the intrinsic reflectance distribution data and the illumination component distribution data, respectively.
4. The method for recognizing text on the metal surface of a workpiece based on image segmentation according to claim 3, characterized in that: In step S2, an energy functional model is constructed that includes a data fidelity term, a total variational sparse term for reflectivity, and an illumination smoothing term, further comprising: Perform local texture activity analysis step: Perform local variance statistical operation on the single frame grayscale image data to generate a texture activity distribution map that characterizes the richness of local details in the image; Perform the regularization weight dynamic mapping step: Based on the texture activity distribution map, generate independent adaptive regularization weight coefficients for each pixel position in the image through a preset inverse proportional mapping function; The weighted energy functional construction step is performed by applying the adaptive regularization weight coefficients pixel by pixel to the total variational sparse term of reflectivity, thereby enhancing the smoothness constraint in flat regions and reducing the smoothness constraint in texture-rich regions.
5. The method for recognizing text on the metal surface of a workpiece based on image segmentation according to claim 4, characterized in that: In step S3, a light-topology hybrid seed dataset is generated, including the following sub-steps: Sub-step 3.1: Calculate the gradient magnitude field of the illumination component distribution data, and transform the gradient magnitude field into the illumination confidence field mapping map with values ranging from 0 to 1 through the negative exponential mapping function, wherein the larger the gradient magnitude, the lower the corresponding confidence value; Sub-step 3.2: Perform morphological corrosion operation on the intrinsic reflectivity distribution data to generate basic corrosion feature data; Sub-step 3.3: Perform topological skeleton extraction operation on the intrinsic reflectance distribution data to generate skeleton connectivity feature data; Sub-step 3.4: For each pixel location in the image, using the value of the illumination confidence field map as the first weight and the complement of the value of the illumination confidence field map as the second weight, linearly weighted summation is performed on the basic erosion feature data and the skeleton connectivity feature data to generate the light-topology hybrid seed data.
6. The method for recognizing text on a workpiece metal surface based on image segmentation according to claim 5, characterized in that: In sub-step 3.1 of step S3, an illumination confidence field mapping map is calculated and generated, specifically including: The structure tensor construction step is performed as follows: For each pixel position of the illumination component distribution data, a positive semidefinite structure tensor matrix is constructed based on the horizontal and vertical gradients in its neighborhood. The coherence index calculation steps are as follows: perform eigenvalue decomposition on the structure tensor matrix to obtain the principal eigenvalues and secondary eigenvalues, and calculate the square of the difference between the principal eigenvalues and the secondary eigenvalues to generate the local structure coherence index. The confidence mapping step is as follows: obtain the preset illumination confidence attenuation rate parameter, calculate the product of the local structure coherence index and the illumination confidence attenuation rate parameter, and perform a negative exponential operation on the product to generate the illumination confidence field mapping map.
7. The method for recognizing text on a workpiece metal surface based on image segmentation according to claim 6, characterized in that: In step S3, the morphological corrosion features and skeleton connectivity features derived from the intrinsic reflectivity distribution data are weighted and fused, specifically including: Configure a disk-shaped structural element with a preset pixel value, and use this disk-shaped structural element to perform morphological erosion on the intrinsic reflectance distribution data to generate basic erosion feature data; Extract the center line of the single pixel width of the intrinsic reflectance distribution data to generate skeleton connectivity feature data; For each pixel location, the value of the illumination confidence field map is used as the first weight, and the difference between the value of the illumination confidence field map and 1 is used as the second weight. A linear weighted sum is then performed on the basic erosion feature data and the skeleton connectivity feature data to generate the light-topology hybrid seed data.
8. The method for recognizing text on a workpiece metal surface based on image segmentation according to claim 7, characterized in that: In step S4, geodesic morphological reconstruction is performed. Based on the morphological reconstruction algorithm, under the numerical height constraint defined by the intrinsic reflectance distribution data, the light-topology hybrid seed data is driven to undergo iterative conditional dilation until the pixel values of all connected regions no longer change. This preserves the image structure that is spatially connected to the light-topology hybrid seed data, while suppressing non-connected texture noise. In step S4, performing the iterative conditional expansion specifically includes: Obtain the preset reconstruction stability threshold and the number of stable cycles; Entering the iteration loop, in each iteration, the light-topology hybrid seed data is dilated and numerically truncated using the intrinsic reflectivity distribution data to generate updated light-topology hybrid seed data; Calculate the total pixel change between the updated light-topology hybrid seed data and the original light-topology hybrid seed data; Establish a stability counter. If the total pixel change is less than the reconstruction stability threshold, increase the value of the stability counter; otherwise, reset the stability counter. The iteration loop terminates only when the value of the stability counter reaches the number of stable periods.
9. The method for recognizing text on a workpiece metal surface based on image segmentation according to claim 8, characterized in that: In step S5, before outputting the final character recognition result data, a surface quality assessment and system self-diagnosis process is also performed: Calculate the difference image data between the intrinsic reflectance distribution data and the character enhancement structure data; Based on the local variance statistics of the differential image data, a surface quality assessment index characterizing the degree of physical defects on the workpiece surface is generated. Simultaneously, the global average illumination value of the illumination confidence field map is calculated. When the global average illumination value is lower than a preset safety threshold, a status alarm signal indicating abnormal ambient lighting or sensor occlusion is generated.
10. A method for recognizing text on a workpiece metal surface based on image segmentation according to claim 9, characterized in that: In step S5, surface quality assessment indicators characterizing the degree of physical defects on the workpiece surface are generated, specifically including: Calculate the difference image data between the intrinsic reflectance distribution data and the character enhancement structure data; The differential image data is divided into multiple local windows. For each local window, a gray-level co-occurrence matrix is constructed and normalized to obtain a probability matrix. For each non-zero element in the probability matrix, calculate the product of the element's value and the natural logarithm of the element's value, and sum all the negative values of the products to generate a local texture disorder index. Calculate the peak value or the proportion of exceeding the limit of the local texture disorder index for all local windows, and use it as the surface quality evaluation index. In step S5, a status alarm signal indicating abnormal ambient light or sensor obstruction is generated, specifically including: Obtain a preset light warning trigger threshold and a light recovery reset threshold, wherein the value of the light recovery reset threshold is greater than the value of the light warning trigger threshold; Calculate the global average illumination value of the illumination confidence field map and read the currently recorded alarm status identifier; If the alarm status indicator indicates a non-alarm state and the global average illumination value is lower than the illumination warning trigger threshold, the status alarm signal is generated and the alarm status indicator is updated to an alarm state. If the alarm status indicator indicates an alarm status and the global average illumination value is higher than the illumination recovery reset threshold, the status alarm signal is deactivated and the alarm status indicator is updated to a non-alarm status. If the global average illumination value is between the illumination warning trigger threshold and the illumination recovery reset threshold, the current state of the alarm status identifier and the status alarm signal remains unchanged.
