A light source automatic adjusting method and device based on image gray scale analysis
Patent Information
- Application Number
- CN202611155833.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-31
- Publication Date
- 2026-10-27
AI Technical Summary
[0005]本发明提供了一种基于图像灰度分析的光源自动调节方法及装置,解决了人工调光无灰度量化依据,亮度调节精度不足的技术问题
[0017]从以上技术方案可以看出,本发明具有以下优点:本发明提供的一种基于图像灰度分析的光源自动调节方法及装置,其通过获取待测工件的多通道图像数据集,同步采集多通工件图像,为亮度量化分析提供全面客观样本数据;通过对多通道图像数据集进行灰度分析,生成目标灰度特征参数,实现对像素灰度的量化计算,以客观数值作为亮度评判标准,消除人眼主观判断偏差;基于目标灰度特征参数与预设灰度阈值,执行光源参数标定,确定目标光源调节量,实现基于灰度偏差确定调节系数,提升调光精准度;基于目标光源调节量,生成光源控制指令并下发至目标光源控制器,实现标准化输出光源控制指令,实现设备自动化闭环控制,无需人工反复试错操作;通过目标光源控制器基于目标光源调节量调节光源点亮参数,并输出与调节后的光源点亮参数匹配的光源亮度,动态适配物料、环境变化,稳定维持标准成像亮度。本发明能够基于图像灰度量化分析实现全自动闭环调光,摒弃人工主观调节模式,有效提升光源亮度调节精度与检测一致性。
Smart Images

Figure CN122994979A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial visual inspection technology, and in particular to an automatic light source adjustment method and apparatus based on image grayscale analysis. Background Technology
[0002] Defect detection of lithium battery electrode sheets falls under the subfield of industrial machine vision. The brightness of the imaging light source directly determines the grayscale acquisition effect of the image, which is the core condition for ensuring the accuracy of identifying defects such as missing coating and scratches on the electrode sheets. Automated production lines need continuous and stable imaging brightness to support online detection.
[0003] The existing production line uses manual adjustment of the light source brightness. Operators repeatedly adjust the light source driving parameters by observing the brightness of the image with the naked eye. After fixing the light source brightness, they perform batch electrode image acquisition and defect detection operations.
[0004] However, existing technologies have the following drawbacks: manual adjustment relies on subjective judgment and lacks quantitative grayscale data support, resulting in insufficient precision in adjusting the brightness of the light source. Summary of the Invention
[0005] This invention provides an automatic light source adjustment method and device based on image grayscale analysis, which solves the technical problems of insufficient brightness adjustment accuracy due to the lack of grayscale quantification basis in manual dimming.
[0006] In a first aspect, the present invention provides an automatic light source adjustment method based on image grayscale analysis, comprising: Acquire a multi-channel image dataset of the workpiece to be tested; Perform grayscale analysis on the multi-channel image dataset to generate target grayscale feature parameters; Based on the target grayscale feature parameters and the preset grayscale threshold, perform light source parameter calibration to determine the target light source adjustment amount; Based on the target light source adjustment amount, a light source control command is generated and sent to the target light source controller; The target light source controller adjusts the light source illumination parameters based on the target light source adjustment amount and outputs a light source brightness that matches the adjusted light source illumination parameters.
[0007] In some embodiments, the multi-channel image dataset includes multiple frames of sample images from each preset acquisition channel, and the grayscale analysis of the multi-channel image dataset to generate target grayscale feature parameters includes: Perform global grayscale statistics and regional grayscale statistics on each frame of sample image to generate grayscale feature parameters for each frame of sample image; Based on the grayscale feature parameters of each frame of sample images, a validity test is performed to select candidate sample images; Based on the electrode type of the workpiece under test and the grayscale feature parameters of all candidate sample images under each preset acquisition channel, a cropping mean filter is performed to generate the channel grayscale feature parameters of each preset acquisition channel. The grayscale feature parameters of all the channels are fused and averaged to generate the target grayscale feature parameters.
[0008] In some embodiments, the step of performing global grayscale statistics and partitioned grayscale statistics on each frame of sample image to generate grayscale feature parameters for each frame of sample image includes: Perform global grayscale statistics on each frame of sample image to generate a global grayscale histogram for each frame of sample image. After smoothing and denoising the global grayscale histogram, peak detection is performed to filter out the global valid peaks and remove the pixel data corresponding to the global invalid peaks. Perform gray-level statistical calculations on the global gray-level histogram after removing invalid peaks, and solve for the global gray-level feature parameters that match the preset gray-level statistical indicators; Each frame of sample image is segmented into pixels according to the preset region division rules, and multiple target detection regions are divided within each frame of sample image. Perform partitioned grayscale statistics on each of the target detection regions to generate a partitioned grayscale histogram for each of the target detection regions; After smoothing and denoising the grayscale histograms of each partition, peak detection is performed to filter the valid peaks of the partitions and remove the pixel data corresponding to the invalid peaks of the partitions. Perform gray-level statistical calculations on the gray-level histograms of each partition after removing invalid peaks, and solve for the partition gray-level feature parameters that match the preset gray-level statistical index; The global grayscale feature parameters and the partition grayscale feature parameters of each frame sample image are integrated to generate the grayscale feature parameters of each frame sample image.
[0009] In some embodiments, the step of performing peak detection after smoothing and denoising the global grayscale histogram, filtering out global valid peaks and removing pixel data corresponding to global invalid peaks, includes: Traverse all gray-level points in the global gray-level histogram after smoothing and noise reduction, extract all local maximum values as candidate peaks, and record the peak gray level, peak height, peak prominence, and peak signal-to-noise ratio of each candidate peak. Statistical calculations are performed on the global pixel count of the global grayscale histogram after smoothing and noise reduction to solve for the histogram pixel mean and histogram pixel standard deviation; According to the preset grayscale distribution weighted conversion rules, the mean value of the histogram pixels and the standard deviation of the histogram pixels are quantized to generate a peak value determination threshold; the peak value determination threshold includes a peak height threshold, a peak prominence threshold and a peak signal-to-noise ratio threshold; Noise peaks whose peak height is less than the peak height threshold among all candidate peaks are marked as globally invalid peaks; Among all candidate peaks, smooth grayscale peaks whose peak prominence is less than the peak prominence threshold are marked as globally invalid peaks; Unstable peaks whose peak signal-to-noise ratio (SNR) is less than the threshold value are marked as globally invalid peaks. Mark all candidate peaks that were not marked as globally invalid peaks as globally valid peaks; According to the peak gray level, all global effective peaks are sorted in ascending order, and the peak gray level difference between adjacent global effective peaks after sorting is calculated. The adjacent global valid peaks whose peak grayscale difference is less than the preset grayscale difference threshold are marked as global invalid peaks; Remove the pixel data of the gray-level interval in the global gray-level histogram after smoothing and noise reduction of each of the aforementioned global invalid peaks, and retain all global valid peaks after removal.
[0010] In some embodiments, the step of performing a validity check based on the grayscale feature parameters of each frame of sample images to filter out candidate sample images includes: Extract all global peak gray levels and all regional peak gray levels of each frame of sample images from the gray-level feature parameters of each frame of sample images; If either the total global peak gray level or the total partition peak gray level is greater than the preset peak gray level threshold, the corresponding frame sample image will be removed. If all global peak grayscale values and all partition peak grayscale values are less than or equal to the preset peak grayscale threshold, then the corresponding frame sample image is determined as a candidate sample image.
[0011] In some embodiments, the step of performing cropping mean filtering based on the electrode type of the workpiece under test and the grayscale feature parameters of all candidate sample images under each preset acquisition channel to generate channel grayscale feature parameters for each preset acquisition channel includes: Extract candidate grayscale feature parameters that match the electrode type of the workpiece to be tested from the grayscale feature parameters of each candidate sample image; Integrate all candidate grayscale feature parameters belonging to the same preset acquisition channel to generate grayscale feature parameter groups corresponding to each preset acquisition channel; After sorting the grayscale feature parameter groups in ascending order, the extreme values at both ends of each grayscale feature parameter group are removed according to a preset cropping ratio. The average value of each grayscale feature parameter group after cropping is calculated to determine the comprehensive grayscale feature value of each grayscale feature parameter group, and the comprehensive grayscale feature value is used as the channel grayscale feature parameter of the corresponding preset acquisition channel.
[0012] In some embodiments, the step of performing cropping mean filtering based on the electrode type of the workpiece under test and the grayscale feature parameters of all candidate sample images under each preset acquisition channel to generate channel grayscale feature parameters for each preset acquisition channel includes: Extract candidate grayscale feature parameters that match the electrode type of the workpiece to be tested from the grayscale feature parameters of each candidate sample image; Integrate all candidate grayscale feature parameters belonging to the same preset acquisition channel to generate grayscale feature parameter groups corresponding to each preset acquisition channel; After sorting the grayscale feature parameter groups in ascending order, the extreme values at both ends of each grayscale feature parameter group are removed according to a preset cropping ratio. The average value of each grayscale feature parameter group after cropping is calculated to determine the comprehensive grayscale feature value of each grayscale feature parameter group, and the comprehensive grayscale feature value is used as the channel grayscale feature parameter of the corresponding preset acquisition channel.
[0013] In some embodiments, the step of fusing and averaging all the channel grayscale feature parameters to generate target grayscale feature parameters includes: Iterate through all the grayscale feature parameters of the channels and calculate the grayscale difference between any two channels' grayscale feature parameters. If all the grayscale differences are less than or equal to the preset difference threshold, then the average of all the channel grayscale feature parameters is calculated to generate the target grayscale feature parameters. If any of the grayscale differences is greater than a preset difference threshold, then the preset grayscale threshold is used as the target grayscale feature parameter.
[0014] In some embodiments, the step of performing light source parameter calibration and determining the target light source adjustment amount based on the target grayscale feature parameters and a preset grayscale threshold includes: The difference between the target grayscale feature parameter and the preset grayscale threshold is calculated to determine the grayscale deviation and match the target deviation range of the grayscale deviation. According to the target adjustment strategy bound to the target deviation range, the preset basic adjustment coefficient is adjusted to generate the target adjustment coefficient; Multiply the target adjustment coefficient by the grayscale deviation to determine the initial light source adjustment amount; If the initial light source adjustment amount does not exceed the preset adjustment limit, then the initial light source adjustment amount is determined as the target light source adjustment amount; If the initial light source adjustment exceeds the preset adjustment limit, then the preset adjustment limit is determined as the target light source adjustment.
[0015] In some embodiments, after performing the step of adjusting the light source illumination parameters based on the target light source adjustment amount by the target light source controller and outputting a light source brightness that matches the adjusted light source illumination parameters, the method includes: Obtain the adjusted feedback image dataset of the workpiece under test; Perform grayscale analysis on the adjusted feedback image dataset to generate adjusted grayscale feature parameters and calculate the adjusted grayscale deviation between the adjusted grayscale feature parameters and the preset grayscale threshold; If the adjusted grayscale deviation is less than the preset dead zone threshold, then the light source adjustment is determined to be complete; If the adjusted grayscale deviation is greater than the preset dead zone threshold, then the current iteration number is incremented; If the current iteration number is less than or equal to a preset threshold number, then the adjusted feedback image dataset is used as a new multi-channel image dataset. Jump to execute the step of performing grayscale analysis on the multi-channel image dataset and generating target grayscale feature parameters until the adjusted grayscale deviation is less than the preset dead zone threshold or the current iteration number is greater than the preset number threshold. If the current iteration count is greater than a preset threshold, an adjustment failure alarm will be triggered.
[0016] Secondly, the present invention provides an automatic light source adjustment device based on image grayscale analysis, used to execute the above-mentioned automatic light source adjustment method based on image grayscale analysis, comprising: The image acquisition module is used to acquire a multi-channel image dataset of the workpiece under test. The grayscale analysis module is used to perform grayscale analysis on the multi-channel image dataset and generate target grayscale feature parameters; The light source calibration module is used to perform light source parameter calibration based on the target grayscale feature parameters and the preset grayscale threshold, and to determine the target light source adjustment amount; The instruction generation module is used to generate light source control instructions based on the target light source adjustment amount and send them to the target light source controller; The light source adjustment module is used to adjust the light source lighting parameters based on the target light source adjustment amount by the target light source controller, and output the light source brightness that matches the adjusted light source lighting parameters.
[0017] As can be seen from the above technical solutions, the present invention has the following advantages: The present invention provides an automatic light source adjustment method and device based on image grayscale analysis, which acquires a multi-channel image dataset of the workpiece to be tested, and simultaneously acquires multiple workpiece images to provide comprehensive and objective sample data for brightness quantification analysis; by performing grayscale analysis on the multi-channel image dataset, target grayscale feature parameters are generated to realize the quantitative calculation of pixel grayscale, using objective values as the brightness evaluation standard to eliminate the subjective judgment bias of the human eye; based on the target grayscale feature parameters and the preset grayscale threshold, the light source parameter calibration is performed to determine the target light source adjustment amount, realizing the determination of the adjustment coefficient based on grayscale deviation, and improving the dimming accuracy; based on the target light source adjustment amount, a light source control command is generated and sent to the target light source controller to realize standardized output of light source control commands, realizing automated closed-loop control of the equipment, eliminating the need for repeated manual trial and error operations; the target light source controller adjusts the light source lighting parameters based on the target light source adjustment amount and outputs the light source brightness that matches the adjusted light source lighting parameters, dynamically adapting to changes in materials and environment, and stably maintaining standard imaging brightness. This invention enables fully automatic closed-loop dimming based on image grayscale quantitative analysis, eliminating the need for manual subjective adjustment and effectively improving the accuracy of light source brightness adjustment and detection consistency. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 A flowchart illustrating an automatic light source adjustment method based on image grayscale analysis provided in an embodiment of the present invention; Figure 2 This is a flowchart of peak detection performed on a grayscale histogram in an embodiment of the present invention; Figure 3 This is a flowchart of grayscale analysis of a single-frame sample image in an embodiment of the present invention; Figure 4 A schematic diagram of the layered architecture of an automatic light source adjustment method based on image grayscale analysis provided in an embodiment of the present invention; Figure 5 Another flowchart of an automatic light source adjustment method based on image grayscale analysis provided in an embodiment of the present invention; Figure 6 A schematic diagram of the partition layout of the automatic light source adjustment monitoring interface provided in an embodiment of the present invention; Figure 7A schematic diagram of the structure of an automatic light source adjustment device based on image grayscale analysis provided in an embodiment of the present invention; Figure 8 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0020] This invention provides an automatic light source adjustment method and apparatus based on image grayscale analysis to solve the technical problem of insufficient brightness adjustment accuracy due to the lack of grayscale quantitative basis in manual dimming.
[0021] To make the objectives, features, and advantages of this invention more apparent and understandable, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0022] Please see Figure 1 , Figure 1 An optional flowchart of an automatic light source adjustment method based on image grayscale analysis provided in an embodiment of the present invention includes steps 101 to 105.
[0023] Step 101: Obtain the multi-channel image dataset of the workpiece to be tested; The preset acquisition channel refers to the independent imaging channel configured in the image acquisition layer. In this embodiment, there are three types: A-side industrial camera channel, B-side industrial camera channel, and pinhole camera channel. Among them, the A-side industrial camera channel and the B-side industrial camera channel are double-sided imaging channels for electrodes, and the pinhole camera channel is used to assist in contour verification.
[0024] Multi-channel time-division stroboscopic acquisition refers to switching the stroboscopic light source of each channel in time-division manner, triggering the corresponding camera to expose and acquire images in time-division manner, avoiding cross-light interference caused by simultaneous exposure of multiple channels.
[0025] A multi-channel image dataset refers to an image set formed by summarizing multiple sample images acquired by each preset acquisition channel within a single automatic adjustment cycle. Each sample image corresponds to a complete image of the workpiece.
[0026] The image acquisition layer refers to a collection of hardware acquisition units, including an A-side industrial camera, a B-side industrial camera, a pinhole camera, a light source controller, and a matching strobe light source.
[0027] The contour-assisted sample image, a high-depth-of-field electrode boundary image acquired by the pointer hole camera, is only used to obtain the workpiece contour coordinates and provide a pixel segmentation benchmark for the grayscale images of side A and side B. It does not participate in the core dimming operations such as grayscale statistics, cropping mean filtering, and grayscale deviation calculation.
[0028] Optionally, the specific execution flow of step 101 is as follows: Based on the type of workpiece to be tested, the preset acquisition channel configuration is retrieved, and all acquisition channels of the industrial camera on side A, industrial camera on side B, and pinhole camera in the image acquisition layer are activated. The light source controller outputs a time-division flicker drive signal to sequentially trigger each preset acquisition channel to perform time-division flicker acquisition, and acquires multiple frame sample images of the workpiece under the corresponding channel. The multi-frame sample images acquired from each preset acquisition channel are aggregated and packaged into a complete multi-channel image dataset.
[0029] For example, in the scenario of double-sided inspection of lithium battery positive electrode sheet, after starting the automatic adjustment process, the image acquisition layer activates three preset acquisition channels: the industrial camera on side A, the industrial camera on side B, and the pinhole camera. Then, the light source controller outputs a strobe signal in a time-division manner to sequentially trigger the A-side camera to acquire 10 frames of front sample images of the electrode, the B-side camera to acquire 10 frames of back sample images of the electrode, and the pinhole camera to acquire 5 frames of auxiliary sample images of the electrode contour. All sample images acquired from the three channels are summarized and packaged to generate a multi-channel image dataset for this adjustment cycle. The multi-channel image dataset is then split and distributed: the 10 grayscale sample images from the A-side and the 10 grayscale sample images from the B-side are output to the grayscale analysis layer Gray Histogram Tool, and the 5 pinhole contour sample images are output to the region segmentation module to extract the electrode boundary coordinates for pixel division of the target detection area (such as the film area, the scribing area, etc.), without participating in grayscale statistics and light source adjustment calculation.
[0030] Step 102: Perform grayscale analysis on the multi-channel image dataset to generate target grayscale feature parameters; Optionally, step 102 includes the following sub-steps: Perform global grayscale statistics and regional grayscale statistics on each frame of sample image to generate grayscale feature parameters for each frame of sample image; Based on the grayscale feature parameters of each frame of sample images, a validity test is performed to select candidate sample images; Based on the electrode type of the workpiece under test and the grayscale feature parameters of all candidate sample images under each preset acquisition channel, a cropping mean filter is performed to generate the channel grayscale feature parameters of each preset acquisition channel. The grayscale feature parameters of all channels are fused and averaged to generate the target grayscale feature parameters.
[0031] The grayscale analysis layer refers to the algorithm processing unit equipped with the Gray Histogram Tool, which relies on the Halcon machine vision operator to realize the whole process of parsing the original image into grayscale feature parameters, including histogram statistics, smoothing and noise reduction, peak detection, and feature classification output functions.
[0032] The data processing layer refers to the computing unit that realizes multi-channel data fusion, cropping and mean filtering, and feature anomaly removal. It can calculate the grayscale difference between the front and back images and output alarm signals, and finally generate comprehensive grayscale feature values that can be used for light source control.
[0033] ROI (Region of Interest) refers to the image analysis range defined based on the workpiece shape and a preset detection area (example: select only the rectangular areas where the workpiece film area and the scribing line are located, and remove invalid background pixels), which can greatly reduce the interference of invalid data on grayscale statistics.
[0034] Mean cropping filtering refers to a statistical processing method that sorts the grayscale features of multiple frames of samples, removes extreme outliers at both ends, and then calculates the mean of the remaining valid data. It is used to eliminate parameter fluctuations caused by instantaneous imaging jitter and workpiece placement deviations.
[0035] Optionally, the specific execution flow of step 102 is as follows: Gray-scale layered parsing, specifically including: Single-frame image preprocessing: Convert single-frame image data into a Halcon-readable image format using BufferToIcon (buffer to image format conversion), delineate the Region of Interest (ROI) to lock the detection range; call the GrayHisto (grayscale histogram) operator to generate grayscale histograms for the corresponding regions, and statistically output five basic statistical measures: average grayscale, median grayscale, standard deviation, minimum grayscale, and maximum grayscale. Histogram smoothing and noise reduction: The window sliding smoothing algorithm is used to continuously filter the grayscale histogram to eliminate histogram spikes caused by sensor thermal noise and ambient light. Initial extraction of candidate peaks: Traverse all gray-level points in the gray-level histogram after smoothing and noise reduction, extract all local maxima as initial candidate peaks, and simultaneously record the four core parameters of each candidate peak: peak gray level, peak height, prominence, and signal-to-noise ratio. Scene-based feature segmentation: Based on the electrode type of the workpiece under test, the grayscale feature datasets of the separation film area and the scribing line are split into two independent categories. Peak filtering operations are then performed on the two types of features respectively. Multi-dimensional adaptive peak filtering, specifically including: Threshold pre-generation: Based on the mean and standard deviation obtained from the current histogram statistics, a peak value judgment threshold is generated according to a preset weighted conversion rule; a preset gray-scale difference threshold (fixed minimum gray-scale difference threshold) is retrieved. Perform a four-stage progressive screening: Initial height screening: Remove noise peaks with peak heights lower than the peak height threshold (adaptive minimum peak height threshold); Prominence screening: Remove smooth, invalid grayscale peaks with peak prominence less than the peak prominence threshold (adaptive prominence benchmark); Signal-to-noise ratio (SNR) screening: Remove unstable candidate peaks with peak SNR lower than the peak SNR threshold (adaptive minimum SNR threshold); Spacing screening: Sort all remaining candidate peaks in ascending order of peak grayscale, calculate the grayscale difference between adjacent candidate peaks group by group, and remove adjacent overlapping peaks with grayscale differences less than a preset grayscale difference threshold; Multi-channel data fusion specifically includes: Single-channel batch verification: Perform validity checks on the grayscale feature parameters of multiple consecutive frames of images output from the same preset acquisition channel, and remove abnormal candidate sample images caused by imaging blur or workpiece offset; Single-channel parameter optimization: Perform cropping mean filtering on the grayscale features of all valid samples in each preset acquisition channel, remove the first and last extreme outliers, and then calculate the mean to obtain the independent channel grayscale feature parameters of surface A and surface B. Double-sided difference verification: Compare the grayscale difference values of the grayscale feature parameters of the channels on sides A and B. If the grayscale difference value exceeds the preset difference threshold, an abnormal alarm signal is pushed to the host computer. Global feature fusion: Perform a fusion mean operation on the channel grayscale feature parameters of surfaces A and B that have passed the difference verification to generate target grayscale feature parameters for light source control.
[0036] In some embodiments, the above-mentioned global grayscale statistics and partitioned grayscale statistics for each frame of sample image to generate grayscale feature parameters for each frame of sample image includes: Perform global grayscale statistics on each frame of sample image to generate a global grayscale histogram for each frame of sample image. After smoothing and denoising the global grayscale histogram, peak detection is performed to filter out the global valid peaks and remove the pixel data corresponding to the global invalid peaks. Perform gray-level statistical calculations on the global gray-level histogram after removing invalid peaks, and solve for the global gray-level feature parameters that match the preset gray-level statistical indicators; Each frame of sample image is segmented into pixels according to the preset region division rules, and multiple target detection regions are divided within each frame of sample image. Perform partitioned grayscale statistics on each target detection area to generate a partitioned grayscale histogram for each target detection area; After smoothing and denoising the grayscale histogram of each partition, peak detection is performed to filter the valid peaks of the partitions and remove the pixel data corresponding to the invalid peaks of the partitions. Perform gray-level statistical calculations on the gray-level histograms of each partition after removing invalid peaks, and solve for the partition gray-level feature parameters that match the preset gray-level statistical indicators; The global grayscale feature parameters and the regional grayscale feature parameters of each frame sample image are integrated to generate the grayscale feature parameters of each frame sample image.
[0037] The global grayscale histogram is a statistical curve of the grayscale distribution of pixels across the entire field of view in a single frame of complete sample image. The horizontal axis represents the grayscale level, and the vertical axis represents the total number of pixels at the corresponding grayscale level. It is generated by the Gray Histogram Tool.
[0038] The partitioned grayscale histogram refers to the statistical curve of pixel grayscale distribution within independent target detection areas such as film areas and scribing areas after pixel region segmentation. It is only used to solve the partitioned grayscale features.
[0039] Smoothing and noise reduction refers to using window sliding mean filtering to smooth the original histogram, eliminating the tiny spikes and fluctuations caused by random pixel noise in industrial imaging.
[0040] Peak detection refers to taking the smoothed and denoised histogram as input, traversing all gray-level points to extract local maxima as candidate peaks, and generating an adaptive peak judgment threshold based on the histogram pixel mean and standard deviation quantization calculation according to the gray-level distribution weighted conversion rules. Through four constraints of minimum peak height, minimum prominence ratio, minimum signal-to-noise ratio, and minimum peak spacing, invalid peaks with noise, low stability, and adjacent overlap are filtered step by step, and the gray-level pixel intervals corresponding to the invalid peaks are identified and removed.
[0041] Global invalid peaks refer to candidate peaks corresponding to noise and lens stray light in the global grayscale histogram, and their associated pixels do not participate in the global grayscale statistical calculation.
[0042] Invalid peak values in a partition refer to interference peak values formed by background and edge stray light within the target detection area. The corresponding pixels are removed before partition grayscale statistics.
[0043] Preset grayscale statistical indicators refer to the pre-configured grayscale calculation benchmarks, including core statistical indicators such as average grayscale, median grayscale, grayscale standard deviation, and peak grayscale.
[0044] The target detection region refers to the effective imaging region divided by pixel region segmentation rules based on the electrode boundary coordinates provided by the pinhole camera contour image. In this embodiment, the target detection region includes at least two types: film region (coating imaging region) and scribing region (electrode edge boundary region).
[0045] Gray-scale feature parameters refer to the complete set of gray-scale indicators of a single frame sample image, which is composed of global gray-scale feature parameters and regional gray-scale feature parameters. They are used for subsequent cropping mean filtering, gray-scale difference fusion, and light source adjustment calculation.
[0046] For example, in step 102, global grayscale statistics and regional grayscale statistics are performed on each frame of sample images. The specific execution process is as follows: Global grayscale statistics and global grayscale feature solving include: Read the A-side sample image or B-side sample image of a single frame, traverse all pixels of the image to perform global grayscale statistics, and generate the global grayscale histogram of the corresponding frame sample image. Perform window smoothing and noise reduction on the global grayscale histogram to eliminate minute pixel noise; Peak detection is performed using the denoised global grayscale histogram as input: all grayscale points are traversed to extract local maxima as candidate peaks, and the peak grayscale, peak height, peak prominence, and peak signal-to-noise ratio of each candidate peak are recorded; the mean and standard deviation of the current histogram are calculated, and an adaptive peak judgment threshold is generated according to the grayscale distribution weighted conversion rule; noise, low prominence, low signal-to-noise ratio, and adjacent overlapping candidate peaks are filtered step by step in combination with the preset grayscale difference threshold; all pixel data corresponding to global invalid peaks are identified and removed to obtain a clean global grayscale histogram. Perform grayscale statistical calculations based on the cleaned global grayscale histogram to solve for global grayscale feature parameters that match the preset grayscale statistical indicators; Pixel region segmentation and partitioned grayscale statistics, including: The auxiliary image of the electrode contour output by the pinhole camera is retrieved, the electrode boundary coordinates are extracted based on the preset region division rules, and pixel region segmentation is performed on the single frame sample image to divide the target detection areas into two types: film area and scribing area. Perform partitioned grayscale statistics on the effective pixels within the film area and the scribing area respectively, and generate corresponding partitioned grayscale histograms for the film area and the scribing area. Partition peak detection and partition grayscale feature solving include: Perform window smoothing and noise reduction on the grayscale histogram of each partition separately; Peak detection is performed on each denoised partition grayscale histogram. The complete processing logic of global grayscale histogram peak detection is reused, including the adaptive peak determination threshold generation mechanism and the fourth-order progressive filtering rule. Pixel data corresponding to invalid peaks in the partition are removed to obtain the cleaned partition grayscale histogram. Perform gray-level statistical calculations based on the cleaned partition gray-level histogram to solve for the partition gray-level feature parameters that match the preset gray-level statistical index; Gray-scale feature parameter integration: Integrate the global gray-scale feature parameters, membrane-division gray-scale feature parameters, and scribing-division gray-scale feature parameters corresponding to a single frame sample image, and package them into a unified package to generate the complete gray-scale feature parameters of the sample image for that frame. Transmit the package to the data processing layer to perform subsequent cropping, mean filtering, and A / B surface data fusion operations.
[0047] In some embodiments, after smoothing and denoising the global grayscale histogram, peak detection is performed to filter out valid global peaks and remove pixel data in the grayscale range corresponding to invalid global peaks, including: Traverse all gray-level points in the global gray-level histogram after smoothing and denoising, extract all local maxima as candidate peaks, and record the peak gray level, peak height, peak prominence, and peak signal-to-noise ratio of each candidate peak. Statistical calculations are performed on the global pixel count of the global grayscale histogram after smoothing and noise reduction to solve for the histogram pixel mean and histogram pixel standard deviation; According to the preset grayscale distribution weighting conversion rules, the mean value of histogram pixels and the standard deviation of histogram pixels are quantized to generate peak value determination thresholds; peak value determination thresholds include peak height threshold, peak prominence threshold and peak signal-to-noise ratio threshold; Noise peaks whose peak height is less than the peak height threshold among all candidate peaks are marked as globally invalid peaks; Among all candidate peaks, smooth grayscale peaks with a peak prominence less than the peak prominence threshold are marked as globally invalid peaks; Unstable peaks with a peak signal-to-noise ratio (PSNR) less than the PSNR threshold among all candidate peaks are marked as globally invalid peaks. Mark all candidate peaks that were not marked as globally invalid peaks as globally valid peaks; Based on the peak gray level, all global effective peaks are sorted in ascending order, and the peak gray level difference between adjacent global effective peaks after sorting is calculated. Mark adjacent global valid peaks whose peak grayscale difference is less than a preset grayscale difference threshold as global invalid peaks; Remove the pixel data of each global invalid peak in the gray-level range of the global gray-level histogram after smoothing and noise reduction, and retain all global valid peaks after removal.
[0048] Local maximum (candidate peak) refers to the grayscale point whose vertical pixel count is higher than its left and right adjacent points after traversing all grayscale points on the horizontal axis of the histogram. These are unfiltered original peak candidate objects.
[0049] Peak grayscale (peak position) refers to the grayscale coordinate value corresponding to the candidate peak on the horizontal axis of the grayscale histogram. It is the core benchmark parameter for determining the horizontal distribution position of the peak and calculating the grayscale difference between adjacent peaks.
[0050] Peak prominence refers to the height difference between a candidate peak and its adjacent gray valleys, which is used to measure the prominence of the peak in the gray distribution. An adaptive prominence benchmark is provided as a judgment threshold.
[0051] Peak signal-to-noise ratio (PSNR) is the ratio of the signal strength of a candidate peak to the fluctuation amplitude of surrounding gray-scale noise. It is used to eliminate unstable peaks caused by imaging noise interference.
[0052] Peak determination threshold refers to a set of determination thresholds dynamically generated in real time based on the mean and standard deviation of the grayscale histogram of a single frame sample image. It includes an adaptive minimum peak height threshold, an adaptive salience benchmark, and an adaptive minimum signal-to-noise ratio threshold, which can adapt to grayscale distribution changes under different lighting conditions and different workpiece batches.
[0053] The preset grayscale difference threshold (fixed minimum peak spacing) refers to the lower limit of the grayscale difference between adjacent peaks that is pre-configured and used to filter out neighboring interference peaks that are too close or have overlapping features in the grayscale distribution.
[0054] The grayscale distribution weighted conversion rule refers to the preset quantization conversion rule (example: adaptive minimum peak height threshold = histogram mean + weight coefficient × histogram standard deviation), which dynamically converts the histogram mean and histogram standard deviation to generate a dynamic peak judgment threshold.
[0055] Specifically, refer to Figure 2 , Figure 2 This is an optional flowchart for performing peak detection on a grayscale histogram in an embodiment of the present invention. Figure 2 The document describes the hierarchical decision-making logic for the entire process of candidate peak selection, invalid peak removal, and valid peak confirmation after grayscale histogram smoothing. The specific execution flow is as follows: Candidate peak selection: The global grayscale histogram or the partition grayscale histogram after smoothing and noise reduction is used as the grayscale histogram to be analyzed. All grayscale points on the horizontal axis of the grayscale histogram to be analyzed are traversed, and all local maximum values are extracted as candidate peaks. The original feature parameters of peak grayscale, peak height, peak prominence, and peak signal-to-noise ratio corresponding to each candidate peak are recorded simultaneously. Histogram statistical operations: Perform global pixel count statistical operations on the smoothed and denoised grayscale histogram to obtain two types of statistical measures: histogram pixel mean and histogram pixel standard deviation; Peak determination threshold generation: According to the gray-scale distribution weighted conversion rule, quantization is performed based on the histogram pixel mean and histogram pixel standard deviation to dynamically generate an adaptive peak determination threshold. This peak determination threshold includes three types of dynamic benchmarks: peak height threshold, peak prominence threshold, and peak signal-to-noise ratio threshold. Candidate peak verification: A hierarchical progressive peak verification mechanism is set up, which marks all candidate peaks as invalid based on the generated peak judgment threshold, including: Candidate peaks with peak heights lower than the peak height threshold are marked as invalid peaks; Candidate peaks with a smooth grayscale intensity that is less than the peak intensity threshold are marked as invalid peaks; Unstable candidate peaks with a peak signal-to-noise ratio (PSNR) below the peak SNR threshold are marked as invalid peaks. Candidate peaks that were not marked as invalid peaks were uniformly marked as valid peaks. All valid peak values are arranged in ascending order of peak gray value, and the peak gray value difference between adjacent groups of valid peak values is calculated for each group after sorting. Adjacent valid peaks with a peak grayscale difference less than a preset grayscale difference threshold are marked as invalid peaks; Invalid peak removal: Identify the gray-level pixel data corresponding to all marked invalid peaks, remove these pixels from the global gray-level histogram after smoothing and noise reduction, and obtain the gray-level histogram after cleaning the interference pixels; Valid result output: Output the cleaned grayscale histogram and the feature parameters corresponding to each valid peak after removing invalid peaks, which are used for subsequent grayscale statistical calculations.
[0056] For example, a peak detection process is performed on the global grayscale histogram of a single-frame grayscale sample image of the A-side of the positive electrode of a lithium battery, as follows: After window smoothing and noise reduction using the Gray Histogram Tool, a global gray-level histogram is output. All gray-level points from 0 to 255 in the histogram are traversed, and 14 local maximum values are detected as candidate peaks. The peak gray level, peak height, peak prominence, and peak signal-to-noise ratio of each candidate peak are recorded in sequence. Statistical calculations were performed on the total pixel count of the histogram, and the mean pixel value of the histogram was 76 and the standard deviation of the histogram pixel value was 11.2. According to the grayscale distribution weighted conversion rule, substituting the preset weight coefficient n and the global pixel total amount correction coefficient K, quantization calculation is performed to generate three sets of adaptive peak determination thresholds, as follows: The base height threshold is calculated by superimposing the base mean of the histogram with n times the standard deviation. Then, the base height threshold is multiplied by the global pixel total correction coefficient K to complete the amplitude correction, resulting in a peak height threshold of 420. The peak prominence threshold is set to a preset fixed ratio coefficient of 0.15, which is the height matching of the maximum pixel statistics of the global histogram. The grayscale fluctuation coefficient is calculated based on the histogram pixel mean and standard deviation. Combined with the preset basic signal-to-noise ratio benchmark and noise safety margin correction, the peak signal-to-noise ratio threshold of 3.8 is obtained. Retrieve the preset grayscale difference threshold of 12; Invalid peak values are marked level by level: Six noise peaks with a peak height less than 420 were removed and marked as globally invalid peaks; Of the remaining 8 candidate peaks, 2 peaks have a prominence of less than 0.15 and are marked as globally invalid peaks. The peak prominence is calculated as follows: obtain the pixel counts of the gray valleys to the left and right of the candidate peak, take the minimum pixel count of the valleys on both sides, calculate the difference between the peak height and the minimum value to obtain the absolute prominence height, and divide the absolute prominence height by the global maximum pixel statistical height of the histogram to obtain the peak prominence. Of the remaining 6 candidate peaks, 1 has a signal-to-noise ratio of only 3.1, which is lower than the benchmark of 3.8, and is marked as a globally invalid peak. The remaining 3 unlabeled candidate peaks are labeled as globally valid peaks, with gray levels of 72, 80, and 95 respectively. The three global effective peaks are sorted in ascending order of peak gray level, and the gray level difference between adjacent peaks is calculated in turn: the gray level difference between 72 and 80 is 8, and the gray level difference between 80 and 95 is 15. If the grayscale difference 8 is less than the preset grayscale difference threshold 12, the two adjacent peaks corresponding to grayscale positions 72 and 80 will be marked as global invalid peaks, and only the single global valid peak corresponding to peak grayscale 95 will be retained. Identify all grayscale pixels corresponding to the marked global invalid peaks and remove them from the histogram to obtain a clean global grayscale histogram after cleaning up noise and clutter pixels. Simultaneously output the global valid peak with a peak grayscale of 95 and all its peak feature parameters for subsequent global average grayscale and grayscale fluctuation index statistical calculations.
[0057] In some embodiments, the above-mentioned validity check based on the grayscale feature parameters of each frame sample image to filter out candidate sample images includes: Extract all global peak gray levels and all regional peak gray levels of each frame of sample images from the gray-level feature parameters of each frame of sample images; If either the total global peak gray level or the total partition peak gray level is greater than the preset peak gray level threshold, the corresponding frame sample image will be removed. If all global peak grayscale values and all partition peak grayscale values are less than or equal to the preset peak grayscale threshold, then the corresponding frame sample image is determined as a candidate sample image.
[0058] Global effective peaks refer to the true gray-level extreme values that are retained without overlap or noise interference after the global gray-level histogram has been filtered by four factors: height, prominence, signal-to-noise ratio, and gray-level difference. A single global gray-level histogram can retain one or more global effective peaks.
[0059] The total global peak grayscale refers to the set of values formed by the horizontal axis grayscale coordinates corresponding to all global effective peaks in a single frame image, used to characterize the grayscale range enriched by all pixels in the entire image.
[0060] The effective peak value of a partition refers to the effective gray-level extreme value retained by the partition gray-level histogram of a single target detection area after a unified adaptive peak value filtering logic; a single partition gray-level histogram may have one or more effective peak values.
[0061] The peak grayscale of all partitions refers to the complete set of grayscale values obtained by extracting the grayscale coordinates of all effective peak values in each partition of the image (e.g., membrane area, scribing area) and integrating them.
[0062] The preset peak grayscale threshold refers to a fixed upper limit constant of grayscale that is fixed in the configuration at the factory stage of the equipment. It is not dynamically adjusted with the mean and standard deviation of the histogram. It is used to identify grayscale saturation distortion caused by camera overexposure, excessive light source brightness, and strong reflection of workpiece.
[0063] For example, the validity verification of each frame of sample images of side A of the positive electrode of a lithium battery is performed, and the specific execution process is as follows: Equipment preset parameter configuration: factory-preset peak grayscale threshold of 240; single frame sample image is divided into two target detection areas, film area and scribing area, based on preset region division rules; Verification of qualified samples (such as the 5th frame sample image): Extract all global peak grayscale sets {74,92}, membrane regional peak grayscale sets {78}, and scribing regional peak grayscale sets {41,46} from the grayscale feature parameters of the 5th frame sample image; integrate them to obtain all peak grayscale values of the sample image participating in the verification: 74, 92, 78, 41, 46; Compare each of the above peak grayscale values with the preset peak grayscale threshold of 240. If all values are less than 240, there are no grayscale items exceeding the threshold. It is determined that the frame image has no grayscale saturation distortion. The frame sample image is marked as a candidate sample image and stored in the A-side channel candidate sample dataset. Validation of abnormal distortion samples (e.g., the 14th frame sample image): Extract all global peak grayscale sets {71, 88}, membrane region peak grayscale sets {247}, and scribe line region peak grayscale sets {43, 49} from the grayscale feature parameters of the 14th frame sample image; integrate them to obtain all peak grayscale values of the sample image participating in the validation: 71, 88, 43, 49, 247; The peak gray level of the membrane area is 247, which is greater than the preset peak gray level threshold of 240. It is determined that the frame is overexposed due to the ring light source, resulting in gray level saturation of the membrane area pixels and loss of imaging details. The 14th frame sample image is directly removed and not included in the subsequent channel mean filtering and A / B double-sided gray level fusion calculation. Batch screening results: 20 frames of polarimetric sample images were continuously acquired in the A-side channel. After the validity test was completed, 3 frames of saturated distortion images with peak grayscale exceeding the threshold were removed, and the remaining 17 frames were all marked as candidate sample images.
[0064] In some embodiments, the above-mentioned cropping mean filtering is performed based on the electrode type of the workpiece under test and the grayscale feature parameters of all candidate sample images under each preset acquisition channel to generate channel grayscale feature parameters for each preset acquisition channel, including: Extract candidate grayscale feature parameters that match the electrode type of the workpiece under test from the grayscale feature parameters of each candidate sample image; Integrate all candidate grayscale feature parameters belonging to the same preset acquisition channel to generate grayscale feature parameter groups corresponding to each preset acquisition channel; After sorting the grayscale feature parameters in ascending order, the extreme values at both ends of each grayscale feature parameter group are removed according to the preset cropping ratio. The average value of each grayscale feature parameter group after cropping is calculated to determine the comprehensive grayscale feature value of each grayscale feature parameter group. The comprehensive grayscale feature value is then used as the channel grayscale feature parameter of the corresponding preset acquisition channel.
[0065] The electrode type of the workpiece under test refers to the workpiece electrode polarity classification identifier (example: positive electrode, negative electrode), which is used to filter effective grayscale features that match the current electrode polarity and filter irrelevant interfering feature data that do not match the electrode polarity.
[0066] Candidate grayscale feature parameters refer to grayscale indices (such as global average grayscale or film area average grayscale) that are selected from the grayscale feature parameters of single-frame candidate samples and match the polarity of the electrode of the workpiece to be tested.
[0067] The preset cropping ratio refers to the factory-fixed extreme value rejection ratio constant (example: 15% of samples are cropped at the beginning and end), which is used to remove extreme abnormal grayscale features within the group and eliminate numerical drift caused by instantaneous imaging jitter and workpiece placement offset.
[0068] The extreme values at both ends refer to the smallest gray-scale feature sample at the front end of the group and the largest gray-scale feature sample at the back end of the group after the gray-scale feature parameters are sorted in ascending order according to a preset cropping ratio. These samples correspond to distorted data caused by severe imaging shift and temporary stray light interference.
[0069] The comprehensive grayscale feature value refers to the arithmetic mean of the remaining valid candidate grayscale feature parameters after removing extreme value samples, representing the standard imaging grayscale level of the workpiece under this acquisition channel.
[0070] For example, the specific execution flow of the above steps is as follows: Feature filtering: Read the grayscale feature parameters of candidate sample images obtained through validity checks from all preset acquisition channels (example: A-side acquisition channel, B-side acquisition channel), and extract candidate grayscale feature parameters based on the electrode polarity of the workpiece to be tested, as follows: If the electrode type of the workpiece to be tested is a positive electrode, the average gray level of the film area of each frame of sample image output by the partitioned gray level statistics is selected as the candidate gray level feature parameter. If the electrode type of the workpiece to be tested is a negative electrode, the global average gray level of each frame of sample images output by global gray level statistics is selected as the candidate gray level feature parameter. Channel grouping and aggregation: Data is grouped and aggregated according to the preset acquisition channel dimensions. All candidate grayscale feature parameters of the same acquisition channel are integrated to generate grayscale feature parameter groups that are independent of each preset acquisition channel. The data in each group is isolated and statistical operations are performed independently. Grouped extreme value clipping processing includes: All candidate grayscale feature parameters within each grayscale feature parameter group are sorted in ascending order of numerical value. According to the preset cropping ratio (e.g., cropping 15% of the samples at the beginning and end of each sorted gray-scale feature parameter group), the extreme value samples at the front and back ends of each sorted gray-scale feature parameter group are extracted and removed, and only the gray-scale feature data in the stable interval in the middle of the group is retained to generate the cropped feature subset. Channel grayscale feature parameter solution: Perform an arithmetic mean operation on the cropped feature subset to solve the comprehensive grayscale feature value of the corresponding grayscale feature parameter group; determine the comprehensive grayscale feature value as the channel grayscale feature parameter of the corresponding preset acquisition channel, and output it to the downstream global data fusion process.
[0071] In some embodiments, the above-mentioned fusion and averaging of all channel grayscale feature parameters to generate target grayscale feature parameters includes: Iterate through all channel grayscale feature parameters and calculate the grayscale difference between any two channel grayscale feature parameters. If all grayscale differences are less than or equal to the preset difference threshold, then the average of all channel grayscale feature parameters is calculated to generate the target grayscale feature parameters. If any grayscale difference is greater than the preset difference threshold, the preset grayscale threshold will be used as the target grayscale feature parameter.
[0072] Specifically, the execution flow of the above steps is as follows: Iterate through all channel grayscale feature parameters, pair them up and calculate the grayscale difference between channel grayscale feature parameters, and all grayscale differences are absolute values of the differences. The calculated grayscale differences are compared item by item with the preset difference threshold, as follows: Judgment Branch 1: If all grayscale differences are less than or equal to the preset difference threshold, it means that the grayscale consistency of each acquisition channel is good. The arithmetic mean of the grayscale feature parameters of all channels is calculated, and the calculated average value is used as the target grayscale feature parameter. Judgment Branch 2: If any grayscale difference value is greater than the preset difference threshold, it means that the brightness and darkness of the dual-channel imaging are seriously offset and the grayscale data do not meet the fusion conditions. The preset grayscale threshold is directly determined as the target grayscale feature parameter. The target grayscale feature parameters are output to the light source parameter calibration process to calculate grayscale deviation and drive the single light source controller to complete brightness compensation.
[0073] In some embodiments, refer to Figure 3 , Figure 3 This is an optional flowchart for grayscale analysis of a single-frame sample image in this embodiment of the invention. It records the entire grayscale analysis operation logic from the original image data to the standardized candidate grayscale feature parameter group, corresponding to the complete execution flow of the grayscale analysis layer. Based on the difference in electrode polarity of the workpiece under test, effective grayscale indicators are screened, and single-indicator candidate grayscale feature parameters adapted to the positive and negative electrodes are output. This provides the original grayscale data source for subsequent data processing layer processes such as cropping, mean filtering, and multi-channel grayscale fusion. The specific execution flow is as follows: Acquire raw image data: Acquire the raw imaging pixel data corresponding to the single-frame sample image captured by the A-side channel industrial camera or the B-side channel industrial camera, which serves as the input data source for this grayscale analysis process; Buffer to Image Conversion: This function standardizes the input raw image data stream and outputs a standard image matrix that can be parsed by the algorithm, eliminating compatibility differences between hardware image buffer formats and grayscale operation tool input formats. Setting the ROI region: Delineate the effective target detection region in the standard image matrix, remove invalid background pixels, and retain only the effective imaging regions of the pole coating and scribing to generate the ROI effective pixel matrix for grayscale statistics, thereby reducing the interference of invalid pixels on grayscale feature calculation; Gray-level histogram generation: Perform frequency statistics on pixel gray-level distribution of the effective pixel matrix of ROI to generate a partition gray-level distribution histogram, which provides basic distribution data for subsequent statistical calculation, smoothing and noise reduction, and peak identification; at the same time, perform global gray-level statistics on all pixels of the image to generate a global gray-level histogram of the corresponding frame sample image. Histogram smoothing: Denoising and smoothing operations are performed on the global grayscale histogram and the regional grayscale histogram respectively to filter out grayscale distribution spikes caused by imaging noise, improve the stability of subsequent peak detection results, and reduce the probability of false identification of noise peaks. Peak detection: Peak detection is performed on the global grayscale histogram and the partition grayscale histogram respectively to identify the effective peaks in the global grayscale histogram and the partition grayscale histogram. The peak position, peak height, prominence and signal-to-noise ratio of each effective peak are output simultaneously, as well as the global grayscale histogram and the partition grayscale histogram after removing invalid peaks. Gray-level histogram statistics: Traverse the gray-level distribution data of the global gray-level histogram and the partition gray-level histogram after removing invalid peaks, solve for four types of global gray-level statistical indicators, and output four basic statistical quantities in parallel: average gray level, median gray level, gray level standard deviation, minimum / maximum gray level, to obtain the global gray-level feature parameters corresponding to the global gray-level histogram and the partition gray-level feature parameters corresponding to the partition gray-level histogram; Electrode type determination: Based on the electrode polarity of the workpiece under test, a differentiated grayscale index screening is performed, divided into two independent branches: positive electrode and negative electrode. Positive electrode branch: Extract the average gray level of the film region from the gray level feature parameters of the partitioned region; Negative electrode branch: Extract the global average gray level from global gray level feature parameters; Gray-scale feature output: Based on the gray-scale features obtained after electrode type screening, a gray-scale feature parameter group is constructed and output to the downstream data processing layer; End: This is the termination node of the single-frame image grayscale feature extraction process, waiting for the next frame of raw image data to enter the above loop operation.
[0074] Step 103: Based on the target grayscale feature parameters and the preset grayscale threshold, perform light source parameter calibration to determine the target light source adjustment amount; Optionally, step 103 includes the following sub-steps: The difference between the target grayscale feature parameters and the preset grayscale threshold is calculated to determine the grayscale deviation and match the target deviation range of the grayscale deviation. According to the target adjustment strategy bound to the target deviation range, the preset basic adjustment coefficient is adjusted to generate the target adjustment coefficient; Multiply the target adjustment coefficient by the grayscale deviation to determine the initial light source adjustment amount; If the initial light source adjustment amount does not exceed the preset adjustment limit, then the initial light source adjustment amount is determined as the target light source adjustment amount; If the initial light source adjustment exceeds the preset adjustment limit, then the preset adjustment limit will be set as the target light source adjustment.
[0075] The deviation range refers to the pre-divided grayscale deviation value segment range (example: deviation range 1: 0~10, deviation range 2: 10~20, deviation range 3: >20), and different deviation ranges are associated with different adjustment strategies.
[0076] The target adjustment strategy refers to the coefficient scaling rules that are bound one-to-one with each target deviation range. For example, if the grayscale deviation is ≤10, the coefficient scaling is 1 / 5; if the grayscale deviation is 10 < ≤20, the coefficient is halved; if the deviation is >20, the preset base adjustment coefficient is used to adapt to the dimming convergence requirements of different deviation levels.
[0077] The preset base adjustment coefficient refers to the fixed base dimming ratio constant, which is the reference coefficient for calculating the light source adjustment amount and has not been corrected for intervals.
[0078] The initial light source adjustment amount refers to the original dimming increment value obtained by multiplying the grayscale deviation by the target adjustment coefficient, without undergoing amplitude limiting constraint processing.
[0079] The preset adjustment upper limit refers to the fixed maximum adjustable amplitude constant of a single-step light source (adjustment increment limit threshold), which is used to limit the dimming amplitude of a single dimming and prevent drastic changes in the brightness of the light source.
[0080] The target light source adjustment amount refers to the dimming increment value output after the incremental limiting verification is completed, which is used to send to the single light source controller to perform brightness adjustment.
[0081] Light source parameter calibration refers to the entire quantization calculation process based on the degree of grayscale deviation, which dynamically corrects the adjustment coefficient and limits the output to stabilize the dimming value. It also undertakes the multi-channel grayscale fusion process.
[0082] For example, regarding the calibration of light source parameters for lithium battery electrode sheets, assuming the preset parameters include a preset grayscale threshold of 130, a preset basic adjustment coefficient of 10, and a preset adjustment upper limit of 8, the specific execution flow of step 103 is as follows: Preprocessing output data: After cropping and mean filtering of candidate samples from multiple acquisition channels and mean calculation of gray-level feature fusion from multiple channels, the target gray-level feature parameters of the multi-channel image dataset are 136. Gray-scale deviation and deviation range matching: Gray-scale deviation = |136-130| = 6, the value 6 matches the target deviation range of 0~10; Adaptive coefficient adjustment: The target adjustment strategy for the target deviation range of 0~10 is a scaling factor of 1 / 5. The target adjustment factor is calculated as: 10×(1 / 5)=2. Calculate the initial light source adjustment increment: The initial light source adjustment increment is: 6 × 2 = 12; Limiting verification judgment: If the initial adjustment increment 12 is greater than the preset adjustment limit 8, the adjustment increment limiting logic is triggered, and the preset adjustment limit 8 is determined as the target light source adjustment increment.
[0083] Step 104: Based on the target light source adjustment amount, generate a light source control command and send it to the target light source controller; Light source control commands refer to standardized digital command data packets encapsulated according to the communication protocol of the light source controller. The data packets contain two core fields: adjustment direction and target light source adjustment amount, which are used to transmit dimming requirements to the hardware control unit.
[0084] The adjustment direction indicator refers to the attribute field in the light source control command, which is determined based on the relationship between the target grayscale feature parameter and the preset grayscale threshold. When the target grayscale feature parameter is larger, a brightness increase indicator is generated, and when the target grayscale feature parameter is smaller, a brightness decrease indicator is generated.
[0085] The target light source controller refers to the light source driving hardware unit (single light source architecture). After receiving the light source control command, it synchronously completes the brightness adjustment of the imaging light source and serves as the unified brightness adjustment execution component for the entire detection system.
[0086] Optionally, step 104 generates standardized light source control commands based on the target light source adjustment increment and sends them to the target light source controller. The specific execution process is as follows: Adjustment direction determination: retrieve the target grayscale feature parameters and preset grayscale threshold obtained from the previous process, compare the two values, and determine the light source adjustment direction indicator; If the target grayscale feature parameter is greater than the preset grayscale threshold, the current image is determined to be too bright, and a brightness reduction indicator is generated. If the target grayscale feature parameter is less than the preset grayscale threshold, the current image is determined to be too dark, and a brightness increase indicator is generated. Encapsulate the light source control instruction data packet: using the target light source adjustment amount as the numerical field and the matching adjustment direction identifier as the attribute field, encapsulate according to the communication protocol format matched by the target light source controller to generate the light source control instruction; Command transmission: The packaged light source control commands are sent to the target light source controller via a pre-set industrial communication link.
[0087] Step 105: Adjust the light source lighting parameters based on the target light source adjustment amount using the target light source controller, and output the light source brightness that matches the adjusted light source lighting parameters.
[0088] Light source illumination parameters refer to the standardized numerical parameters (e.g., light source drive duty cycle, current output level) stored inside the target light source controller and used to control the output power of the light source. The magnitude of the parameter values directly determines the light intensity of the light source and is the underlying control variable for brightness adjustment.
[0089] Light source brightness refers to the light intensity output by the target light source controller based on the currently effective light source lighting parameters. The grayscale of the image corresponds one-to-one with this brightness value, which is the final physical output result of light source adjustment.
[0090] Specifically, in step 105, the target light source controller corrects the light source illumination parameters based on the target light source adjustment amount and outputs the light source brightness that matches the adjusted light source illumination parameters. The specific execution process is as follows: Controller parameter reading: The target light source controller receives the light source control command sent from the upstream, parses the target light source adjustment amount and adjustment direction indicator carried in the command, and reads the original light source lighting parameters stored locally; Lighting parameter correction calculation: Based on the adjustment direction indicator, the original light source lighting parameters are updated using the target light source adjustment amount; If the instruction carries a brightness reduction indicator, the adjusted light source lighting parameters are obtained by subtracting the target light source adjustment increment from the original light source lighting parameters. If the instruction carries a brightness increase indicator, the adjusted light source lighting parameters are obtained by adding the target light source adjustment increment to the original light source lighting parameters; Parameter storage update: The target light source controller sets the adjusted light source lighting parameters as the currently effective driving parameters; Light source brightness output control: Based on the currently effective driving parameters, the target light source controller outputs a driving signal with corresponding power, and outputs a light source brightness that matches the value of the currently effective driving parameters, thus completing a single grayscale closed-loop correction.
[0091] In some embodiments, after performing step 105, the above-described automatic light source adjustment method based on image grayscale analysis further includes the following steps: Obtain the adjusted feedback image dataset of the workpiece under test; Perform grayscale analysis on the adjusted feedback image dataset, generate adjusted grayscale feature parameters, and calculate the adjusted grayscale deviation between the adjusted grayscale feature parameters and the preset grayscale threshold; If the adjusted grayscale deviation is less than the preset dead zone threshold, the light source adjustment is considered complete. If the adjusted grayscale deviation is greater than the preset dead zone threshold, then the current iteration count is incremented. If the current iteration number is less than or equal to the preset threshold number, the adjusted feedback image dataset will be used as the new multi-channel image dataset. Jump to execute the step of performing grayscale analysis on the multi-channel image dataset and generating target grayscale feature parameters until the grayscale deviation is adjusted to be less than the preset dead zone threshold or the current iteration number is greater than the preset number threshold. If the current iteration count exceeds the preset threshold, an adjustment failure alarm will be triggered.
[0092] The adjusted feedback image dataset refers to the set of images formed by the acquisition device re-acquiring all preset acquisition channels of the workpiece after the target light source controller completes the adjustment of the light source lighting parameters. It is used to provide feedback and verify the grayscale correction effect of this brightness adjustment and serves as the original input data for this closed-loop verification step.
[0093] The adjusted grayscale feature parameters refer to the unified grayscale reference parameters obtained after performing cropping mean filtering and multi-channel grayscale fusion mean processing on the adjusted feedback image dataset. The calculation logic is completely consistent with that of the target grayscale feature parameters mentioned above, and is used to quantify the actual imaging grayscale level after the adjustment is completed.
[0094] Adjusting grayscale deviation refers to the value obtained by calculating the absolute difference between the adjusted grayscale feature parameter and the preset grayscale threshold. It represents the degree of remaining deviation between the actual image grayscale and the standard reference grayscale after the light source adjustment is completed.
[0095] The preset dead zone threshold refers to the fixed grayscale deviation judgment constant (example: dead zone threshold 2), which is the boundary of the preset dead zone range. When the grayscale deviation value is adjusted to be less than this threshold, the deviation between the image grayscale and the standard reference grayscale is negligible, and no further light adjustment is required.
[0096] The iteration count refers to the number of times the automatic light source adjustment process completes a full cycle of grayscale analysis, parameter calibration, dimming command issuance, and hardware brightness adjustment. The iteration count is incremented by 1 for each complete closed-loop operation.
[0097] The adjustment failure alarm is an abnormal alarm signal triggered after the current iteration number exceeds the limit. It is used to prompt the operator that the grayscale adjustment of the light source cannot converge to the standard range.
[0098] The "dead zone too large" anomaly refers to a situation where the adjustment amount of the target light source in a single dimming operation is lower than the preset judgment threshold (e.g., 1 microsecond). This indicates that the grayscale deviation is extremely small but cannot converge, and the dead zone parameter configuration is unreasonable, so an abnormal alarm is directly output.
[0099] Optionally, after performing step 105, the closed-loop iterative verification process for light source adjustment is initiated, including the following steps: Acquire feedback images: Reacquire the imaging images of all preset acquisition channels of the workpiece under test, and integrate them to generate an adjusted feedback image dataset; Gray-scale analysis and deviation recalculation: Perform a complete gray-scale analysis process on the adjusted feedback image dataset to generate adjusted gray-scale feature parameters; calculate the difference between the adjusted gray-scale feature parameters and the preset gray-scale threshold to obtain the adjusted gray-scale deviation; synchronously read the target light source adjustment amount of this closed-loop operation and perform incremental anomaly verification, including: If the target light source adjustment amount is less than the preset judgment threshold (e.g., 1 microsecond), the dead zone is judged to be too large and an abnormality is triggered directly, and the current automatic light source adjustment process is terminated. Dead zone convergence determination: The adjusted grayscale deviation is numerically compared with the preset dead zone threshold; If the grayscale deviation is less than the preset dead zone threshold, it means that the current image grayscale has fallen into the allowable deviation range, and the light source adjustment is directly determined to be complete, ending all dimming cycles; If the grayscale deviation is greater than the preset dead zone threshold, it means that the current image grayscale does not meet the standard, and the iteration count is incremented by 1. Iteration count exceeding limit determination: Compare the accumulated current iteration count with a preset threshold (e.g., 20 times); If the current iteration number is less than or equal to the preset threshold number, the adjusted feedback image dataset will be assigned to a new multi-channel image dataset, and the pre-processing steps of multi-channel image grayscale analysis and target grayscale feature parameter generation will be executed, restarting a complete dimming closed loop. If the current iteration count is greater than the preset threshold, it means that multiple cycles of dimming still cannot converge the grayscale deviation to the dead zone range, triggering an adjustment failure alarm and terminating the automatic light source adjustment process.
[0100] In some embodiments, refer to Figure 4 , Figure 4 This is a schematic diagram of an optional layered architecture for an automatic light source adjustment method based on image grayscale analysis provided in an embodiment of the present invention. The automatic light source adjustment system based on image grayscale analysis is divided into five independent business modules: image acquisition layer, grayscale analysis layer, data processing layer, adjustment control layer, and monitoring and display layer. Data flows unidirectionally between modules and the layers are decoupled. It fully supports the entire technical process described above, including cropping and mean filtering, multi-channel grayscale fusion, light source parameter calibration, and closed-loop iterative verification. The specific functions of each module are as follows: Image acquisition layer: Includes two types of preset acquisition channel cameras, A-side industrial camera and B-side industrial camera (example: A-side acquisition channel, B-side acquisition channel), pinhole camera, image acquisition card, RSee light source controller (single light source hardware driver unit, i.e. target light source controller), and light source; the image acquisition card synchronously acquires the raw image data output from the two industrial cameras as the raw data source for grayscale analysis of the entire system; the RSee light source controller receives adjustment commands to change the light source illumination parameters and outputs an imaging light source with matching brightness; Gray-scale analysis layer: The core operation unit is the Gray Histogram Tool, which receives the raw image data output from the image acquisition layer and sequentially performs gray-scale histogram calculation, histogram smoothing, peak detection, and statistical solution. The peak detection unit is used to distinguish significant peaks (such as the candidate peaks mentioned above) and noise peaks, filter valid candidate sample images, and output the gray-scale feature parameters of the valid candidate sample images. The data processing layer includes two core computational modules: cropping mean filtering and A / B surface data fusion. It receives grayscale feature parameters output from the grayscale analysis layer. The cropping mean filtering module is used to perform grouped extreme value removal and sub-item mean calculation, and outputs channel grayscale feature parameters for each preset acquisition channel. The A / B surface data fusion module is used to perform multi-channel grayscale difference verification and fusion mean calculation, and generate target grayscale feature parameters. Adjustment and control layer: The core thread is COM\LightThread (light source adjustment communication thread), which receives the target grayscale feature parameters output by the data processing layer. It has a built-in deviation calculation module, adaptive adjustment module, and incremental limiting module. The deviation calculation module solves the grayscale deviation and matches the target deviation range. The adaptive adjustment module corrects the preset basic adjustment coefficient according to the target adjustment strategy matched by the target deviation range. The incremental limiting module generates the initial light source adjustment increment based on the grayscale deviation and the corrected adjustment coefficient, performs limiting verification on the initial light source adjustment increment, outputs the target light source adjustment increment, encapsulates it into a light source control command, and sends it to the RSee light source controller. The monitoring and display layer includes the Light Auto Adjust Monitor Dialog (an interactive monitoring window for adaptive light source adjustment) and a real-time status display unit. The Light Auto Adjust Monitor Dialog synchronously collects all process calculation data (including all calculation data from the grayscale analysis layer, data processing layer, and adjustment control layer), iteration count, and alarm signals, and displays grayscale deviation, target light source adjustment increment, iteration count, and equipment abnormal alarm information in real time. The real-time status display unit visualizes the closed-loop verification results such as dead zone convergence status, iteration over-limit alarm, and dead zone too large alarm.
[0101] In some embodiments, refer to Figure 5 , Figure 5 Another optional flowchart for an automatic light source adjustment method based on image grayscale analysis provided in an embodiment of the present invention. Figure 5 This document fully documents the closed-loop iterative execution logic for automatic light source adjustment based on image grayscale analysis. It connects all technical steps, including image acquisition, grayscale statistics, multi-channel data fusion, adaptive adjustment coefficient calculation, dimming command issuance, dead zone convergence determination, iteration count control, and multi-branch anomaly alarms, to achieve automatic brightness correction closed-loop control for a single light source controller. The specific execution flow is as follows: Start Automatic Adjustment: The automatic light source adjustment process starts at the entry point, triggered by acquiring sufficient raw image data of the workpiece to be tested and starting the entire grayscale correction calculation chain. Sample quantity check: The sample quantity of the multi-channel image dataset of the workpiece to be tested is checked. If the sample quantity is less than the preset quantity threshold, it is judged as "no" and jumps to the step of continuing to collect data. After supplementing the image samples, the sample quantity check is re-entered. If the number of samples is equal to or greater than the preset number threshold, it is determined as "yes" and the A / B face data processing steps are executed. Continue collecting data: Supplement the collection of raw image datasets from each preset acquisition channel (including side A and side B) to expand the total sample size. After completing one round of supplementary collection, return to the step of starting automatic adjustment. A / B surface data processing: Perform grayscale analysis on the multi-channel image dataset and output the grayscale feature parameters of all candidate sample images under each preset acquisition channel; Cropping mean filtering: Based on the electrode type of the workpiece under test, the gray-level feature parameters of all candidate sample images under each preset acquisition channel are sequentially subjected to group extreme value elimination and sub-term mean operation to generate channel gray-level feature parameters of surface A and surface B respectively. A / B surface difference verification: Calculate the grayscale difference between the two sets of channel grayscale feature parameters and compare it with the preset difference threshold; If the grayscale difference is greater than the preset difference threshold, it is determined as "no" and jumps to the step of triggering an alarm, outputting a multi-channel imaging grayscale inconsistency abnormal alarm; If the grayscale difference is less than or equal to the preset difference threshold, it is determined as "yes". The average value of the grayscale feature parameters of the two channels is calculated as the target grayscale feature parameter, and the grayscale deviation calculation step is executed. Calculate grayscale deviation: Perform a difference calculation between the target grayscale feature parameters generated by fusion and the preset grayscale threshold to solve for the grayscale deviation, providing a basis for the matching of adaptive adjustment coefficients; Adjustment coefficient generation: Three deviation intervals are defined, and each deviation interval is bound to a differentiated coefficient adjustment strategy. The target deviation interval corresponding to the grayscale deviation is matched from the three deviation intervals. The preset basic adjustment coefficient is adjusted according to the coefficient adjustment strategy of the target deviation interval to generate the target adjustment coefficient. The deviation intervals and their coefficient adjustment strategies are as follows: If the deviation value is ≤10, a scaling strategy of 1 / 5 matching coefficient is adopted; If the deviation value is 10 < and the value is ≤ 20, the matching coefficient is halved for scaling. If the deviation value is greater than 20, the preset basic adjustment coefficient will be used directly. Adjustment increment limit: Multiply the grayscale deviation by the target adjustment coefficient to obtain the initial light source adjustment increment, compare it with the preset adjustment upper limit to complete the amplitude constraint, and output the target light source adjustment amount after limit; Issuing adjustment instructions: Standardized light source control instructions are encapsulated with the target light source adjustment increment as the core field and issued to the target light source controller; Closed-loop convergence determination: The adjusted grayscale deviation is compared with the preset dead zone threshold. If the adjusted grayscale deviation is less than the preset dead zone threshold, it is determined as "yes", indicating that the grayscale deviation falls within the allowable error range. The process then jumps to the step where the adjustment is completed and ends the current automatic adjustment cycle. If the adjusted grayscale deviation is greater than the preset dead zone threshold, it is determined as "No", and the step of checking the number of adjustments is executed. Adjustment count check: Compare the current iteration count with the preset count threshold. If the current iteration count is greater than the preset count threshold, it is judged as "No", indicating that multiple iterations still cannot converge, and jump to the step of triggering an alarm. If the current iteration count is less than or equal to the preset threshold, it is determined as "yes", and the step of accumulating the iteration count is executed; Iteration count increment: The current iteration count is incremented by 1, the adjusted feedback image dataset is used as the new multi-channel image dataset, and the process jumps to the upstream A / B plane data processing step to start a new round of complete grayscale adjustment iteration loop; Trigger alarm: Receive two types of abnormal operating conditions: dual-channel grayscale difference exceeding the limit and iteration number exceeding the limit, output alarm signal to the monitoring display layer and perform visual display; Adjustment complete: The process terminates at the point where the grayscale deviation converges to the dead zone range, marking the end of the closed loop of the single-workpiece light source automatic adjustment process.
[0102] In some embodiments, refer to Figure 6 , Figure 6 This is a schematic diagram of an optional partition layout for the automatic light source adjustment monitoring interface provided in an embodiment of the present invention. The automatic light source adjustment monitoring interface is divided into six functional partitions: status display area, grayscale data area, light source parameter area, adjustment progress area, control button area, and parameter configuration area. Each partition works together to complete the data visualization and human-computer interaction of the entire automatic light source adjustment process.
[0103] Specifically, the status display area contains two types of real-time information: adjustment status and alarm information. The adjustment status refers to the automatic adjustment operation status of the light source, including three status indicators: adjustment in progress, adjustment successful, and adjustment failed. It also provides synchronous feedback on process judgment results such as dead zone convergence, iteration exceeding limits, and excessive dead zone. The alarm information includes all abnormal alarm signals such as dual-channel grayscale difference exceeding limits, iteration count exceeding 20 times, and adjustment increment less than 1 microsecond. The fault type is presented visually, making it easy for operators to quickly locate the cause of adjustment failure.
[0104] The grayscale data area has grayscale data display function, with four grayscale display items set up: channel A1, channel A2, channel B1, and channel B2. Each channel grayscale display item synchronously displays the complete grayscale statistics of the corresponding preset acquisition channel, including the channel grayscale feature parameters obtained by the cropping mean filtering operation, the average grayscale of the membrane area under positive electrode conditions, and the original calculated values of the average grayscale of the scribe line. After the data from the four channels are aggregated, the A / B side data fusion operation is performed, and the target grayscale feature parameters generated by the multi-channel fusion are refreshed in real time in the partition, completely restoring the full grayscale statistics output by the A / B side data fusion and cropping mean filtering processes.
[0105] The light source parameter area has a light source parameter display function, with three groups of light source parameter display items set up: Channel 1, Channel 2, and Channel 3. Each group of light source parameter display items synchronously displays the light source lighting parameters, real-time output brightness values, and the target light source adjustment increment issued this time for the corresponding light source path. The light source lighting parameters stored locally in the RSee light source controller (RSee light source controller: single light source target light source controller) are read in real time and the real-time parameter values in each group of display items are continuously refreshed, intuitively presenting the hardware light source output benchmark after each target light source adjustment increment update, and fully reflecting the real-time driving status of each light source path.
[0106] The adjustment progress area has an adjustment progress display function, with three types of progress display items: sample count, adjustment times, and progress bar. The sample count displays the total number of valid candidate image samples that have been collected in real time, which is used for visualization of the number of samples to verify the previous sample count. The adjustment times are synchronized with the number of closed-loop iterations in real time, which intuitively presents the current dimming iteration round. The progress bar visualizes the overall completion progress of sample collection and iterative dimming, and fully reproduces the closed-loop process sample verification and iteration number control logic.
[0107] The control button area has control button functions and is configured with four types of operation controls: start, stop, reset, and apply. The start button triggers the entire automatic light source adjustment process; the stop button forcibly terminates the current iteration dimming cycle; the reset button clears the iteration count, cached grayscale features, historical alarm information, and resets all calculation caches; the apply button saves the currently effective light source lighting parameters to the local storage of the light source controller and uses them as new reference brightness parameters.
[0108] The parameter configuration area has parameter configuration functions, setting four types of parameter input items: initial light source value, target grayscale value, adjustment coefficient, and dead zone range; the initial light source value is used to preset the initial light source lighting parameters; the target grayscale value is the device dimming reference grayscale constant; the adjustment coefficient supports custom preset basic adjustment coefficients to adapt to different grayscale convergence speed requirements; the dead zone range corresponds to the preset dead zone threshold, and the allowable deviation range of grayscale convergence can be flexibly adjusted manually. After all configuration parameters are sent, they are synchronously updated to the adjustment control layer (light source adjustment communication thread) to participate in the calculation of grayscale deviation and target adjustment coefficient.
[0109] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0110] The automatic light source adjustment device based on image grayscale analysis provided in the embodiments of this application will be described below. The automatic light source adjustment device based on image grayscale analysis described below can be referred to in correspondence with the automatic light source adjustment method based on image grayscale analysis described above.
[0111] Reference Figure 7 , Figure 7 This is an optional structural diagram of an automatic light source adjustment device based on image grayscale analysis provided in an embodiment of the present invention. The device is used to execute the aforementioned automatic light source adjustment method based on image grayscale analysis, including: Image acquisition module 201 is used to acquire a multi-channel image dataset of the workpiece to be tested; Gray-scale analysis module 202 is used to perform gray-scale analysis on multi-channel image datasets and generate target gray-scale feature parameters; The light source calibration module 203 is used to perform light source parameter calibration based on the target gray-scale feature parameters and the preset gray-scale threshold, and to determine the target light source adjustment amount; The instruction generation module 204 is used to generate light source control instructions based on the target light source adjustment amount and send them to the target light source controller; The light source adjustment module 205 is used to adjust the light source lighting parameters based on the target light source adjustment amount by the target light source controller, and output the light source brightness that matches the adjusted light source lighting parameters.
[0112] In some embodiments, the grayscale analysis module 202 includes: The grayscale statistics unit is used to perform global grayscale statistics and partitioned grayscale statistics on each frame of sample image to generate grayscale feature parameters for each frame of sample image. The filtering and verification unit is used to perform validity checks based on the grayscale feature parameters of each frame of sample images and to filter out candidate sample images. The cropping and filtering unit is used to perform cropping mean filtering based on the electrode type of the workpiece under test and the gray-level feature parameters of all candidate sample images under each preset acquisition channel to generate channel gray-level feature parameters for each preset acquisition channel. The fusion averaging unit is used to perform fusion averaging on the grayscale feature parameters of all channels to generate the target grayscale feature parameters.
[0113] In some embodiments, the grayscale statistics unit is configured as follows: Perform global grayscale statistics on each frame of sample image to generate a global grayscale histogram for each frame of sample image. After smoothing and denoising the global grayscale histogram, peak detection is performed to filter out the global valid peaks and remove the pixel data corresponding to the global invalid peaks. Perform gray-level statistical calculations on the global gray-level histogram after removing invalid peaks, and solve for the global gray-level feature parameters that match the preset gray-level statistical indicators; Each frame of sample image is segmented into pixels according to the preset region division rules, and multiple target detection regions are divided within each frame of sample image. Perform partitioned grayscale statistics on each target detection area to generate a partitioned grayscale histogram for each target detection area; After smoothing and denoising the grayscale histogram of each partition, peak detection is performed to filter the valid peaks of the partitions and remove the pixel data corresponding to the invalid peaks of the partitions. Perform gray-level statistical calculations on the gray-level histograms of each partition after removing invalid peaks, and solve for the partition gray-level feature parameters that match the preset gray-level statistical indicators; Integrate the global grayscale feature parameters and the partition grayscale feature parameters of each frame of sample image to generate the grayscale feature parameters of each frame of sample image. After smoothing and denoising the global grayscale histogram, peak detection is performed to filter out valid global peaks and remove pixel data in the grayscale range corresponding to invalid global peaks, including: Traverse all gray-level points in the global gray-level histogram after smoothing and denoising, extract all local maxima as candidate peaks, and record the peak gray level, peak height, peak prominence, and peak signal-to-noise ratio of each candidate peak. Statistical calculations are performed on the global pixel count of the global grayscale histogram after smoothing and noise reduction to solve for the histogram pixel mean and histogram pixel standard deviation; According to the preset grayscale distribution weighting conversion rules, the mean value of histogram pixels and the standard deviation of histogram pixels are quantized to generate peak value determination thresholds; peak value determination thresholds include peak height threshold, peak prominence threshold and peak signal-to-noise ratio threshold; Noise peaks whose peak height is less than the peak height threshold among all candidate peaks are marked as globally invalid peaks; Among all candidate peaks, smooth grayscale peaks with a peak prominence less than the peak prominence threshold are marked as globally invalid peaks; Unstable peaks with a peak signal-to-noise ratio (PSNR) less than the PSNR threshold among all candidate peaks are marked as globally invalid peaks. Mark all candidate peaks that were not marked as globally invalid peaks as globally valid peaks; Based on the peak gray level, all global effective peaks are sorted in ascending order, and the peak gray level difference between adjacent global effective peaks after sorting is calculated. Mark adjacent global valid peaks whose peak grayscale difference is less than a preset grayscale difference threshold as global invalid peaks; Remove the pixel data of each global invalid peak in the gray-level range of the global gray-level histogram after smoothing and noise reduction, and retain all global valid peaks after removal.
[0114] In some embodiments, the filtering and verification unit is configured as follows: Extract all global peak gray levels and all regional peak gray levels of each frame of sample images from the gray-level feature parameters of each frame of sample images; If either the total global peak gray level or the total partition peak gray level is greater than the preset peak gray level threshold, the corresponding frame sample image will be removed. If all global peak grayscale values and all partition peak grayscale values are less than or equal to the preset peak grayscale threshold, then the corresponding frame sample image is determined as a candidate sample image.
[0115] In some embodiments, the clipping filter unit is configured as follows: Extract candidate grayscale feature parameters that match the electrode type of the workpiece under test from the grayscale feature parameters of each candidate sample image; Integrate all candidate grayscale feature parameters belonging to the same preset acquisition channel to generate grayscale feature parameter groups corresponding to each preset acquisition channel; After sorting the grayscale feature parameters in ascending order, the extreme values at both ends of each grayscale feature parameter group are removed according to the preset cropping ratio. The average value of each grayscale feature parameter group after cropping is calculated to determine the comprehensive grayscale feature value of each grayscale feature parameter group. The comprehensive grayscale feature value is then used as the channel grayscale feature parameter of the corresponding preset acquisition channel.
[0116] In some embodiments, the fusion mean unit is configured as follows: Iterate through all channel grayscale feature parameters and calculate the grayscale difference between any two channel grayscale feature parameters. If all grayscale differences are less than or equal to the preset difference threshold, then the average of all channel grayscale feature parameters is calculated to generate the target grayscale feature parameters. If any grayscale difference is greater than the preset difference threshold, the preset grayscale threshold will be used as the target grayscale feature parameter.
[0117] In some embodiments, the light source calibration module 203 is configured as follows: The difference between the target grayscale feature parameters and the preset grayscale threshold is calculated to determine the grayscale deviation and match the target deviation range of the grayscale deviation. According to the target adjustment strategy bound to the target deviation range, the preset basic adjustment coefficient is adjusted to generate the target adjustment coefficient; Multiply the target adjustment coefficient by the grayscale deviation to determine the initial light source adjustment amount; If the initial light source adjustment amount does not exceed the preset adjustment limit, then the initial light source adjustment amount is determined as the target light source adjustment amount; If the initial light source adjustment exceeds the preset adjustment limit, then the preset adjustment limit will be set as the target light source adjustment.
[0118] In some embodiments, the above-described automatic light source adjustment device based on image grayscale analysis further includes an iterative adjustment module, which is configured as follows: Obtain the adjusted feedback image dataset of the workpiece under test; Perform grayscale analysis on the adjusted feedback image dataset, generate adjusted grayscale feature parameters, and calculate the adjusted grayscale deviation between the adjusted grayscale feature parameters and the preset grayscale threshold; If the adjusted grayscale deviation is less than the preset dead zone threshold, the light source adjustment is considered complete. If the adjusted grayscale deviation is greater than the preset dead zone threshold, then the current iteration count is incremented. If the current iteration number is less than or equal to the preset threshold number, the adjusted feedback image dataset will be used as the new multi-channel image dataset. Jump to execute the step of performing grayscale analysis on the multi-channel image dataset and generating target grayscale feature parameters until the grayscale deviation is adjusted to be less than the preset dead zone threshold or the current iteration number is greater than the preset number threshold. If the current iteration count exceeds the preset threshold, an adjustment failure alarm will be triggered.
[0119] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described device and module can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0120] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.
[0121] The modules described as separate components may or may not be physically separate. Similarly, the components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0122] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.
[0123] If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0124] This invention also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described automatic light source adjustment method based on image grayscale analysis. This electronic device can be any smart terminal, including a tablet computer.
[0125] It is understood that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented by this device embodiment are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0126] Please see Figure 8 , Figure 8 The hardware structure of an electronic device according to another embodiment is illustrated, including: The processor 901 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present invention. The memory 902 can be implemented as a read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 902 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 902 and is called and executed by the processor 901 to execute the automatic light source adjustment method based on image grayscale analysis of the embodiments of this invention. The input / output interface 903 is used to implement information input and output; The communication interface 904 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.). Bus 905 transmits information between various components of the device (e.g., processor 901, memory 902, input / output interface 903, and communication interface 904); The processor 901, memory 902, input / output interface 903, and communication interface 904 are connected to each other within the device via bus 905.
[0127] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described automatic light source adjustment method based on image grayscale analysis.
[0128] It is understood that the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0129] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0130] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for automatic light source adjustment based on image grayscale analysis, characterized in that, include: Acquire a multi-channel image dataset of the workpiece to be tested; Perform grayscale analysis on the multi-channel image dataset to generate target grayscale feature parameters; Based on the target grayscale feature parameters and the preset grayscale threshold, perform light source parameter calibration to determine the target light source adjustment amount; Based on the target light source adjustment amount, a light source control command is generated and sent to the target light source controller; The target light source controller adjusts the light source illumination parameters based on the target light source adjustment amount and outputs a light source brightness that matches the adjusted light source illumination parameters.
2. The automatic light source adjustment method based on image grayscale analysis according to claim 1, characterized in that, The multi-channel image dataset includes multiple frames of sample images from each preset acquisition channel. The grayscale analysis of the multi-channel image dataset to generate target grayscale feature parameters includes: Perform global grayscale statistics and regional grayscale statistics on each frame of sample image to generate grayscale feature parameters for each frame of sample image; Based on the grayscale feature parameters of each frame of sample images, a validity test is performed to select candidate sample images; Based on the electrode type of the workpiece under test and the grayscale feature parameters of all candidate sample images under each preset acquisition channel, a cropping mean filter is performed to generate the channel grayscale feature parameters of each preset acquisition channel. The grayscale feature parameters of all the channels are fused and averaged to generate the target grayscale feature parameters.
3. The automatic light source adjustment method based on image grayscale analysis according to claim 2, characterized in that, The process of performing global grayscale statistics and partitioned grayscale statistics on each frame of sample image to generate grayscale feature parameters for each frame of sample image includes: Perform global grayscale statistics on each frame of sample image to generate a global grayscale histogram for each frame of sample image. After smoothing and denoising the global grayscale histogram, peak detection is performed to filter out the global valid peaks and remove the pixel data corresponding to the global invalid peaks. Perform gray-level statistical calculations on the global gray-level histogram after removing invalid peaks, and solve for the global gray-level feature parameters that match the preset gray-level statistical indicators; Each frame of sample image is segmented into pixels according to the preset region division rules, and multiple target detection regions are divided within each frame of sample image. Perform partitioned grayscale statistics on each of the target detection regions to generate a partitioned grayscale histogram for each of the target detection regions; After smoothing and denoising the grayscale histograms of each partition, peak detection is performed to filter the valid peaks of the partitions and remove the pixel data corresponding to the invalid peaks of the partitions. Perform gray-level statistical calculations on the gray-level histograms of each partition after removing invalid peaks, and solve for the partition gray-level feature parameters that match the preset gray-level statistical index; The global grayscale feature parameters and the partition grayscale feature parameters of each frame sample image are integrated to generate the grayscale feature parameters of each frame sample image.
4. The automatic light source adjustment method based on image grayscale analysis according to claim 3, characterized in that, The step of performing peak detection after smoothing and denoising the global grayscale histogram, filtering out global valid peaks and removing pixel data corresponding to global invalid peaks, includes: Traverse all gray-level points in the global gray-level histogram after smoothing and noise reduction, extract all local maximum values as candidate peaks, and record the peak gray level, peak height, peak prominence, and peak signal-to-noise ratio of each candidate peak. Statistical calculations are performed on the global pixel count of the global grayscale histogram after smoothing and noise reduction to solve for the histogram pixel mean and histogram pixel standard deviation; According to the preset grayscale distribution weighted conversion rules, the mean value of the histogram pixels and the standard deviation of the histogram pixels are quantized to generate a peak value determination threshold; the peak value determination threshold includes a peak height threshold, a peak prominence threshold and a peak signal-to-noise ratio threshold; Noise peaks whose peak height is less than the peak height threshold among all candidate peaks are marked as globally invalid peaks; Among all candidate peaks, smooth grayscale peaks whose peak prominence is less than the peak prominence threshold are marked as globally invalid peaks; Unstable peaks whose peak signal-to-noise ratio (SNR) is less than the threshold value are marked as globally invalid peaks. Mark all candidate peaks that were not marked as globally invalid peaks as globally valid peaks; According to the peak gray level, all global effective peaks are sorted in ascending order, and the peak gray level difference between adjacent global effective peaks after sorting is calculated. The adjacent global valid peaks whose peak grayscale difference is less than the preset grayscale difference threshold are marked as global invalid peaks; Remove the pixel data of the gray-level interval in the global gray-level histogram after smoothing and noise reduction of each of the aforementioned global invalid peaks, and retain all global valid peaks after removal.
5. The automatic light source adjustment method based on image grayscale analysis according to claim 2, characterized in that, The validity check is performed based on the grayscale feature parameters of each frame of sample images to filter out candidate sample images, including: Extract all global peak gray levels and all regional peak gray levels of each frame of sample images from the gray-level feature parameters of each frame of sample images; If either the total global peak gray level or the total partition peak gray level is greater than the preset peak gray level threshold, the corresponding frame sample image will be removed. If all global peak grayscale values and all partition peak grayscale values are less than or equal to the preset peak grayscale threshold, then the corresponding frame sample image is determined as a candidate sample image.
6. The automatic light source adjustment method based on image grayscale analysis according to claim 2, characterized in that, Based on the electrode type of the workpiece under test and the grayscale feature parameters of all candidate sample images under each preset acquisition channel, a cropping mean filter is performed to generate channel grayscale feature parameters for each preset acquisition channel, including: Extract candidate grayscale feature parameters that match the electrode type of the workpiece to be tested from the grayscale feature parameters of each candidate sample image; Integrate all candidate grayscale feature parameters belonging to the same preset acquisition channel to generate grayscale feature parameter groups corresponding to each preset acquisition channel; After sorting the grayscale feature parameter groups in ascending order, the extreme values at both ends of each grayscale feature parameter group are removed according to a preset cropping ratio. The average value of each grayscale feature parameter group after cropping is calculated to determine the comprehensive grayscale feature value of each grayscale feature parameter group, and the comprehensive grayscale feature value is used as the channel grayscale feature parameter of the corresponding preset acquisition channel.
7. The automatic light source adjustment method based on image grayscale analysis according to claim 2, characterized in that, The step of fusing and averaging all the grayscale feature parameters of the channels to generate target grayscale feature parameters includes: Iterate through all the grayscale feature parameters of the channels and calculate the grayscale difference between any two channels' grayscale feature parameters. If all the grayscale differences are less than or equal to the preset difference threshold, then the average of all the channel grayscale feature parameters is calculated to generate the target grayscale feature parameters. If any of the grayscale differences is greater than a preset difference threshold, then the preset grayscale threshold is used as the target grayscale feature parameter.
8. The automatic light source adjustment method based on image grayscale analysis according to claim 1, characterized in that, The step of performing light source parameter calibration and determining the target light source adjustment amount based on the target gray-scale feature parameters and a preset gray-scale threshold includes: The difference between the target grayscale feature parameter and the preset grayscale threshold is calculated to determine the grayscale deviation and match the target deviation range of the grayscale deviation. According to the target adjustment strategy bound to the target deviation range, the preset basic adjustment coefficient is adjusted to generate the target adjustment coefficient; Multiply the target adjustment coefficient by the grayscale deviation to determine the initial light source adjustment amount; If the initial light source adjustment amount does not exceed the preset adjustment limit, then the initial light source adjustment amount is determined as the target light source adjustment amount; If the initial light source adjustment exceeds the preset adjustment limit, then the preset adjustment limit is determined as the target light source adjustment.
9. The automatic light source adjustment method based on image grayscale analysis according to claim 1, characterized in that, After performing the step of adjusting the light source illumination parameters based on the target light source adjustment amount by the target light source controller and outputting a light source brightness that matches the adjusted light source illumination parameters, the process includes: Obtain the adjusted feedback image dataset of the workpiece under test; Perform grayscale analysis on the adjusted feedback image dataset to generate adjusted grayscale feature parameters and calculate the adjusted grayscale deviation between the adjusted grayscale feature parameters and the preset grayscale threshold; If the adjusted grayscale deviation is less than the preset dead zone threshold, then the light source adjustment is determined to be complete; If the adjusted grayscale deviation is greater than the preset dead zone threshold, then the current iteration number is incremented; If the current iteration number is less than or equal to a preset threshold number, then the adjusted feedback image dataset is used as a new multi-channel image dataset. Jump to execute the step of performing grayscale analysis on the multi-channel image dataset and generating target grayscale feature parameters until the adjusted grayscale deviation is less than the preset dead zone threshold or the current iteration number is greater than the preset number threshold. If the current iteration count is greater than a preset threshold, an adjustment failure alarm will be triggered.
10. An automatic light source adjustment device based on image grayscale analysis, characterized in that, The method for automatically adjusting a light source based on image grayscale analysis as described in any one of claims 1 to 9 includes: The image acquisition module is used to acquire a multi-channel image dataset of the workpiece under test. The grayscale analysis module is used to perform grayscale analysis on the multi-channel image dataset and generate target grayscale feature parameters; The light source calibration module is used to perform light source parameter calibration based on the target grayscale feature parameters and the preset grayscale threshold, and to determine the target light source adjustment amount; The instruction generation module is used to generate light source control instructions based on the target light source adjustment amount and send them to the target light source controller; The light source adjustment module is used to adjust the light source lighting parameters based on the target light source adjustment amount by the target light source controller, and output the light source brightness that matches the adjusted light source lighting parameters.