A tablet disintegration detection method and system
By acquiring images through a main camera and an auxiliary camera, and combining noise filtering and image enhancement processing, the tablet region is screened using the inter-frame difference method and the GrabCut semantic segmentation algorithm. Features are extracted and the CNN-LSTM model is used to predict the disintegration time limit, which solves the problem of time-consuming and labor-intensive manual detection and realizes automated, fast and accurate tablet disintegration detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- JIANGZHONG PHARMA CO LTD
- Filing Date
- 2025-11-13
- Publication Date
- 2026-04-24
AI Technical Summary
In the existing technology, tablet disintegration detection is time-consuming and labor-intensive, and prone to errors, relying on manual observation and timing.
Disintegration images were acquired using a main camera and an auxiliary camera. Noise filtering and image enhancement were combined, and tablet regions were screened using the inter-frame difference method and GrabCut semantic segmentation algorithm. Macroscopic and microscopic features were extracted, and the disintegration time limit was predicted by a pre-trained CNN-LSTM hybrid neural network model. A transfer learning strategy was adopted to adapt to the disintegration characteristics of different batches of tablets.
It achieves automated, rapid, and accurate tablet disintegration detection, effectively replacing manual observation and significantly shortening the detection time.
Smart Images

Figure CN121121658B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing technology, and specifically relates to a method and system for detecting tablet disintegration. Background Technology
[0002] During the tablet manufacturing process, disintegration is one of the important quality control indicators. Disintegration testing is typically required for regular tablets, sustained-release tablets, and controlled-release tablets.
[0003] Specifically, tablets are placed in the basket of a disintegrator and stirred in a medium (water, hydrochloric acid solution, etc., selected according to tablet type) at 37℃±1℃. The time for complete disintegration and passage through a sieve is recorded. Different tablets have different disintegration time requirements. For example, ordinary tablets: within 15 minutes; film-coated tablets: within 30 minutes; sugar-coated tablets: within 60 minutes; enteric-coated tablets: first, they must not disintegrate in hydrochloric acid solution for 2 hours, and then disintegrate in phosphate buffer solution for 1 hour.
[0004] Currently, tablet disintegration is detected by manual observation and timing. This process is time-consuming and labor-intensive. Moreover, the tablets are not large, making it easy to overlook details and record incorrect disintegration times. Summary of the Invention
[0005] Based on this, the present invention provides a tablet disintegration detection method and system, which aims to solve the problem that the detection of tablet disintegration by manual observation and timing in the prior art is time-consuming and labor-intensive.
[0006] A first aspect of this invention provides a tablet disintegration detection method, applied to a tablet disintegration scenario. The tablet disintegration scenario includes a transparent container containing a medium. The tablet is placed in the transparent container containing the medium for disintegration. A main camera is vertically mounted directly above the transparent container, and four auxiliary cameras are symmetrically arranged around the transparent container at 45° angles. The method includes:
[0007] The main camera and auxiliary camera capture disintegration images, and noise filtering and image enhancement processing are performed on the disintegration images to obtain disintegration images without color diffusion regions.
[0008] Based on the inter-frame difference method and the GrabCut semantic segmentation algorithm, the tablet body region in the disintegrated image without color diffusion region is selected;
[0009] Macroscopic and microscopic features of the main body region of the tablet are extracted. The macroscopic features include at least the area and roundness of the tablet, and the microscopic features include at least the number, length, and depth of cracks on the tablet surface.
[0010] The macroscopic and microscopic features are input into a pre-trained CNN-LSTM hybrid neural network model, which outputs a predicted disintegration time. The CNN-LSTM hybrid neural network model is optimized using a transfer learning strategy to quickly adapt to the disintegration characteristics of new batches of tablets when there are differences between different batches of tablets.
[0011] Furthermore, the step of acquiring the disintegration images captured by the main camera and the auxiliary camera, and performing noise filtering and image enhancement processing on the disintegration images to obtain disintegration images without color diffusion regions includes:
[0012] Based on the color of the current batch of tablets, sample images of undissolved tablets and pure media are collected. The a-channel color range and b-channel color range of the tablet body are extracted in the Lab color space. Based on the a-channel color range and the b-channel color range, the threshold range of the color diffusion area is set.
[0013] The disintegrated image is converted to the Lab color space, and it is determined whether the a value or b value of the pixel falls within the threshold range of the color diffusion region.
[0014] If so, it is identified as a preliminary color diffusion region, and connected component analysis is performed on the preliminary color diffusion region to obtain the preliminary color diffusion region mask, which is marked as the region to be removed.
[0015] The image converted to Lab color space is input into the trained U-Net model, which outputs semantic segmentation masks for three types of regions: tablet region, color diffusion region, and background medium region.
[0016] Perform a logical AND operation between the initial color diffusion region mask and the semantic segmentation mask to obtain the precise diffusion region mask;
[0017] The color diffusion region in the disintegration image is removed by using the precise mask of the diffusion region, and the tablet region is edge repaired and high-definition sharpened to obtain a disintegration image without color diffusion region.
[0018] Furthermore, the step of filtering tablet regions in a disintegrated image that does not contain color diffusion regions based on the inter-frame difference method and the GrabCut semantic segmentation algorithm includes:
[0019] The tablet body and particle region in the disintegration image without color diffusion area were initially screened by the inter-frame difference method to exclude the static transparent container background;
[0020] Using the preliminary screening results as seed points, the GrabCut semantic segmentation algorithm is used to segment the tablet body and the particles generated from disintegration, thereby determining the tablet body region.
[0021] Furthermore, in the step of extracting the macroscopic and microscopic features of the tablet body region, the number, length, and depth of cracks on the tablet surface are extracted using an edge detection algorithm.
[0022] Furthermore, the CNN-LSTM hybrid neural network model includes a CNN feature extraction module and an LSTM tablet disintegration detection temporal prediction module. The CNN feature extraction module adopts a structure of four tablet disintegration detection layers and two fully connected layers. The first three tablet disintegration detection layers use 3×3 and 5×5 hybrid convolutional kernels to extract the macroscopic and microscopic features of the tablet. The fourth tablet disintegration detection layer combines a 1×1 convolutional kernel to compress the feature dimension and reduce parameter redundancy. The fully connected layer maps the high-dimensional features output by the convolutional layers to a 256-dimensional feature vector, providing structured input for temporal prediction.
[0023] The LSTM tablet disintegration detection time-series prediction module includes a 3-layer LSTM tablet disintegration detection network, each layer containing 128 hidden units. It uses a gating mechanism to memorize key feature changes during the disintegration process. The 256-dimensional feature vectors output by the tablet disintegration detection CNN are arranged into a time-series sequence according to time steps. After being input into the LSTM network, the disintegration time prediction value for the current time step is obtained through a fully connected output layer.
[0024] Furthermore, in the step of using a transfer learning strategy to optimize the CNN-LSTM hybrid neural network model to quickly adapt to the disintegration characteristics of a new batch of tablets by fine-tuning parameters when there are differences between different batches of tablets, initial disintegration data within 10 minutes is collected for the new batch of tablets, and the parameters of the first two layers of the CNN feature extraction module and the LSTM temporal prediction module are frozen. Only the parameters of the third layer and the output layer of the LSTM temporal prediction module are adjusted, and the learning rate is reduced to 0.0001.
[0025] Furthermore, the step of inputting the macroscopic features and the microscopic features into a pre-trained CNN-LSTM hybrid neural network model and outputting a predicted collapse time limit includes:
[0026] Using a preset time as the time unit window, image features within the time unit window are acquired in real time, and continuous time-series data segments are formed through overlapping sampling.
[0027] The data from the time series data segments are sequentially input into a pre-trained CNN-LSTM hybrid neural network model, which outputs the corresponding predicted collapse time limit and confidence level.
[0028] Determine whether the deviation of the predicted collapse time limit for three consecutive times is less than 5%, and whether the confidence level is greater than or equal to 90%;
[0029] If so, the prediction result is considered convergent, and the final prediction collapse time limit is output.
[0030] If not, continue collecting data for the next time unit window until the prediction results converge.
[0031] A second aspect of this invention provides a tablet disintegration detection system for implementing the tablet disintegration detection method provided in the first aspect, the system comprising:
[0032] The acquisition module is used to acquire the disintegration images captured by the main camera and the auxiliary camera, and to perform noise filtering and image enhancement processing on the disintegration images to obtain disintegration images without color diffusion regions.
[0033] The filtering module is used to filter tablet body regions in disintegrated images that do not contain color diffusion regions, based on the inter-frame difference method and the GrabCut semantic segmentation algorithm.
[0034] An extraction module is used to extract macroscopic and microscopic features of the main body region of the tablet. The macroscopic features include at least the area and roundness of the tablet, and the microscopic features include at least the number, length, and depth of cracks on the tablet surface.
[0035] The input module is used to input the macroscopic features and the microscopic features into a pre-trained CNN-LSTM hybrid neural network model and output the predicted disintegration time limit. The CNN-LSTM hybrid neural network model is optimized by a transfer learning strategy so that when there are differences between different batches of tablets, the disintegration characteristics of the new batch of tablets can be quickly adapted by fine-tuning the parameters.
[0036] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the tablet disintegration detection method provided in the first aspect.
[0037] A fourth aspect of the present invention provides an electronic device including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor executes the program to implement the tablet disintegration detection method provided in the first aspect.
[0038] This invention provides a tablet disintegration detection method and system. The method acquires disintegration images from a main camera and an auxiliary camera, performs noise filtering and image enhancement on these images to obtain disintegration images without color diffusion regions. Based on the inter-frame difference method and the GrabCut semantic segmentation algorithm, the main tablet region within the disintegration images without color diffusion regions is selected. Macroscopic and microscopic features of the main tablet region are extracted. Macroscopic features include at least the tablet's area and roundness, while microscopic features include at least the number, length, and depth of surface cracks. The macroscopic and microscopic features are input into a pre-trained CNN-LSTM hybrid neural network model, which outputs a predicted disintegration timeframe. The CNN-LSTM hybrid neural network model is optimized using a transfer learning strategy to quickly adapt to the disintegration characteristics of new batches of tablets when there are differences between different batches, ultimately effectively replacing manual observation and significantly shortening the detection time. Attached Figure Description
[0039] Figure 1 This is a flowchart illustrating the implementation of a tablet disintegration detection method provided in Embodiment 1 of the present invention.
[0040] Figure 2 This is a structural block diagram of a tablet disintegration detection system provided in Embodiment 2 of the present invention;
[0041] Figure 3 This is a structural block diagram of an electronic device provided in Embodiment 3 of the present invention. Detailed Implementation
[0042] To facilitate understanding of the present invention, a more complete description will be given below with reference to the accompanying drawings. Several embodiments of the invention are illustrated in the drawings. However, the invention can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete.
[0043] It should be noted that when a component is said to be "fixed to" another component, it can be directly on the other component or there may be an intervening component. When a component is said to be "connected to" another component, it can be directly connected to the other component or there may be an intervening component. The terms "vertical," "horizontal," "left," "right," and similar expressions used in this document are for illustrative purposes only.
[0044] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0045] Example 1
[0046] Please see Figure 1 , Figure 1 The diagram illustrates a flowchart of a tablet disintegration detection method according to Embodiment 1 of the present invention. The tablet disintegration detection method specifically includes steps S01 to S04. It should be noted that this tablet disintegration detection method is applied to a tablet disintegration scenario. The scenario includes a transparent container containing a medium, where the tablet is placed in the transparent container to disintegrate. A main camera is vertically mounted directly above the transparent container, and four auxiliary cameras are symmetrically arranged around the transparent container at 45° angles. Understandably, all cameras are focused on the tablet.
[0047] Step S01: Acquire the disintegration images captured by the main camera and the auxiliary camera, and perform noise filtering and image enhancement processing on the disintegration images to obtain disintegration images without color diffusion regions.
[0048] Based on the color of the current batch of tablets, sample images of undissolved tablets and pure media are collected. The a-channel and b-channel color ranges of the tablet body are extracted in the Lab color space. A threshold range for the color diffusion region is then set based on these a-channel and b-channel color ranges. It should be noted that the L-channel in the Lab color space only reflects brightness information and is not affected by color diffusion. The a-channel (red-green opposing channel) and b-channel (yellow-blue opposing channel) are specifically used to carry color information. Pigments diffused from tablet dissolution (e.g., red diffusion in red tablets, yellow diffusion in yellow tablets) will form obvious color anomaly regions in the a / b channels, providing a clear basis for subsequent screening. Additionally, the a and b-channel color ranges of the tablet body are extracted in the Lab space (e.g., the a-channel value for red tablets is typically 50-80, and the b-channel value is -10-20), and a threshold range for the color diffusion region is set (the a / b value of the diffusion region will be 10-30 lower than that of the tablet body and closer to the a / b value of the medium).
[0049] The disintegrated image is converted to the Lab color space (instead of the traditional RGB space), and it is determined whether the a value or b value of the pixel falls within the threshold range of the color diffusion region.
[0050] If so, it is identified as a preliminary color diffusion region, and connected component analysis is performed on the preliminary color diffusion region to filter out isolated points with an area of less than 50 pixels (such as color interference from tiny impurities in the medium), and the preliminary color diffusion region mask is obtained and marked as the region to be removed.
[0051] The image converted to Lab color space is input into the trained U-Net model, which outputs semantic segmentation masks for three types of regions: tablet region, color diffusion region, and background medium region. The U-Net model is a lightweight improved U-Net semantic segmentation model. In this embodiment of the invention, tablet dissolution images with different degrees of color diffusion (slight diffusion: diffusion range < 10% of tablet area, moderate diffusion: 10%-30%, heavy diffusion: > 30%) are collected, and the tablet region, color diffusion region, and background medium region are manually labeled to form a training sample library. In addition, based on the traditional U-Net, depthwise separable convolution is used to replace ordinary convolution to reduce the amount of computation. At the same time, an attention gating module is added between the encoder and decoder to force the model to focus on the boundary region between the color diffusion and the tablet body, thereby improving the segmentation accuracy.
[0052] The preliminary color diffusion region mask and the semantic segmentation mask are logically ANDed to obtain the precise diffusion region mask. Specifically, when a pixel is marked by both the preliminary color diffusion region mask and the semantic segmentation mask, it is determined to be a color diffusion region that needs to be removed. Furthermore, morphological closing operations (dilation followed by erosion) are performed on the edges of the precise diffusion region mask to fill in the tiny holes in the diffusion region and avoid incomplete removal due to segmentation loopholes. At the same time, the edges are smoothed (e.g., Gaussian blur with a radius of 1-2 pixels) to prevent obvious mask traces during subsequent repair.
[0053] The color diffusion region in the disintegration image is removed pixel-level using the precise diffusion region mask, and the tablet area is then edge-repaired and sharpened to obtain a disintegration image free of color diffusion regions. It should be noted that in the RGB image, the pixel values of the diffusion region marked by the precise diffusion region mask are replaced with the average pixel values of the medium background (by real-time acquisition of the medium area not contaminated by diffusion in the image and calculation of the average brightness value of the RGB three channels), so that the diffusion region blends seamlessly with the surrounding medium background, initially eliminating color interference. In addition, for light-colored tablets such as white and transparent tablets (where the color difference between the diffusion region and the medium is small), brightness equalization is performed on the diffusion region in the L channel (brightness channel) to ensure that the brightness of the replaced area is consistent with the medium, avoiding bright and dark patches.
[0054] The steps for edge restoration and high-definition sharpening of the tablet area include:
[0055] Extract the edge contour of the tablet (obtained using the Canny operator). Using the edge contour as a reference, perform interpolation repair on the missing pixels at the tablet edge after the diffusion area is removed (e.g., generate pixel values with natural transitions based on the color and brightness change trends of pixels on both sides of the edge).
[0056] Apply Gaussian blur (standard deviation 1.5-2.0) to the repaired image to generate a blurred image;
[0057] Subtract the blurred image from the original restored image to obtain the edge-enhanced image;
[0058] The edge enhancement image is superimposed on the original restoration image at a ratio of 1:3 to improve the clarity of details such as cracks and textures on the tablet surface, and finally output a high-definition disintegration image without color diffusion areas.
[0059] Step S02: Based on the inter-frame difference method and the GrabCut semantic segmentation algorithm, filter the tablet body region in the disintegrated image that does not contain color diffusion regions.
[0060] It should be noted that the inter-frame difference method is used to initially screen the moving tablet body and particle regions in the disintegration image that do not contain color diffusion areas, so as to exclude the static transparent container background.
[0061] Using the preliminary screening results as seed points, the GrabCut semantic segmentation algorithm is used to segment the tablet body and the particles generated from disintegration, thereby determining the tablet body region.
[0062] Step S03: Extract the macroscopic and microscopic features of the main body region of the tablet. The macroscopic features include at least the area and roundness of the tablet, and the microscopic features include at least the number, length, and depth of cracks on the tablet surface.
[0063] The number, length, and depth of cracks on the tablet surface are extracted using edge detection algorithms (such as the Canny operator).
[0064] Step S04: Input the macroscopic features and the microscopic features into the pre-trained CNN-LSTM hybrid neural network model and output the predicted collapse time limit.
[0065] Among them, a transfer learning strategy is used to optimize the CNN-LSTM hybrid neural network model, which is used to quickly adapt to the disintegration characteristics of new batches of tablets by fine-tuning parameters when there are differences between different batches of tablets.
[0066] In this embodiment of the invention, the CNN-LSTM hybrid neural network model includes a CNN feature extraction module and an LSTM temporal prediction module. The CNN feature extraction module adopts a structure of 4 convolutional layers and 2 fully connected layers. The first 3 convolutional layers extract the macroscopic and microscopic features of the tablet through 3×3 and 5×5 hybrid convolutional kernels. The 4th convolutional layer combines 1×1 convolutional kernels to compress the feature dimension and reduce parameter redundancy. The fully connected layer maps the high-dimensional features output by the convolutional layers into a 256-dimensional feature vector, providing structured input for temporal prediction.
[0067] The LSTM time-series prediction module includes a 3-layer LSTM network, each layer containing 128 hidden units. It uses a gating mechanism (input gate, forget gate, output gate) to remember key feature changes during the collapse process. The 256-dimensional feature vector output by the CNN is arranged into a time-series sequence according to time steps (1 time step every 30 seconds). After being input into the LSTM network, the collapse time prediction value for the current time step is obtained through the fully connected output layer.
[0068] It should be noted that in the input layer, the tablet's main body region and quantified feature parameters can be fused into input data. The tablet's main body region, after normalization (pixel values scaled to 0-1), is input as a 480×480×3 (RGB channels) tensor. Quantified feature parameters (such as tablet area, number of cracks, length, and depth) are standardized and then concatenated with the image feature vector to form a multimodal input. Furthermore, in the output layer, a classification-regression combined output layer is designed based on different tablet disintegration criteria. For single-stage disintegration tablets such as regular tablets and film-coated tablets, the output layer uses a linear regression unit to directly output the predicted disintegration time (in minutes). For two-stage disintegration tablets such as enteric-coated tablets, the output layer is divided into two branches: the first branch outputs a binary classification result (0=not disintegrated, 1=disintegrated) using a Sigmoid activation function, and the second branch outputs the "disintegration time in phosphate buffer" through linear regression, meeting the prediction needs of multiple scenarios.
[0069] Furthermore, in the pre-training of the basic model, the training set was obtained using disintegration data of standard batches of tablets (covering four types: regular tablets, film-coated tablets, sugar-coated tablets, and enteric-coated tablets). The Adam optimizer (learning rate 0.001) was used to train the CNN-LSTM hybrid neural network model. When a new batch of tablets appeared, initial disintegration data within 10 minutes was collected, and the parameters of the first two layers of the CNN feature extraction module and the LSTM temporal prediction module were frozen. Only the parameters of the third layer and the output layer of the LSTM temporal prediction module were adjusted, with the learning rate reduced to 0.0001 to avoid the high time consumption of retraining while maintaining the generalization ability of the basic model.
[0070] Furthermore, to improve detection efficiency, the step of inputting the macroscopic features and the microscopic features into a pre-trained CNN-LSTM hybrid neural network model and outputting the predicted collapse time limit includes:
[0071] Using a preset time unit window, image features within the time unit window are collected in real time, and continuous time-series data segments are formed through overlapping sampling. For example, the first window collects data from 0 to 30 seconds, and the second window collects data from 15 to 45 seconds (window overlap rate 50%). Overlapping sampling reduces data omissions and improves temporal continuity.
[0072] The data in the time series data segment are sequentially input into the pre-trained CNN-LSTM hybrid neural network model, and the corresponding predicted collapse time limit and confidence score are output (based on the variance calculation of the model output layer).
[0073] Determine whether the deviation of the predicted collapse time limit for three consecutive times is less than 5%, and whether the confidence level is greater than or equal to 90%;
[0074] If so, the prediction result is considered convergent, and the final prediction collapse time limit is output.
[0075] If not, continue collecting data for the next time unit window until the prediction results converge, balancing prediction efficiency and accuracy.
[0076] In summary, the tablet disintegration detection method in the above embodiments of the present invention acquires disintegration images from a main camera and an auxiliary camera, performs noise filtering and image enhancement processing on the disintegration images to obtain disintegration images without color diffusion regions; based on the inter-frame difference method and the GrabCut semantic segmentation algorithm, the tablet main body region in the disintegration image without color diffusion regions is selected; macroscopic and microscopic features of the tablet main body region are extracted, with macroscopic features including at least the area and roundness of the tablet, and microscopic features including at least the number, length, and depth of cracks on the tablet surface; the macroscopic and microscopic features are input into a pre-trained CNN-LSTM hybrid neural network model, which outputs a predicted disintegration time limit. The CNN-LSTM hybrid neural network model is optimized using a transfer learning strategy to quickly adapt to the disintegration characteristics of new batches of tablets when there are differences between different batches, ultimately achieving the goal of effectively replacing manual observation and significantly shortening the detection time.
[0077] Example 2
[0078] Please see Figure 2 , Figure 2 This is a structural block diagram of a tablet disintegration detection system provided in Embodiment 2 of the present invention. The tablet disintegration detection system 200 includes: an acquisition module 21, a screening module 22, an extraction module 23, and an input module 24, wherein:
[0079] The acquisition module 21 is used to acquire the disintegration images captured by the main camera and the auxiliary camera, and to perform noise filtering and image enhancement processing on the disintegration images to obtain disintegration images without color diffusion regions;
[0080] The filtering module 22 is used to filter the tablet body region in the disintegration image that does not contain color diffusion region according to the inter-frame difference method and the GrabCut semantic segmentation algorithm.
[0081] Extraction module 23 is used to extract macroscopic and microscopic features of the main body area of the tablet. The macroscopic features include at least the area and roundness of the tablet, and the microscopic features include at least the number, length and depth of cracks on the tablet surface. The number, length and depth of cracks on the tablet surface are extracted by an edge detection algorithm.
[0082] Input module 24 is used to input the macroscopic features and microscopic features into a pre-trained CNN-LSTM hybrid neural network model and output the predicted disintegration time limit. The CNN-LSTM hybrid neural network model is optimized using a transfer learning strategy to quickly adapt to the disintegration characteristics of new batches of tablets when there are differences between different batches. The CNN-LSTM hybrid neural network model includes a CNN feature extraction module and an LSTM temporal prediction module. The CNN feature extraction module adopts a structure of 4 convolutional layers and 2 fully connected layers. The first 3 convolutional layers extract the macroscopic and microscopic features of the tablets using 3×3 and 5×5 hybrid convolutional kernels. The 4th convolutional layer combines a 1×1 convolutional kernel to compress the feature dimension and reduce parameter redundancy. The fully connected layer maps the high-dimensional features output by the convolutional layers into a 256-dimensional feature vector, providing structured input for temporal prediction.
[0083] The LSTM time-series prediction module includes a 3-layer LSTM network, each layer containing 128 hidden units. It uses a gating mechanism to remember key feature changes during the collapse process. The 256-dimensional feature vectors output by the CNN are arranged into a time-series sequence according to time steps. After being input into the LSTM network, the collapse time prediction value for the current time step is obtained through a fully connected output layer.
[0084] In the step of optimizing the CNN-LSTM hybrid neural network model using a transfer learning strategy to quickly adapt to the disintegration characteristics of a new batch of tablets by fine-tuning parameters when there are differences between different batches of tablets, initial disintegration data within 10 minutes is collected for the new batch of tablets, and the parameters of the first two layers of the CNN feature extraction module and the LSTM temporal prediction module are frozen. Only the parameters of the third layer and the output layer of the LSTM temporal prediction module are adjusted, and the learning rate is reduced to 0.0001.
[0085] Furthermore, in other embodiments of the present invention, the acquisition module 21 includes:
[0086] The extraction unit is used to acquire sample images of undissolved tablets and pure media based on the color of the current batch of tablets, extract the a-channel color range and b-channel color range of the tablet body in the Lab color space, and set the threshold range of the color diffusion region based on the a-channel color range and the b-channel color range.
[0087] The first judgment unit is used to convert the disintegrated image to the Lab color space and determine whether the a value or b value of the pixel falls within the threshold range of the color diffusion region.
[0088] The determining unit is used to determine a preliminary color diffusion region when the a value or b value of a pixel falls within the threshold range of the color diffusion region, and to perform connected component analysis on the preliminary color diffusion region to obtain a preliminary color diffusion region mask, which is then marked as a region to be removed.
[0089] The input unit is used to input the image after Lab color space conversion into the trained U-Net model and output semantic segmentation masks for three types of regions: tablet region, color diffusion region, and background medium region.
[0090] The operation unit is used to perform a logical AND operation on the preliminary color diffusion region mask and the semantic segmentation mask to obtain the accurate diffusion region mask.
[0091] The removal unit is used to remove the color diffusion region in the disintegration image using the precise mask of the diffusion region, and to perform edge repair and high-definition sharpening processing on the tablet region to obtain a disintegration image without the color diffusion region.
[0092] Furthermore, in other embodiments of the present invention, the screening module 22 includes:
[0093] The screening unit is used to initially screen the tablet body and particle regions in the disintegration image that do not contain color diffusion regions using the inter-frame difference method, so as to exclude the static transparent container background.
[0094] The segmentation unit is used to segment the tablet body and the particles generated from disintegration, using the preliminary screening results as seed points and the GrabCut semantic segmentation algorithm, to determine the tablet body region.
[0095] Furthermore, in other embodiments of the present invention, the input module 24 includes:
[0096] The first acquisition unit is used to acquire image features within a preset time unit window in real time, and form continuous time-series data segments through overlapping sampling.
[0097] The input unit is used to sequentially input data from time-series data segments into a pre-trained CNN-LSTM hybrid neural network model and output the corresponding predicted collapse time limit and confidence level.
[0098] The second judgment unit is used to determine whether the deviation of the three consecutive predictions of the collapse time limit is less than 5% and whether the confidence level is greater than or equal to 90%.
[0099] The decision unit is used to determine the prediction result as convergent when the deviation of the predicted collapse time limit for three consecutive predictions is less than 5% and the confidence level is greater than or equal to 90%, and outputs the final predicted collapse time limit.
[0100] The second acquisition unit is used to continue acquiring data for the next time unit window when the deviation of the prediction collapse time limit for three consecutive predictions is not less than 5% and / or the confidence level is less than 90%, until the prediction results converge.
[0101] Example 3
[0102] In another aspect, the present invention also proposes an electronic device, please refer to [link to relevant documentation]. Figure 3 The electronic device shown is an embodiment of the present invention, including a memory 20, a processor 10, and a computer program 30 stored in the memory and executable on the processor. When the processor 10 executes the computer program 30, it implements the tablet disintegration detection method as described above.
[0103] In some embodiments, the processor 10 may be a central processing unit (CPU), controller, microcontroller, microprocessor or other data processing chip, used to run program code stored in memory 20 or process data, such as executing access restriction programs.
[0104] The memory 20 includes at least one type of readable storage medium, such as flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 20 can be an internal storage unit of an electronic device, such as the hard disk of the electronic device. In other embodiments, the memory 20 can also be an external storage device of the electronic device, such as a plug-in hard disk, SmartMediaCard (SMC), SecureDigital (SD) card, FlashCard, etc., equipped on the electronic device. Furthermore, the memory 20 can include both internal and external storage units of the electronic device. The memory 20 can be used not only to store application software and various types of data of the electronic device, but also to temporarily store data that has been output or will be output.
[0105] It should be pointed out that, Figure 3 The structure shown does not constitute a limitation on the electronic device. In other embodiments, the electronic device may include fewer or more components than shown, or combine certain components, or have different component arrangements.
[0106] This invention also proposes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the tablet disintegration detection method described above.
[0107] Those skilled in the art will understand that the logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can mean any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.
[0108] More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.
[0109] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0110] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0111] The above embodiments merely illustrate several implementation methods of the present invention, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of this patent should be determined by the appended claims.
Claims
1. A method for detecting tablet disintegration, characterized in that, In a scenario involving tablet disintegration, the tablets are placed in a transparent container filled with a medium for disintegration. A main camera is vertically mounted above the transparent container, and four auxiliary cameras are symmetrically arranged around the container at 45° angles. The method includes: The main camera and auxiliary camera capture disintegration images, and noise filtering and image enhancement processing are performed on the disintegration images to obtain disintegration images without color diffusion regions. Based on the inter-frame difference method and the GrabCut semantic segmentation algorithm, the tablet body region in the disintegrated image without color diffusion region is selected; Macroscopic and microscopic features of the main body region of the tablet are extracted. The macroscopic features include at least the area and roundness of the tablet, and the microscopic features include at least the number, length, and depth of cracks on the tablet surface. The macroscopic features and the microscopic features are input into a pre-trained CNN-LSTM hybrid neural network model, which outputs a predicted disintegration time limit. The CNN-LSTM hybrid neural network model is optimized by a transfer learning strategy, which is used to quickly adapt to the disintegration characteristics of new batches of tablets by fine-tuning parameters when there are differences between different batches of tablets. The steps of acquiring the disintegration images captured by the main camera and the auxiliary camera, and performing noise filtering and image enhancement processing on the disintegration images to obtain disintegration images without color diffusion regions include: Based on the color of the current batch of tablets, sample images of undissolved tablets and pure media are collected. The a-channel color range and b-channel color range of the tablet body are extracted in the Lab color space. Based on the a-channel color range and the b-channel color range, the threshold range of the color diffusion area is set. The disintegrated image is converted to the Lab color space, and it is determined whether the a value or b value of the pixel falls within the threshold range of the color diffusion region. If so, it is identified as a preliminary color diffusion region, and connected component analysis is performed on the preliminary color diffusion region to obtain the preliminary color diffusion region mask, which is marked as the region to be removed. The image converted to Lab color space is input into the trained U-Net model, which outputs semantic segmentation masks for three types of regions: tablet region, color diffusion region, and background medium region. Perform a logical AND operation between the initial color diffusion region mask and the semantic segmentation mask to obtain the precise diffusion region mask; The color diffusion region in the disintegration image is removed by using the precise mask of the diffusion region, and the tablet region is edge repaired and high-definition sharpened to obtain a disintegration image without color diffusion region.
2. The tablet disintegration detection method according to claim 1, characterized in that, The step of filtering tablet regions in a disintegrated image that does not contain color diffusion regions based on the inter-frame difference method and the GrabCut semantic segmentation algorithm includes: The tablet body and particle region in the disintegration image without color diffusion area were initially screened by the inter-frame difference method to exclude the static transparent container background; Using the preliminary screening results as seed points, the GrabCut semantic segmentation algorithm is used to segment the tablet body and the particles generated from disintegration, thereby determining the tablet body region.
3. The tablet disintegration detection method according to claim 2, characterized in that, In the step of extracting the macroscopic and microscopic features of the tablet body region, the number, length, and depth of cracks on the tablet surface are extracted using an edge detection algorithm.
4. The tablet disintegration detection method according to claim 3, characterized in that, The CNN-LSTM hybrid neural network model includes a CNN feature extraction module and an LSTM temporal prediction module. The CNN feature extraction module adopts a structure of 4 convolutional layers and 2 fully connected layers. The first 3 convolutional layers use 3×3 and 5×5 hybrid convolutional kernels to extract the macroscopic and microscopic features of the tablet. The 4th convolutional layer combines a 1×1 convolutional kernel to compress the feature dimension and reduce parameter redundancy. The fully connected layer maps the high-dimensional features output by the convolutional layers into a 256-dimensional feature vector, providing structured input for temporal prediction. The LSTM time-series prediction module includes a 3-layer LSTM network, each layer containing 128 hidden units. It uses a gating mechanism to remember key feature changes during the collapse process. The 256-dimensional feature vectors output by the CNN are arranged into a time-series sequence according to time steps. After being input into the LSTM network, the collapse time prediction value for the current time step is obtained through a fully connected output layer.
5. The tablet disintegration detection method according to claim 4, characterized in that, In the step of optimizing the CNN-LSTM hybrid neural network model using a transfer learning strategy to quickly adapt to the disintegration characteristics of a new batch of tablets by fine-tuning parameters when there are differences between different batches of tablets, initial disintegration data within 10 minutes is collected for the new batch of tablets, and the parameters of the first two layers of the CNN feature extraction module and the LSTM temporal prediction module are frozen. Only the parameters of the third layer and the output layer of the LSTM temporal prediction module are adjusted, and the learning rate is reduced to 0.0001.
6. The tablet disintegration detection method according to claim 5, characterized in that, The step of inputting the macroscopic features and the microscopic features into a pre-trained CNN-LSTM hybrid neural network model and outputting a predicted collapse time limit includes: Using a preset time as the time unit window, image features within the time unit window are acquired in real time, and continuous time-series data segments are formed through overlapping sampling. The data from the time series data segments are sequentially input into a pre-trained CNN-LSTM hybrid neural network model, which outputs the corresponding predicted collapse time limit and confidence level. Determine whether the deviation of the predicted collapse time limit for three consecutive times is less than 5%, and whether the confidence level is greater than or equal to 90%; If so, the prediction result is considered convergent, and the final prediction collapse time limit is output. If not, continue collecting data for the next time unit window until the prediction results converge.
7. A tablet disintegration detection system, characterized in that, For implementing the tablet disintegration detection method according to any one of claims 1-6, the system comprises: The acquisition module is used to acquire the disintegration images captured by the main camera and the auxiliary camera, and to perform noise filtering and image enhancement processing on the disintegration images to obtain disintegration images without color diffusion regions. The filtering module is used to filter tablet body regions in disintegrated images that do not contain color diffusion regions, based on the inter-frame difference method and the GrabCut semantic segmentation algorithm. An extraction module is used to extract macroscopic and microscopic features of the main body region of the tablet. The macroscopic features include at least the area and roundness of the tablet, and the microscopic features include at least the number, length, and depth of cracks on the tablet surface. The input module is used to input the macroscopic features and the microscopic features into a pre-trained CNN-LSTM hybrid neural network model and output the predicted disintegration time limit. The CNN-LSTM hybrid neural network model is optimized by a transfer learning strategy so that when there are differences between different batches of tablets, the disintegration characteristics of the new batch of tablets can be quickly adapted by fine-tuning the parameters.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements the tablet disintegration detection method as described in any one of claims 1-6.
9. An electronic device, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor, when executing the program, implements the tablet disintegration detection method as described in any one of claims 1-6.