A capsule wall thickness online detection system and method
Through the combination of light correction, edge enhancement and wall thickness calculation modules, the problems of reduced imaging contrast caused by uneven light in traditional detection systems and insufficient analysis of wall thickness fluctuations in wall thickness are solved, and the accuracy and stability of capsule wall thickness detection are achieved, providing trend warning in the production process.
Patent Information
- Application Number
- CN202510453334.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-11
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2045-04-11
AI Technical Summary
When traditional capsule wall thickness online detection systems deal with the problem of uneven light, they lead to reduced imaging contrast and lower edge recognition accuracy, and cannot effectively analyze the wall thickness fluctuation trend, affecting the effectiveness of production adjustments, and lack accurate evaluation of the number of abnormal capsules, resulting in unreasonable early warning level setting.
The light gradient value is adjusted through the light correction module, the edge enhancement module enhances the edge contrast, the wall thickness calculation module screens the wall thickness boundary points, the abnormal trend analysis module analyzes the wall thickness fluctuation trend, and provides early warning signals with the early warning feedback module to ensure the accuracy and stability of wall thickness detection.
It improves the accuracy and stability of capsule wall thickness detection, identifys wall thickness instability problems in the production process in advance, provides trend warning capabilities, and improves the ability to respond to production abnormalities.
Smart Images

Figure CN120374704B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of wall thickness detection, and in particular to an online detection system and method for capsule wall thickness. Background Art
[0002] The field of wall thickness testing involves measuring the wall thickness of various materials or structural components to ensure that products meet design requirements and meet performance requirements. This technology is widely used in manufacturing, pharmaceutical packaging, aerospace, automotive, and other fields, covering a variety of materials such as metals, plastics, glass, and composites. Wall thickness testing methods include ultrasonic thickness measurement, optical measurement, X-ray fluoroscopy, laser scanning, and eddy current testing. The specific measurement method is selected based on material characteristics, accuracy requirements, and testing environment. The primary goals of this technology are to improve production quality, reduce material loss, and ensure product safety and stability during use.
[0003] Among them, the online capsule wall thickness detection system is used to monitor the wall thickness of the capsule shell in real time to ensure the consistency and stability of the capsule. Suitable for the pharmaceutical industry, this system can perform non-contact measurement of capsules during the production process, obtain accurate data on capsule wall thickness, and implement anomaly detection and quality control. The system typically integrates ultrasonic, optical, or laser thickness measurement technology, and uses automated control systems for data processing and feedback to optimize production parameters, improve capsule product qualification rate, and improve production efficiency.
[0004] Traditional detection systems fail to effectively deal with the problem of uneven lighting, resulting in reduced imaging contrast in some detection areas, affecting edge recognition accuracy, and thus reducing the accuracy of wall thickness measurement. Wall thickness calculation relies on fixed thresholds to determine boundary points, which cannot adapt to different lighting environments and the imaging characteristics of transparent capsules, and can easily lead to boundary misjudgment or omissions. In terms of abnormal trend analysis, it only relies on single measurement data for over-limit alarms, fails to comprehensively analyze the wall thickness fluctuation trend between batches, and is difficult to promptly detect deviations in capsule wall thickness during the production process, affecting the effectiveness of production adjustments. There is a lack of analysis of the proportion of abnormal capsules, and it is impossible to accurately assess the degree of batch abnormality, resulting in unreasonable warning level settings, which affects the judgment basis of managers. Summary of the Invention
[0005] The purpose of the present invention is to solve the shortcomings of the prior art and to propose an online detection system and method for capsule wall thickness.
[0006] In order to achieve the above object, the present invention adopts the following technical solution: an online detection system for capsule wall thickness, the system comprising:
[0007] The illumination correction module obtains the illumination gradient value of pixels in the capsule wall thickness detection area, analyzes and identifies areas with uneven illumination distribution, adjusts the pixel grayscale in areas with sudden illumination gradient changes, and obtains adjusted illumination distribution information;
[0008] The edge enhancement module calculates the gradient distribution range in the local area based on the adjusted illumination distribution information, performs dynamic adjustment on the gradient distribution range, adjusts the local contrast, and adjusts the grayscale difference between edge pixels to a set range to obtain edge contrast enhancement information;
[0009] The wall thickness calculation module calculates the gradient change rate of adjacent pixel points based on the edge contrast enhancement information, selects pixel points whose change rate reaches a set threshold as wall thickness boundary points, calls the pixel distance between the boundary points, calculates the wall thickness value, selects the wall thickness data that deviates from the set threshold, and marks and removes capsules to obtain abnormal wall thickness removal information;
[0010] Based on the wall thickness abnormality rejection information, the abnormal trend analysis module obtains the wall thickness value sequence of the capsule wall thickness detection batch, calculates the fluctuation degree of the wall thickness value, analyzes the changing trend of the wall thickness fluctuation, calls the set fluctuation threshold, marks the batches whose wall thickness fluctuation exceeds the threshold range, and obtains the wall thickness fluctuation trend information.
[0011] The present invention has improvements in that the adjusted illumination distribution information includes illumination gradient adjustment parameters, local grayscale compensation coefficients, illumination balance area division standards, and pixel grayscale dynamic adjustment values; the edge contrast enhancement information includes edge gradient direction distribution, local contrast enhancement coefficients, pixel grayscale differential calculation values, and edge area pixel adjustment parameters; the wall thickness anomaly rejection information includes wall thickness data mean deviation, wall thickness data standard deviation, wall thickness fluctuation range, and wall thickness anomaly point identification labels; and the wall thickness fluctuation trend information includes wall thickness fluctuation change rate, wall thickness fluctuation anomaly batch mark, wall thickness trend fluctuation amplitude, and wall thickness stability assessment coefficient.
[0012] The present invention is improved in that the illumination correction module includes:
[0013] The illumination gradient calculation submodule and the illumination correction module obtain the illumination gradient value of the pixels in the capsule wall thickness detection area, calculate the grayscale change between adjacent pixels, and obtain the illumination gradient value of the pixel;
[0014] The illumination gradient change analysis submodule calls the illumination gradient value of the pixel point, calculates the illumination gradient change between adjacent pixels, filters the illumination gradient change value, obtains the illumination gradient mutation area, and calculates the local grayscale mean and standard deviation based on the pixel distribution characteristics of the mutation area, using the formula:
[0015]
[0016] Calculate the change of the pixel points in the mutation area relative to the local grayscale mean and generate the distribution coefficient of the illumination mutation area;
[0017] Among them, D represents the regional distribution coefficient of light mutation, G i represents the illumination gradient of pixel i, μ represents the local grayscale mean, σ represents the local grayscale standard deviation, and ∈ is a stability constant;
[0018] The illumination distribution adjustment submodule calls the illumination mutation area distribution coefficient, adjusts the grayscale value of the pixel point in the illumination mutation area, adjusts the grayscale value to a weighted balance value of the local grayscale mean and the illumination gradient change, and obtains the adjusted illumination distribution information.
[0019] The present invention is improved in that the edge enhancement module includes:
[0020] The edge gradient calculation submodule extracts edge pixels within the capsule wall thickness detection imaging area based on the adjusted illumination distribution information, calculates the gradient direction of each edge pixel, calls the grayscale difference within the local window of the pixel point, obtains the local gradient distribution range, calculates the gradient direction change rate of the pixel point within the local window, and screens the edge gradient direction stable area based on the distribution characteristics of the gradient direction change rate to obtain the edge gradient direction stable interval;
[0021] The local contrast adjustment submodule calls the edge gradient direction stability interval, calculates the gradient amplitude mean change rate under multiple window scales, obtains the gradient dynamic distribution range of the current area, and calculates the contrast adjustment coefficient within the local window scale based on the gradient dynamic distribution range, using the formula:
[0022]
[0023] Calculating a local contrast adjustment value to obtain local contrast adjustment information;
[0024] Among them, C adj Represents the local contrast adjustment value, G C,j Represents the gradient magnitude of the pixel in the local window, G man Represents the mean gradient amplitude in the local window, G std Represents the standard deviation of the gradient amplitude in the local window, N represents the total number of pixels in the local window, max(G) represents the maximum gradient amplitude in the local window, and min(G) represents the minimum gradient amplitude in the local window;
[0025] The edge contrast modulation submodule calls the local contrast adjustment information, adjusts the contrast in the local window according to the grayscale difference between edge pixels, controls the grayscale difference between edge pixels to fall within a set range, calculates the edge gradient enhancement value of the adjusted area, and obtains edge contrast enhancement information.
[0026] The present invention is improved in that the wall thickness calculation module includes:
[0027] The edge pixel extraction submodule obtains the edge pixel point set within the capsule wall thickness detection area based on the edge contrast enhancement information, calls the pixel gradient data in the neighborhood window, calculates the gradient change rate of adjacent pixel points, screens the gradient change rate of adjacent pixel points, and extracts the pixel points whose change rate reaches the set threshold as the wall thickness boundary point to obtain capsule edge recognition information;
[0028] The wall thickness boundary calculation submodule calls the capsule edge identification information and uses the formula:
[0029]
[0030] Calculate and obtain the wall thickness value;
[0031] Where W represents the wall thickness value, m represents the matching number of wall thickness boundary points, (X L,k , Y L,k ) represents the coordinates of the left boundary point of the kth group, (X R,k , Y R,k ) represents the coordinates of the right boundary points of the kth group, S W Represents the physical size ratio corresponding to the pixel pitch;
[0032] The wall thickness abnormality rejection submodule compares the obtained wall thickness value with the set capsule wall thickness standard, screens the wall thickness that deviates from the set threshold, marks and rejects the capsules, and obtains wall thickness abnormality rejection information.
[0033] The present invention is improved in that the abnormal trend analysis module includes:
[0034] The wall thickness data extraction submodule obtains a wall thickness value sequence of a capsule wall thickness detection batch based on the wall thickness abnormality rejection information, extracts the wall thickness values within the same batch, and arranges them in the detection order to form a wall thickness value sequence;
[0035] The wall thickness fluctuation calculation submodule calls the wall thickness value sequence and uses the formula:
[0036]
[0037] Calculate the fluctuation degree of the wall thickness value;
[0038] Among them, V represents the fluctuation degree of wall thickness value, W a Represents the ath wall thickness value in the batch, Represents the average value of the wall thickness of this batch, N V Represents the total number of wall thickness measurement data in the batch, σ VRepresents the standard deviation of the wall thickness values in the batch, C V represents the scaling factor;
[0039] The wall thickness trend judgment submodule calls the fluctuation degree of the wall thickness value, analyzes the changing trend of the wall thickness fluctuation of multiple batches, arranges the batches according to the time sequence, calculates the fluctuation change between adjacent batches, and judges whether the fluctuation change shows an increasing, decreasing or stable trend. It calls the set fluctuation threshold, marks the batches whose wall thickness fluctuation exceeds the threshold range, and obtains the wall thickness fluctuation trend information.
[0040] The present invention is improved in that the system further comprises:
[0041] Based on the wall thickness fluctuation trend information, the early warning feedback module obtains the number of capsules with abnormal wall thickness in the corresponding batch, calculates the proportion of the number of capsules with abnormal wall thickness to the total number of capsules in the batch, evaluates the abnormality level of the batch capsules, and classifies the abnormality level based on the wall thickness fluctuation trend. It then calls the set early warning level threshold, evaluates the early warning level of the batch, selects the batches that meet the early warning conditions, sends early warning information to the management personnel, and obtains the batch wall thickness early warning signal;
[0042] The batch wall thickness warning signal includes an abnormal batch warning level, an abnormal wall thickness ratio threshold, an abnormal wall thickness batch sequence, and a management personnel notification status.
[0043] The present invention is improved in that the early warning feedback module includes:
[0044] The abnormal wall thickness ratio calculation submodule obtains the number of abnormal wall thickness capsules of the corresponding batch based on the wall thickness fluctuation trend information, calls the batch total data, calculates the ratio of the number of abnormal wall thickness capsules, and obtains abnormal wall thickness ratio data;
[0045] The warning level assessment submodule evaluates the abnormality of the batch of capsules based on the abnormal wall thickness ratio data and the wall thickness fluctuation trend, classifies the abnormality, and calls the set warning level threshold using the formula:
[0046]
[0047] Calculate the batch warning level and obtain batch warning level data;
[0048] Among them, L represents the warning level, N a The number of capsules with abnormal wall thickness in a representative batch, N t Represents the total number of capsules in a batch, W L Represents the batch weight factor, T L The average wall thickness of capsules from a representative batch, T m Represents the production standard wall thickness of the capsule;
[0049] The early warning signal sending submodule screens batches that meet the early warning conditions based on the batch early warning level data, sends early warning information to management personnel, and obtains batch wall thickness early warning signals.
[0050] The capsule wall thickness online detection method is based on the capsule wall thickness online detection system and includes the following steps:
[0051] S1: Obtain the illumination gradient value of pixels in the capsule wall thickness detection area, analyze and identify areas with uneven illumination distribution, adjust the pixel grayscale in areas with sudden illumination gradient changes, and obtain adjusted illumination distribution information;
[0052] S2: Based on the adjusted illumination distribution information, calculating the gradient distribution range in the local area, dynamically adjusting the gradient distribution range, adjusting the local contrast, and adjusting the grayscale difference between edge pixels to a set range to obtain edge contrast enhancement information;
[0053] S3: Based on the edge contrast enhancement information, calculate the gradient change rate of adjacent pixel points, select pixel points whose change rate reaches a set threshold as wall thickness boundary points, calculate the wall thickness value, select wall thickness data that deviates from the set threshold, mark and remove capsules, and obtain wall thickness abnormality removal information;
[0054] S4: Based on the abnormal wall thickness rejection information, calculate the fluctuation degree of the wall thickness value, analyze the changing trend of the wall thickness fluctuation, mark the batches whose wall thickness fluctuation exceeds the threshold range, and obtain wall thickness fluctuation trend information;
[0055] S5: Based on the wall thickness fluctuation trend information, evaluate the abnormality degree of the batch capsules, classify the abnormality degree, screen the batches that meet the warning conditions, send warning information to the management personnel, and obtain the batch wall thickness warning signal.
[0056] Compared with the prior art, the advantages and positive effects of the present invention are:
[0057] In the present invention, by analyzing and adjusting the uneven illumination area, the capsule edge features are made clearer, the imaging error is reduced, the edge gradient direction of the capsule wall thickness detection imaging area is extracted, and the local pixel grayscale difference is used to enhance the capsule boundary clarity and ensure the accuracy of wall thickness calculation. In the process of calculating the wall thickness, the edge pixel point set is extracted, the gradient change rate of adjacent pixel points is calculated, the pixel points whose gradient change rate meets the set threshold are screened as wall thickness boundary points, the wall thickness data that deviates from the set threshold is marked and eliminated, the stability of wall thickness detection is improved, the numerical sequence of batch capsule wall thickness is obtained, the degree of wall thickness fluctuation is calculated, the fluctuation trend of wall thickness between batches is analyzed, the batches with abnormal wall thickness fluctuation are marked, the problem of unstable wall thickness in the production process is identified in advance, and the trend warning capability is provided. Combined with the wall thickness fluctuation trend and the number of capsules with abnormal wall thickness in the batch, the proportion of abnormal capsules in the total batch is calculated, the degree of batch abnormality is evaluated, and the warning level is divided according to the set threshold. The batches that meet the warning conditions are screened and a warning signal is sent to improve the response capability to production abnormalities. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 is a system flow chart of the present invention;
[0059] Figure 2 This is a flow chart of the illumination correction module of the present invention;
[0060] Figure 3 is a flow chart of the edge enhancement module of the present invention;
[0061] Figure 4 This is a flow chart of the wall thickness calculation module of the present invention;
[0062] Figure 5 This is a flow chart of the abnormal trend analysis module of the present invention;
[0063] Figure 6 This is a flow chart of the early warning feedback module of the present invention. DETAILED DESCRIPTION
[0064] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0065] In the description of the present invention, it should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating directions or positional relationships, are based on the directions or positional relationships shown in the accompanying drawings and are only for the convenience of describing the present invention and simplifying the description. They do not indicate or imply that the devices or elements referred to must have a specific direction, be constructed and operate in a specific direction, and therefore should not be understood as limiting the present invention. In addition, in the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0066] See also Figure 1 The present invention provides a technical solution: an online detection system for capsule wall thickness, the system comprising:
[0067] The illumination correction module obtains the illumination gradient value of pixels in the capsule wall thickness detection area, calculates the illumination gradient variation between adjacent pixels, analyzes and identifies areas with uneven illumination distribution, calls the local grayscale mean and standard deviation, adjusts the pixel grayscale in areas with sudden illumination gradient changes, and obtains the adjusted illumination distribution information.
[0068] Based on the adjusted illumination distribution information, the edge enhancement module obtains the gradient direction of edge pixels within the capsule wall thickness detection imaging area, calls the grayscale difference of pixels within the local window, calculates the gradient distribution range within the local area, dynamically adjusts the gradient distribution range, adjusts the local contrast, and adjusts the grayscale difference between edge pixels to the set range to obtain edge contrast enhancement information;
[0069] The wall thickness calculation module obtains the edge pixel point set within the capsule wall thickness detection area based on edge contrast enhancement information, calculates the gradient change rate of adjacent pixel points, selects the pixel points whose change rate reaches the set threshold as the wall thickness boundary points, calls the pixel distance between the boundary points, calculates the wall thickness value, selects the wall thickness data that deviates from the set threshold, and marks and removes capsules to obtain abnormal wall thickness rejection information;
[0070] The abnormal trend analysis module obtains the wall thickness value sequence of the capsule wall thickness detection batch based on the wall thickness abnormal rejection information, calculates the fluctuation degree of the wall thickness value, analyzes the changing trend of the wall thickness fluctuation, calls the set fluctuation threshold, marks the batches with wall thickness fluctuation exceeding the threshold range, and obtains the wall thickness fluctuation trend information;
[0071] Based on the wall thickness fluctuation trend information, the early warning feedback module obtains the number of capsules with abnormal wall thickness in the corresponding batch, calculates the proportion of the number of capsules with abnormal wall thickness to the total number of capsules in the batch, evaluates the abnormality level of the batch capsules, and classifies the abnormality level based on the wall thickness fluctuation trend. It then calls the set early warning level threshold, evaluates the early warning level of the batch, selects the batches that meet the early warning conditions, sends early warning information to the management personnel, and obtains the batch wall thickness early warning signal;
[0072] The adjusted illumination distribution information includes illumination gradient adjustment parameters, local grayscale compensation coefficient, illumination balance area division standard and pixel grayscale dynamic adjustment value; the edge contrast enhancement information includes edge gradient direction distribution, local contrast enhancement coefficient, pixel grayscale difference calculation value and edge area pixel adjustment parameter; the wall thickness anomaly rejection information includes wall thickness data mean deviation, wall thickness data standard deviation, wall thickness fluctuation range and wall thickness anomaly point identification label; the wall thickness fluctuation trend information includes wall thickness fluctuation change rate, wall thickness fluctuation abnormal batch mark, wall thickness trend fluctuation amplitude and wall thickness stability assessment coefficient; the batch wall thickness warning signal includes abnormal batch warning level, abnormal wall thickness ratio threshold, wall thickness abnormal batch sequence and management personnel notification status.
[0073] See also Figure 2 , the illumination correction module includes:
[0074] The illumination gradient calculation submodule and the illumination correction module obtain the illumination gradient value of the pixels in the capsule wall thickness detection area, calculate the grayscale change between adjacent pixels, and obtain the illumination gradient value of the pixel;
[0075] The illumination gradient calculation submodule and the illumination correction module obtain the illumination gradient value of the pixels in the capsule wall thickness detection area. First, the pixel points in the detection area are selected, the grayscale value of each pixel point is recorded, and the adjacent pixel points are selected. The grayscale change of the adjacent pixel points is calculated by the grayscale value of the pixel points. The calculation method is: compare the grayscale values of two adjacent pixel points and obtain their difference. If the difference is positive, it means that the grayscale of the current pixel point is higher than that of the adjacent pixel point. If the difference is negative, it means that the grayscale of the current pixel point is lower than that of the adjacent pixel point. The grayscale change is the illumination gradient value. In the actual calculation process, multiple pixel points in an area are selected, and the window scanning method is adopted. One pixel point and its surrounding 8 pixel points are selected each time to traverse the entire detection area to obtain the illumination gradient values of all pixel points. In order to ensure the stability of the calculation, the grayscale value change is set. The upper and lower limits of the grayscale value refer to the dynamic range of the imaging system. Usually for 8-bit grayscale images, the grayscale range is between 0 and 255. Therefore, when calculating the illumination gradient, the low threshold T1 is set to 5 and the high threshold T2 is set to 50. The low threshold T1 indicates that the illumination gradient changes slightly, which is mainly used to ignore small grayscale changes, while the high threshold T2 indicates that the illumination gradient changes significantly. The area exceeding this threshold can be regarded as a significant illumination mutation area. This value is based on the mean statistics of the illumination mutation area under different light source conditions, and is usually set to between 1 / 5 and 1 / 3 of the dynamic range. After experimental analysis, T1=5 ensures that the background noise has the least impact on the calculation results, while T2=50 can effectively distinguish the illumination mutation area and record the calculation results, and finally obtain the illumination gradient values of all pixels in the detection area.
[0076] The illumination gradient change analysis submodule calls the illumination gradient value of the pixel point, calculates the illumination gradient change between adjacent pixels, filters the illumination gradient change value, obtains the illumination gradient mutation area, and calculates the local grayscale mean and standard deviation based on the pixel distribution characteristics of the mutation area. The formula is:
[0077]
[0078] Calculate the change of the pixel points in the mutation area relative to the local grayscale mean and generate the distribution coefficient of the illumination mutation area;
[0079] Among them, D represents the regional distribution coefficient of light mutation, G i represents the illumination gradient of pixel i, μ represents the local grayscale mean, σ represents the local grayscale standard deviation, and ∈ is a stability constant;
[0080] The illumination gradient change analysis submodule calls the illumination gradient value of the pixel point, calculates the illumination gradient change between adjacent pixel points, filters the illumination gradient change values, and obtains the illumination gradient mutation area. First, the illumination gradient value of the pixel point in the detection area is selected, and the illumination gradient change of the adjacent pixel points is calculated. The specific operation is to set the scanning window size, such as a 3×3 window, select a pixel point in the window, calculate the illumination gradient change between the pixel point and other pixels in the window, set the change threshold, and set the threshold value T3 of the illumination gradient change to 30. This value is determined based on the distribution statistics of the illumination gradient. In the capsule wall thickness detection area, the illumination gradient distribution of multiple samples is statistically analyzed. It is found that when the illumination gradient changes between 20 and 40, the normal area and the illumination mutation area can be better separated. Therefore, T3 is set to 30, which improves the detection accuracy of the mutation area by 10 % or more. For example, if the illumination gradient change of adjacent pixels exceeds 30, the pixel is determined to be located in the illumination gradient mutation area. All pixels in the illumination gradient mutation area are counted, and the local grayscale mean is calculated based on these pixels. The calculation method is: average the grayscale values of all pixels in the mutation area, calculate the local grayscale standard deviation, and calculate the square sum of the deviations of the grayscale values of all pixels in the mutation area from the mean, and take the square root. In order to stabilize the calculation, a stability constant ∈ is set, for example, ∈=0.001 is set. This value is used to avoid calculation anomalies caused by the denominator being zero. The value of ∈ should be small enough so that its influence on the calculation result can be ignored. Therefore, it is usually set between 0.001 and 0.01. In this embodiment, 0.001 is selected based on the data accuracy requirements and the results of calculation stability analysis. Finally, the illumination mutation area distribution coefficient is calculated. The specific calculation method is as follows:
[0081]
[0082] Among them, G iRepresents the illumination gradient of pixel i, μ represents the local grayscale mean, σ represents the local grayscale standard deviation, and ∈ is a stability constant. In actual calculation, it is assumed that there are 5 pixels in the mutation area, and the grayscale values are (120, 140, 160, 180, 200) respectively. Then the local grayscale mean μ is calculated as follows:
[0083]
[0084] The local grayscale standard deviation σ is calculated as follows:
[0085]
[0086] Substitute the formula to calculate the regional distribution coefficient of light mutation:
[0087]
[0088] The calculated result D=4.24 shows that the illumination gradient has a large mutation and the mutation area is more obvious.
[0089] The illumination distribution adjustment submodule calls the illumination mutation area distribution coefficient to adjust the grayscale value of the pixel point in the illumination mutation area to the weighted balance value of the local grayscale mean and the illumination gradient change, and obtains the adjusted illumination distribution information;
[0090] The illumination distribution adjustment submodule calls the illumination mutation area distribution coefficient to adjust the grayscale value of the pixel point in the illumination mutation area, adjusts the grayscale value to the weighted balance value of the local grayscale mean and the illumination gradient change, and obtains the adjusted illumination distribution information. First, the pixel points in the mutation area are selected, the illumination gradient mutation area distribution coefficient D is determined, the adjustment target value is calculated, and the adjustment factor α is set. For example, α=0.5 is set. The weight value is set based on the illumination balance analysis of the mutation area. If α is set too high, the adjusted grayscale value changes too drastically, which may affect the local contrast. If α is set too low, the adjusted grayscale value deviates from the original illumination distribution, affecting the detection accuracy. Therefore, through multiple experiments, α=0.5 is selected to improve the uniformity of the adjusted grayscale value by more than 15%. The calculation method of the adjusted grayscale value is set as follows:
[0091] G′ i =G i +α·(160-G i );
[0092] Among them, G′ i is the adjusted pixel grayscale value, G i is the pixel grayscale value before adjustment, and the grayscale value of each pixel after adjustment is calculated:
[0093] G'1=120+0.5×(160-120)=140;
[0094] G'2=140+0.5×(160-140)=150;
[0095] G′3=160;
[0096] G′4=180+0.5×(160-180)=170;
[0097] G′5=2200+0.5×(160-200)=180;
[0098] Get the adjusted lighting distribution information.
[0099] See also Figure 3 , the edge enhancement module includes:
[0100] The edge gradient calculation submodule extracts edge pixels within the capsule wall thickness detection imaging area based on the adjusted illumination distribution information, calculates the gradient direction of each edge pixel, calls the grayscale difference within the local window of the pixel point, obtains the local gradient distribution range, calculates the gradient direction change rate of the pixel point within the local window, and screens the edge gradient direction stable area based on the distribution characteristics of the gradient direction change rate to obtain the edge gradient direction stable interval;
[0101] The edge gradient calculation submodule calls the adjusted illumination distribution information and extracts the edge pixels in the capsule wall thickness detection imaging area. First, the edge pixels are identified by calculating the gradient amplitude of each pixel. The gradient amplitude can be calculated by the Sobel operator, which calculates the pixel grayscale change in the X and Y directions respectively and takes the square root of the sum of their squares, that is:
[0102]
[0103] Among them, G x is the horizontal gradient, G y The vertical gradient is calculated. After the calculation is completed, the pixels with gradient amplitude greater than the set threshold T = 30 are selected as edge pixels. The threshold is set based on the statistical characteristics of the gradient amplitude under standard lighting conditions. Under different capsule wall thickness imaging environments, the distribution statistics of the edge pixel gradient amplitude of a large number of sample images are performed. It is found that the gradient amplitude is mainly concentrated between 20 and 40, and the area less than 25 is mostly affected by noise. Therefore, 30 is set as the minimum standard for edge pixel screening to avoid misjudgment due to noise interference. If the calculated gradient amplitude of a pixel is greater than 30, it is determined to be an edge pixel. Then, a local window of m×m (such as 3×3 or 5×5) is selected around the edge pixel, and the grayscale values of all pixels in the window are called to calculate their gradient direction. The gradient direction can be calculated by the inverse tangent function:
[0104]
[0105] Where θ is the gradient direction angle (unit: °). After obtaining the gradient directions of all pixels in the local window, the rate of change of the gradient direction is calculated. This rate of change is the average of the gradient direction changes of adjacent pixels in the window:
[0106]
[0107] Where N is the total number of pixels in the window, θ i is the gradient direction angle of the i-th pixel point, and the gradient direction change rate is lower than the set threshold T θ = 5°, it is determined to be the edge gradient direction stable interval. The threshold is set based on the gradient direction variation range of edge pixels. After statistical analysis of the gradient directions of a large number of edge pixels, it is found that for smooth areas, the gradient direction variation is usually less than 5°, while for complex texture areas, the variation can reach more than 10°. Therefore, 5° is set as the upper limit of the stable interval to exclude areas with high-frequency gradient variations. For example, if the gradient direction variation rate in a window is less than 5°, the gradient direction of this area is determined to be stable. This stable interval will serve as reference data for subsequent local contrast adjustment.
[0108] The local contrast adjustment submodule calls the edge gradient direction stability interval, calculates the gradient amplitude mean change rate under multiple window scales, obtains the gradient dynamic distribution range of the current area, and calculates the contrast adjustment coefficient within the local window scale based on the gradient dynamic distribution range. The formula is:
[0109]
[0110] Calculating a local contrast adjustment value to obtain local contrast adjustment information;
[0111] Among them, C adj Represents the local contrast adjustment value, G C,j Represents the gradient magnitude of the pixel in the local window, G mean Represents the mean gradient amplitude in the local window, G std Represents the standard deviation of the gradient amplitude in the local window, N represents the total number of pixels in the local window, max(G) represents the maximum gradient amplitude in the local window, and min(G) represents the minimum gradient amplitude in the local window;
[0112] The local contrast adjustment submodule calls the edge gradient direction stabilization interval and calculates the mean gradient amplitude change rate under multiple window scales. First, multiple scale windows are selected in each stabilization interval, such as 3×3, 5×5, 7×7, etc., and the mean gradient amplitude within different window scales is calculated. The calculation formula for the mean gradient amplitude change rate is set as:
[0113]
[0114] in, and Represent the mean value of the gradient amplitude in different window scales s1 and s2 respectively. After obtaining the dynamic distribution range of the gradient in the current area, the contrast adjustment coefficient in the local window scale is calculated based on the range. The following formula is used:
[0115]
[0116] Among them, C adj Represents the local contrast adjustment value, G C,j is the gradient amplitude of the j-th pixel in the local window, G mean is the mean gradient amplitude in the local window, G std is the standard deviation of the gradient amplitude in the local window, N is the total number of pixels in the window, max(G) and min(G) are the maximum and minimum gradient amplitudes in the window respectively. std The setting range is usually between 2 and 10. If it is less than 2, it means that the gradient distribution in the window is too uniform and is not suitable for contrast enhancement. If it is greater than 10, it means that there is a strong gradient mutation in the window, which may lead to over-enhancement. Therefore, the reasonable setting range is between 2 and 10.
[0117] The edge contrast modulation submodule calls the local contrast adjustment information, adjusts the contrast within the local window according to the grayscale difference between edge pixels, controls the grayscale difference between edge pixels to fall within the set range, calculates the edge gradient enhancement value of the adjusted area, and obtains the edge contrast enhancement information.
[0118] The edge contrast modulation submodule calls the local contrast adjustment information and adjusts the contrast in the local window according to the grayscale difference between edge pixels. First, the grayscale difference between edge pixels is calculated and the maximum grayscale value G in the local window is selected. max and the minimum gray value G min , calculate its range:
[0119] ΔG=G max -G min ;
[0120] If ΔG exceeds the set range T G =40, the grayscale values of all pixels are scaled proportionally. This setting is based on the fact that in visual perception experiments, the human eye is more sensitive to grayscale changes within 40. If it exceeds 40, it may cause excessive contrast adjustment, thus affecting edge details. Therefore, 40 is set as the maximum adjustment range, and the scaling factor is set as follows:
[0121]
[0122] Set the maximum grayscale value in the local window to 200 and the minimum grayscale value to 120, then:
[0123] ΔG = 200 - 120 = 80;
[0124] If you set T G =40, then:
[0125]
[0126] For a certain pixel G=180, the adjusted grayscale value is:
[0127] G′=120+0.5×(180-120)=150;
[0128] After adjustment, the edge gradient enhancement value of the adjusted area is calculated to obtain edge contrast enhancement information.
[0129] See also Figure 4 , the wall thickness calculation module includes:
[0130] The edge pixel extraction submodule obtains the edge pixel point set within the capsule wall thickness detection area based on the edge contrast enhancement information, calls the pixel gradient data in the neighborhood window, calculates the gradient change rate of adjacent pixel points, filters the gradient change rate of adjacent pixel points, and extracts the pixel points whose change rate reaches the set threshold as the wall thickness boundary point to obtain the capsule edge recognition information;
[0131] The edge pixel extraction submodule calls the edge contrast enhancement information and obtains the edge pixel point set in the capsule wall thickness detection area. First, based on the enhanced contrast information, the gradient amplitude of each pixel point is calculated. By calculating the gradient changes in the horizontal and vertical directions, the square root of the sum of their squares is taken as the gradient amplitude of the pixel point. The pixel points with gradient amplitude greater than the set threshold are screened out as candidate edge pixel points. The gradient amplitude threshold T G The setting basis is the average grayscale variation range in the capsule wall thickness detection imaging area. By statistically analyzing the imaging data of multiple groups of capsules with different wall thicknesses, the average gradient amplitude of the edge area is obtained, and the threshold is set to 1.2 times the mean to ensure that only obvious edge pixels are retained. The statistical result of the average gradient amplitude is set to 20, then T G =20×1.2=24. If the gradient amplitude of a pixel is greater than 24, it is determined to be a candidate edge pixel. Then, within the neighborhood window (such as 3×3 or 5×5) of each candidate edge pixel, the gradient data of adjacent pixels are called and the gradient change rate between adjacent pixels is calculated:
[0132]
[0133] Among them, G i and Gi+1 Represents the gradient values of adjacent pixels respectively. After calculating the gradient change rate of all adjacent pixels, the ones with a change rate greater than the set threshold T are screened. ΔG The pixel point is taken as the wall thickness boundary point, and the gradient change rate threshold T ΔG According to the gradient change range of the edge area, the gradient change rate between all adjacent pixels in the edge area is counted, and the 75% percentile value is taken as the threshold. If the 75% percentile value obtained by statistics is 0.18, then T is set. ΔG =0.18. If the gradient change rate of a pixel point is greater than 0.18, it is determined to be a wall thickness boundary point. The set of all eligible wall thickness boundary points constitutes the capsule edge recognition information.
[0134] The wall thickness boundary calculation submodule calls the capsule edge recognition information and uses the formula:
[0135]
[0136] Calculate and obtain the wall thickness value;
[0137] Where W represents the wall thickness value, m represents the matching number of wall thickness boundary points, (X L,k , Y L,k ) represents the coordinates of the left boundary point of the kth group, (X R,k , Y R,k ) represents the coordinates of the right boundary points of the kth group, S W Represents the physical size ratio corresponding to the pixel pitch;
[0138] The wall thickness boundary calculation submodule calls the capsule edge recognition information and calculates the wall thickness value. First, the identified left boundary points and right boundary points are paired to ensure that the left and right boundary points within the same horizontal coordinate range correspond to each other. The pairing principle is set as follows: within the same vertical coordinate range, the boundary points closest to the left and closest to the right are selected as matching pairs. The number of matching pairs m is set to the number of all successfully matched boundary point pairs. The wall thickness calculation formula for each pair of matching boundary points is:
[0139]
[0140] Among them, (X L,k , Y L,k ) and (X R,k , Y R,k ) represent the coordinates of the left and right boundary points of the kth group, and the physical size ratio S corresponding to the pixel spacing W The setting basis is the optical resolution of the imaging system, which is determined by the camera system magnification and the sensor pixel size. For example, if the camera system magnification is 5× and the sensor pixel size is 0.25 mm / pixel, then calculate S W= 0.25 / 5 = 0.05mm / pixel, the final wall thickness is calculated as:
[0141]
[0142] The number of detected boundary point matching pairs is set to m=5, and the coordinates and wall thickness calculation results are shown in Table 1.
[0143] Table 1 Example data for wall thickness calculation
[0144]
[0145] According to Table 1, the final wall thickness calculation results are:
[0146]
[0147] The resulting wall thickness was 3.89 mm.
[0148] The wall thickness abnormality rejection submodule obtains the wall thickness value, compares it with the set capsule wall thickness standard, screens out the wall thickness that deviates from the set threshold, marks and rejects the capsules, and obtains the wall thickness abnormality rejection information.
[0149] The abnormal wall thickness rejection submodule obtains the wall thickness value and compares it with the set capsule wall thickness standard, filters the wall thickness that deviates from the set threshold, and marks and rejects the capsules. First, set the normal range of wall thickness [W min , W max ], the normal range of wall thickness is set based on the capsule production process standard, and the upper and lower bounds of the 95% confidence interval are obtained by combining the statistics of qualified product data. The range is set to [3.5, 4.2] mm, and W is set min =3.5mm, W max =4.2mm, judge the calculated wall thickness value W:
[0150] W min ≤W≤W max ;
[0151] If the wall thickness value is within the set range, it is considered normal, otherwise it is marked as abnormal. The set sample wall thickness for detection is shown in Table 2.
[0152] Table 2 Abnormal wall thickness screening data
[0153] Sample No. Calculate wall thickness W(mm) Is it abnormal? 1 3.89 no 2 3.45 yes 3 4.15 no 4 4.30 yes 5 3.75 no
[0154] As shown in Table 2, the wall thickness values of sample 2 and sample 4 are 3.45 mm and 4.30 mm respectively, which are beyond the set range. Therefore, they are judged as abnormal capsules and are rejected. Finally, the wall thickness abnormality rejection information is obtained.
[0155] See also Figure 5, the abnormal trend analysis module includes:
[0156] The wall thickness data extraction submodule obtains the wall thickness value sequence of the capsule wall thickness detection batch based on the wall thickness abnormality rejection information, extracts the wall thickness values within the same batch, and arranges them in the detection order to form a wall thickness value sequence;
[0157] The wall thickness data extraction submodule obtains the wall thickness value sequence of the capsule wall thickness detection batch based on the wall thickness abnormality rejection information. First, the wall thickness abnormality rejection information is called to screen the wall thickness data that meets the standard wall thickness range (such as 3.5mm to 4.5mm), and the abnormal data outside the range is eliminated. The valid wall thickness data in the current batch are obtained and arranged in the detection order to form a wall thickness value sequence. In the actual detection process, the wall thickness values detected in a certain batch are set to (4.0mm, 4.2mm, 3.8mm, 4.6mm, 3.3mm, 4.1mm, 3.9mm, The wall thickness data that exceeds the range (4.6mm, 3.3mm, 3.4mm) are eliminated to form the final wall thickness value sequence (4.0mm, 4.2mm, 3.8mm, 4.1mm, 3.9mm, 3.6mm, 4.3mm). The standard range of wall thickness from 3.5mm to 4.5mm is set based on the industry capsule preparation manufacturing tolerance standard, specifically based on the thickness uniformity requirement of the capsule shell material. The tolerance value is determined by the processing accuracy of the production line equipment, usually taking a tolerance interval of ±0.5mm. If the value is
[0158] The wall thickness fluctuation calculation submodule calls the wall thickness value sequence and uses the formula:
[0159]
[0160] Calculate the fluctuation degree of the wall thickness value;
[0161] Among them, V represents the fluctuation degree of wall thickness value, W a Represents the ath wall thickness value in the batch, Represents the average value of the wall thickness of this batch, N V Represents the total number of wall thickness measurement data in the batch, σ V Represents the standard deviation of the wall thickness values in the batch, C V represents the scaling factor;
[0162] The wall thickness fluctuation calculation submodule calls the wall thickness value sequence to calculate the wall thickness fluctuation degree of the batch. First, the mean of the batch wall thickness data is calculated. The calculation formula is as follows:
[0163]
[0164] Among them, W a Represents the ath wall thickness value, NV Represents the total number of wall thickness data in this batch. In this example:
[0165]
[0166] Next, calculate the standard deviation of the wall thickness data for this batch:
[0167]
[0168] Calculate the wall thickness fluctuation degree, the calculation formula is as follows:
[0169]
[0170] Among them, the scaling factor C V =1.5 is set to adjust the calculated standardized fluctuation to a comparable range, ensuring uniform comparability of data across different batches at varying deviation levels. This value is derived from the adjustment parameter for capsule wall thickness uniformity in the production quality management system and is typically set between 1.0 and 2.0 based on the actual measurement accuracy of the production line. The value of 1.5 is determined based on average production tolerance data and is substituted into the calculation:
[0171]
[0172] The calculated wall thickness fluctuation degree V=1.53 indicates the wall thickness stability of this batch.
[0173] The wall thickness trend judgment submodule calls the fluctuation degree of the wall thickness value, analyzes the changing trend of the wall thickness fluctuation of multiple batches, arranges the batches according to the time sequence, calculates the fluctuation change between adjacent batches, and judges whether the fluctuation change shows an increasing, decreasing or stable trend. It calls the set fluctuation threshold, marks the batches whose wall thickness fluctuation exceeds the threshold range, and obtains the wall thickness fluctuation trend information.
[0174] The wall thickness trend judgment submodule calls the fluctuation degree of wall thickness values and analyzes the fluctuation trend of wall thickness of multiple batches. First, the wall thickness fluctuation data of each batch are arranged in chronological order, the fluctuation change between adjacent batches is calculated, and the fluctuation change threshold T is set. V =0.5. This value is set based on the allowable fluctuation range of wall thickness during the production process, usually with reference to equipment accuracy and the variation trend between production batches. If this value is too small, a normal batch may be misjudged as having abnormal fluctuations. If this value is too large, abnormal fluctuations in wall thickness during the actual production process may be ignored. Therefore, 0.5 is used as an empirical value derived from the stable control range of the capsule manufacturing equipment. In this example, the fluctuation data of five existing batches are set as shown in Table 3.
[0175] Table 3 Wall thickness fluctuation trend data
[0176] Batch number Wall thickness fluctuation V Batch 1 1.40 Batch 2 1.45 Batch 3 1.53 Batch 4 1.20 Batch 5 1.80
[0177] Calculate the fluctuation between adjacent batches:
[0178] ΔV 2,1 =|1.45-1.40|=0.05;
[0179] ΔV 3,2 =|1.53-1.45|=0.08;
[0180] ΔV 4,3 =|1.20-1.53|=0.33;
[0181] ΔV 5,4 =|1.80-1.20|=0.60;
[0182] To determine the trend, set a judgment standard. If ΔV>0.5, it is determined to be abnormal fluctuation. If ΔV is between 0.1 and 0.5, it is determined to be normal fluctuation. If ΔV<0.1, it is determined to be stable fluctuation. This standard is based on the average wall thickness variation range in industry production statistics. In the manufacturing process, fluctuations less than 0.1 are usually normal errors. Fluctuations between 0.1 and 0.5 are acceptable process fluctuations. Fluctuations greater than 0.5 may mean abnormal equipment control or raw material quality problems. According to this standard:
[0183] Batch 2 relative to batch 1, ΔV 2,1 =0.05<0.1, it is judged as stable fluctuation;
[0184] Batch 3 relative to batch 2, ΔV 3,2 =0.08<0.1, it is judged as stable fluctuation;
[0185] Batch 4 relative to batch 3, ΔV 4,3 =0.33, between 0.1 and 0.5, which is considered normal fluctuation;
[0186] Batch 5 relative to batch 4, ΔV 5,4 =0.60>0.5, it is judged as abnormal fluctuation;
[0187] The wall thickness fluctuation trend information is obtained, and it is determined that batch 5 has abnormal fluctuations, and the batch is marked as an abnormal batch.
[0188] See also Figure 6 , the early warning feedback module includes:
[0189] The abnormal wall thickness ratio calculation submodule obtains the number of abnormal wall thickness capsules in the corresponding batch based on the wall thickness fluctuation trend information, calls the batch total data, calculates the ratio of the number of abnormal wall thickness capsules, and obtains the abnormal wall thickness ratio data;
[0190] The abnormal wall thickness ratio calculation submodule obtains the number of abnormal wall thickness capsules in the corresponding batch based on the wall thickness fluctuation trend information, calls the filtered abnormal wall thickness batch data, counts the number of capsules marked as abnormal in each batch, sets the calculation rules, for example, if the capsule wall thickness exceeds the standard range (3.5mm to 4.5mm), it is recorded as an abnormal capsule, traverses all capsules in the batch, and counts the total number of abnormal capsules N a , get the total number of capsules in this batch N t , calculate the proportion of capsules with abnormal wall thickness as follows:
[0191]
[0192] In actual calculation, assume that the total number of capsules in a batch is 500 and the number of capsules with abnormal wall thickness is 35. Then calculate the abnormal ratio:
[0193]
[0194] The wall thickness abnormality judgment threshold (3.5mm to 4.5mm) is determined according to the capsule production process standard, with specific reference to the target wall thickness setting of the batch production process. The upper and lower limits of this value depend on the processing accuracy of the production equipment and the allowable wall thickness deviation. Usually the equipment error is within ±0.5mm, so 4.0mm is set as the base wall thickness, and a deviation range of 0.5mm is allowed to ensure that the wall thickness is not excessively increased while meeting the physical strength, affecting the drug release rate. Too thin wall thickness may cause capsule damage, and too thick wall thickness may affect the capsule dissolution rate. Therefore, the threshold setting is derived from a comprehensive evaluation of the capsule material properties and dissolution test data, and the range changes with the adjustment accuracy of the batch production equipment, and finally the abnormal wall thickness ratio data of the batch is obtained.
[0195] The warning level assessment submodule evaluates the abnormality of the batch of capsules based on the abnormal wall thickness ratio data and the wall thickness fluctuation trend, classifies the abnormality, and calls the set warning level threshold using the formula:
[0196]
[0197] Calculate the batch warning level and obtain batch warning level data;
[0198] Among them, L represents the warning level, N a The number of capsules with abnormal wall thickness in a representative batch, N t Represents the total number of capsules in a batch, W L Represents the batch weight factor, T L The average wall thickness of capsules from a representative batch, T m Represents the production standard wall thickness of the capsule;
[0199] The warning level assessment submodule evaluates the abnormality of the batch of capsules based on the abnormal wall thickness ratio data and the wall thickness fluctuation trend, and grades the abnormality. First, the abnormal wall thickness ratio P of the batch and the wall thickness fluctuation degree V of the batch are called to obtain the average wall thickness T of the batch. L Calculate the wall thickness T of this batch and the production standard m The deviation between them is calculated as follows:
[0200] ΔT=|T L -T m |;
[0201] Set the average wall thickness T of the batch L =4.6mm, and the standard wall thickness T m =4.0mm, then:
[0202] ΔT=|4.6-4.0|=0.6mm;
[0203] Set the weight factor W L , set W L =2, calculate the warning level of the batch:
[0204]
[0205] Bring in data:
[0206]
[0207] Weight factor W in warning level assessment L Setting it to 2 is based on the weight adjustment of the influence of abnormal wall thickness ratio and wall thickness fluctuation trend. The determination of the weight factor is based on the production process control requirements. If the abnormal wall thickness ratio of a batch is high, the wall thickness deviation will have a greater impact on the entire batch, so the weight is increased. During the setting of this value, referring to past production data, it was found that batches with abnormal wall thickness ratios of more than 10% are usually accompanied by large production deviations. Therefore, W is set. L Between 1 and 3, when the abnormality ratio is less than 5%, W L =1, when the abnormal ratio is between 5% and 10%, W L =2, when the abnormal ratio exceeds 10%, W L =3. This value can be adjusted in the future according to production trends. According to the set warning level threshold, the threshold range is set as follows:
[0208] L<0.01 is low risk;
[0209] 0.01≤L<0.05 is medium risk;
[0210] L ≥ 0.05 is high risk;
[0211] According to the calculation result L=0.021, the batch was assessed as medium risk, and the warning level data of the batch was finally obtained.
[0212] The early warning signal sending submodule screens batches that meet the early warning conditions based on the batch early warning level data, sends early warning information to the management personnel, and obtains the batch wall thickness early warning signal;
[0213] The early warning signal sending submodule is based on the batch early warning level data, screens batches that meet the early warning conditions, and sets early warning trigger conditions. For example, if L ≥ 0.05, a high-risk early warning is triggered, if 0.01 ≤ L < 0.05, a medium-risk early warning is triggered, and if L < 0.01, no early warning is triggered. The early warning level data of each batch is called, all batches are traversed, and batches with an early warning level not lower than medium risk are screened. The batch information that meets the conditions is stored in the early warning record, and early warning information is generated. The batch wall thickness early warning signal is sent to the management personnel. The trigger threshold of the early warning level (low risk 0.01, medium risk 0.05, high risk 0.05 or above) is derived from the historical batch quality control standard. The benchmark value is set based on the production qualification rate analysis. Usually, when the qualification rate is lower than 90%, it affects the stability of drug production. Therefore, L> 0.05 is set as a high-risk early warning, and L between 0.01 and 0.05 is an acceptable fluctuation range, but attention should be paid to trend changes. The threshold can be adjusted as production requirements change.
[0214] A method for online detection of capsule wall thickness comprises the following steps:
[0215] S1: Obtain the illumination gradient value of pixels in the capsule wall thickness detection area, analyze and identify areas with uneven illumination distribution, adjust the pixel grayscale in areas with sudden illumination gradient changes, and obtain adjusted illumination distribution information;
[0216] S2: Based on the adjusted illumination distribution information, the gradient distribution range in the local area is calculated, the gradient distribution range is dynamically adjusted, the local contrast is adjusted, and the grayscale difference between edge pixels is adjusted to a set range to obtain edge contrast enhancement information;
[0217] S3: Based on the edge contrast enhancement information, the gradient change rate of adjacent pixels is calculated. Pixels whose change rate reaches the set threshold are selected as wall thickness boundary points. The pixel distance between the boundary points is called to calculate the wall thickness value. Wall thickness data that deviates from the set threshold is selected and marked for removal. The capsules are then removed to obtain abnormal wall thickness removal information.
[0218] S4: Based on the wall thickness abnormality rejection information, obtain the wall thickness value sequence of the capsule wall thickness detection batch, calculate the fluctuation degree of the wall thickness value, analyze the changing trend of the wall thickness fluctuation, call the set fluctuation threshold, mark the batches whose wall thickness fluctuation exceeds the threshold range, and obtain the wall thickness fluctuation trend information;
[0219] S5: Based on the wall thickness fluctuation trend information, calculate the proportion of capsules with abnormal wall thickness to the total number of the batch, evaluate the abnormality of the batch capsules, classify the abnormality, screen the batches that meet the warning conditions, send warning information to the management personnel, and obtain the batch wall thickness warning signal.
[0220] The above are merely preferred embodiments of the present invention and do not limit the present invention in any other form. Any technician familiar with the profession may use the technical content disclosed above to change or modify it into an equivalent embodiment with equivalent changes and apply it to other fields. However, any simple modification, equivalent change and modification made to the above embodiment based on the technical essence of the present invention without departing from the content of the technical solution of the present invention shall still fall within the scope of protection of the technical solution of the present invention.
Claims
1. A capsule wall thickness online detection system, characterized in that: The system comprises: The illumination correction module obtains the illumination gradient value of pixels in the capsule wall thickness detection area, analyzes and identifies areas with uneven illumination distribution, adjusts the pixel grayscale in areas with sudden illumination gradient changes, and obtains adjusted illumination distribution information; The edge enhancement module calculates the gradient distribution range in the local area based on the adjusted illumination distribution information, performs dynamic adjustment on the gradient distribution range, adjusts the local contrast, and adjusts the grayscale difference between edge pixels to a set range to obtain edge contrast enhancement information; The wall thickness calculation module calculates the gradient change rate of adjacent pixel points based on the edge contrast enhancement information, selects pixel points whose change rate reaches a set threshold as wall thickness boundary points, calls the pixel distance between the boundary points, calculates the wall thickness value, selects the wall thickness data that deviates from the set threshold, and marks and removes capsules to obtain abnormal wall thickness removal information; Based on the wall thickness abnormality rejection information, the abnormal trend analysis module obtains the wall thickness value sequence of the capsule wall thickness detection batch, calculates the fluctuation degree of the wall thickness value, analyzes the changing trend of the wall thickness fluctuation, calls the set fluctuation threshold, marks the batches whose wall thickness fluctuation exceeds the threshold range, and obtains the wall thickness fluctuation trend information.
2. The capsule wall thickness online detection system according to claim 1, characterized in that: The adjusted illumination distribution information includes illumination gradient adjustment parameters, local grayscale compensation coefficients, illumination balance area division standards, and pixel grayscale dynamic adjustment values; the edge contrast enhancement information includes edge gradient direction distribution, local contrast enhancement coefficients, pixel grayscale differential calculation values, and edge area pixel adjustment parameters; the wall thickness anomaly rejection information includes wall thickness data mean deviation, wall thickness data standard deviation, wall thickness fluctuation range, and wall thickness anomaly point identification labels; the wall thickness fluctuation trend information includes wall thickness fluctuation change rate, wall thickness fluctuation anomaly batch mark, wall thickness trend fluctuation amplitude, and wall thickness stability assessment coefficient.
3. The capsule wall thickness online detection system according to claim 1, characterized in that: The illumination correction module includes: The illumination gradient calculation submodule and the illumination correction module obtain the illumination gradient value of the pixels in the capsule wall thickness detection area, calculate the grayscale change between adjacent pixels, and obtain the illumination gradient value of the pixel; The illumination gradient change analysis submodule calls the illumination gradient value of the pixel point, calculates the illumination gradient change between adjacent pixels, filters the illumination gradient change value, obtains the illumination gradient mutation area, and calculates the local grayscale mean and standard deviation based on the pixel distribution characteristics of the mutation area, using the formula: Calculate the change of the pixel points in the mutation area relative to the local grayscale mean and generate the distribution coefficient of the illumination mutation area; Among them, D represents the regional distribution coefficient of light mutation, G i represents the illumination gradient of pixel i, μ represents the local grayscale mean, σ represents the local grayscale standard deviation, and ∈ is a stability constant; The illumination distribution adjustment submodule calls the illumination mutation area distribution coefficient, adjusts the grayscale value of the pixel point in the illumination mutation area, adjusts the grayscale value to a weighted balance value of the local grayscale mean and the illumination gradient change, and obtains the adjusted illumination distribution information.
4. The capsule wall thickness online detection system according to claim 1, characterized in that: The edge enhancement module includes: The edge gradient calculation submodule extracts edge pixels within the capsule wall thickness detection imaging area based on the adjusted illumination distribution information, calculates the gradient direction of each edge pixel, calls the grayscale difference within the local window of the pixel point, obtains the local gradient distribution range, calculates the gradient direction change rate of the pixel point within the local window, and screens the edge gradient direction stable area based on the distribution characteristics of the gradient direction change rate to obtain the edge gradient direction stable interval; The local contrast adjustment submodule calls the edge gradient direction stability interval, calculates the gradient amplitude mean change rate under multiple window scales, obtains the gradient dynamic distribution range of the current area, and calculates the contrast adjustment coefficient within the local window scale based on the gradient dynamic distribution range, using the formula: Calculating a local contrast adjustment value to obtain local contrast adjustment information; Among them, C adj Represents the local contrast adjustment value, G C,j Represents the gradient magnitude of the pixel in the local window, G mean Represents the mean gradient amplitude in the local window, G std Represents the standard deviation of the gradient amplitude in the local window, N represents the total number of pixels in the local window, max(G) represents the maximum gradient amplitude in the local window, and min(G) represents the minimum gradient amplitude in the local window; The edge contrast modulation submodule calls the local contrast adjustment information, adjusts the contrast in the local window according to the grayscale difference between edge pixels, controls the grayscale difference between edge pixels to fall within a set range, calculates the edge gradient enhancement value of the adjusted area, and obtains edge contrast enhancement information.
5. The capsule wall thickness online detection system according to claim 1, characterized in that: The wall thickness calculation module includes: The edge pixel extraction submodule obtains the edge pixel point set within the capsule wall thickness detection area based on the edge contrast enhancement information, calls the pixel gradient data in the neighborhood window, calculates the gradient change rate of adjacent pixel points, screens the gradient change rate of adjacent pixel points, and extracts the pixel points whose change rate reaches the set threshold as the wall thickness boundary point to obtain capsule edge recognition information; The wall thickness boundary calculation submodule calls the capsule edge identification information and uses the formula: Calculate and obtain the wall thickness value; Where W represents the wall thickness value, m represents the matching number of wall thickness boundary points, (X L,k , Y L,k ) represents the coordinates of the left boundary point of the kth group, (X R,k , Y R,k ) represents the coordinates of the right boundary points of the kth group, S W Represents the physical size ratio corresponding to the pixel pitch; The wall thickness abnormality rejection submodule compares the obtained wall thickness value with the set capsule wall thickness standard, screens the wall thickness that deviates from the set threshold, marks and rejects the capsules, and obtains wall thickness abnormality rejection information.
6. The capsule wall thickness online detection system according to claim 1, characterized in that: The abnormal trend analysis module includes: The wall thickness data extraction submodule obtains a wall thickness value sequence of a capsule wall thickness detection batch based on the wall thickness abnormality rejection information, extracts the wall thickness values within the same batch, and arranges them in the detection order to form a wall thickness value sequence; The wall thickness fluctuation calculation submodule calls the wall thickness value sequence and uses the formula: Calculate the fluctuation degree of the wall thickness value; Among them, V represents the fluctuation degree of wall thickness value, W a Represents the ath wall thickness value in the batch, Represents the average value of the wall thickness of this batch, N V Represents the total number of wall thickness measurement data in the batch, σ V Represents the standard deviation of the wall thickness values in the batch, C V represents the scaling factor; The wall thickness trend judgment submodule calls the fluctuation degree of the wall thickness value, analyzes the changing trend of the wall thickness fluctuation of multiple batches, arranges the batches according to the time sequence, calculates the fluctuation change between adjacent batches, and judges whether the fluctuation change shows an increasing, decreasing or stable trend. It calls the set fluctuation threshold, marks the batches whose wall thickness fluctuation exceeds the threshold range, and obtains the wall thickness fluctuation trend information.
7. The capsule wall thickness online detection system according to claim 1, characterized in that: The system further comprises: Based on the wall thickness fluctuation trend information, the early warning feedback module obtains the number of capsules with abnormal wall thickness in the corresponding batch, calculates the proportion of the number of capsules with abnormal wall thickness to the total number of capsules in the batch, evaluates the abnormality level of the batch capsules, and classifies the abnormality level based on the wall thickness fluctuation trend. It then calls the set early warning level threshold, evaluates the early warning level of the batch, selects the batches that meet the early warning conditions, sends early warning information to the management personnel, and obtains the batch wall thickness early warning signal; The batch wall thickness warning signal includes an abnormal batch warning level, an abnormal wall thickness ratio threshold, an abnormal wall thickness batch sequence, and a management personnel notification status.
8. The capsule wall thickness online detection system according to claim 7, characterized in that: The early warning feedback module includes: The abnormal wall thickness ratio calculation submodule obtains the number of abnormal wall thickness capsules of the corresponding batch based on the wall thickness fluctuation trend information, calls the batch total data, calculates the ratio of the number of abnormal wall thickness capsules, and obtains abnormal wall thickness ratio data; The warning level assessment submodule evaluates the abnormality of the batch of capsules based on the abnormal wall thickness ratio data and the wall thickness fluctuation trend, classifies the abnormality, and calls the set warning level threshold using the formula: Calculate the batch warning level and obtain batch warning level data; Among them, L represents the warning level, N a The number of capsules with abnormal wall thickness in a representative batch, N t Represents the total number of capsules in a batch, W L Represents the batch weight factor, T L The average wall thickness of capsules from a representative batch, T m Represents the production standard wall thickness of the capsule; The early warning signal sending submodule screens batches that meet the early warning conditions based on the batch early warning level data, sends early warning information to management personnel, and obtains batch wall thickness early warning signals.
9. The online detection method of capsule wall thickness is characterized by: The capsule wall thickness online detection system according to any one of claims 1 to 8 comprises the following steps: S1: Obtain the illumination gradient value of pixels in the capsule wall thickness detection area, analyze and identify areas with uneven illumination distribution, adjust the pixel grayscale in areas with sudden illumination gradient changes, and obtain adjusted illumination distribution information; S2: Based on the adjusted illumination distribution information, calculating the gradient distribution range in the local area, dynamically adjusting the gradient distribution range, adjusting the local contrast, and adjusting the grayscale difference between edge pixels to a set range to obtain edge contrast enhancement information; S3: Based on the edge contrast enhancement information, calculate the gradient change rate of adjacent pixel points, select pixel points whose change rate reaches a set threshold as wall thickness boundary points, calculate the wall thickness value, select wall thickness data that deviates from the set threshold, mark and remove capsules, and obtain wall thickness abnormality removal information; S4: Based on the abnormal wall thickness rejection information, calculate the fluctuation degree of the wall thickness value, analyze the changing trend of the wall thickness fluctuation, mark the batches whose wall thickness fluctuation exceeds the threshold range, and obtain wall thickness fluctuation trend information; S5: Based on the wall thickness fluctuation trend information, evaluate the abnormality degree of the batch capsules, classify the abnormality degree, screen the batches that meet the warning conditions, send warning information to the management personnel, and obtain the batch wall thickness warning signal.
Citation Information
Patent Citations
Turbine blade front edge impact hole simulation part design method considering temperature gradient
CN118568898A
Shaving board quality detection method and system based on image recognition
CN119379701A