Traditional Chinese medicine decoction piece quality detection method based on hyperspectral imaging
By acquiring the spectral curves and reflectance of Chinese herbal medicine slices, identifying abnormal bands and pixels, and setting area thresholds, the problem of low accuracy in identifying mold in the quality inspection of Chinese herbal medicine slices was solved, and accurate quality inspection was achieved.
Patent Information
- Application Number
- CN202511880177.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-12
- Publication Date
- 2026-02-27
AI Technical Summary
Existing technologies for testing the quality of Chinese medicinal herbs have low accuracy in identifying mold and make it difficult to determine the extent of mold, leading to incorrect quality identification results for Chinese medicinal herbs.
By acquiring the spectral curves of normal Chinese herbal medicine slices, obtaining the first and second normal reflectances, identifying abnormal bands, marking abnormal pixels and areas, setting abnormal area thresholds, and obtaining the quality inspection results of Chinese herbal medicine slices based on these data.
It improves the accuracy of identifying moldy Chinese medicinal herbs, enabling timely handling of mild or severe mold growth and preventing more Chinese medicinal herbs from becoming moldy or being misused.
Smart Images

Figure CN121577551A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of quality testing technology for traditional Chinese medicine decoction pieces, specifically a method for quality testing of traditional Chinese medicine decoction pieces based on hyperspectral imaging. Background Technology
[0002] As a major form of disease prevention and treatment in traditional Chinese medicine, the quality of prepared herbal medicines directly affects the safety and effectiveness of medication. However, prepared herbal medicines are easily affected by environmental factors during storage and distribution, leading to mold and deterioration, rendering them unusable. Therefore, it is necessary to test prepared herbal medicines for mold.
[0003] Current methods for detecting the quality of processed Chinese medicinal herbs often rely on visual inspection by quality control personnel to check for mold spots and mycelia on the surface of the herbs. This method is highly subjective, depends heavily on personal experience, and is prone to missing early, slight, or inconspicuous mold growth, making it inefficient. This results in the inability to quickly and accurately screen for mold growth, especially early-stage mold, in actual production. Early detection of mold allows for timely treatment of the herbs, preventing further mold growth or misuse. Mold growth in processed Chinese medicinal herbs alters the content and structure of chemical components such as moisture, protein, and starch, leading to changes in hyperspectral imaging. Therefore, hyperspectral imaging can be used to analyze mold growth. However, current quality control technologies for processed Chinese medicinal herbs suffer from low accuracy in identifying mold and difficulty in determining the extent of mold growth, easily resulting in erroneous quality identification results. Summary of the Invention
[0004] This invention aims to at least partially solve one of the technical problems in the prior art. It obtains historical normal reflectance based on the spectral curve of normal Chinese herbal medicine (TCM) decoction pieces; obtains a first normal reflectance and a second normal reflectance based on the historical normal reflectance; obtains abnormal bands based on the spectral curve, first normal reflectance, and second normal reflectance of moldy TCM decoction pieces; acquires the spectral image of the TCM decoction piece to be tested and marks it as a real-time spectral image; obtains abnormal pixels based on the real-time spectral image and abnormal bands; obtains the real-time area based on the abnormal pixels; obtains an abnormal area threshold based on the spectral image of moldy, unusable TCM decoction pieces; and obtains the quality inspection result of the TCM decoction piece based on the abnormal area threshold and the real-time area. This addresses the problem in existing TCM decoction piece quality inspection technologies where the accuracy of identifying mold is low and the degree of mold is difficult to determine, leading to easily erroneous TCM decoction piece quality identification results.
[0005] To achieve the above objectives, this application provides a method for quality detection of traditional Chinese medicine decoction pieces based on hyperspectral imaging, comprising the following steps:
[0006] Historical normal reflectance was obtained based on the spectral curves of normal Chinese herbal medicine slices;
[0007] The first and second normal reflectances are obtained based on historical normal reflectances;
[0008] Abnormal bands were obtained based on the spectral curves, first normal reflectance, and second normal reflectance of moldy Chinese medicinal herbs.
[0009] Acquire the spectral image of the Chinese herbal medicine slices to be tested and label it as a real-time spectral image;
[0010] Abnormal pixels are obtained based on real-time spectral images and abnormal bands;
[0011] Real-time area is obtained based on abnormal pixels;
[0012] Abnormal area thresholds are obtained based on the spectral data of moldy and unusable Chinese herbal medicine pieces;
[0013] The quality test results of Chinese herbal medicine slices are obtained based on the abnormal area threshold and the real-time area.
[0014] Furthermore, obtaining historical normal reflectance based on the spectral curves of normal Chinese herbal medicine slices includes the following sub-steps:
[0015] The spectral curves of normal Chinese herbal medicine slices are marked as historical normal spectral curves;
[0016] Obtain the first number of historical normal spectral curves;
[0017] Obtain the reflectance at the same wavelength in different historical normal spectral curves and label it as historical normal reflectance.
[0018] Furthermore, obtaining the first normal reflectance and the second normal reflectance based on historical normal reflectance includes the following sub-steps:
[0019] Obtain the range of historical normal reflectance, and establish a number line based on the range of historical normal reflectance values, which is then marked as the normal reflectance number line.
[0020] Plot the historical normal reflectance on the normal reflectance axis to obtain coordinate points, and mark them as normal reflectance coordinate points;
[0021] The length of the historical normal reflectance range on the normal reflectance axis is obtained and marked as the normal reflectance data length.
[0022] Obtain the number of coordinate points of normal reflectivity and mark them as the total number of normal reflectivity points;
[0023] Mark the line segment of length Q1 on the normal reflectivity axis as the first line segment;
[0024] The threshold for the number of line segments is calculated as follows: W1 = e1 × [(Q1 ÷ R1) × T1]; where W1 is the threshold for the number of line segments, e1 is the proportion of the number of line segments, R1 is the length of the normal reflectance data, and T1 is the total number of normal reflectance data.
[0025] Furthermore, obtaining the first normal reflectance and the second normal reflectance based on historical normal reflectance also includes the following sub-steps:
[0026] The number of normal reflectivity coordinate points on the first line segment is marked as the first evaluation number;
[0027] Move the leftmost end of the first line segment to the leftmost normal reflectance coordinate point. If the number of first evaluations is less than the line segment number threshold, delete the leftmost normal reflectance coordinate point and move the first line segment to the right so that the leftmost end of the first line segment coincides with the next normal reflectance coordinate point. If the number of first evaluations is greater than or equal to the line segment number threshold, stop moving. If not, continue deleting and moving. Obtain the value of the leftmost end of the first line segment after stopping and mark it as the first normal reflectance.
[0028] Move the rightmost end of the first line segment to the rightmost normal reflectivity coordinate point. If the number of first evaluations is less than the line segment number threshold, delete the leftmost normal reflectivity coordinate point and move the first line segment to the right so that the leftmost end of the first line segment coincides with the next normal reflectivity coordinate point. If the number of first evaluations is greater than or equal to the line segment number threshold, stop moving. If not, continue deleting and moving. Obtain the value of the leftmost end of the first line segment after stopping and mark it as the second normal reflectivity.
[0029] Furthermore, obtaining the abnormal band based on the spectral curve, first normal reflectance, and second normal reflectance of the moldy Chinese herbal medicine slices includes the following sub-steps:
[0030] The spectral curves of moldy Chinese medicinal herbs were marked as historical moldy spectral curves;
[0031] Obtain the reflectance of each band in the historical mold spectral curve and mark it as historical abnormal reflectance;
[0032] Determine whether the historical abnormal reflectance is less than the corresponding first normal reflectance or greater than the corresponding second normal reflectance. If so, mark the band corresponding to the historical abnormal reflectance as an abnormal band.
[0033] Furthermore, obtaining anomalous pixel points based on real-time spectral images and anomalous bands includes the following sub-steps:
[0034] Obtain the spectral curve of each pixel in the real-time spectral image and label it as the real-time spectral curve;
[0035] Obtain the reflectance of anomalous bands in the real-time spectral curve, including real-time reflectance;
[0036] Determine whether the real-time reflectance is greater than the first normal reflectance and less than the second normal reflectance. If so, mark the pixel corresponding to this real-time spectral curve as an abnormal pixel.
[0037] Furthermore, obtaining the real-time area value based on abnormal pixels includes the following sub-steps:
[0038] Mark the square region with a length and width of 3 pixels as the base region;
[0039] Establish a base region centered on any abnormal pixel. If no new abnormal pixel appears in the base region, establish a new base region centered on the new abnormal pixel. If a new abnormal pixel appears in the base region, establish a new base region centered on the new abnormal pixel, and then establish a new base region centered on the new abnormal pixel in the new base region, until no new abnormal pixels appear in the new base region. Mark the region composed of the abnormal pixels obtained in this acquisition as an abnormal region.
[0040] Get all abnormal regions;
[0041] Obtain the minimum bounding circle of all abnormal regions and mark it as the real-time bounding circle;
[0042] Obtain the area of the circumcircle in real time and mark it as the real-time area.
[0043] Furthermore, obtaining the abnormal area threshold based on the spectral image of moldy and unusable Chinese herbal medicine pieces includes the following sub-steps:
[0044] Obtain the spectral images of moldy and unusable Chinese medicinal herbs and mark them as historical abnormal spectra;
[0045] The historical anomaly spectral map is treated as a real-time spectral map to obtain the real-time area, which is then marked as the historical anomaly area.
[0046] Obtain the second number of historical areas;
[0047] Obtain the range of historical area, and establish a number line using the range of historical area as the range of number line values, marking it as the historical area number line;
[0048] Plot the historical area on the historical area number line to obtain coordinate points, and mark them as historical area coordinate points;
[0049] The length of the historical area range on the historical area axis is obtained and marked as the historical area data length.
[0050] Get the number of historical area coordinate points and mark it as the total number of historical areas;
[0051] Mark the line segment of length Q2 on the historical area number line as the second line segment;
[0052] The threshold for the second number is calculated as: W2 = e2 × [(Q2 ÷ R2) × T2]; where W2 is the threshold for the second number, e2 is the proportion of the second number, R2 is the length of the historical area data, and T2 is the total number of historical areas.
[0053] Furthermore, obtaining the abnormal area threshold based on the spectral image of moldy and unusable Chinese herbal medicine pieces also includes the following sub-steps:
[0054] The number of historical area coordinate points on the second line segment is marked as the number of second evaluation points;
[0055] Move the leftmost end of the second line segment to the leftmost historical area coordinate point. If the number of second evaluations is less than the second threshold, delete the leftmost historical area coordinate point and move the second line segment to the right so that the leftmost end of the second line segment coincides with the next historical area coordinate point. If the number of second evaluations is greater than or equal to the second threshold, stop moving. If not, continue deleting and moving. Obtain the value of the leftmost end of the second line segment after stopping and mark it as the abnormal area threshold.
[0056] Furthermore, obtaining the quality inspection results of traditional Chinese medicine decoction pieces based on the abnormal area threshold and real-time area includes the following sub-steps:
[0057] If no abnormal pixels are found, the tested Chinese herbal medicine slices are considered to be free of mold. If abnormal pixels are found and the real-time area is less than the abnormal area threshold, the tested Chinese herbal medicine slices are considered to be slightly moldy. If abnormal pixels are found and the real-time area is greater than or equal to the abnormal area threshold, the tested Chinese herbal medicine slices are considered to be severely moldy.
[0058] The beneficial effects of this invention are as follows: This invention obtains historical normal reflectance based on the spectral curve of normal Chinese herbal medicine slices; obtains a first normal reflectance and a second normal reflectance based on the historical normal reflectance; obtains abnormal bands based on the spectral curve, first normal reflectance, and second normal reflectance of moldy Chinese herbal medicine slices; obtains the spectral image of the Chinese herbal medicine slices to be tested and marks it as a real-time spectral image; obtains abnormal pixels based on the real-time spectral image and abnormal bands; obtains the real-time area based on the abnormal pixels; obtains an abnormal area threshold based on the spectral image of moldy and unusable Chinese herbal medicine slices; and obtains the quality detection result of Chinese herbal medicine slices based on the abnormal area threshold and the real-time area. The advantages are that it improves the accuracy of identifying mold and allows for the timely processing of Chinese herbal medicine slices to prevent further mold growth or misuse.
[0059] This invention obtains abnormal wavelengths based on the spectral curves, first normal reflectance, and second normal reflectance of moldy Chinese medicinal herbs. Its advantage lies in its ability to obtain abnormal wavelengths that indicate changes in Chinese medicinal herbs when they become moldy, thereby improving the accuracy of mold identification. Attached Figure Description
[0060] Figure 1 This is a flowchart illustrating the steps of the method of the present invention;
[0061] Figure 2 This is a schematic diagram of the normal reflectivity axis of the present invention;
[0062] Figure 3 This is a schematic diagram of the real-time circumscribed circle of the present invention. Detailed Implementation
[0063] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0064] Example 1, please refer to Figure 1 As shown, this application provides a method for quality detection of traditional Chinese medicine decoction pieces based on hyperspectral imaging, including the following steps:
[0065] Step S1: Obtain historical normal reflectance based on the spectral curve of normal Chinese herbal medicine slices; Step S1 includes the following sub-steps:
[0066] Step S101: Mark the spectral curve of normal Chinese herbal medicine slices as historical normal spectral curves;
[0067] Step S102: Obtain a first number of historical normal spectral curves; the first number is set to obtain the distribution range of historical normal reflectance, so the more the first number is set, the more accurate the data; for example, the first number is 100.
[0068] Step S103: Obtain the reflectance of the same band in different historical normal spectral curves and mark it as historical normal reflectance; here, a band can be obtained every 5nm to reduce the amount of data analysis.
[0069] Step S2: Obtain the first normal reflectance and the second normal reflectance based on historical normal reflectance; Step S2 includes the following sub-steps:
[0070] Step S201: Obtain the range of historical normal reflectance, establish a number axis with the range of historical normal reflectance as the range of number axis values, and mark it as the normal reflectance number axis; the normal reflectance number axis is established to observe the distribution of normal reflectance and to facilitate the filtering out of historical normal reflectance that is abnormally small or large.
[0071] Step S202: Plot the historical normal reflectance on the normal reflectance axis to obtain coordinate points, and mark them as normal reflectance coordinate points;
[0072] Step S203: Obtain the length of the historical normal reflectance range on the normal reflectance axis and mark it as the normal reflectance data length;
[0073] Step S204: Obtain the number of coordinate points of normal reflectivity and mark them as the total number of normal reflectivity points;
[0074] Step S205: Mark the line segment of length Q1 as the first line segment on the normal reflectance axis; move the first line segment on the normal reflectance axis for searching, for example, the normal reflectance data length is 20cm, and Q1 is 1cm;
[0075] Step S206, calculate the threshold for the number of line segments as: W1=e1×[(Q1÷R1)×T1]; where W1 is the threshold for the number of line segments, e1 is the proportion of the number of line segments, R1 is the length of the normal reflectivity data, T1 is the total number of normal reflectivity data, and (Q1÷R1)×T1 represents the average number of normal reflectivity coordinate points on the first line segment; obtaining the threshold for the number of line segments makes it easier to filter out historical normal reflectivity that is abnormally small or large, so e1 is set to a small value, for example, e1 is 0.4;
[0076] For practical applications, please refer to Figure 2 As shown, for example, the historical normal reflectance at a wavelength of 1450nm, the total number of normal reflectances is 100, and the threshold for the number of line segments is calculated as: W1=0.4×[(1÷10)×100]=2.
[0077] Step S207: Mark the number of normal reflectivity coordinate points on the first line segment as the first evaluation number;
[0078] Step S208: Move the leftmost end of the first line segment to the leftmost normal reflectance coordinate point. If the number of first evaluations is less than the line segment number threshold, delete the leftmost normal reflectance coordinate point and move the first line segment to the right so that the leftmost end of the first line segment coincides with the next normal reflectance coordinate point. If the number of first evaluations is greater than or equal to the line segment number threshold, stop moving. If not, continue deleting and moving. Obtain the value of the leftmost end of the first line segment after stopping and mark it as the first normal reflectance. The first normal reflectance is used to filter historical normal reflectances that are abnormally low.
[0079] Step S209: Move the rightmost end of the first line segment to the rightmost normal reflectance coordinate point. If the number of first evaluations is less than the line segment number threshold, delete the leftmost normal reflectance coordinate point and move the first line segment to the right so that the leftmost end of the first line segment coincides with the next normal reflectance coordinate point. If the number of first evaluations is greater than or equal to the line segment number threshold, stop moving. If not, continue deleting and moving. Obtain the value of the leftmost end of the first line segment after stopping and mark it as the second normal reflectance. The second normal reflectance is used to filter historical normal reflectances that are abnormally high.
[0080] For practical applications, please refer to Figure 2 As shown, the leftmost end of the first line segment is moved to the leftmost normal reflectivity coordinate point. At this time, the first evaluation count 1 is less than the line segment count threshold 2, so the leftmost normal reflectivity coordinate point is deleted. The first line segment is moved to the right until the leftmost end of the first line segment coincides with the next normal reflectivity coordinate point. The first evaluation count 3 is equal to the line segment count threshold 2, so the movement stops. The value of the leftmost end of the first line segment after stopping is 0.29, so the first normal reflectivity is 0.29. The rightmost end of the first line segment is moved to the rightmost normal reflectivity coordinate point. At this time, the first evaluation count 1 is less than the line segment count threshold 2, so the leftmost normal reflectivity coordinate point is deleted. The first line segment is moved to the right until the leftmost end of the first line segment coincides with the next normal reflectivity coordinate point. The first evaluation count 2 is equal to the line segment count threshold 2, so the movement stops. The value of the leftmost end of the first line segment after stopping is 0.37, so the second normal reflectivity is 0.37.
[0081] Step S3: Obtain the abnormal band based on the spectral curve of the moldy Chinese herbal medicine slices, the first normal reflectance, and the second normal reflectance; Step S3 includes the following sub-steps:
[0082] Step S301: Mark the spectral curve of the moldy Chinese herbal medicine slices as the historical moldy spectral curve;
[0083] Step S302: Obtain the reflectance of each band in the historical mold spectral curve and mark it as historical abnormal reflectance;
[0084] Step S303: Determine whether the historical abnormal reflectance is less than the corresponding first normal reflectance or greater than the corresponding second normal reflectance. If so, mark the band corresponding to the historical abnormal reflectance as an abnormal band.
[0085] In practical applications, for example, if the historical abnormal reflectance is 0.21 when the wavelength is 1450nm, and the historical abnormal reflectance of 0.21 is less than the corresponding first normal reflectance of 0.29, then 1450nm is designated as an abnormal wavelength. Obtaining the abnormal wavelength facilitates subsequent mold growth assessment.
[0086] Step S4: Obtain the spectral image of the Chinese herbal medicine slices to be detected and mark it as a real-time spectral image.
[0087] Step S5: Obtain abnormal pixels based on the real-time spectral image and abnormal bands; Step S5 includes the following sub-steps:
[0088] Step S501: Obtain the spectral curve of each pixel in the real-time spectral image and mark it as the real-time spectral curve;
[0089] Step S502: Obtain the reflectance of the abnormal bands in the real-time spectral curve, including the real-time reflectance;
[0090] Step S503: Determine whether the real-time reflectance is greater than the first normal reflectance and less than the second normal reflectance. If so, mark the pixel corresponding to this real-time spectral curve as an abnormal pixel. An abnormal pixel indicates that the pixel has the same moldy condition.
[0091] Step S6: Obtain the real-time area based on abnormal pixels; Step S6 includes the following sub-steps:
[0092] Step S601: Mark the square region with a length and width of 3 pixels as the base region;
[0093] Step S602: Establish a base region centered on any abnormal pixel. If no new abnormal pixel appears in the base region, re-establish the base region centered on the new abnormal pixel. If a new abnormal pixel appears in the base region, establish a new base region centered on the new abnormal pixel, and then establish a new base region centered on the new abnormal pixel in the new base region, until no new abnormal pixel appears in the new base region. Mark the region composed of the abnormal pixels obtained this time as an abnormal region. Eliminate isolated interfering abnormal pixels and obtain continuous moldy regions.
[0094] Step S603: Obtain all abnormal regions;
[0095] Step S604: Obtain a minimum bounding circle for all abnormal areas and mark it as the real-time bounding circle; Construct the minimum bounding circle to obtain the size of the area where mold is distributed. In the case of spot mold, the area of mold can be represented by the real-time bounding circle.
[0096] Step S605: Obtain the area of the real-time circumcircle and mark it as the real-time area;
[0097] For practical applications, please refer to Figure 3 The diagram shown is a schematic of the real-time circumscribed circle obtained.
[0098] Step S7: Obtain the abnormal area threshold based on the spectral image of the moldy and unusable Chinese herbal medicine pieces; Step S7 includes the following sub-steps:
[0099] Step S701: Obtain the spectral image of the moldy and unusable Chinese herbal medicine pieces and mark it as a historical abnormal spectral image; here, different characters indicate Chinese herbal medicine pieces that cannot be repaired or those in the middle or late stages of mold growth;
[0100] Step S702: Treat the historical abnormal spectral map as a real-time spectral map to obtain the real-time area, and mark it as the historical abnormal area;
[0101] Step S703: Obtain the second number of historical areas; the second number is the distribution range of the historical areas, so the larger the second number is, the better, for example, the second number is 200;
[0102] Step S704: Obtain the range of historical area, establish a number line with the range of historical area as the range of number line values, and mark it as the historical area number line;
[0103] Step S705: Plot the historical area on the historical area axis to obtain coordinate points, and mark them as historical area coordinate points;
[0104] Step S706: Obtain the length of the historical area range on the historical area number axis and mark it as the historical area data length;
[0105] Step S707: Obtain the number of historical area coordinate points and mark them as the total number of historical areas;
[0106] Step S708: Mark the line segment of length Q2 as the second line segment on the historical area axis; Q2 is set to be less than the length of the historical area data, for example, if the length of the historical area data is 20cm, Q2 is 1cm;
[0107] Step S709, calculate the second threshold as: W2=e2×[(Q2÷R2)×T2]; where W2 is the second threshold, e2 is the second ratio, R2 is the length of historical area data, and T2 is the total number of historical areas; the second threshold is set to a small value for e2 in order to filter out historical areas that are too small, for example, e2 is 0.4.
[0108] In practical applications, for example, if the total number of historical areas is 100, the threshold for the second number is calculated as: W2 = 0.4 × [(1 ÷ 10) × 100] = 2.
[0109] Step S710: Mark the number of historical area coordinate points on the second line segment as the second evaluation number;
[0110] Step S711: Move the leftmost end of the second line segment to the leftmost historical area coordinate point. If the number of second evaluations is less than the second threshold, delete the leftmost historical area coordinate point and move the second line segment to the right so that the leftmost end of the second line segment coincides with the next historical area coordinate point. If the number of second evaluations is greater than or equal to the second threshold, stop moving. If not, continue deleting and moving. Obtain the value of the leftmost end of the second line segment after stopping and mark it as the abnormal area threshold. The abnormal area threshold is used to filter out abnormally small values.
[0111] In practical applications, for example, the threshold for obtaining the abnormal area is 0.2 mm. 2 .
[0112] Step S8: Obtain the quality inspection results of traditional Chinese medicine decoction pieces based on the abnormal area threshold and real-time area; Step S8 includes the following sub-steps:
[0113] Step S801: If no abnormal pixels are found, the detected Chinese herbal medicine slices are considered to be unmolded; if abnormal pixels are found and the real-time area is less than the abnormal area threshold, the detected Chinese herbal medicine slices are considered to be slightly moldy; if abnormal pixels are found and the real-time area is greater than or equal to the abnormal area threshold, the detected Chinese herbal medicine slices are considered to be severely moldy; if the Chinese herbal medicine slices are slightly moldy, i.e., in the early stage of mold growth, they can be processed into Chinese herbal medicine slices to prevent the spread of mold to other Chinese herbal medicine slices; if the Chinese herbal medicine slices are severely moldy, i.e. in the later stage of mold growth, the Chinese herbal medicine slices cannot be used.
[0114] In practical applications, for example, obtaining a real-time area of 100mm. 2 Real-time area 100mm 2 Area greater than the abnormal area threshold of 0.2 mm 2 If the tested Chinese herbal medicine slices are found to be severely moldy, then it is considered that the tested slices are severely moldy.
[0115] Example 2: This application also provides an electronic device, which may include: a processor, a communication interface, a memory, and a communication bus. The processor, communication interface, and memory communicate with each other via the communication bus. The memory stores computer-readable instructions, and the processor can call the instructions in the memory. When the computer-readable instructions are executed by the processor, steps such as those in the method for quality detection of traditional Chinese medicine decoction pieces based on hyperspectral imaging are performed to achieve the following functions: obtaining historical normal reflectance based on the spectral curve of normal traditional Chinese medicine decoction pieces; obtaining a first normal reflectance and a second normal reflectance based on the historical normal reflectance; obtaining abnormal bands based on the spectral curve, the first normal reflectance, and the second normal reflectance of moldy traditional Chinese medicine decoction pieces; acquiring the spectral image of the traditional Chinese medicine decoction piece to be detected and marking it as a real-time spectral image; obtaining abnormal pixels based on the real-time spectral image and the abnormal bands; obtaining the real-time area based on the abnormal pixels; obtaining an abnormal area threshold based on the spectral image of moldy and unusable traditional Chinese medicine decoction pieces; and obtaining the quality detection result of the traditional Chinese medicine decoction piece based on the abnormal area threshold and the real-time area.
[0116] Furthermore, when the logical instructions in the aforementioned memory can be implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0117] Example 3: This application also provides a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the method for quality detection of traditional Chinese medicine decoction pieces based on hyperspectral imaging provided by the above methods. The method includes: obtaining historical normal reflectance based on the spectral curve of normal traditional Chinese medicine decoction pieces; obtaining a first normal reflectance and a second normal reflectance based on the historical normal reflectance; obtaining abnormal bands based on the spectral curve, the first normal reflectance, and the second normal reflectance of moldy traditional Chinese medicine decoction pieces; obtaining a spectral image of the traditional Chinese medicine decoction pieces to be detected and marking it as a real-time spectral image; obtaining abnormal pixels based on the real-time spectral image and the abnormal bands; obtaining a real-time area based on the abnormal pixels; obtaining an abnormal area threshold based on the spectral image of moldy and unusable traditional Chinese medicine decoction pieces; and obtaining the quality detection result of traditional Chinese medicine decoction pieces based on the abnormal area threshold and the real-time area.
[0118] Example 4: This application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it performs the steps of the above-described method for quality detection of traditional Chinese medicine decoction pieces based on hyperspectral imaging to achieve the following functions: obtaining historical normal reflectance based on the spectral curve of normal traditional Chinese medicine decoction pieces; obtaining a first normal reflectance and a second normal reflectance based on the historical normal reflectance; obtaining abnormal bands based on the spectral curve, the first normal reflectance, and the second normal reflectance of moldy traditional Chinese medicine decoction pieces; acquiring the spectral image of the traditional Chinese medicine decoction pieces to be detected and marking it as a real-time spectral image; obtaining abnormal pixels based on the real-time spectral image and the abnormal bands; obtaining the real-time area based on the abnormal pixels; obtaining an abnormal area threshold based on the spectral image of moldy and unusable traditional Chinese medicine decoction pieces; and obtaining the quality detection result of traditional Chinese medicine decoction pieces based on the abnormal area threshold and the real-time area.
[0119] Based on the above description of the embodiments, the embodiments of the present invention can be provided as methods, systems, or computer program products. Based on this understanding, the above technical solutions, in essence or in terms of their contribution to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or certain parts of the embodiments.
[0120] In the embodiments provided in this application, it should be understood that the disclosed system or method can be implemented in other ways. The embodiments described above are merely illustrative. For example, the division of modules or units is only a logical functional division, and there may be other division methods in actual implementation. Furthermore, multiple modules or units may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the coupling or direct coupling or communication connection shown or discussed may be through some communication interfaces. The indirect coupling or communication connection between systems, modules, and units may be electrical, mechanical, or other forms.
[0121] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A method for quality detection of traditional Chinese medicine decoction pieces based on hyperspectral imaging, characterized in that, Includes the following steps: Historical normal reflectance was obtained based on the spectral curves of normal Chinese herbal medicine slices; The first and second normal reflectances are obtained based on historical normal reflectances; Abnormal bands were obtained based on the spectral curves, first normal reflectance, and second normal reflectance of moldy Chinese medicinal herbs. Acquire the spectral image of the Chinese herbal medicine slices to be tested and label it as a real-time spectral image; Abnormal pixels are obtained based on real-time spectral images and abnormal bands; Real-time area is obtained based on abnormal pixels; Abnormal area thresholds are obtained based on the spectral data of moldy and unusable Chinese herbal medicine pieces; The quality test results of Chinese herbal medicine slices are obtained based on the abnormal area threshold and the real-time area.
2. The method for quality detection of traditional Chinese medicine decoction pieces based on hyperspectral imaging according to claim 1, characterized in that, Obtaining historical normal reflectance based on the spectral curves of normal Chinese herbal medicine slices includes the following sub-steps: The spectral curves of normal Chinese herbal medicine slices are marked as historical normal spectral curves; Obtain the first number of historical normal spectral curves; Obtain the reflectance at the same wavelength in different historical normal spectral curves and label it as historical normal reflectance.
3. The method for quality detection of traditional Chinese medicine decoction pieces based on hyperspectral imaging according to claim 2, characterized in that, Obtaining the first and second normal reflectance based on historical normal reflectance includes the following sub-steps: Obtain the range of historical normal reflectance, and establish a number line based on the range of historical normal reflectance values, which is then marked as the normal reflectance number line. Plot the historical normal reflectance on the normal reflectance axis to obtain coordinate points, and mark them as normal reflectance coordinate points; The length of the historical normal reflectance range on the normal reflectance axis is obtained and marked as the normal reflectance data length. Obtain the number of coordinate points of normal reflectivity and mark them as the total number of normal reflectivity points; Mark the line segment of length Q1 on the normal reflectivity axis as the first line segment; The threshold for the number of line segments is calculated as follows: W1 = e1 × [(Q1 ÷ R1) × T1]; where W1 is the threshold for the number of line segments, e1 is the proportion of the number of line segments, R1 is the length of the normal reflectance data, and T1 is the total number of normal reflectance data.
4. The method for quality detection of traditional Chinese medicine decoction pieces based on hyperspectral imaging according to claim 3, characterized in that, Obtaining the first and second normal reflectances based on historical normal reflectances also includes the following sub-steps: The number of normal reflectivity coordinate points on the first line segment is marked as the first evaluation number; Move the leftmost end of the first line segment to the leftmost normal reflectance coordinate point. If the number of first evaluations is less than the line segment number threshold, delete the leftmost normal reflectance coordinate point and move the first line segment to the right so that the leftmost end of the first line segment coincides with the next normal reflectance coordinate point. If the number of first evaluations is greater than or equal to the line segment number threshold, stop moving. If not, continue deleting and moving. Obtain the value of the leftmost end of the first line segment after stopping and mark it as the first normal reflectance. Move the rightmost end of the first line segment to the rightmost normal reflectivity coordinate point. If the number of first evaluations is less than the line segment number threshold, delete the leftmost normal reflectivity coordinate point and move the first line segment to the right so that the leftmost end of the first line segment coincides with the next normal reflectivity coordinate point. If the number of first evaluations is greater than or equal to the line segment number threshold, stop moving. If not, continue deleting and moving. Obtain the value of the leftmost end of the first line segment after stopping and mark it as the second normal reflectivity.
5. The method for quality detection of traditional Chinese medicine decoction pieces based on hyperspectral imaging according to claim 4, characterized in that, Obtaining abnormal bands based on the spectral curves, first normal reflectance, and second normal reflectance of moldy Chinese medicinal herbs includes the following sub-steps: The spectral curves of moldy Chinese medicinal herbs were marked as historical moldy spectral curves; Obtain the reflectance of each band in the historical mold spectral curve and mark it as historical abnormal reflectance; Determine whether the historical abnormal reflectance is less than the corresponding first normal reflectance or greater than the corresponding second normal reflectance. If so, mark the band corresponding to the historical abnormal reflectance as an abnormal band.
6. The method for quality detection of traditional Chinese medicine decoction pieces based on hyperspectral imaging according to claim 5, characterized in that, The acquisition of anomalous pixels based on real-time spectral images and anomalous bands includes the following sub-steps: Obtain the spectral curve of each pixel in the real-time spectrum and label it as the real-time spectral curve; Obtain the reflectance of anomalous bands in the real-time spectral curve, including real-time reflectance; Determine whether the real-time reflectance is greater than the first normal reflectance and less than the second normal reflectance. If so, mark the pixel corresponding to this real-time spectral curve as an abnormal pixel.
7. The method for quality detection of traditional Chinese medicine decoction pieces based on hyperspectral imaging according to claim 6, characterized in that, Obtaining the real-time area value based on abnormal pixels includes the following sub-steps: Mark the square region with a length and width of 3 pixels as the base region; Establish a base region centered on any abnormal pixel. If there are no new abnormal pixels in the base region, re-establish the base region centered on the new abnormal pixel. If a new abnormal pixel appears in the base region, a new base region is established with the new abnormal pixel as the center, and then a new base region is established with the new abnormal pixels in the new base region, until no new abnormal pixels appear in the new base region; the region composed of the abnormal pixels obtained this time is marked as an abnormal region. Get all abnormal regions; Obtain the minimum bounding circle of all abnormal regions and mark it as the real-time bounding circle; Obtain the area of the circumcircle in real time and mark it as the real-time area.
8. The method for quality detection of traditional Chinese medicine decoction pieces based on hyperspectral imaging according to claim 7, characterized in that, Obtaining the abnormal area threshold based on the spectral data of moldy and unusable Chinese herbal medicine pieces includes the following sub-steps: Obtain the spectral images of moldy and unusable Chinese medicinal herbs and mark them as historical abnormal spectra; The historical anomaly spectral map is treated as a real-time spectral map to obtain the real-time area, which is then marked as the historical anomaly area. Obtain the second number of historical areas; Obtain the range of historical area, and establish a number line using the range of historical area as the range of number line values, marking it as the historical area number line; Plot the historical area on the historical area number line to obtain coordinate points, and mark them as historical area coordinate points; The length of the historical area range on the historical area axis is obtained and marked as the historical area data length. Get the number of historical area coordinate points and mark it as the total number of historical areas; Mark the line segment of length Q2 on the historical area number line as the second line segment; The threshold for the second number is calculated as: W2 = e2 × [(Q2 ÷ R2) × T2]; where W2 is the threshold for the second number, e2 is the proportion of the second number, R2 is the length of the historical area data, and T2 is the total number of historical areas.
9. The method for quality detection of traditional Chinese medicine decoction pieces based on hyperspectral imaging according to claim 8, characterized in that, Obtaining the abnormal area threshold based on the spectral data of moldy and unusable Chinese herbal medicine pieces also includes the following sub-steps: The number of historical area coordinate points on the second line segment is marked as the number of second evaluation points; Move the leftmost end of the second line segment to the leftmost historical area coordinate point. If the number of second evaluations is less than the second threshold, delete the leftmost historical area coordinate point and move the second line segment to the right so that the leftmost end of the second line segment coincides with the next historical area coordinate point. If the number of second evaluations is greater than or equal to the second threshold, stop moving. If not, continue deleting and moving. Obtain the value of the leftmost end of the second line segment after stopping and mark it as the abnormal area threshold.
10. The method for quality detection of traditional Chinese medicine decoction pieces based on hyperspectral imaging according to claim 9, characterized in that, Obtaining the quality inspection results of traditional Chinese medicine decoction pieces based on the abnormal area threshold and real-time area includes the following sub-steps: If no abnormal pixels are found, the tested Chinese herbal medicine slices are considered to be free of mold; if abnormal pixels are found and the real-time area is less than the abnormal area threshold, the tested Chinese herbal medicine slices are considered to be slightly moldy. If abnormal pixels are found, and the real-time area is greater than or equal to the abnormal area threshold, the detected Chinese herbal medicine slices are considered to be severely moldy.
Citation Information
Patent Citations
Method for detecting pesticide residue on surface of navel orange based on hyperspectral imaging technology
CN103630498A
Visual detection and analysis system for quality of traditional Chinese medicine decoction pieces
CN116862911A
Nut impurity rapid detection method and device suitable for mobile production line and computing equipment
CN119044076A
Agricultural product quality detection method and system
CN120468080A
Mildew identification method for medicinal and edible traditional Chinese medicinal materials
CN120666076A