Quality detection method of San She Fengshi medicine wine
Patent Information
- Application Number
- CN202611143636.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-30
- Publication Date
- 2026-10-13
AI Technical Summary
[0004]为此,本发明提供一种三蛇风湿药酒的质量检测方法,用以克服现有技术中单一的图像处理方式无法动态适应不同的药酒检测情况,未能考虑质量检测时的实际变化情况并做出适应性调节,导致质量检测的灵活性差的问题
[0035]与现有技术相比,本发明的有益效果在于,本发明通过图像变化指数确定检测图像的处理方式,其中,图像变化指数反映相邻两帧检测图像之间灰度显著变化的区域占比程度,在液体波动较小时采用边缘分割以精准定位液体区域边界,在液体波动较大时采用均匀分割以快速锁定液体图像,避免了单一分割方式在沉淀物运动剧烈时边缘分割失效,在沉淀物运动平缓时均匀分割精度不足的问题,兼顾了液体图像提取的精度与计算效率。
Smart Images

Figure CN122905503A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of quality testing technology, and in particular to a quality testing method for a three-snake rheumatism medicinal wine. Background Technology
[0002] Three-Snake Rheumatism Wine is a traditional Chinese medicine wine made from three types of snakes—the Golden-ringed Snake, the Black-striped Snake, and the King Rat Snake—combined with a variety of Chinese medicinal herbs including Astragalus membranaceus, Angelica pubescens, Salvia miltiorrhiza, Erythrina variegata bark, Photinia serratifolia, Lycium barbarum, Notopterygium incisum, Chaenomeles speciosa, and Boswellia carterii. It is extracted through soaking in baijiu (Chinese white liquor). This wine is believed to dispel wind and dampness, penetrate muscles and bones, clear meridians, relieve pain, and disperse swelling and bruising. Clinically, it is used for general rheumatic pain, numbness in the limbs, lower back and knee pain, sciatica, traumatic injuries, and hemiplegia. In its preparation, the three types of snakes are soaked in baijiu in a sealed container for 60 days, while the remaining medicinal herbs are pulverized and soaked in baijiu for 45 days. The two liquids are then combined, allowed to stand, and filtered to obtain a clear, reddish-brown liquid. The presence of suspensions or precipitates in packaged medicinal wines, which contain a large number of active ingredients, is closely related to the stability and quality of the medicinal wine. Existing testing methods often require opening the bottle for sampling, which destroys the complete packaging of the medicine. Furthermore, static observation cannot obtain information on the suspension trajectory and morphological changes of precipitates in the liquid. Therefore, how to achieve non-destructive testing of packaged medicinal wine products to improve the accuracy of quality testing is a problem of great concern to those skilled in the art.
[0003] Chinese Patent Publication No. CN119624876A discloses a method for identifying impurities and bubbles inside a wine bottle based on multi-feature comprehensive judgment. The method includes: continuously capturing multiple frames of images of the wine bottle using a high-resolution industrial camera combined with an LED light source under consistent shooting angle and lighting conditions; preprocessing the acquired images using adaptive histogram equalization and Gaussian blurring methods; extracting the edges of impurities and bubbles inside the wine bottle from the images using the Canny edge detection algorithm to obtain edge images; segmenting the edge images into multiple target regions using contour detection technology, and extracting possible bubble and impurity regions from the edge images; extracting features of the target regions, including roundness, gray-level mean, gray-level uniformity, texture features, and color space; and applying comprehensive judgment rules to distinguish between bubbles and impurities based on the extracted features. However, the above technical solution suffers from the following problems: a single image processing method cannot dynamically adapt to different medicinal wine testing conditions, fails to consider actual changes during quality testing and make adaptive adjustments, resulting in poor flexibility in quality testing. Summary of the Invention
[0004] Therefore, this invention provides a quality testing method for Sanshe Rheumatism Medicinal Wine, which overcomes the problem that the single image processing method in the prior art cannot dynamically adapt to different medicinal wine testing conditions, fails to consider the actual changes during quality testing and make adaptive adjustments, resulting in poor flexibility in quality testing.
[0005] To achieve the above objectives, the present invention provides a quality testing method for Three-Snake Rheumatism Medicinal Wine, comprising:
[0006] A rotational excitation is applied to the target medicinal wine bottle to obtain a sequence of detection images of the target wine bottle after the rotational excitation;
[0007] The processing method for the detected image is determined based on the image change index of the detected image sequence, which is either edge segmentation or uniform segmentation to obtain the liquid image sequence;
[0008] Candidate validation analysis is performed on liquid image sequences to determine the corresponding sedimentation regions in each liquid image based on the gray values of pixels.
[0009] Cross-frame comparison is performed on each sedimentation region in the first frame of the liquid image sequence. Cross-frame comparison determines whether there is a matching object in each sedimentation region by positional distance and morphological similarity, and determines whether each sedimentation region is sediment based on the number of matching objects.
[0010] Determine whether to issue an abnormal warning for the target medicinal wine bottle based on the area and quantity of sediment.
[0011] Specifically, the active region corresponding to the precipitate is obtained, and the number of liquid images compared across frames is increased based on the change in the proportion of the active region. The adjustment benchmark is determined based on the change in the number of precipitates.
[0012] Furthermore, the rotational excitation includes:
[0013] Place the target medicinal wine bottle on the rotating device and drive the target medicinal wine bottle to rotate for a preset time, so that the sediment in the target medicinal wine bottle leaves the bottom of the bottle under the action of centrifugal force and is suspended in the liquid.
[0014] Within a preset time window after the target medicinal wine bottle stops rotating, multiple frames of images of the target medicinal wine bottle are acquired and uniformly extracted. The extracted images are recorded as detection images, and the detection images are arranged in order from earliest to latest acquisition time to obtain a detection image sequence.
[0015] Furthermore, based on the condition that the image change index of the detected image sequence is less than or equal to a preset image change index, the processing method for the detected image is determined to be edge segmentation, which includes:
[0016] Obtain the gradient intensity of each pixel in the detection image, and record the pixels in the detection image whose gradient intensity is greater than the preset gradient intensity as boundary candidate pixels;
[0017] Starting from the top left corner of the detected image, the preset scanning window moves with a preset step size, and the boundary candidate pixels with the largest gray-level gradient within the window are obtained in turn and recorded as boundary pixels.
[0018] The detection image region that can be enclosed by the connected boundary pixels is denoted as a liquid image. The liquid images are arranged in order from earliest to latest according to their corresponding acquisition time to obtain a liquid image sequence.
[0019] Furthermore, based on the condition that the image change index of the detected image sequence is greater than a preset image change index, the processing method for the detected image is determined to be uniform segmentation, which includes:
[0020] Each detected image is uniformly divided to obtain several regions of the same area. Regions with pixel limit variation greater than the preset pixel limit variation are recorded as boundary blocks.
[0021] The detection image region corresponding to the smallest rectangle that can surround each boundary block is denoted as the liquid image. The liquid images are arranged in order from earliest to latest according to their corresponding acquisition time to obtain the liquid image sequence.
[0022] Furthermore, pixels in each liquid image whose grayscale value is less than or equal to a preset grayscale value are recorded as sedimentation pixels;
[0023] Candidate validation analysis is performed on each deposited pixel in a random order. For a single deposited pixel, the candidate validation analysis includes:
[0024] Obtain the neighboring pixels corresponding to the precipitated pixel, record the precipitated pixel and its corresponding neighboring pixels as precipitated analysis pixels, and check whether each precipitated analysis pixel has a corresponding neighboring pixel. If it does, record the neighboring pixel as a precipitated analysis pixel. Continue to check whether each precipitated analysis pixel has a corresponding neighboring pixel. Repeat this process until no new neighboring pixels are found, then stop the loop and record the precipitated analysis pixel corresponding to the precipitated pixel as a precipitated region.
[0025] Furthermore, cross-frame comparisons are performed on each sedimentation region of the first frame of the liquid image sequence in a random order. For a single sedimentation region, the cross-frame comparison includes:
[0026] The first frame of liquid image is recorded as the target image. The sedimentation area in the next frame of liquid image corresponding to the target image whose positional distance is less than or equal to the preset positional distance and whose morphological similarity is greater than the preset morphological similarity is recorded as the matching object corresponding to the sedimentation area.
[0027] The liquid image of the matching object corresponding to the sedimentation area is recorded as the target image, and cross-frame comparison is performed with the corresponding next frame liquid image.
[0028] The sedimentation area where the number of matched objects exceeds the preset number of matched objects is recorded as sediment.
[0029] Furthermore, an abnormal warning is issued for target medicinal wine bottles where the sediment area index is greater than the preset sediment area index or the sediment quantity index is greater than the preset sediment quantity index.
[0030] Furthermore, the smallest rectangle in the liquid image that can contain all the sediment is recorded as the active region. For the target medicinal wine bottle whose proportion change is greater than the preset proportion change, cross-frame comparison and adjustment analysis is determined.
[0031] Furthermore, in the cross-frame comparison and adjustment analysis, for the condition that the change in the amount of sediment in each active region is greater than the preset change in the amount of sediment, the adjustment benchmark for increasing the amount of liquid image is determined to be the change in the amount of sediment.
[0032] The adjustment range of the number of liquid images is positively correlated with the degree of change in the amount of sediment.
[0033] Furthermore, for the condition that the change in the amount of sediment in each activity area is less than or equal to the preset change in the amount of sediment, the adjustment benchmark for increasing the amount of liquid image is determined to be the sediment area fluctuation.
[0034] The adjustment range of the number of liquid images is positively correlated with the fluctuation of the sedimentation area.
[0035] Compared with the prior art, the beneficial effects of the present invention are that the present invention determines the processing method of the detection image through the image change index, wherein the image change index reflects the proportion of the region with significant gray-scale change between two adjacent detection images. When the liquid fluctuation is small, edge segmentation is used to accurately locate the boundary of the liquid region, and when the liquid fluctuation is large, uniform segmentation is used to quickly lock the liquid image. This avoids the problem that edge segmentation fails when the sediment movement is violent, and uniform segmentation is not accurate enough when the sediment movement is slow. It takes into account both the accuracy and computational efficiency of liquid image extraction.
[0036] Furthermore, this invention performs cross-frame comparison of sedimentation areas, constrains the spatial continuity of the same sediment in adjacent frames by positional distance, and constrains the shape consistency of the same sediment in adjacent frames by morphological similarity. Matching objects belonging to the same sedimentation area in each detection image are grouped into the same sediment. This enables continuous tracking and identification of the sediment's trajectory during suspension and movement, and determines the sediment by the number of matching objects, thus improving the accuracy of sediment identification.
[0037] Furthermore, this invention comprehensively determines whether to issue an abnormal warning for the target medicinal wine bottle by using the sediment area index and sediment quantity index. The sediment area index reflects the overall level of the size of each sediment in the target medicinal wine bottle, while the sediment quantity index reflects the level of the quantity of sediment that is continuously and stably present. This avoids misjudgment or omission caused by relying on only a single dimension, and achieves accurate screening of abnormal medicinal wine bottles, thereby improving the reliability and automation of quality inspection.
[0038] Furthermore, this invention determines whether to perform cross-frame comparison adjustment analysis by the percentage change of the active area, where the percentage change reflects the degree of fluctuation in the activity range of the sediment in each frame image. It determines that cross-frame comparison adjustment analysis is triggered only when the activity range of the sediment fluctuates significantly, thus avoiding unnecessary increase in the number of detection images when the sediment distribution is stable, and adaptively increasing the amount of matching data when the sediment distribution fluctuates drastically, thus balancing matching accuracy and computational resource overhead.
[0039] Furthermore, this invention determines the adjustment benchmark for increasing the number of detection images by the degree of change in the amount of sediment. The degree of change in the amount of sediment reflects the degree of fluctuation in the number of sediment regions in each frame of the detection image. When the sediment quantity fluctuates significantly, the degree of change in the amount of sediment is used as the adjustment benchmark. When the sediment quantity fluctuates less, the degree of fluctuation in the sediment area is used as the adjustment benchmark. The degree of fluctuation in the sediment area reflects the degree of fluctuation in the total area of the larger sediment regions in each frame. This allows for priority supplementation of frames to track quantity changes when the sediment quantity distribution is uneven, and priority supplementation of frames to track area evolution when the sediment size distribution is uneven. This achieves optimal adaptation between the adjustment of the number of detection images and the actual dynamic characteristics of the sediment. Attached Figure Description
[0040] Figure 1 This is a schematic diagram of a quality testing method for a three-snake rheumatism medicinal wine according to an embodiment of the present invention;
[0041] Figure 2 This is a flowchart illustrating how the detection image processing method is determined based on the image change index, according to an embodiment of the present invention.
[0042] Figure 3 This is a flowchart illustrating how to determine whether to issue an abnormal warning to the target medicinal wine bottle based on the area or quantity of sediment, according to an embodiment of the present invention.
[0043] Figure 4 This is a flowchart illustrating how to determine whether to perform cross-frame comparison and adjustment analysis based on the percentage change of the active area, according to an embodiment of the present invention. Detailed Implementation
[0044] To make the objectives and advantages of the present invention clearer, the present invention will be further described below with reference to embodiments; it should be understood that the specific embodiments described herein are merely for explaining the present invention and are not intended to limit the present invention.
[0045] Preferred embodiments of the present invention will now be described with reference to the accompanying drawings. Those skilled in the art should understand that these embodiments are merely illustrative of the technical principles of the present invention and are not intended to limit the scope of protection of the present invention.
[0046] It should be noted that in the description of this invention, the terms "upper," "lower," "left," "right," "inner," and "outer," etc., which indicate directions or positional relationships, are based on the directions or positional relationships shown in the accompanying drawings. This is merely for ease of description and does not indicate or imply that the device or element must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, it should not be construed as a limitation of this invention.
[0047] Please see Figure 1 As shown, it is a schematic diagram of a quality testing method for a three-snake rheumatism medicinal wine according to an embodiment of the present invention. The method includes:
[0048] A rotational excitation is applied to the target medicinal wine bottle to obtain a sequence of detection images of the target wine bottle after the rotational excitation;
[0049] The processing method for the detected image is determined based on the image change index of the detected image sequence, which is either edge segmentation or uniform segmentation to obtain the liquid image sequence;
[0050] Candidate validation analysis is performed on liquid image sequences to determine the corresponding sedimentation regions in each liquid image based on the gray values of pixels.
[0051] Cross-frame comparison is performed on each sedimentation region in the first frame of the liquid image sequence. Cross-frame comparison determines whether there is a matching object in each sedimentation region by positional distance and morphological similarity, and determines whether each sedimentation region is sediment based on the number of matching objects.
[0052] Determine whether to issue an abnormal warning for the target medicinal wine bottle based on the area and quantity of sediment.
[0053] Specifically, the active region corresponding to the precipitate is obtained, and the number of liquid images compared across frames is increased based on the change in the proportion of the active region. The adjustment benchmark is determined based on the change in the number of precipitates.
[0054] In this embodiment of the invention, an industrial camera is used to acquire a sequence of detection images of the target medicinal wine bottle to analyze whether there are any abnormalities in the sediment. The target medicinal wine bottle is a sealed bottle containing Sanshe Rheumatism Medicinal Wine after the label has been removed. The bottle is placed in a rotating device and rotated, causing it to rotate around the central axis of the smallest cylinder that can surround the bottle, suspending the sediment in the liquid. A backlight source positioned behind the bottle provides supplemental illumination. The industrial camera acquires detection images of the target medicinal wine bottle at a preset frequency to form a sequence of detection images. The detection images can completely capture the liquid portion of the target medicinal wine bottle, and may include, but are not limited to, a portion of the bottle and the entire bottle. Subsequent analysis focuses on the liquid portion to reduce computational load. In this embodiment, the shape of the medicinal wine bottle can be, but is not limited to, cylindrical or elliptical, and the rotating device can be, but is not limited to, a bottle-rotating disc.
[0055] In this embodiment of the invention, the preset frequency is obtained by means of: the higher the preset frequency, the more detection images are collected, the more analysis data is generated for quality detection, and the higher the user's requirements for the quality detection accuracy of the medicinal wine, the higher the value of the preset frequency. In this embodiment, the preset frequency is recorded by obtaining the acquisition frequency of the industrial camera in historical working conditions and calculating the average value after removing outliers.
[0056] Specifically, the rotational excitation includes:
[0057] Place the target medicinal wine bottle on the rotating device and drive the target medicinal wine bottle to rotate for a preset time, so that the sediment in the target medicinal wine bottle leaves the bottom of the bottle under the action of centrifugal force and is suspended in the liquid.
[0058] Within a preset time window after the target medicinal wine bottle stops rotating, multiple frames of images of the target medicinal wine bottle are acquired and uniformly extracted. The extracted images are recorded as detection images, and the detection images are arranged in order from earliest to latest acquisition time to obtain a detection image sequence.
[0059] In this embodiment of the invention, the method of obtaining the preset time includes: the longer the preset time, the longer the target medicinal wine bottle rotates, the better the suspension effect of the sediment, the higher the dispersion of the sediment in the detection image, the better the detection effect, and the higher the user's requirements for the quality detection accuracy of the medicinal wine, the longer the preset time value. By obtaining the preset time in historical working conditions, the average preset time after removing outliers is calculated as the preset time for rotation.
[0060] In this embodiment of the invention, the methods for obtaining the preset time window and the number of frames include: the shorter the preset time window, the lower the degree of change of the sediment; the longer the preset time window, the greater the ambiguity caused by sedimentation; the smaller the number of frames, the more images are detected, the larger the amount of data to be calculated, and the higher the user's requirements for the timeliness of the medicinal wine quality detection, the smaller the values of the preset time window and the number of frames.
[0061] In this embodiment of the invention, the preset value can also be obtained numerically through simulation. For example, in this embodiment, multiple sets of detection data from medicinal wine bottles with different sedimentation rates and different liquid viscosities are collected for simulation. Different time window thresholds are set for image acquisition tests, and the detection recall rate is used as the evaluation index. The average value of the time window threshold that meets the user's needs is selected as the preset time window.
[0062] Please see Figure 2 As shown, this is a flowchart illustrating how the processing method for a detected image is determined based on an image change index according to an embodiment of the present invention. For cases where the image change index of the detected image sequence is less than or equal to a preset image change index, the processing method for the detected image is determined to be edge segmentation. Edge segmentation includes:
[0063] Obtain the gradient intensity of each pixel in the detection image, and record the pixels in the detection image whose gradient intensity is greater than the preset gradient intensity as boundary candidate pixels;
[0064] To obtain boundary pixels, the detection image is scanned using a preset scanning window. First, the starting position of the preset scanning window is placed at the top left corner of the detection image, so that the top left corner pixel of the window coincides with the top left corner pixel of the detection image. The column containing the top left corner pixel of the detection image is recorded as the starting column.
[0065] Then, a horizontal scan is performed, and the window is controlled to move sequentially from left to right along the current row with a preset step size. Each time the window moves, all pixels in the current coverage area are recorded.
[0066] When the window moves horizontally to the far right of the current line, and the number of pixels contained in the window is less than the maximum number of pixels the window can hold, a vertical line break is performed.
[0067] When performing a vertical line break, the window is moved down one pixel in the vertical direction and reset to the leftmost end of the new line, so that the top left pixel of the window coincides with the pixel where the new line intersects with the starting column;
[0068] Repeat the horizontal scanning and vertical line wrapping process until all pixels in the image to be detected have been covered by the window at least once, thus completing the full image scan and stopping the scan.
[0069] Finally, the boundary candidate pixel with the largest gray-level gradient in each preset scanning window is recorded as the boundary pixel. If there is no boundary candidate pixel in the window, the window is skipped and scanning continues. If the boundary candidate pixel with the largest gray-level gradient in the window has been marked, the boundary candidate pixel with the largest gray-level gradient other than the boundary pixel is recorded as the boundary pixel.
[0070] Connectivity analysis is performed: If the boundary pixels can form a connected closed region, the detection image region enclosed by the connected closed region is denoted as the liquid image; if the boundary pixels cannot form a connected closed region, the connected boundary pixel segments formed by the boundary pixels are obtained, and the endpoints of the boundary pixel segments are denoted as target endpoints. The connection of each target endpoint is confirmed in a random order. For a single target endpoint, the connection is confirmed by obtaining the target endpoint that is closest to it but not connected to it and denoting it as the connection endpoint. The target endpoint is connected to the connection endpoint, and the detection image region enclosed by the connected boundary pixels is denoted as the liquid image. The liquid images are arranged in order from earliest to latest according to their corresponding acquisition time to obtain the liquid image sequence.
[0071] In this embodiment of the invention, the process of confirming the image change index includes: the image change index is used to determine the degree of change between two adjacent detection images. The larger the image change index, the more pixels with significant grayscale changes in the two adjacent detection images, and the more obvious the displacement of the deposits. In this embodiment, the image change index is determined based on the number of change groups in two adjacent detection images and the total number of pixels in the detection images. The image change index is positively correlated with the number of change groups and negatively correlated with the total number of pixels. Specifically, the image change index is the average of the adjacent difference indices of each adjacent image group. An adjacent image group consists of two adjacent detection images in the detection image sequence. For a single adjacent image group, the adjacent difference index is the ratio of the number of change pixel groups in two adjacent detection images to the total number of pixels in the detection images. A change group is a combination of pixels whose absolute value of the grayscale difference between two pixels is greater than a preset grayscale difference. A pixel combination consists of pixels at the same position in two adjacent detection images, wherein the grayscale value of each pixel in the detection image is obtained after grayscale processing.
[0072] In this embodiment of the invention, the gradient intensity acquisition process includes: the gradient intensity is used to determine the degree of grayscale change of each pixel in the detection image in the horizontal and vertical directions. The greater the gradient intensity, the higher the probability that the pixel is located at the boundary of the bottle texture. In this embodiment, the gradient intensity confirmation process includes: the gradient intensity is determined based on the absolute values of the horizontal gradient and the absolute values of the vertical gradient of the pixel. The gradient intensity is positively correlated with both the absolute values of the horizontal gradient and the absolute values of the vertical gradient. Specifically, the gradient intensity is the sum of the absolute values of the horizontal gradient and the absolute values of the vertical gradient of a single pixel obtained by the absolute value summation method. The horizontal gradient is the difference between the sum of the grayscale values of pixels within a preset distance to the right of the pixel and the sum of the grayscale values of pixels within a preset distance to the left. The vertical gradient is the difference between the sum of the grayscale values of pixels within a preset distance to the lower side of the pixel and the sum of the grayscale values of pixels within a preset distance to the upper side.
[0073] The process of obtaining the preset distance includes the following: the larger the preset distance, the higher the accuracy of gradient strength calculation, but the greater the computational cost; the more sensitive users are to the timeliness of quality testing of the medicinal wine, the smaller the value of the preset distance. In this embodiment, the average value of the preset distance after removing outliers from the preset distance obtained in historical working conditions is recorded as the preset distance for gradient strength calculation.
[0074] In this embodiment of the invention, the process of obtaining the preset image change index includes: simulating the acquisition of multiple sets of detection image data of target medicinal wine bottles with different sediment distribution densities and different image noise levels; setting different image change index thresholds to determine the detection image processing method; using the time consumed in a single segmentation process as the evaluation index; and selecting the average value of the image change index thresholds that meet the user's needs as the preset image change index.
[0075] In this embodiment of the invention, the process of obtaining the preset grayscale difference includes: It is understood that medicinal wine liquid is usually brownish-yellow or dark brown, the contrast between the sediment and the liquid background is low, while the contrast between the target medicinal wine bottle and the backlight source is high. The higher the user's requirements for the quality detection accuracy of medicinal wine, the larger the value of the preset grayscale difference. By collecting multiple sets of medicinal wine bottle detection image data under different lighting conditions and different sediment grayscale differences for simulation, different grayscale difference thresholds are set for change group judgment tests. The accuracy rate of change group recognition is used as the evaluation index, and the average value of the grayscale difference threshold that meets the user's needs is selected as the preset grayscale difference.
[0076] In this embodiment of the invention, the process of obtaining the preset gradient intensity includes: simulating the detection of multiple sets of medicinal wine bottles with different texture complexities, setting different gradient intensity thresholds for boundary candidate pixel determination tests, using the boundary pixel error rate as the evaluation index, and selecting the average value of the gradient intensity thresholds that meet the user's needs as the preset gradient intensity.
[0077] In this embodiment of the invention, the process of obtaining the preset scanning window and preset step size includes: the smaller the preset scanning window, the higher the positioning accuracy of the liquid edge and the higher the acquisition accuracy of the liquid image; the smaller the preset step size, the more detailed the screening of boundary pixels; and the higher the user's requirements for the quality detection accuracy of the medicinal wine, the smaller the values of the preset scanning window and preset step size. In this embodiment, the preset scanning window and preset step size are obtained from historical working conditions, and the average value of the preset scanning window and preset step size after removing outliers is calculated, which are then used as the preset scanning window and preset step size for boundary pixel acquisition.
[0078] Specifically, for the condition that the image change index of the detected image sequence is greater than a preset image change index, the processing method for the detected image is determined to be uniform segmentation. Uniform segmentation includes:
[0079] Each detected image is uniformly divided to obtain several regions of the same area. Regions with pixel limit variation greater than the preset pixel limit variation are recorded as boundary blocks.
[0080] The detection image region corresponding to the smallest rectangle that can surround each boundary block is denoted as the liquid image. The liquid images are arranged in order from earliest to latest according to their corresponding acquisition time to obtain the liquid image sequence.
[0081] The area of the detected image is the product of the total number of pixels in the horizontal direction and the total number of pixels in the vertical direction.
[0082] In this embodiment of the invention, the process of confirming the pixel limit variation range includes: the pixel limit variation range is used to determine the maximum difference in grayscale values of pixels within a single region block after uniform segmentation of the detected image. The larger the pixel limit variation range, the more significant the grayscale difference within the region block, and the higher the probability of including the bottle boundary. In this embodiment, the pixel limit variation range is determined based on the maximum absolute value of the grayscale value difference between any two pixels in the region block, and the pixel limit variation range is positively correlated with the maximum absolute value of the grayscale value difference. Specifically, the pixel limit variation range is the maximum absolute value of the grayscale value difference between any two pixels in the region block.
[0083] In this embodiment of the invention, the process of obtaining the preset pixel limit variation range includes: the smaller the pixel limit variation range, the smaller the grayscale difference within the region block, the higher the probability that it belongs to the liquid inside the bottle or the background, the lower the probability that it includes the bottle boundary, and the more sensitive the user is to the quality detection accuracy of the medicinal wine, the larger the value of the preset pixel limit variation range. In this embodiment, multiple sets of target medicinal wine bottle detection image data with different illumination uniformity are collected for simulation, and different pixel limit variation range thresholds are set for boundary block judgment tests. The boundary block recognition recall rate is used as the evaluation index, and the average value of the pixel limit variation range threshold that meets the user's needs is selected as the preset pixel limit variation range.
[0084] In this embodiment of the invention, the process of obtaining the number of segments during uniform segmentation includes: the larger the number of segments, the smaller the area of each region block, and the higher the positioning accuracy of the liquid region boundary; conversely, the smaller the number of segments, the larger the area of each region block, the smaller the computational load of a single segmentation process, and the lower the positioning accuracy of the liquid region boundary. Furthermore, the higher the user's requirements for the quality testing of the medicinal wine, the larger the value of the number of segments should be. In this embodiment, the number of segments is obtained from historical operating conditions, and the average number of segments after removing outliers is calculated and recorded as the number of segments for uniform segmentation.
[0085] Specifically, candidate validation analysis is performed on liquid images, including:
[0086] Pixels in each liquid image whose grayscale value is less than or equal to a preset grayscale value are recorded as sedimentation pixels;
[0087] Candidate validation analysis is performed on each deposited pixel in a random order. For a single deposited pixel, the candidate validation analysis includes:
[0088] The precipitated pixels located in the square region centered on the precipitated pixel and with three pixels as the sides are recorded as adjacent pixels. The system checks whether each precipitated analysis pixel has a corresponding adjacent pixel. If it does, the adjacent pixel is recorded as a precipitated analysis pixel. The system continues to check whether each precipitated analysis pixel has a corresponding adjacent pixel. This process is repeated until no new adjacent pixels are found. The system then stops and the precipitated analysis pixel corresponding to the precipitated pixel is recorded as a precipitated region.
[0089] In this embodiment of the invention, the process of setting the preset grayscale value includes: the smaller the preset grayscale value, the darker the pixels judged as deposited pixels, and the lower the false labeling rate of deposited pixels, but it may miss labeling real deposited pixels with slightly higher grayscale values; the larger the preset grayscale value, the more lenient the screening conditions for deposited pixels, the lower the possibility of missing labeling real deposited pixels with higher grayscale values, and the higher the user's requirements for the quality detection accuracy of medicinal wine, the smaller the value of the preset grayscale value. In this embodiment, the preset grayscale value is obtained by acquiring the preset grayscale value in historical working conditions and calculating the average value of the preset grayscale value after removing outliers, which is recorded as the preset grayscale value obtained by the deposited pixels.
[0090] Specifically, cross-frame comparison includes:
[0091] Cross-frame comparisons are performed on each sedimentation region of the first frame of the liquid image sequence in a random order. For a single sedimentation region, the cross-frame comparison includes:
[0092] The first frame of liquid image is recorded as the target image. The sedimentation area in the next frame of liquid image corresponding to the target image whose positional distance is less than or equal to the preset positional distance and whose morphological similarity is greater than the preset morphological similarity is recorded as the matching object corresponding to the sedimentation area.
[0093] The liquid image containing the matching object corresponding to the sedimentation area is recorded as the target image, and cross-frame comparison is performed with the liquid image of the next frame corresponding to it. This process is repeated to compare each target image across frames to obtain the number of matching objects for the sedimentation area.
[0094] The sedimentation area where the number of matched objects exceeds the preset number of matched objects is recorded as sediment.
[0095] If there is no matching object for the sedimentation area in the next frame of the liquid image corresponding to the target image, then cross-frame comparison will not be performed, and it will be determined that the sedimentation area is not sediment.
[0096] In this embodiment of the invention, the process of confirming the positional distance includes: the positional distance is used to determine the degree of spatial proximity between two sedimentation regions in different detection images. The greater the positional distance, the farther the spatial interval between the two sedimentation regions in the image, and the lower the probability that they belong to the same sediment. In this embodiment, the positional distance is determined based on the modulus between the coordinates of the center points of any two sedimentation regions, and the positional distance is positively correlated with the straight-line distance. Specifically, the positional distance is the modulus between the coordinates of the center points of any two sedimentation regions, and the coordinates of the center points are the coordinates of the center points in the detection image coordinate system, which has the pixel at the top left corner of the detection image as the origin, the column direction as the vertical axis, and the row direction as the horizontal axis.
[0097] In this embodiment of the invention, the process of confirming morphological similarity includes: morphological similarity is used to determine the degree of similarity in the outline shape of two sedimentation regions. The greater the morphological similarity, the smaller the area difference between the two sedimentation regions, the closer their shapes, and the higher the probability that they belong to the same sediment. In this embodiment, morphological similarity is determined based on the area of similar circles in the two sedimentation regions, and the absolute value of the difference in area between the morphological similarity and the similar circles is negatively correlated. Specifically, morphological similarity is the absolute value of the difference in area between similar circles in the two sedimentation regions, and the similar circle is the smallest circle that can contain a single sedimentation region.
[0098] In this embodiment of the invention, the process of obtaining the preset number of matching objects includes: the larger the number of matching objects, the more stable the existence of the sedimentation area, the greater the certainty of the sediment, and the higher the user's requirements for the quality detection accuracy of the medicinal wine, the larger the value of the preset number of matching objects. In this embodiment, the average value of the number of matching objects after removing outliers is calculated by obtaining the number of matching objects in historical working conditions and recorded as the preset number of matching objects.
[0099] In this embodiment of the invention, the process of obtaining the preset position distance and preset morphological similarity includes: the higher the user's requirement for the accuracy of cross-frame comparison, the smaller the value of the preset position distance and the larger the value of the preset morphological similarity. By obtaining the position distance and morphological similarity in historical working conditions, the average value of the position distance and morphological similarity after removing outliers is calculated and recorded as the preset position distance and preset morphological similarity.
[0100] Please see Figure 3 As shown, it is a flowchart of an embodiment of the present invention for determining whether to issue an abnormal warning to the target medicinal wine bottle based on the sediment area or sediment quantity. An abnormal warning is issued for the target medicinal wine bottle whose sediment area index is greater than a preset sediment area index or sediment quantity index is greater than a preset sediment quantity index. The abnormal warning methods include, but are not limited to, sound reminders and light flashing.
[0101] In this embodiment of the invention, the process of confirming the sediment area index includes: the sediment area index is used to determine the average size of the sediment in the target medicinal wine bottle. The larger the sediment area index, the larger the size of each sediment, and the higher the risk of abnormal quality of the medicinal wine. In this embodiment, the sediment area index is determined based on the average value of the comprehensive area of each sediment, and the sediment area index and the average value of the comprehensive area are positively correlated. Specifically, the sediment area index is the average value of the comprehensive area of each sediment. For a single sediment, the comprehensive area is the average value of the area of the matching object corresponding to that sediment in each detection image.
[0102] In this embodiment of the invention, the process of confirming the sediment quantity index includes: the sediment quantity index is used to determine the level of sediment that persists in the target medicinal wine bottle. The larger the sediment quantity index, the more sediments with a matching ratio greater than a preset matching ratio, the more stable suspended particles in the target medicinal wine bottle, and the higher the risk of abnormal medicinal wine quality. In this embodiment, the sediment quantity index is determined based on the matching ratio corresponding to the sediment, and the sediment quantity index is positively correlated with the number of sediments with a matching ratio greater than a preset matching ratio. Specifically, the sediment quantity index is the number of sediments with a matching ratio greater than a preset matching ratio. For a single sediment, the matching ratio is the ratio of the number of detection images containing that sediment to the total number of detection images.
[0103] In this embodiment of the invention, the process of setting the preset sediment area index includes: a smaller preset sediment area index indicates higher sensitivity to sediment area and higher accuracy of abnormal warnings, but may lead to some qualified medicinal wine bottles being misjudged as abnormal; a larger preset sediment area index reduces the false alarm rate, but may result in some sediment areas not exceeding the standard but still affecting the quality of the medicinal wine, thus reducing detection accuracy. In this embodiment, multiple sets of medicinal wine bottle detection image data with different sediment size distributions and different sediment aggregation forms are collected for simulation. Different sediment area index thresholds are set for abnormal warning triggering tests. The accuracy of issuing abnormal warnings is used as the evaluation index, and the average value of the sediment area index thresholds that meet user needs is selected as the preset sediment area index.
[0104] In this embodiment of the invention, the process of setting the preset sediment quantity index includes: a smaller preset sediment quantity index value results in higher sensitivity to sediment quantity and improved accuracy of abnormal warnings, but may lead to some qualified medicinal wine bottles being falsely judged as abnormal; a larger preset sediment quantity index value indicates that warnings are only issued to target medicinal wine bottles with a large amount of sediment, reducing the false alarm rate, but may result in some sediments not exceeding the standard but exhibiting clustered abnormalities, leading to decreased detection accuracy. In this embodiment, multiple sets of medicinal wine bottle detection image data with different sediment quantities and different sediment distribution densities are collected for simulation. Different sediment quantity index thresholds are set for abnormal warning triggering tests. The false alarm rate of normal medicinal wine bottles is used as the evaluation index, and the average value of the sediment quantity index thresholds that meet user needs is selected as the preset sediment quantity index.
[0105] Please see Figure 4 As shown, it is a flowchart of an embodiment of the present invention for determining whether to perform cross-frame comparison adjustment analysis based on the percentage change of the active area. The smallest rectangle in the liquid image that can contain all the sediments is recorded as the active area. For the target medicinal wine bottle whose percentage change of the active area is greater than the preset percentage change, it is determined to perform cross-frame comparison adjustment analysis.
[0106] For target medicinal wine bottles with a percentage change less than or equal to a preset percentage change, no cross-frame comparison and adjustment analysis is required.
[0107] In this embodiment of the invention, the process of confirming the change in the proportion of the active area includes: the change in the proportion of the active area is used to determine the degree of fluctuation in the ratio of the area of the active region of the sediment to the area of the liquid image in each liquid image. The greater the change in the proportion of the active area, the more drastic the change in the activity range of the sediment in each frame of the liquid image, and the more unstable the sedimentation or diffusion behavior of the sediment. In this embodiment, the change in the proportion of the active area is determined based on the variance and average value of the activity proportion of each liquid image. The change in the proportion of the active area is positively correlated with the variance of the activity proportion and negatively correlated with the average value of the activity proportion. Specifically, the change in the proportion of the active area is the ratio of the variance of the activity proportion of each liquid image to the average value, and the activity proportion is the ratio of the area of the active region to the area of the liquid image in a single frame of the liquid image.
[0108] In this embodiment of the invention, the process of setting the preset percentage change degree includes: when the preset percentage change degree is too small, it is more sensitive to fluctuations in the range of sediment activity; small fluctuations may trigger an increase in the number of liquid images, improving matching accuracy, but increasing the rate of increase in computational resources; when the preset percentage change degree is too large, it indicates that adjustment is only triggered when there are significant fluctuations in the range of sediment activity, resulting in a lower rate of increase in computational resources, but potentially a decrease in matching accuracy. In this embodiment, the preset percentage change degree is obtained by acquiring the percentage change degree in historical operating conditions, calculating the average percentage change degree after removing outliers, and recording it as the preset percentage change degree.
[0109] Specifically, in the cross-frame comparison adjustment analysis, for the condition that the change in the number of sediments in each active area is greater than the preset change in the number of sediments, the adjustment benchmark for increasing the number of liquid images is determined to be the change in the number of sediments.
[0110] The adjustment range of the number of liquid images is positively correlated with the degree of change in the amount of sediment.
[0111] In this embodiment of the invention, the process of confirming the degree of change in the amount of sediment includes: the degree of change in the amount of sediment is used to determine the level of difference in the number of sediment regions in each liquid image. The greater the degree of change in the amount of sediment, the more obvious the fluctuation in the number of sediment regions in each liquid image, the higher the degree of change in the distribution state of the sediment, and the more liquid images need to be acquired to improve the detection accuracy. In this embodiment, the degree of change in the amount of sediment is determined based on the number of sediment regions in each liquid image, and the degree of change in the amount of sediment is positively correlated with the range of the number of sediment regions. Specifically, the degree of change in the amount of sediment is the range of the number of sediment regions in each liquid image.
[0112] The adjusted number of liquid images is the product of the number of liquid images before adjustment and the change adjustment coefficient, which is the ratio of the change in the number of sediments to the preset change in the number of sediments.
[0113] In this embodiment of the invention, the process of obtaining the preset sediment quantity variation degree is as follows: multiple sets of target medicinal wine bottle liquid image data with different sediment quantity fluctuation ranges are collected for simulation, and different sediment quantity variation degree thresholds are set for adjustment benchmark judgment tests. The accuracy of matching after adjustment and the increase in computing resources are used as evaluation indicators, and the average value of the sediment quantity variation degree threshold that meets the user's needs is selected as the preset sediment quantity variation degree.
[0114] Specifically, for the condition that the change in the amount of sediment in each liquid image is less than or equal to the preset change in the amount of sediment, the adjustment benchmark for increasing the amount of liquid image is determined to be the sediment area fluctuation.
[0115] The adjustment range of the number of liquid images is positively correlated with the fluctuation of the sedimentation area.
[0116] In this embodiment of the invention, the process of confirming the sedimentation area fluctuation includes: the sedimentation area fluctuation is used to determine the degree of area fluctuation of larger sedimentation areas in each liquid image. The greater the sedimentation area fluctuation, the more significant the fluctuation in the total area of sedimentation areas exceeding the average level in each frame of images, and the more unstable the sedimentation and aggregation state of the sediment. In this embodiment, the sedimentation area fluctuation is determined based on the variance of the total area of a class of regions in each liquid image, and the sedimentation area fluctuation is positively correlated with the variance of the number of class of regions. Specifically, the sedimentation area fluctuation is the variance of the total area of a class of regions in each liquid image, and a class of regions refers to sedimentation areas in a single frame of liquid image whose sedimentation area is greater than the average area of all sedimentation areas.
[0117] The adjusted number of liquid images is the product of the original number of liquid images and the fluctuation adjustment coefficient, which is the ratio of the sedimentation area fluctuation to the preset sedimentation area fluctuation. It is worth noting that the increased number of liquid images after adjustment has a maximum value, which is the number of images of the target medicinal liquor bottle captured by the industrial camera within a preset time window.
[0118] In this embodiment of the invention, the process of setting the preset sedimentation area fluctuation degree includes: if the preset sedimentation area fluctuation degree is too small, the sensitivity to sedimentation area fluctuations is high, and small area fluctuations may trigger an increase in the number of liquid images, improving the cross-frame comparison matching accuracy, but increasing the computational resource increase rate; if the preset sedimentation area fluctuation degree is too large, it indicates that the adjustment is only triggered when the sedimentation area fluctuates significantly, resulting in a lower computational resource increase rate, but the cross-frame comparison matching accuracy may decrease due to insufficient liquid images. In this embodiment, by obtaining the sedimentation area fluctuation degree in historical working conditions, the average value of the sedimentation area fluctuation degree after removing outliers is calculated and recorded as the preset sedimentation area fluctuation degree.
[0119] In this embodiment of the invention, historical operating conditions refer to parameter records from previous medicinal wine quality testing processes. These records document the parameter values used in this method. For any given operating condition, if its testing accuracy meets the quality testing requirements, then that historical operating condition is considered a historically qualified operating condition. Whether the testing accuracy corresponding to a historical operating condition meets the quality testing requirements can be determined based on, but is not limited to, the detection rate of non-conforming products and the false detection rate of conforming products. How to determine whether the quality testing requirements are met is a topic already understood by those skilled in the art and will not be elaborated further.
[0120] The technical solution of the present invention has been described above with reference to the preferred embodiments shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will all fall within the scope of protection of the present invention.
Claims
1. A quality testing method for a three-snake rheumatism medicinal wine, characterized in that, include: A rotational excitation is applied to the target medicinal wine bottle to obtain a sequence of detection images of the target wine bottle after the rotational excitation; The processing method for the detected image is determined based on the image change index of the detected image sequence, which is either edge segmentation or uniform segmentation to obtain the liquid image sequence; Candidate validation analysis is performed on liquid image sequences to determine the corresponding sedimentation regions in each liquid image based on the gray values of pixels. Cross-frame comparison is performed on each sedimentation region in the first frame of the liquid image sequence. Cross-frame comparison determines whether there is a matching object in each sedimentation region by positional distance and morphological similarity, and determines whether each sedimentation region is sediment based on the number of matching objects. Determine whether to issue an abnormal warning for the target medicinal wine bottle based on the area and quantity of sediment. Specifically, the active region corresponding to the precipitate is obtained, and the number of liquid images compared across frames is increased based on the change in the proportion of the active region. The adjustment benchmark is determined based on the change in the number of precipitates.
2. The quality testing method for the Three-Snake Rheumatism Medicinal Wine according to claim 1, characterized in that, The rotational excitation includes: Place the target medicinal wine bottle on the rotating device and drive the target medicinal wine bottle to rotate for a preset time, so that the sediment in the target medicinal wine bottle leaves the bottom of the bottle under the action of centrifugal force and is suspended in the liquid. Within a preset time window after the target medicinal wine bottle stops rotating, multiple frames of images of the target medicinal wine bottle are acquired and uniformly extracted. The extracted images are recorded as detection images, and the detection images are arranged in order from earliest to latest acquisition time to obtain a detection image sequence.
3. The quality testing method for the Three-Snake Rheumatism Medicinal Wine according to claim 2, characterized in that, For the condition that the image change index of the detected image sequence is less than or equal to a preset image change index, the processing method for the detected image is determined to be edge segmentation. Edge segmentation includes: Obtain the gradient intensity of each pixel in the detection image, and record the pixels in the detection image whose gradient intensity is greater than the preset gradient intensity as boundary candidate pixels; Starting from the top left corner of the detected image, the preset scanning window moves with a preset step size, and the boundary candidate pixels with the largest gray-level gradient within the window are obtained in turn and recorded as boundary pixels. The detection image region that can be enclosed by the connected boundary pixels is denoted as a liquid image. The liquid images are arranged in order from earliest to latest according to their corresponding acquisition time to obtain a liquid image sequence.
4. The quality testing method for the Three-Snake Rheumatism Medicinal Wine according to claim 3, characterized in that, For the condition that the image change index of the detected image sequence is greater than the preset image change index, the processing method for the detected image is determined to be uniform segmentation. Uniform segmentation includes: Each detected image is uniformly divided to obtain several regions of the same area. Regions with pixel limit variation greater than the preset pixel limit variation are recorded as boundary blocks. The detection image region corresponding to the smallest rectangle that can surround each boundary block is denoted as the liquid image. The liquid images are arranged in order from earliest to latest according to their corresponding acquisition time to obtain the liquid image sequence.
5. The quality testing method for the Three-Snake Rheumatism Medicinal Wine according to claim 3 or 4, characterized in that, Pixels in each liquid image whose grayscale value is less than or equal to a preset grayscale value are recorded as sedimentation pixels; Candidate validation analysis is performed on each deposited pixel in a random order. For a single deposited pixel, the candidate validation analysis includes: Obtain the neighboring pixels corresponding to the precipitated pixel, record the precipitated pixel and its corresponding neighboring pixels as precipitated analysis pixels, and check whether each precipitated analysis pixel has a corresponding neighboring pixel. If it does, record the neighboring pixel as a precipitated analysis pixel. Continue to check whether each precipitated analysis pixel has a corresponding neighboring pixel. Repeat this process until no new neighboring pixels are found, then stop the loop and record the precipitated analysis pixel corresponding to the precipitated pixel as a precipitated region.
6. The quality testing method for the Three-Snake Rheumatism Medicinal Wine according to claim 1, characterized in that, Cross-frame comparisons are performed on each sedimentation region of the first frame of the liquid image sequence in a random order. For a single sedimentation region, the cross-frame comparison includes: The first frame of liquid image is recorded as the target image. The sedimentation area in the next frame of liquid image corresponding to the target image whose positional distance is less than or equal to the preset positional distance and whose morphological similarity is greater than the preset morphological similarity is recorded as the matching object corresponding to the sedimentation area. The liquid image of the matching object corresponding to the sedimentation area is recorded as the target image, and cross-frame comparison is performed with the corresponding next frame liquid image. The sedimentation area where the number of matched objects exceeds the preset number of matched objects is recorded as sediment.
7. The quality testing method for the Three-Snake Rheumatism Medicinal Wine according to claim 6, characterized in that, An abnormal warning is issued for target medicinal wine bottles where the sediment area index is greater than the preset sediment area index or the sediment quantity index is greater than the preset sediment quantity index.
8. The quality testing method for the Three-Snake Rheumatism Medicinal Wine according to claim 6, characterized in that, The smallest rectangle in the liquid image that can contain all the sediment is recorded as the active region. For the target medicinal wine bottle whose proportion change is greater than the preset proportion change, cross-frame comparison and adjustment analysis is determined.
9. The quality testing method for the Three-Snake Rheumatism Medicinal Wine according to claim 8, characterized in that, In cross-frame comparison and adjustment analysis, for the condition that the change in the amount of sediment in each active region is greater than the preset change in the amount of sediment, the adjustment benchmark for increasing the amount of liquid image is determined to be the change in the amount of sediment. The adjustment range of the number of liquid images is positively correlated with the degree of change in the amount of sediment.
10. The quality testing method for the Three-Snake Rheumatism Medicinal Wine according to claim 8, characterized in that, For the condition that the change in the amount of sediment in each activity area is less than or equal to the preset change in the amount of sediment, the adjustment benchmark for increasing the amount of liquid image is determined to be the sediment area fluctuation. The adjustment range of the number of liquid images is positively correlated with the fluctuation of the sedimentation area.
Citation Information
Patent Citations
Method for identifying impurities and bubbles in wine bottle based on multi-feature comprehensive judgment
CN119624876A