Capsule wall thickness online detection system and method
Through the combination of light correction, edge enhancement and wall thickness calculation modules, the edge identification and wall thickness fluctuation analysis problems of the capsule wall thickness detection system under uneven light conditions are solved, achieving more accurate wall thickness detection and early warning capabilities, and improving production quality and efficiency.
Patent Information
- Application Number
- CN202510453334.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-11
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2045-04-11
AI Technical Summary
The existing capsule wall thickness detection system has reduced imaging contrast under uneven lighting conditions, insufficient edge recognition accuracy, and cannot effectively deal with the fluctuation trend of wall thickness between batches. It lacks analysis of the proportion of abnormal capsules, resulting in unreasonable warning level, affecting the effectiveness of production adjustment.
The light correction module is used to adjust the light gradient mutation area, 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 combines the early warning feedback module to evaluate the degree of abnormality and sends an early warning signal.
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 enhances the ability to respond to production abnormalities.
Smart Images

Figure CN120374704A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of wall thickness detection, and in particular to an on-line capsule wall thickness detection system and method. Background Art
[0002] The technical field of wall thickness detection involves measuring the wall thickness of various materials or structural components to ensure that products meet design requirements and usage performance. This technology is widely used in manufacturing, pharmaceutical packaging, aerospace, automotive manufacturing and other fields, covering a variety of materials such as metals, plastics, glass, and composite materials. Methods for wall thickness detection include ultrasonic thickness measurement, optical measurement, X-ray fluoroscopy, laser scanning, eddy current detection, etc. The specific measurement method is selected according to material characteristics, accuracy requirements and detection environment. The main goal of this technology is to improve production quality, reduce material loss, and ensure the safety and stability of products during use.
[0003] Among them, an on-line 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 capsules. This system is applicable to the pharmaceutical industry, can perform non-contact measurement on capsules during the production process, obtain accurate data on the capsule wall thickness, and achieve abnormal detection and quality control. The system usually integrates ultrasonic, optical or laser thickness measurement technology, and processes and feeds back data through an automated control system to optimize production parameters and improve the pass rate and production efficiency of capsule products.
[0004] Traditional detection systems fail to effectively handle uneven illumination problems, resulting in reduced imaging contrast in some detection areas, affecting edge recognition accuracy, and further reducing the accuracy of wall thickness measurement. Wall thickness calculation relies on a fixed threshold to determine boundary points, and cannot adapt to the imaging characteristics of different illumination environments and transparent capsules, easily leading to boundary misjudgment or omission. In terms of abnormal trend analysis, only single measurement data is relied on for over-limit alarm, and the wall thickness fluctuation trend between batches is not comprehensively analyzed, making it difficult to detect deviations in capsule wall thickness during the production process in a timely manner, affecting the effectiveness of production adjustment. There is a lack of analysis of the proportion of abnormal capsules, and the abnormal degree of batches cannot be accurately evaluated, resulting in unreasonable setting of warning levels and affecting the judgment basis of management personnel. Summary of the Invention
[0005] The purpose of the present invention is to solve the deficiencies existing in the prior art, and to propose an on-line capsule wall thickness detection system and method.
[0006] To achieve the above purpose, the present invention adopts the following technical solution: An on-line capsule wall thickness detection system, the system includes:
[0007] The illumination correction module obtains the illumination gradient values of the pixels within the capsule wall thickness detection area, analyzes and identifies the uneven illumination distribution areas, adjusts the pixel grayscales in the illumination gradient mutation areas, and obtains the adjusted illumination distribution information;
[0008] Based on the adjusted illumination distribution information, the edge enhancement module calculates the gradient distribution range within the local area, performs dynamic adjustment on the gradient distribution range, adjusts the local contrast, and adjusts the gray difference between edge pixels to the set range to obtain the edge contrast enhancement information;
[0009] Based on the edge contrast enhancement information, the wall thickness calculation module calculates the gradient change rate between adjacent pixel points, selects the pixel points with the change rate reaching the set threshold as the wall thickness boundary points, calls the pixel distance between the boundary points, calculates the wall thickness value, screens the wall thickness data deviating from the set threshold, and marks and eliminates the capsules to obtain the wall thickness anomaly elimination information;
[0010] Based on the wall thickness anomaly elimination information, the anomaly 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 change trend of the wall thickness fluctuation, calls the set fluctuation threshold, and marks the batches with the wall thickness fluctuation exceeding the threshold range to obtain the wall thickness fluctuation trend information.
[0011] The improvements of the present invention are that the adjusted illumination distribution information includes illumination gradient adjustment parameters, local gray compensation coefficients, illumination equalization area division criteria, and pixel gray dynamic adjustment values; the edge contrast enhancement information includes edge gradient direction distributions, local contrast enhancement coefficients, pixel gray difference calculation values, and edge area pixel adjustment parameters; the wall thickness anomaly elimination information includes wall thickness data mean deviation, wall thickness data standard deviation, wall thickness fluctuation range interval, 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 marks, wall thickness trend fluctuation amplitude, and wall thickness stability evaluation coefficients.
[0012] The improvements of the present invention are that the illumination correction module includes:
[0013] The illumination gradient calculation sub-module of the illumination correction module obtains the illumination gradient values of the pixels within the capsule wall thickness detection area, calculates the gray change amount between adjacent pixel points, and obtains the illumination gradient values of the pixel points;
[0014] The illumination gradient change analysis sub-module calls the illumination gradient values of the pixel points, calculates the illumination gradient change amount between adjacent pixel points, screens the illumination gradient change values, obtains the illumination gradient mutation areas, and based on the pixel distribution characteristics of the mutation areas, calculates the local gray mean and standard deviation, using the formula:
[0015]
[0016] Calculate the change degree of pixel points in the mutation region relative to the local gray mean value, and generate the illumination mutation region distribution coefficient;
[0017] Among them, D represents the illumination mutation region distribution coefficient, G i represents the illumination gradient of pixel point i, μ represents the local gray mean value, σ represents the local gray standard deviation, and ∈ is a stability constant;
[0018] The illumination distribution adjustment sub-module calls the illumination mutation region distribution coefficient to adjust the gray value of pixel points in the illumination mutation region, adjusts the gray value to the weighted balance value of the local gray mean value and the illumination gradient change amount, and obtains the adjusted illumination distribution information.
[0019] The improvement of the present invention is that the edge enhancement module includes:
[0020] The edge gradient calculation sub-module extracts edge pixels in the capsule wall thickness detection imaging region based on the adjusted illumination distribution information, calculates the gradient direction of each edge pixel, calls the gray difference value within the local window of the pixel point, obtains the local gradient distribution range, calculates the gradient direction change rate of pixel points within the local window, and filters the edge gradient direction stable region according to the distribution characteristics of the gradient direction change rate to obtain the edge gradient direction stable interval;
[0021] The local contrast adjustment sub-module calls the edge gradient direction stable interval, calculates the change rate of the mean value of gradient amplitudes at multiple window scales, obtains the gradient dynamic distribution range of the current region, calculates the contrast adjustment coefficient within the local window scale according to the gradient dynamic distribution range, and uses the formula:
[0022]
[0023] Calculate the local contrast adjustment value to obtain the local contrast adjustment information;
[0024] Among them, C adj represents the local contrast adjustment value, G C,j represents the gradient amplitude of pixel points within the local window, G man represents the mean value of gradient amplitudes within the local window, G std represents the standard deviation of gradient amplitudes within the local window, N represents the total number of pixel points within the local window, max(G) represents the maximum gradient amplitude within the local window, and min(G) represents the minimum gradient amplitude within the local window;
[0025] The edge contrast modulation sub-module calls the local contrast adjustment information, adjusts the contrast within the local window according to the gray difference between edge pixels, controls the gray difference between edge pixels to fall within the set range, and calculates the edge gradient enhancement value of the adjusted region to obtain the edge contrast enhancement information.
[0026] The improvement of the present invention is that the wall thickness calculation module includes:
[0027] Based on the edge contrast enhancement information, the edge pixel extraction sub-module obtains the set of edge pixel points in the capsule wall thickness detection area, calls the pixel gradient data within 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 points to obtain the capsule edge recognition information;
[0028] The wall thickness boundary calculation sub-module calls the capsule edge recognition information and uses the formula:
[0029]
[0030] Performs operations to obtain the wall thickness value;
[0031] Where, W represents the wall thickness value, m represents the number of matching pairs of wall thickness boundary points, (X L,k , Y L,k ) represents the coordinates of the kth group of left boundary points, (X R,k , Y R,k ) represents the coordinates of the kth group of right boundary points, S W represents the physical size ratio corresponding to the pixel point spacing;
[0032] Based on the obtained wall thickness value, the wall thickness abnormality elimination sub-module compares the set capsule wall thickness standard, screens the wall thickness that deviates from the set threshold, and marks and eliminates the capsule to obtain the wall thickness abnormality elimination information.
[0033] The improvement of the present invention is that the abnormal trend analysis module includes:
[0034] Based on the wall thickness abnormality elimination information, the wall thickness data extraction sub-module obtains the wall thickness value sequence of the capsule wall thickness detection batch, 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 sub-module calls the wall thickness value sequence and uses the formula:
[0036]
[0037] Performs operations to obtain the fluctuation degree of the wall thickness value;
[0038] Where, V represents the fluctuation degree of the wall thickness value, W a represents the a-th wall thickness value within the batch, represents the average value of the wall thickness values of this batch, N V represents the total number of wall thickness measurement data within the batch, σ VStandard deviation of the inner wall thickness value of the representative batch, C V Represents the scaling factor;
[0039] The wall thickness trend judgment sub-module calls the degree of fluctuation of the wall thickness value, analyzes the change trend of the wall thickness fluctuations of multiple batches, arranges the batches according to the time sequence, calculates the fluctuation change amount between adjacent batches, and judges whether the fluctuation change shows an increasing, decreasing or stable trend. It calls the set fluctuation threshold to mark the batches with wall thickness fluctuations exceeding the threshold range, and obtains the wall thickness fluctuation trend information.
[0040] The improvement of the present invention is that the system further includes:
[0041] Based on the wall thickness fluctuation trend information, the early warning feedback module obtains the number of abnormal wall thickness capsules in the corresponding batch, calculates the proportion of the number of abnormal wall thickness capsules in the total batch quantity, evaluates the abnormality degree of the batch of capsules, combines the wall thickness fluctuation trend, classifies the abnormality degree, calls the set early warning level threshold, evaluates the early warning level of the batch, screens the batches that meet the early warning conditions, and sends early warning information to the management personnel to obtain the batch wall thickness early warning signal;
[0042] The batch wall thickness early warning signal includes the early warning level of the abnormal batch, the threshold of the abnormal wall thickness ratio, the sequence of the wall thickness abnormal batches, and the notification status of the management personnel.
[0043] The improvement of the present invention is that the early warning feedback module includes:
[0044] The abnormal wall thickness ratio calculation sub-module, based on the wall thickness fluctuation trend information, obtains the number of abnormal wall thickness capsules in the corresponding batch, calls the total batch quantity data, calculates the proportion of the number of abnormal wall thickness capsules, and obtains the abnormal wall thickness ratio data;
[0045] The early warning level evaluation sub-module, based on the abnormal wall thickness ratio data, combines the wall thickness fluctuation trend, evaluates the abnormality degree of the batch of capsules, classifies the abnormality degree, calls the set early warning level threshold, and uses the formula:
[0046]
[0047] Calculates the early warning level of the batch and obtains the batch early warning level data;
[0048] Wherein, L represents the early warning level, N a Represents the number of abnormal wall thickness capsules in the batch, N t Represents the total number of capsules in the batch, W L Represents the weight factor of the batch, T L Represents the average wall thickness of the capsules in the batch, T m Represents the standard wall thickness of the capsules during production;
[0049] The warning signal sending sub-module filters out the batches that meet the warning conditions based on the batch warning level data, and sends warning messages to the management personnel to obtain the batch wall thickness warning signal.
[0050] An online capsule wall thickness detection method, which is executed based on the above-mentioned online capsule wall thickness detection system, and includes the following steps:
[0051] S1: Obtain the light intensity gradient values of the pixels in the capsule wall thickness detection area, analyze and identify the areas with uneven light distribution, and adjust the pixel grayscale of the areas with sudden changes in light intensity gradient to obtain the adjusted light distribution information;
[0052] S2: Based on the adjusted light distribution information, calculate the gradient distribution range in the local area, perform dynamic adjustment on the gradient distribution range, adjust the local contrast, and adjust the gray level difference between the edge pixels to the set range to obtain the edge contrast enhancement information;
[0053] S3: Based on the edge contrast enhancement information, calculate the gradient change rate of adjacent pixel points, filter out the pixel points whose change rate reaches the set threshold as the wall thickness boundary points, calculate the wall thickness value, filter out the wall thickness data that deviates from the set threshold, and mark and eliminate the capsules to obtain the wall thickness anomaly elimination information;
[0054] S4: Based on the wall thickness anomaly elimination information, calculate the fluctuation degree of the wall thickness value, analyze the change trend of the wall thickness fluctuation, and mark the batches with wall thickness fluctuation exceeding the threshold range to obtain the wall thickness fluctuation trend information;
[0055] S5: Based on the wall thickness fluctuation trend information, evaluate the anomaly degree of the batch capsules, classify the anomaly degree, filter out the batches that meet the warning conditions, and send warning messages to the management personnel to obtain the batch wall thickness warning signal.
[0056] Compared with the prior art, the advantages and positive effects of the present invention are as follows:
[0057] In the present invention, by analyzing and adjusting the uneven illumination area, the edge features of the capsule are made clearer, the imaging error is reduced, the edge gradient direction of the imaging area for capsule wall thickness detection is extracted, the local pixel gray difference is utilized to enhance the clarity of the capsule boundary, ensuring the accuracy of wall thickness calculation. During the process of calculating the wall thickness, the edge pixel point set is extracted, the gradient change rate of adjacent pixel points is calculated, and the pixel points with the gradient change rate meeting the set threshold are selected as the wall thickness boundary points. The wall thickness data deviating from the set threshold is marked and excluded, improving the stability of wall thickness detection. The numerical sequence of the wall thickness of batches of capsules is obtained, the degree of wall thickness fluctuation is calculated, the fluctuation trend of the wall thickness among batches is analyzed, the batches with abnormal wall thickness fluctuation are marked, the problem of unstable wall thickness during the production process is identified in advance, providing the ability of trend warning. Combining the wall thickness fluctuation trend and the number of batches of capsules with abnormal wall thickness, the proportion of abnormal capsules in the total batch quantity is calculated, the degree of batch abnormality is evaluated, and the warning level is divided according to the set threshold. The batches meeting the warning conditions are screened and a warning signal is sent, improving the response ability to production abnormalities. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 is the system flow chart of the present invention;
[0059] Figure 2 is the flow chart of the illumination correction module of the present invention;
[0060] Figure 3 is the flow chart of the edge enhancement module of the present invention;
[0061] Figure 4 is the flow chart of the wall thickness calculation module of the present invention;
[0062] Figure 5 is the flow chart of the abnormal trend analysis module of the present invention;
[0063] Figure 6 is the flow chart of the warning feedback module of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0064] In order to make the objectives, technical solutions and advantages of the present invention clearer and more understandable, 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 used to limit the present invention.
[0065] In the description of the present invention, it should be understood that the orientation or positional relationship indicated by terms such as "length", "width", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc. is based on the orientation or positional relationship shown in the drawings. It is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it should not be construed as a limitation to the present invention. In addition, in the description of the present invention, the meaning of "a plurality of" is two or more, unless otherwise specifically defined.
[0066] Please refer to Figure 1 , the present invention provides a technical solution: an on-line detection system for the wall thickness of capsules, the system includes:
[0067] The light correction module obtains the light gradient values of the pixels in the capsule wall thickness detection area, calculates the change amount of the light gradient between adjacent pixel points, analyzes and identifies the uneven light distribution area, calls the local gray mean and standard deviation, and adjusts the pixel gray levels in the light gradient mutation area to obtain the adjusted light distribution information;
[0068] Based on the adjusted light distribution information, the edge enhancement module obtains the edge pixel gradient directions in the capsule wall thickness detection imaging area, calls the pixel gray difference within the local window, calculates the gradient distribution range in the local area, performs dynamic adjustment on the gradient distribution range, adjusts the local contrast, and adjusts the gray difference between edge pixels to the set range to obtain the edge contrast enhancement information;
[0069] Based on the edge contrast enhancement information, the wall thickness calculation module obtains the set of edge pixel points in the capsule wall thickness detection area, calculates the gradient change rate between adjacent pixel points, screens 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, screens the wall thickness data that deviates from the set threshold, and marks and eliminates the capsules to obtain the wall thickness abnormality elimination information;
[0070] Based on the wall thickness abnormality elimination 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 change trend of the wall thickness fluctuation, calls the set fluctuation threshold, and marks the batches with wall thickness fluctuations exceeding the threshold range to obtain the wall thickness fluctuation trend information;
[0071] Based on the wall thickness fluctuation trend information, the warning feedback module obtains the number of abnormal wall thickness capsules in the corresponding batch, calculates the proportion of the number of abnormal wall thickness capsules in the total batch quantity, evaluates the abnormality degree of the batch of capsules, combines the wall thickness fluctuation trend, classifies the abnormality degree, calls the set warning level threshold, evaluates the warning level of the batch, screens the batches that meet the warning conditions, and sends warning information to the management personnel to obtain the batch wall thickness warning signal;
[0072] The adjusted light distribution information includes light gradient adjustment parameters, local gray compensation coefficients, light balance area division criteria, and pixel gray dynamic adjustment values. The edge contrast enhancement information includes edge gradient direction distribution, local contrast enhancement coefficients, pixel gray difference calculation values, and edge area pixel adjustment parameters. The wall thickness anomaly elimination information includes wall thickness data mean deviation, wall thickness data standard deviation, wall thickness fluctuation range interval, 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 evaluation coefficients. The batch wall thickness warning signal includes abnormal batch warning level, abnormal wall thickness ratio threshold, wall thickness abnormal batch sequence, and management staff notification status.
[0073] Please refer to Figure 2 , the light correction module includes:
[0074] The light gradient calculation sub-module of the light correction module obtains the light gradient values of the pixels within the capsule wall thickness detection area, calculates the gray change amount between adjacent pixel points, and obtains the light gradient values of the pixel points;
[0075] The light gradient calculation sub-module of the light correction module obtains the light gradient values of the pixels within the capsule wall thickness detection area. First, select the pixel points in the detection area, record the gray values of each pixel point, select adjacent pixel point pairs, and calculate the gray change amount between adjacent pixel points through the gray values of the pixel points. The calculation method is as follows: compare the gray values of two adjacent pixel points and obtain their difference. If the difference is positive, it means that the gray value of the current pixel point is higher than that of the adjacent pixel point. If the difference is negative, it means that the gray value of the current pixel point is lower than that of the adjacent pixel point. This gray change amount is the light gradient value. In the actual calculation process, select multiple pixel points within a region and use the window scanning method. Each time, select a pixel point and its surrounding 8 pixel points, traverse the entire detection area, and obtain the light gradient values of all pixel points. To ensure the stability of the calculation, set the upper and lower limit ranges of the gray value change. The upper and lower limits of the gray value refer to the dynamic range of the imaging system. Usually, for an 8-bit gray image, the gray range is between 0 and 255. Therefore, when calculating the light gradient, set the low threshold T1 = 5 and the high threshold T2 = 50. The low threshold T1 represents a small change in the light gradient and is mainly used to ignore minor gray changes. The high threshold T2 represents a large change in the light gradient, and the area exceeding this threshold can be regarded as a significant light mutation area. This value is based on the mean statistics of the light mutation area under different light source conditions and is usually set between 1 / 5 and 1 / 3 of the dynamic range. After experimental analysis, T1 = 5 ensures that the influence of background noise on the calculation result is minimized, while T2 = 50 can effectively distinguish the light mutation area and record the calculation result. Finally, obtain the light gradient values of all pixel points within the detection area.
[0076] The illumination gradient change analysis sub-module calls the illumination gradient values of pixel points, calculates the illumination gradient change amount between adjacent pixel points, screens the illumination gradient change values, obtains the illumination gradient mutation region, and based on the pixel distribution characteristics of the mutation region, calculates the local gray mean and standard deviation. The formula is as follows:
[0077]
[0078] Calculate the change degree of the pixel points in the mutation region relative to the local gray mean, and generate the illumination mutation region distribution coefficient;
[0079] Among them, D represents the illumination mutation region distribution coefficient, G i represents the illumination gradient of pixel point i, μ represents the local gray mean, σ represents the local gray standard deviation, and ∈ is a stability constant;
[0080] The illumination gradient change analysis sub-module calls the illumination gradient values of pixel points, calculates the illumination gradient change amount between adjacent pixel points, screens the illumination gradient change values, and obtains the illumination gradient mutation region. First, select the illumination gradient values of the pixel points in the detection region and calculate the illumination gradient change amount between adjacent pixel points. The specific operation is as follows: Set the scanning window size, for example, a 3×3 window. Select a pixel point within the window and calculate the illumination gradient change amount between this pixel point and other pixel points within the window. Set the change threshold. The threshold T3 of the illumination gradient change amount is set to 30. This value is determined based on the distribution statistics of the illumination gradient. In the capsule wall thickness detection region, the illumination gradient distributions of multiple samples are statistically analyzed, and it is found that when the illumination gradient change is between 20 and 40, the normal region and the illumination mutation region can be better separated. Therefore, T3 is set to 30, which improves the detection accuracy of the mutation region by more than 10%. For example, if the illumination gradient change amount between adjacent pixel points exceeds 30, it is determined that this pixel point is located in the illumination gradient mutation region. Count all the pixel points in the illumination gradient mutation region and calculate the local gray mean based on these pixel points. The calculation method is: Take the mean of the gray values of all pixel points in the mutation region. Calculate the local gray standard deviation. The calculation method is: Calculate the sum of the squares of the deviations between the gray values of all pixel points in the mutation region and the mean, and take the square root. To stabilize the calculation, set the stability constant ∈. For example, set ∈ = 0.001. 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 calculation stability analysis results. Finally, calculate the illumination mutation region distribution coefficient. The specific calculation method is as follows:
[0081]
[0082] Among them, G iThe illumination gradient of pixel point i, μ represents the local gray - level mean, σ represents the local gray - level standard deviation, ∈ is a stability constant. In actual calculation, it is assumed that there are 5 pixel points in the mutation region, and the gray - level values are (120, 140, 160, 180, 200) respectively. Then the local gray - level mean μ is calculated as follows:
[0083]
[0084] The local gray - level standard deviation σ is calculated as follows:
[0085]
[0086] Substitute into the formula to calculate the illumination mutation region distribution coefficient:
[0087]
[0088] The calculation result D = 4.24 indicates that the illumination gradient mutation is large and the mutation region is obvious.
[0089] The illumination distribution adjustment sub - module calls the illumination mutation region distribution coefficient to adjust the gray - level values of the pixel points in the illumination mutation region, adjusts the gray - level values to the weighted balance value of the local gray - level mean and the illumination gradient change amount, and obtains the adjusted illumination distribution information;
[0090] The illumination distribution adjustment sub - module calls the illumination mutation region distribution coefficient to adjust the gray - level values of the pixel points in the illumination mutation region, adjusts the gray - level values to the weighted balance value of the local gray - level mean and the illumination gradient change amount, and obtains the adjusted illumination distribution information. First, select the pixel points in the mutation region, determine the illumination gradient mutation region distribution coefficient D, calculate the adjustment target value, set the adjustment factor α. For example, set α = 0.5. This weight value setting is based on the analysis of the illumination balance degree of the mutation region. If α is set too high, the changed gray - level value after adjustment is too drastic, which may affect the local contrast. If α is set too low, the changed gray - level value after adjustment deviates from the original illumination distribution, affecting the detection accuracy. Therefore, through multiple experiments, α = 0.5 is selected to make the uniformity of the gray - level value after adjustment increase by more than 15%. Set the calculation method of the gray - level value after adjustment:
[0091] G′ i = G i +α·(160 - G i );
[0092] Among them, G′ i is the adjusted pixel gray - level value, G i is the pixel gray - level value before adjustment. Calculate the gray - level values of each pixel point after adjustment:
[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] Obtain the adjusted light distribution information.
[0099] Please refer to Figure 3 , the edge enhancement module includes:
[0100] Based on the adjusted light distribution information, the edge gradient calculation sub-module extracts the edge pixels within the imaging area for capsule wall thickness detection, calculates the gradient direction of each edge pixel, calls the gray difference within the local window of the pixel point, obtains the local gradient distribution range, calculates the change rate of the gradient direction of the pixel points within the local window, and filters the stable area of the edge gradient direction according to the distribution characteristics of the gradient direction change rate to obtain the stable interval of the edge gradient direction;
[0101] The edge gradient calculation sub-module calls the adjusted light distribution information and extracts the edge pixels within the imaging area for capsule wall thickness detection. First, the edge pixels are identified by calculating the gradient amplitude of each pixel point. The gradient amplitude can be calculated by the Sobel operator, which calculates the pixel gray change amount in the X direction and the Y direction respectively and takes the square root of the sum of their squares, that is:
[0102]
[0103] where G x is the gradient in the horizontal direction, G y is the gradient in the vertical direction. After the calculation, the pixel points with a gradient amplitude greater than the set threshold T = 30 are selected as edge pixel points. The setting basis of this threshold is the statistical characteristics of the gradient amplitude under standard light conditions. In different imaging environments of capsule wall thickness, the distribution statistics of the edge pixel gradient amplitudes of a large number of sample images are carried out. It is found that the gradient amplitudes are mainly concentrated between 20 - 40. Among them, the area less than 25 is mostly affected by noise. Therefore, 30 is set as the lowest standard for edge pixel screening to avoid misjudgment caused by noise interference. If the calculated gradient amplitude of a certain pixel point is greater than 30, it is determined as an edge pixel point. Then, an m×m (such as 3×3 or 5×5) local window is selected around the edge pixel point, and the gray values of all pixel points within this window are called to calculate its gradient direction. This gradient direction can be calculated by the arctangent function:
[0104]
[0105] Among them, θ is the gradient direction angle (unit: °). After obtaining the gradient directions of all pixel points in the local window, the change rate of the gradient direction is calculated, and this change rate is the average value of the change amounts of the gradient directions of adjacent pixel points in the window:
[0106]
[0107] where N is the total number of pixels in the window, and θ i is the gradient direction angle of the i-th pixel point. Filter the area where the change rate of the gradient direction is lower than the set threshold T θ = 5°, and determine it as the stable interval of the edge gradient direction. The setting basis of this threshold is the change range of the gradient directions of edge pixels. Through the statistics of the gradient directions of a large number of edge pixel points, it is found that for smooth areas, the change of the gradient direction is usually less than 5°, while for complex texture areas, the change can reach more than 10°. Therefore, 5° is set as the upper limit of the stable interval to exclude high-frequency gradient change areas. For example, if the change rate of the gradient direction in a certain window is less than 5°, it is determined that the gradient direction of this area is stable, and this stable interval will be used as the reference data for subsequent local contrast adjustment.
[0108] The local contrast adjustment sub-module calls the stable interval of the edge gradient direction, calculates the change rate of the average gradient amplitude at multiple window scales, obtains the gradient dynamic distribution range of the current area, and calculates the contrast adjustment coefficient within the local window scale according to the gradient dynamic distribution range, using the formula:
[0109]
[0110] Calculate the local contrast adjustment value to obtain the local contrast adjustment information;
[0111] where C adj represents the local contrast adjustment value, G C,j represents the gradient amplitude of the pixel points in the local window, G mean represents the average 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 pixel points 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 sub-module calls the stable interval of the edge gradient direction and calculates the change rate of the average gradient amplitude at multiple window scales. First, select multiple scale windows within each stable interval, such as 3×3, 5×5, 7×7, etc., and calculate the average gradient amplitude within different window scales. Set the calculation formula for the change rate of the average gradient amplitude:
[0113]
[0114] Among them, and respectively represent the average gradient magnitudes within different window scales s1 and s2. After obtaining the gradient dynamic distribution range of the current region, the contrast adjustment coefficient within the local window scale is calculated using:
[0115]
[0116] Among them, C adj represents the local contrast adjustment value, G C,j is the gradient magnitude of the j-th pixel point within the local window, G mean is the average gradient magnitude within the local window, G std is the standard deviation of the gradient magnitudes within the local window, N is the total number of pixel points within the window, max(G) and min(G) are the maximum and minimum gradient magnitudes within the window respectively. Among them, the standard deviation of the gradient magnitudes G std is usually set in the range of 2 - 10. If it is less than 2, it means that the gradient distribution within the window is too uniform and not suitable for enhancing contrast; if it is greater than 10, it means that there are strong gradient mutations within the window, which may lead to over-enhancement. Therefore, the reasonable setting range is between 2 and 10.
[0117] The edge contrast modulation sub-module calls the local contrast adjustment information, adjusts the contrast within the local window according to the gray-scale difference between edge pixels, controls the gray-scale difference between edge pixels to fall within the set range, calculates the edge gradient enhancement value of the adjusted region, and obtains the edge contrast enhancement information.
[0118] The edge contrast modulation sub-module calls the local contrast adjustment information and adjusts the contrast within the local window according to the gray-scale difference between edge pixels. First, calculate the gray-scale difference between edge pixel points, select the maximum gray-scale value G max and the minimum gray-scale value G min , and calculate their range:
[0119] ΔG = G max - G min ;
[0120] If ΔG exceeds the set range T G = 40, then scale the gray-scale values of all pixel points proportionally. This setting is based on the discovery in visual perception experiments that the human eye is more sensitive to gray-scale changes within 40. If it exceeds 40, it may lead to excessive contrast adjustment, thus affecting edge details. Therefore, 40 is set as the maximum adjustment range, and the scaling factor is set as:
[0121]
[0122] Set the maximum gray value within the local window to 200 and the minimum gray value to 120, then:
[0123] ΔG = 200 - 120 = 80;
[0124] If set T G = 40, then:
[0125]
[0126] For a certain pixel point G = 180, the adjusted gray value:
[0127] G' = 120 + 0.5×(180 - 120) = 150;
[0128] After adjustment, calculate the edge gradient enhancement value of the adjusted area to obtain the edge contrast enhancement information.
[0129] Please refer to Figure 4 , the wall thickness calculation module includes:
[0130] The edge pixel extraction sub-module, based on the edge contrast enhancement information, obtains the set of edge pixel points within the capsule wall thickness detection area, calls the pixel gradient data within 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 points to obtain the capsule edge recognition information;
[0131] The edge pixel extraction sub-module calls the edge contrast enhancement information and obtains the set of edge pixel points within the capsule wall thickness detection area. First, based on the enhanced contrast information, calculate the gradient amplitude of each pixel point. By calculating the gradient change amounts in the horizontal and vertical directions, take the square root of the sum of their squares as the gradient amplitude of the pixel point. Filter out the pixel points whose gradient amplitude is greater than the set threshold as candidate edge pixel points. The setting basis of the gradient amplitude threshold T G is the average gray change range within the capsule wall thickness detection imaging area. By statistically analyzing the imaging data of multiple capsules with different wall thicknesses, obtain the average gradient amplitude of the edge area, and set the threshold to 1.2 times of this average value to ensure that only obvious edge pixel points are retained. Set the statistical result of the average gradient amplitude to 20, then T G = 20×1.2 = 24. If the gradient amplitude of a certain pixel point is greater than 24, then determine it as an edge candidate pixel point. Then, within the neighborhood window (such as 3×3 or 5×5) of each candidate edge pixel point, call the gradient data of adjacent pixel points and calculate the gradient change rate between adjacent pixel points:
[0132]
[0133] Among them, G i and Gi+1 respectively represent the gradient values of adjacent pixel points. After calculating the gradient change rates of all adjacent pixel points, filter out the pixel points whose change rates are greater than the set threshold T ΔG as the wall thickness boundary points, and the gradient change rate threshold T ΔG is set according to the gradient change range of the edge region. Statistically calculate the gradient change rates between all adjacent pixel points in the edge region, and take its 75th percentile value as the threshold. If the 75th percentile value obtained statistically is 0.18, then set T ΔG = 0.18. If the gradient change rate of a certain pixel point is greater than 0.18, then determine it as a wall thickness boundary point. The set of all qualified wall thickness boundary points constitutes the capsule edge recognition information.
[0134] The wall thickness boundary calculation sub-module calls the capsule edge recognition information and uses the formula:
[0135]
[0136] to calculate the wall thickness value through operations;
[0137] where, W represents the wall thickness value, m represents the number of matching pairs 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 point of the kth group, and S W represents the physical size ratio corresponding to the pixel point spacing;
[0138] The wall thickness boundary calculation sub-module calls the capsule edge recognition information and calculates the wall thickness value through operations. First, pair the identified left and right boundary points to ensure that the left and right boundary points within the same abscissa range correspond one by one. Set the pairing principle as: within the same ordinate range, select the boundary point closest to the left and the boundary point closest to the right as the matching pair. Set the number of matching pairs m as the number of all successfully matched boundary points. The wall thickness calculation formula for each pair of matching boundary points is:
[0139]
[0140] where, (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 respectively. The setting basis of the physical size ratio S W corresponding to the pixel point spacing is the optical resolution of the imaging system. This value is jointly determined by the magnification of the imaging system and the pixel size of the sensor. For example, if the magnification of the imaging system is 5× and the pixel size of the sensor is 0.25 mm / pixel, then calculate S W= 0.25 / 5 = 0.05 mm / pixel, and the final wall thickness value is calculated as:
[0141]
[0142] Set the number of pairs of boundary points detected and matched m = 5, and its 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 result is:
[0146]
[0147] The obtained wall thickness is 3.89 mm.
[0148] The wall thickness abnormality rejection sub-module is based on the obtained wall thickness value, compares the set capsule wall thickness standard, screens the wall thickness that deviates from the set threshold, and marks and rejects the capsule to obtain the wall thickness abnormality rejection information.
[0149] The wall thickness abnormality rejection sub-module is based on the obtained wall thickness value and compares the set capsule wall thickness standard, screens the wall thickness that deviates from the set threshold, and marks and rejects the capsule. First, set the normal wall thickness range [W min , W max , and the setting basis of the normal wall thickness range is the capsule production process standard. Combining the qualified product data statistics, the upper and lower bounds of the 95% confidence interval are obtained. Set this range as [3.5, 4.2] mm, then set W min = 3.5 mm, W max = 4.2 mm, and 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 wall thickness of the detected samples is shown in Table 2.
[0152] Table 2 Wall thickness abnormality screening data
[0153] Sample Number 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 exceed the set range. Therefore, they are judged as abnormal capsules and are subject to rejection processing, and finally the wall thickness abnormality rejection information is obtained.
[0155] Please refer to Figure 5, the abnormal trend analysis module includes:
[0156] The wall thickness data extraction sub-module, based on the wall thickness abnormal rejection information, obtains the wall thickness numerical sequence of the capsule wall thickness detection batch, extracts the wall thickness values within the same batch, and arranges them in the detection order to form a wall thickness numerical sequence;
[0157] The wall thickness data extraction sub-module, based on the wall thickness abnormal rejection information, obtains the wall thickness numerical sequence of the capsule wall thickness detection batch. First, it calls the wall thickness abnormal rejection information, screens the wall thickness data that meets the standard wall thickness range (such as 3.5 mm to 4.5 mm), rejects the abnormal data outside the range, obtains the effective wall thickness data within the current batch, arranges them in the detection order to form a wall thickness numerical sequence. In the actual detection process, assume that the wall thickness values detected in a certain batch are (4.0 mm, 4.2 mm, 3.8 mm, 4.6 mm, 3.3 mm, 4.1 mm, 3.9 mm, 3.6 mm, 4.3 mm, 3.4 mm), and the wall thickness data outside the range (4.6 mm, 3.3 mm, 3.4 mm) are rejected to form the final wall thickness numerical sequence (4.0 mm, 4.2 mm, 3.8 mm, 4.1 mm, 3.9 mm, 3.6 mm, 4.3 mm). The setting basis of the wall thickness standard range from 3.5 mm to 4.5 mm is the manufacturing tolerance standard of the industry's capsule preparations. Specifically, based on the thickness uniformity requirements of the capsule shell material, this tolerance value is determined by the processing accuracy of the production line equipment. Usually, a tolerance interval of ±0.5 mm is taken. If this value
[0158] The wall thickness fluctuation calculation sub-module calls the wall thickness numerical sequence and uses the formula:
[0159]
[0160] Performs operations to obtain the fluctuation degree of the wall thickness values;
[0161] Among them, V represents the fluctuation degree of the wall thickness values, and W a represents the a-th wall thickness value within the batch, represents the average value of the wall thickness values of this batch, and N V represents the total number of wall thickness measurement data within the batch, and σ V represents the standard deviation of the wall thickness values within the batch, and C V represents the scaling factor;
[0162] The wall thickness fluctuation calculation sub-module calls the wall thickness numerical sequence to calculate the wall thickness fluctuation degree of this batch. First, it calculates the average value of the batch wall thickness data. The calculation formula is as follows:
[0163]
[0164] Among them, W a represents the a-th wall thickness value, and NV Represents the total number of wall thickness data for this batch. In this example:
[0165]
[0166] Next, calculate the standard deviation of the wall thickness data for this batch:
[0167]
[0168] Calculate the degree of wall thickness fluctuation. The calculation formula is as follows:
[0169]
[0170] Among them, the scaling factor C V = The setting basis of 1.5 is that it is used to adjust the calculated standardized fluctuation amount to a comparable range, ensuring the unified comparability of data from different batches at different deviation levels. This value comes from the adjustment parameters for the wall thickness uniformity of capsules in the production quality management system and is usually set between 1.0 and 2.0 according to the actual measurement accuracy of the production line. The value of 1.5 in this case is determined based on the average production tolerance data. Substitute it into the calculation:
[0171]
[0172] The calculated degree of wall thickness fluctuation V = 1.53 represents the wall thickness stability of this batch.
[0173] The wall thickness trend judgment sub-module calls the degree of fluctuation of the wall thickness value, analyzes the change trend of the wall thickness fluctuations of multiple batches, arranges the batches according to the time sequence, calculates the fluctuation change amount between adjacent batches, and judges whether the fluctuation change shows an increasing, decreasing or stable trend. It calls the set fluctuation threshold to mark the batches with wall thickness fluctuations exceeding the threshold range to obtain the wall thickness fluctuation trend information.
[0174] The wall thickness trend judgment sub-module calls the degree of fluctuation of the wall thickness value, analyzes the change trend of the wall thickness fluctuations of multiple batches. First, arrange the wall thickness fluctuation data of each batch in chronological order, calculate the fluctuation change amount between adjacent batches, and set the fluctuation change threshold T V = 0.5. The setting basis of this value is the allowable wall thickness fluctuation range during the production process, usually referring to the equipment accuracy and the change trend between production batches. If this value is too small, normal batches may be misjudged as having abnormal fluctuations. If this value is too large, abnormal fluctuations in the wall thickness during the actual production process may be ignored. Therefore, 0.5 as an empirical value comes from the stable control range of the capsule manufacturing equipment. In this example, the fluctuation data of 5 existing batches are set as shown in Table 3.
[0175] Table 3 Wall thickness fluctuation trend data
[0176] Batch Number Wall Thickness Fluctuation Degree 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 change amount 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] Judge the trend and set the judgment criteria. If ΔV > 0.5, it is determined that the fluctuation is abnormal. If ΔV is between 0.1 and 0.5, it is determined that the fluctuation is normal. If ΔV < 0.1, it is determined that the fluctuation is stable. This standard is based on the wall thickness mean value change range in the industry production statistics data. During the manufacturing process, a fluctuation less than 0.1 usually belongs to normal error, a fluctuation between 0.1 and 0.5 is an acceptable process fluctuation, and a fluctuation greater than 0.5 may mean abnormal equipment regulation or raw material quality problems. According to this standard:
[0183] For batch 2 relative to batch 1, ΔV 2,1 = 0.05 < 0.1, determined to be stable fluctuation;
[0184] For batch 3 relative to batch 2, ΔV 3,2 = 0.08 < 0.1, determined to be stable fluctuation;
[0185] For batch 4 relative to batch 3, ΔV 4,3 = 0.33, between 0.1 and 0.5, determined to be normal fluctuation;
[0186] For batch 5 relative to batch 4, ΔV 5,4 = 0.60 > 0.5, determined to be abnormal fluctuation;
[0187] Obtain the wall thickness fluctuation trend information, determine that batch 5 has abnormal fluctuation, and mark this batch as an abnormal batch.
[0188] Please refer to Figure 6 , the early warning feedback module includes:
[0189] The abnormal wall thickness ratio calculation sub-module, based on the wall thickness fluctuation trend information, obtains the number of abnormal wall thickness capsules in the corresponding batch, calls the total batch quantity data, calculates the proportion of the number of abnormal wall thickness capsules, and obtains the abnormal wall thickness ratio data;
[0190] Based on the wall thickness fluctuation trend information, the abnormal wall thickness ratio calculation sub-module obtains the number of abnormal wall thickness capsules in the corresponding batch, calls the screened data of batches with abnormal wall thickness, counts the number of capsules marked as abnormal in each batch, sets calculation rules. For example, if the wall thickness of a capsule exceeds the standard range (3.5 mm to 4.5 mm), it is recorded as an abnormal capsule. Traverse all the capsules in this batch and count the total number N of abnormal capsules. a , obtain the total number N of capsules in this batch. t , calculate the proportion of abnormal wall thickness capsules. The calculation method is as follows:
[0191]
[0192] In actual calculation, assume that the total number of capsules in a certain batch is 500, and the number of capsules with abnormal wall thickness is 35. Then calculate the abnormal ratio:
[0193]
[0194] The abnormal wall thickness judgment threshold (3.5 mm to 4.5 mm) is determined according to the capsule production process standard, specifically referring to the target wall thickness 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.5 mm. Therefore, 4.0 mm is set as the reference wall thickness and a deviation range of 0.5 mm is allowed to ensure that while meeting the physical strength, the wall thickness is not excessively increased, which may affect the drug release rate. If the wall thickness is too thin, the capsule may be damaged; if it is too thick, it may affect the dissolution rate of the capsule. Therefore, this threshold setting is derived from the comprehensive evaluation of the capsule material characteristics and dissolution test data, and this range changes with the adjustment accuracy of the batch production equipment. Finally, obtain the abnormal wall thickness ratio data of this batch.
[0195] Based on the abnormal wall thickness ratio data and combined with the wall thickness fluctuation trend, the early warning level evaluation sub-module evaluates the abnormal degree of the batch of capsules, classifies the abnormal degree, calls the set early warning level threshold, and uses the formula:
[0196]
[0197] Calculate the early warning level of the batch and obtain the batch early warning level data;
[0198] Among them, L represents the early warning level, N a represents the number of capsules with abnormal wall thickness in the batch, N t represents the total number of capsules in the batch, W L represents the weight factor of the batch, T L represents the average wall thickness of the capsules in the batch, T m represents the production standard wall thickness of the capsule;
[0199] The early warning level assessment sub-module evaluates the abnormality degree of the batch of capsules based on the abnormal wall thickness ratio data and in combination with the wall thickness fluctuation trend, and classifies the abnormality degree. First, it calls the abnormal wall thickness ratio P of this batch and the wall thickness fluctuation degree V of this batch to obtain the average wall thickness T of the batch L , calculates the deviation between this batch and the production standard wall thickness T m . The calculation method is as follows:
[0200] ΔT = |T L - T m |;
[0201] Set the average wall thickness T of this 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, and calculate the early warning level of the batch:
[0204]
[0205] Substitute the data:
[0206]
[0207] The weight factor W in the early warning level assessment L Is set to 2, which is based on the influence weight adjustment of the wall thickness abnormality ratio and the wall thickness fluctuation trend. The determination of the weight factor comes from the production process control requirements. If the abnormal wall thickness ratio of a certain batch is high, the wall thickness deviation has a greater impact on the overall batch. Therefore, the weight is increased. During the setting of this value, referring to past production data, it is found that batches with an abnormal wall thickness ratio of more than 10% usually have relatively large production deviations. Therefore, W L Is between 1 and 3. When the abnormal 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 according to the production trend in the future. According to the set early warning level threshold, the threshold range is set as follows:
[0208] L < 0.01 is a low risk;
[0209] 0.01 ≤ L < 0.05 is a medium risk;
[0210] L ≥ 0.05 is a high risk;
[0211] According to the calculation result L = 0.021, this batch is rated as medium risk, and the early warning level data of this batch is finally obtained.
[0212] Based on the batch early warning level data, the early warning signal sending sub-module screens 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.
[0213] Based on the batch early warning level data, the early warning signal sending sub-module screens the batches that meet the early warning conditions, sets the early warning trigger conditions. For example, it is set that if L≥0.05, a high-risk early warning is triggered; if 0.01≤L<0.05, a medium-risk early warning is triggered; if L<0.01, no early warning is triggered. The early warning level data of each batch is called, all batches are traversed, the 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, early warning information is generated, and the batch wall thickness early warning signal is sent to the management personnel. The trigger thresholds for this early warning level (low risk 0.01, medium risk 0.05, high risk above 0.05) are derived from the historical batch quality control standards. The setting of the benchmark value is based on the analysis of the production qualification rate. Usually, when the qualification rate is lower than 90%, the stability of drug production is affected. Therefore, when L>0.05, it is set as a high-risk early warning, and when L is between 0.01 and 0.05, it is an acceptable fluctuation range, but the trend change needs to be concerned. This threshold can be adjusted according to production requirements.
[0214] An on-line detection method for the wall thickness of capsules, comprising the following steps:
[0215] S1: Obtain the light intensity gradient values of the pixels in the capsule wall thickness detection area, analyze and identify the areas with uneven light distribution, adjust the pixel gray levels in the areas with sudden changes in light intensity gradient, and obtain the adjusted light distribution information.
[0216] S2: Based on the adjusted light distribution information, calculate the gradient distribution range in the local area, perform dynamic adjustment on the gradient distribution range, adjust the local contrast, and adjust the gray level difference between the edge pixels to the set range to obtain the edge contrast enhancement information.
[0217] S3: Based on the edge contrast enhancement information, calculate the gradient change rate of adjacent pixel points, screen the pixel points with a change rate reaching the set threshold as the wall thickness boundary points, call the pixel distance between the boundary points, calculate the wall thickness value, screen the wall thickness data that deviates from the set threshold, and mark and eliminate the capsules to obtain the wall thickness abnormality elimination information.
[0218] S4: Based on the wall thickness abnormality elimination 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 change trend of the wall thickness fluctuation, call the set fluctuation threshold, and mark the batches with wall thickness fluctuations exceeding the threshold range to obtain the wall thickness fluctuation trend information.
[0219] S5: Based on the wall thickness fluctuation trend information, calculate the proportion of the number of capsules with abnormal wall thickness in the total batch quantity, evaluate the abnormality degree of the batch of 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.
[0220] The above is only the preferred embodiment of the present invention, and does not limit the present invention in other forms. Any person skilled in the art may use the technical content disclosed above to make changes or modifications into equivalent embodiments with equivalent changes and apply them to other fields. However, as long as it does not depart from the technical solution content of the present invention, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present invention still fall within the protection scope of the technical solution of the present invention.
Claims
1. An on-line capsule wall thickness detection system, characterized in that, The system includes: The illumination correction module obtains the illumination gradient values of the pixels in the capsule wall thickness detection area, analyzes and identifies the uneven illumination distribution areas, and adjusts the pixel grayscales in the illumination gradient mutation areas to obtain the adjusted illumination distribution information; Based on the adjusted illumination distribution information, the edge enhancement module calculates the gradient distribution range in the local area, performs dynamic adjustment on the gradient distribution range, adjusts the local contrast, and adjusts the gray difference between edge pixels to a set range to obtain the edge contrast enhancement information; Based on the edge contrast enhancement information, the wall thickness calculation module calculates the gradient change rate of adjacent pixel points, selects the pixel points with the change rate reaching the set threshold as the wall thickness boundary points, calls the pixel distance between the boundary points, calculates the wall thickness value, filters out the wall thickness data deviating from the set threshold, and marks and eliminates the capsules to obtain the wall thickness abnormality elimination information; Based on the wall thickness abnormality elimination 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 change trend of the wall thickness fluctuation, calls the set fluctuation threshold, and marks the batches with the wall thickness fluctuation exceeding the threshold range to obtain the wall thickness fluctuation trend information.
2. The on-line capsule wall thickness detection system according to claim 1, characterized in that, The adjusted illumination distribution information includes illumination gradient adjustment parameters, local gray compensation coefficients, illumination equalization area division criteria, and pixel gray dynamic adjustment values. The edge contrast enhancement information includes edge gradient direction distributions, local contrast enhancement coefficients, pixel gray difference calculation values, and edge area pixel adjustment parameters. The wall thickness abnormality elimination information includes wall thickness data mean deviation, wall thickness data standard deviation, wall thickness fluctuation range interval, and wall thickness abnormality point identification tags. The wall thickness fluctuation trend information includes wall thickness fluctuation change rate, wall thickness fluctuation abnormal batch marks, wall thickness trend fluctuation amplitude, and wall thickness stability evaluation coefficients.
3. The on-line inspection system for the wall thickness of the capsule according to claim 1, characterized in that, The illumination correction module includes: The illumination gradient calculation sub-module of the illumination correction module obtains the illumination gradient values of the pixels in the capsule wall thickness detection area, calculates the gray change amount between adjacent pixel points, and obtains the illumination gradient values of the pixel points; The illumination gradient change analysis sub-module calls the illumination gradient values of the pixel points, calculates the illumination gradient change amount between adjacent pixel points, filters the illumination gradient change values, obtains the illumination gradient mutation areas, and calculates the local gray mean and standard deviation based on the pixel distribution characteristics of the mutation areas. Using the formula: Calculate the change degree of the pixel points in the mutation area relative to the local gray mean, and generate the illumination mutation area distribution coefficient; Among them, D represents the distribution coefficient of the light mutation region, G i represents the light gradient of pixel point i, μ represents the local gray mean, σ represents the local gray standard deviation, and ∈ is a stability constant; The illumination distribution adjustment sub-module calls the illumination mutation area distribution coefficient, adjusts the gray values of the pixel points in the illumination mutation area, and adjusts the gray values to the weighted balance value of the local gray mean and the illumination gradient change amount to obtain the adjusted illumination distribution information.
4. The on-line inspection system for the wall thickness of the capsule according to claim 1, characterized in that, The edge enhancement module includes: Based on the adjusted illumination distribution information, the edge gradient calculation sub-module extracts edge pixels within the imaging region for capsule wall thickness detection, calculates the gradient direction of each edge pixel, calls the gray-scale difference values within the local window of the pixel points to obtain the local gradient distribution range, calculates the rate of change of the gradient direction of the pixel points within the local window, and based on the distribution characteristics of the rate of change of the gradient direction, filters the stable region of the edge gradient direction to obtain the stable interval of the edge gradient direction; The local contrast adjustment sub-module calls the stable interval of the edge gradient direction, calculates the rate of change of the average gradient amplitude at multiple window scales to obtain the dynamic gradient distribution range of the current region, and based on the dynamic gradient distribution range, calculates the contrast adjustment coefficient within the local window scale, using the formula: Calculate the local contrast adjustment value to obtain the local contrast adjustment information; Among them, C adj represents the local contrast adjustment value, G C,j represents the gradient magnitude of the pixel points within the local window, G mean represents the average gradient magnitude within the local window, G std represents the standard deviation of the gradient magnitude within the local window, N represents the total number of pixel points within the local window, max(G) represents the maximum gradient magnitude within the local window, and min(G) represents the minimum gradient magnitude within the local window; The edge contrast modulation sub-module calls the local contrast adjustment information, adjusts the contrast within the local window according to the gray-scale difference between edge pixels, controls the gray-scale difference between edge pixels to fall within the set range, calculates the edge gradient enhancement value of the adjusted region to obtain the edge contrast enhancement information.
5. The on-line inspection system for the wall thickness of the capsule according to claim 1, wherein, The wall thickness calculation module includes: The edge pixel extraction sub-module, based on the edge contrast enhancement information, obtains the set of edge pixel points within the capsule wall thickness detection region, calls the pixel gradient data within the neighborhood window, calculates the rate of change of the gradient between adjacent pixel points, filters the rate of change of the gradient between adjacent pixel points, and extracts the pixel points whose rate of change reaches the set threshold as the wall thickness boundary points to obtain the capsule edge recognition information; The wall thickness boundary calculation sub-module calls the capsule edge recognition information and uses the formula: Perform operations to obtain the wall thickness value; Among them, W represents the wall thickness value, m represents the number of pairs of matching wall thickness boundary points, (X L,k , Y L,k ) represents the coordinates of the kth group of left boundary points, (X R,k , Y R,k ) represents the coordinates of the kth group of right boundary points, S W represents the physical size ratio corresponding to the pixel point pitch; The wall thickness anomaly elimination sub-module, based on the obtained wall thickness value, compares it with the set capsule wall thickness standard, filters the wall thicknesses that deviate from the set threshold, and marks and eliminates the capsules to obtain the wall thickness anomaly elimination information.
6. The on-line capsule wall thickness detection system according to claim 1, characterized in that, The anomaly trend analysis module includes: The wall thickness data extraction sub-module, based on the wall thickness anomaly elimination information, obtains the sequence of wall thickness values for the batch of capsule wall thickness detections, extracts the wall thickness values within the same batch, and arranges them in the detection order to form a sequence of wall thickness values; The wall thickness fluctuation calculation sub-module calls the sequence of wall thickness values and uses the formula: Perform operations to obtain the degree of fluctuation of the wall thickness value; Among them, V represents the degree of fluctuation of the wall thickness value, and W a represents the a-th wall thickness value within the batch, represents the average value of the wall thickness values of this batch, and N V represents the total number of wall thickness measurement data within the batch, and σ V represents the standard deviation of the wall thickness values within the batch, and C V represents the scaling factor; The wall thickness trend judgment sub-module calls the degree of fluctuation of the wall thickness value, analyzes the change trend of the wall thickness fluctuations in multiple batches, arranges the batches according to the time sequence, calculates the change amount of the fluctuations between adjacent batches, and judges whether the fluctuation change shows an increasing, decreasing or stable trend. Calls the set fluctuation threshold to mark the batches with wall thickness fluctuations exceeding the threshold range to obtain the wall thickness fluctuation trend information.
7. The on-line inspection system for the wall thickness of the capsule according to claim 1, characterized in that, The system further includes: Based on the wall thickness fluctuation trend information, the 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 in the total batch quantity, evaluates the abnormality degree of the batch of capsules, combines the wall thickness fluctuation trend, classifies the abnormality degree, calls the set warning level threshold, evaluates the warning level of the batch, filters the batches that meet the warning conditions, and sends warning information to the management personnel to obtain the batch wall thickness warning signal; The batch wall thickness warning signal includes an abnormal batch warning level, an abnormal wall thickness proportion threshold, a wall thickness abnormal batch sequence, and a management personnel notification status.
8. The on-line detection system for the wall thickness of the capsule according to claim 7, characterized in that, The warning feedback module includes: The abnormal wall thickness ratio calculation sub-module obtains the number of abnormal wall thickness capsules in the corresponding batch based on the wall thickness fluctuation trend information, calls the batch total amount data, calculates the proportion of the number of abnormal wall thickness capsules, and obtains the abnormal wall thickness ratio data; The warning level evaluation sub-module evaluates the abnormality degree of the batch capsules based on the abnormal wall thickness ratio data, combines with the wall thickness fluctuation trend, classifies the abnormality degree, calls the set warning level threshold, and uses the formula: Calculate the warning level of the batch and obtain the batch warning level data; Among them, L represents the early warning level, N a represents the number of abnormal wall thickness capsules in the batch, N t represents the total number of capsules in the batch, W L represents the weight factor of the batch, T L represents the average wall thickness of the capsules in the batch, T m represents the production standard wall thickness of the capsules; The warning signal sending sub-module screens the batches that meet the warning conditions based on the batch warning level data, sends a warning message to the management personnel, and obtains the batch wall thickness warning signal.
9. An on-line inspection method for the wall thickness of a capsule, characterized in that, The capsule wall thickness online detection system according to any one of claims 1-8 is executed, including the following steps: S1: Obtain the illumination gradient value of the pixels in the capsule wall thickness detection area, analyze and identify the uneven illumination distribution area, and adjust the pixel gray level of the illumination gradient mutation area to obtain the adjusted illumination distribution information; S2: Based on the adjusted illumination distribution information, calculate the gradient distribution range in the local area, perform dynamic adjustment on the gradient distribution range, adjust the local contrast, and adjust the gray level difference between the edge pixels to the set range to obtain the edge contrast enhancement information; S3: Based on the edge contrast enhancement information, calculate the gradient change rate of adjacent pixel points, screen the pixel points whose change rate reaches the set threshold as the wall thickness boundary points, calculate the wall thickness value, screen the wall thickness data that deviates from the set threshold, and mark and eliminate the capsules to obtain the wall thickness abnormality elimination information; S4: Based on the wall thickness abnormality elimination information, calculate the fluctuation degree of the wall thickness value, analyze the change trend of the wall thickness fluctuation, and mark the batches whose wall thickness fluctuation exceeds the threshold range to obtain the 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, and send a warning message to the management personnel to 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
Light steering and focusing by dielectrophoresis
WO2018148153A1
Screen defect detection method and apparatus, and device and storage medium
WO2025045021A1
Cited By
Quality control method for traditional Chinese medicine capsules
CN121563329A
Multi-feature adaptive cloud detection method based on satellite cloud picture
CN121837682A
A Multi-Feature Adaptive Cloud Detection Method Based on Satellite Cloud Images
CN121837682B