A centipede quality identification method, system, device and storage medium
By acquiring characteristic images of centipedes and their color samples, and combining the HIS model and convolutional neural network, a method for identifying centipede quality grades was established. This method solves the problem of convenience in centipede quality identification and enables fast and accurate centipede quality judgment.
Patent Information
- Application Number
- CN202510297557.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-13
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2045-03-13
AI Technical Summary
Existing technologies make it difficult to easily identify the quality of centipedes, especially for inexperienced buyers and merchants who cannot judge the quality by the centipede's color, length, and chemical composition, thus limiting the purchase of centipedes.
By acquiring characteristic parts and color sample images of the spiny giant centipede, and using a color matrix, HIS model, and convolutional neural network, combined with chemical composition content, a centipede quality grade identification method was established, including the calculation of color score, length score, and composition score. Finally, a centipede quality grade comparison table was established.
It enables rapid identification of centipede quality without chemical component testing, and judges the quality grade of centipedes through photos, thus improving identification efficiency and accuracy.
Smart Images

Figure CN120220140B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of centipede quality identification, and specifically discloses a centipede quality identification method, system, device and storage medium. Background Technology
[0002] In recent years, with the increasing acceptance of traditional Chinese medicine, the demand for centipedes has been growing year by year. The spiny giant centipede is one of the centipedes that can be used in medicine. However, there are certain requirements regarding the color, length, and chemical composition of centipedes for medicinal use. Experienced merchants and buyers can judge the quality of centipedes by their color, length, and smell. Inexperienced buyers and merchants find it difficult to judge the quality of centipedes, which limits their purchasing options.
[0003] In related technologies, the quality inspection of centipedes is mainly carried out through sampling inspection. From a batch of centipede samples, a portion of the centipedes are randomly selected, and then the quality of the centipedes is inspected using high performance liquid chromatography and a single standard for multiple determinations analysis method.
[0004] The aforementioned technologies, which involve chemically analyzing centipede samples, are not convenient for merchants and buyers to implement. This method cannot easily determine the quality grade of centipedes and requires a considerable amount of time. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to provide a method, system, device and storage medium for identifying the quality of centipedes, which can quickly identify the quality of centipedes.
[0006] A method for identifying the quality of centipedes, comprising:
[0007] Obtain sample images of characteristic parts and color samples of the spiny giant centipede;
[0008] Based on the color sample image, a color matrix is extracted, which includes a head color matrix, a back color matrix, and an abdomen color matrix.
[0009] Two quantiles are selected, and a receptive field is formed based on the two quantiles. The elements in the color matrix are filtered according to the receptive field to obtain the filtered elements. The mean vector is calculated based on the filtered elements.
[0010] The mean vector is transformed using the HIS model to obtain the transformed vector;
[0011] Based on the transformation vector and color constraints, centipedes are screened to obtain screened centipedes. Based on the transformation vector and color formula of the screened centipedes, the color score of the centipedes is obtained.
[0012] Obtain the content of test components in the centipedes being screened;
[0013] A component matrix is generated based on the content of the tested components. The centipedes are then screened according to the component matrix and the component constraints to obtain the remaining centipedes. The remaining centipedes are numbered to obtain a numbering matrix. The numbering matrix is then scaled to obtain a filling matrix.
[0014] Obtain the penalty coefficient;
[0015] The component scores are obtained based on the filling matrix, the penalty coefficient, and the weight constraints.
[0016] Calculate the length fraction based on the centipede's length;
[0017] Based on the length score, the component score, and the color score, the final score is obtained. The final score is then distributed normally to establish a centipede quality grade comparison table.
[0018] The feature image is converted to grayscale to obtain a processed centipede image;
[0019] The centipede image is preprocessed to obtain a preprocessed image;
[0020] The preprocessed image is subjected to deformable convolution to extract features;
[0021] The extracted features are input into a category convolutional neural network for training to obtain a centipede category training network.
[0022] Obtain color sample images corresponding to the remaining centipedes as category training set images;
[0023] The training set images of the aforementioned categories are normalized to obtain normalized images, and the normalized images are cropped to obtain a cropped image set.
[0024] The cropped image set and the centipede quality grade comparison table are input into the graded convolutional neural network for training to obtain the centipede quality grade training network.
[0025] The actual feature images are input into the category training network, and the actual color images corresponding to the centipede category of Giant Centipede with Lesser Spinach are input into the centipede quality level training network to obtain the centipede quality level corresponding to the actual images.
[0026] Optionally, the step of selecting two quantiles, forming an acceptor region based on the two quantiles, filtering the elements in the color matrix based on the acceptor region to obtain filtered elements, and calculating the mean vector based on the filtered elements includes:
[0027] Each column of the head color matrix, back color matrix, and abdomen color matrix is analyzed separately, and the elements within the receiving domain are selected to obtain the head screening elements, back screening elements, and abdomen screening elements.
[0028] The mean values of the head, back, and abdomen screening elements are calculated respectively to obtain the head mean vector, abdomen mean vector, and back mean vector. The mean vectors of the color values of different parts are then formed based on the head mean vector, abdomen mean vector, and back mean vector.
[0029] Optionally, the step of generating a component matrix based on the content of the tested component, screening the centipedes according to the component matrix and component constraints to obtain the remaining centipedes, numbering the remaining centipedes to obtain a numbering matrix, and scaling the numbering matrix to obtain a weight matrix includes:
[0030] The tested component contents include moisture content, total ash content, aflatoxin content, and extract content. The aflatoxin content includes aflatoxin B1, aflatoxin G2, aflatoxin G1, and aflatoxin B2.
[0031] A component matrix is constructed with the moisture content as the first column, the total ash content as the second column, the aflatoxin B1 content as the third column, the total content of aflatoxin G2, aflatoxin G1, aflatoxin B2 and aflatoxin B1 as the fourth column, and the extract content as the fifth column.
[0032] Based on the component matrix and component constraints, the centipedes are screened to obtain the remaining centipedes, and the remaining centipedes are numbered to obtain the numbering matrix.
[0033] For each element in the numbering matrix represented in scientific notation, find the maximum element in each column of the numbering matrix and sort them.
[0034] The elements in each column are numerically scaled according to column order to obtain new elements, forming a filled matrix.
[0035] Optionally, obtaining the component scores based on the filling matrix, the penalty coefficient, and the weight constraints includes:
[0036] The influence weights of different component contents on the content fractions of medicinal chemical components in centipede were obtained;
[0037] The component score is obtained based on the filling matrix, the influence weight, the penalty coefficient, and the component score formula.
[0038] The formula for the component fraction is expressed as follows:
[0039] S = C·WT -A * ·σ T ;
[0040] Where S is the component score, W is the weight matrix influencing the weight composition, σ is the penalty coefficient, and A * C is the test component content matrix extracted from the component matrix and corresponding to the filling matrix, where C is the filling matrix and T is the transpose matrix.
[0041] Optionally, calculating the length fraction based on the centipede's length includes:
[0042] Obtain the prices of giant spiny centipedes of different lengths and widths, and calculate the average unit price;
[0043] Plot a 3D image with length as the x-axis, width as the y-axis, and average unit price as the z-axis, and perform interpolation to obtain an interpolated image;
[0044] The Z-axis of the interpolated image is scaled to obtain the scaled Z-axis length;
[0045] The least squares fitting algorithm is used to fit the correlation function of the scaling Z-axis length with respect to length x and width y;
[0046] The length fraction is obtained based on the correlation function and the length of the spiny giant centipede.
[0047] Optionally, obtaining extracted features by performing deformable convolution on the preprocessed image includes:
[0048] Set the offset;
[0049] Select several sampling points on the preprocessed image;
[0050] Based on the sampling points and the offset, the actual offset is obtained;
[0051] Based on the actual offset and the deformable convolution formula, the extracted features are obtained.
[0052] Optionally, the deformable convolution formula is:
[0053]
[0054] in, This is the offset. This is the actual offset. These are the convolution kernel coefficients.
[0055] A centipede quality identification system, comprising:
[0056] The first acquisition module is used to acquire sample images of characteristic parts of the giant centipede with few spines;
[0057] The first extraction module is used to extract a color matrix based on the color sample image, the color matrix including a head color matrix, a back color matrix and an abdomen color matrix;
[0058] The first calculation module is used to select two quantiles, form an acceptance region based on the two quantiles, filter the elements in the color matrix based on the acceptance region to obtain the filtered elements, and calculate the mean vector based on the filtered elements.
[0059] The transformation module is used to transform the mean vector using the HIS model to obtain a transformed vector;
[0060] The second calculation module is used to filter centipedes according to the transformation vector and color constraints to obtain filtered centipedes, and to obtain the color score of the centipedes according to the transformation vector and color formula of the filtered centipedes.
[0061] The second acquisition module is used to acquire the content of test components in the centipedes being screened;
[0062] The screening module is used to generate a component matrix based on the content of the test component, and to screen the centipedes according to the component matrix and component constraints to obtain the remaining centipedes, to number the remaining centipedes to obtain a numbering matrix, and to scale the numbering matrix to obtain a filling matrix.
[0063] The third acquisition module is used to acquire the penalty coefficient;
[0064] The third calculation module is used to obtain the component scores based on the filling matrix, the penalty coefficient, and the weight constraints.
[0065] The fourth calculation module is used to calculate the length fraction based on the centipede's length;
[0066] A module is established to obtain a final score based on the length score, the component score, and the color score, and to establish a centipede quality grade comparison table by performing a normal distribution on the final score.
[0067] The grayscale processing module is used to perform grayscale processing on the feature image to obtain a processed centipede image;
[0068] The second extraction module is used to extract features from the preprocessed image through deformable convolution.
[0069] The first training module is used to input the extracted features into the category convolutional neural network for training, thereby obtaining the centipede category training network;
[0070] The fourth acquisition module is used to acquire color sample images corresponding to the remaining centipedes as category training set images;
[0071] The preprocessing module is used to normalize the images in the category training set to obtain normalized images, and to crop the normalized images to obtain a cropped image set.
[0072] The second training module is used to input the cropped image set and the centipede quality level comparison table into the graded convolutional neural network for training, so as to obtain the centipede quality level training network.
[0073] The recognition module is used to input actual feature images into the category training network, and input the actual color image corresponding to the centipede category of Giant Centipede with Lesser Spinach into the centipede quality level training network to obtain the centipede quality level corresponding to the actual image.
[0074] A terminal device includes a memory and a processor. The memory stores a computer program that can run on the processor. When the processor loads and executes the computer program, it employs a centipede quality identification method.
[0075] A computer-readable storage medium storing a computer program, which, when loaded and executed by a processor, employs a centipede quality identification method.
[0076] The beneficial effects of this invention are:
[0077] A sample of *Gymnocyprini spicata* is selected, and images of characteristic parts and color samples are obtained after photographing. Color and length scores are calculated based on the color sample images. Component scores are obtained by measuring component content. A final score is derived from the color, length, and component scores, and a centipede quality grade comparison table is established. Then, the characteristic part sample images are preprocessed and subjected to deformable convolution to extract features, which are then input into a convolutional neural network for training, resulting in a category training network. Similarly, preprocessed color sample images are input into the convolutional neural network for training, resulting in a centipede quality grade training network. Actual images are input into the category training network, specifically images corresponding to the *Gymnocyprini spicata* category, to obtain the centipede quality grade corresponding to the actual image. In practical use, this application eliminates the need to test component content; the centipede quality grade can be obtained solely from photographs. Attached Figure Description
[0078] Figure 1 This is a centipede quality grade comparison table for the present invention. Detailed Implementation
[0079] A method for identifying the quality of centipedes, the present invention includes:
[0080] S1. Obtain sample images of characteristic parts and color of the spiny giant centipede.
[0081] Specifically, the spiny giant centipede is the centipede that is permitted to be used in medicine.
[0082] A centipede sample was placed in the center of a 20cm*20cm white background. Images of both sides of the centipede were taken at a 1:1 aspect ratio, obtaining color photos of both sides of each sample. The length per pixel (LPP) of the image was calculated based on the pixel value L of the captured image. The calculation formula is:
[0083]
[0084] Place a sample centipede in the center of a 1cm*1cm white background and take photos of the centipede's characteristic parts (posterior end of the basal lateral plate, lateral and medial ventral surfaces of the prefemur of the last pair of walking legs, and medial dorsal surface of the prefemur of the last pair of walking legs) with a length-to-width ratio of 1:1. This will yield photos of the characteristic parts of each centipede.
[0085] S2. Extract the color matrix based on the color sample image. The color matrix includes the color matrix of the head, the color matrix of the back, and the color matrix of the abdomen.
[0086] To extract the color matrix from all color photos, the centipede's head contains various distracting elements such as mouthparts and tentacles. Therefore, the area around the centipede's head is selected, resulting in a region free of distracting elements. Within this region, a 20×20 pixel rectangular area is divided, and 100 points are taken at equal intervals to obtain the head color matrix. The head color matrix is as follows:
[0087]
[0088] Compared to its head, the centipede's back has fewer distracting elements. Avoiding the joints between the back plates, select the five central back plates. Choose a region from each back plate, and then divide each region into a 10×10 pixel rectangular area. Take 20 points at equal intervals within each rectangular area, for a total of 100 points, to obtain the back color matrix. The back color matrix is as follows:
[0089]
[0090] Centipedes are composed of a series of repeating segments called rings. Therefore, the abdominal structure is similar to the dorsal plate structure; only the connecting points on the abdomen need to be avoided when selecting regions. The five dorsal plates in the middle correspond to the five abdominal plates. A region is selected from each abdominal plate, and each region is divided into a 10×10 pixel rectangular area. Points are selected at equal intervals, with 20 points selected from each rectangular area, for a total of 100 points, to obtain the abdominal color matrix. The abdominal color matrix is as follows:
[0091]
[0092] R represents the centipede's value in the red channel, while G and B represent the values in the green and blue channels, respectively. All values are integers ranging from 0 to 255.
[0093] S3. Select two quantiles and form an acceptance region based on the two quantiles. Filter the elements in the color matrix according to the acceptance region to obtain the filtered elements, and calculate the mean vector based on the filtered elements.
[0094] Two quantiles are selected, and a receptive field is formed based on these two quantiles. Elements in the color matrix are then filtered according to the receptive field to obtain filtered elements. The mean vector is then calculated based on these filtered elements, including:
[0095] Each column of the head color matrix, back color matrix, and abdomen color matrix is analyzed separately, and the elements within the receiving domain are selected to obtain the head selection elements, back selection elements, and abdomen selection elements.
[0096] The mean values of the head, back, and abdomen filter elements are calculated separately to obtain the head mean vector, abdomen mean vector, and back mean vector. The mean vectors of the color values of different parts are then formed based on the head mean vector, abdomen mean vector, and back mean vector.
[0097] Taking the head color matrix HC as an example, we analyze each column of the head color matrix. Taking the first column as an example, we arrange all elements in the first column from smallest to largest, select the data that fall between the 0.025 quantile and the 0.925 quantile, and record the two quantiles as follows:
[0098]
[0099] Using these two points as the receptive field for the red channel values in the header, the receptive field is denoted as:
[0100]
[0101] The remaining two columns are processed in the same way as the first column, resulting in two additional acceptor fields:
[0102]
[0103] The same processing is applied to the back color matrix BC and the belly color matrix AC, resulting in the following receptive fields using a similar naming convention. Their receptive fields are:
[0104]
[0105] Let n be the number of centipedes remaining within the receiving region. Calculate the mean value of all elements within the receiving region to obtain the mean vector of color values for different parts. Its mean vector is:
[0106]
[0107] in, The head mean vector, The back mean vector, The mean vector of the abdomen. These are the pigment values in the head color matrix. The pigment values in the back color matrix. The value represents the pigment value in the abdominal color matrix.
[0108] S4. Transform the mean vector using the HIS model to obtain the transformed vector.
[0109] Specifically, HIS images are better able to compare the saturation differences of similar colors compared to RGB images, thus better reflecting color differences. Therefore, all the above data is transformed into the HIS(hue, saturation, intensity) model using the formula: Hue represents the color type, saturation reflects the color purity, and intensity represents the brightness of the color. The transformation formula is as follows:
[0110]
[0111] The transformed receptive domain is denoted as:
[0112]
[0113] The transformed mean vector is denoted as:
[0114]
[0115] S5. Based on the transformation vector and color constraints, the centipedes are screened to obtain the screened centipedes. Based on the transformation vector and color formula of the screened centipedes, the color score of the centipedes is obtained.
[0116] Specifically, the color constraints are as follows:
[0117]
[0118] Centipedes that do not meet the color constraints receive a color score of 0. Centipedes that meet the color constraints are calculated using the color formula, which is:
[0119]
[0120] Where, τ g (g=1,2,3,4,5,6) is obtained by expert evaluation method and is used to reflect the influence coefficients of different parts of color and color saturation on the centipede's color score. The score range is limited by weighted calculation, and the limiting conditions are as follows:
[0121] 0 <cs≤100
[0122] S6. Obtain the content of test components in the centipedes being screened.
[0123] S7. Generate a component matrix based on the content of the tested components, and filter the centipedes according to the component matrix and component constraints to obtain the remaining centipedes. Number the remaining centipedes to obtain a numbering matrix, and scale the numbering matrix to obtain a filling matrix.
[0124] A component matrix is generated based on the content of the tested components. Then, based on the component matrix and component constraints, the centipedes are screened to obtain the remaining centipedes. These remaining centipedes are numbered to obtain a numbering matrix. The numbering matrix is then scaled to obtain a weight matrix, which includes:
[0125] The tested components include moisture content, total ash content, aflatoxin content, and extract content. The aflatoxin content includes aflatoxin B1, aflatoxin G2, aflatoxin G1, and aflatoxin B2.
[0126] A component matrix is constructed with moisture content as the first column, total ash content as the second column, aflatoxin B1 content as the third column, the total content of aflatoxin G2, aflatoxin G1, aflatoxin B2 and aflatoxin B1 as the fourth column, and extract content as the fifth column.
[0127] Specifically, the moisture, total ash, and aflatoxin content of all n samples within the aforementioned acceptance domain were determined.
[0128] Construct an n×5 matrix A, and fill matrix A with the detection results. The moisture content is in the first column, the total ash content in the second column, the aflatoxin B1 content in the third column, the content of aflatoxin G2, aflatoxin G1, aflatoxin B2, and the total content of aflatoxin B1 in the fourth column, and the leachate content in the fifth column. Matrix A is as follows:
[0129]
[0130] The extractives shall be determined by the hot extraction method under the method for determination of alcohol-soluble extractives (General Rule 2201), using dilute ethanol as the solvent, and shall not be less than 20.0%.
[0131] Based on the component matrix and component constraints, the centipedes are screened to obtain the remaining centipedes. The remaining centipedes are then numbered to obtain the numbering matrix.
[0132] Specifically, based on the requirements for moisture, total ash, and aflatoxin content when centipedes are used in medicine, five constraints are established for the elements in matrix A above. These constraints are:
[0133]
[0134] Among them, a i,1 a represents the moisture content. i,2 For total ash content, a i,3 The content of aflatoxin B1, a i,4 The total content of aflatoxin G2, aflatoxin G1, aflatoxin B2 and aflatoxin B1, a i,5 This refers to the content of leachate.
[0135] All centipedes meeting the above conditions are obtained. The remaining number of centipedes is denoted as n', and they are renumbered 1, 2, ..., n'. To reduce testing costs, only the centipedes with the newly numbered centipedes are tested for the content of medicinal chemical components (assuming there are j kinds of medicinal chemical components). The test results are recorded, and the content matrix of medicinal chemical components of centipedes is obtained, denoted as the numbering matrix B. Matrix B is:
[0136]
[0137] For each element in the numbering matrix represented in scientific notation, find the largest element in each column of the numbering matrix and sort them.
[0138] Specifically, each element in matrix B is represented using scientific notation, as follows:
[0139]
[0140] The elements in each column are numerically scaled according to column order to obtain new elements, forming a filled matrix.
[0141] Specifically, find the maximum element in each column of matrix B. This can be represented as follows:
[0142]
[0143] Scalculate the values of all elements in each column according to column order to obtain a new element c. x,y Its scaling formula is:
[0144]
[0145] Use element c x,y The filling matrix C is:
[0146]
[0147] S8. Obtain the penalty coefficient.
[0148] Specifically, since moisture, total ash, and aflatoxin directly affect the quality of centipedes, when calculating the content of medicinal chemical components in centipedes where all three levels are within acceptable limits, these three factors are considered as penalty factors. The penalty coefficients for these three factors (moisture, total ash, and aflatoxin) are determined through expert evaluation. The penalty coefficients are as follows:
[0149] σ=(σ1,σ2,σ3,σ4)
[0150] S9. Based on the filling matrix, penalty coefficients, and weight constraints, obtain the component scores.
[0151] Based on the filling matrix, penalty coefficients, and weight constraints, the component scores are obtained as follows:
[0152] The influence weights of different component contents on the content fractions of medicinal chemical components in centipedes were obtained.
[0153] Specifically, to simplify the calculation of the pharmacodynamic chemical content fraction and ensure that the selected weights have reference value, the weights can be set to meet the following constraints. The weight constraints are:
[0154]
[0155] The component scores are obtained based on the filling matrix, influence weights, penalty coefficients, and component score formulas.
[0156] The formula for component fraction is expressed as:
[0157] S = C·W T -A * ·σ T .
[0158] Where S is the component score, W is the weight matrix influencing the weight composition, σ is the penalty coefficient, and A * C is the test component content matrix extracted from the component matrix and corresponding to the filling matrix, where C is the filling matrix and T is the transpose matrix.
[0159] If any of the following parameters of the centipede's content—moisture, total ash, aflatoxin, or extract—fail to meet the standard, its medicinal chemical component content score will be recorded as 0. The formula is:
[0160] S = 0
[0161] S10. Calculate the length fraction based on the length of the centipede.
[0162] Calculating length fractions based on the centipede's length includes:
[0163] Obtain the prices of giant spiny centipedes of different lengths and widths, and calculate the average unit price.
[0164] Draw a 3D image with length as the x-axis, width as the y-axis, and average unit price as the z-axis, and perform interpolation to obtain an interpolated image.
[0165] The Z-axis of the interpolated image is scaled to obtain the scaled Z-axis length.
[0166] The least squares fitting algorithm is used to fit the correlation function of the scaling Z-axis length with respect to length x and width y.
[0167] The length fraction is obtained based on the correlation function and the length of the spiny giant centipede.
[0168] Specifically, collect and record the prices of centipedes of different lengths and widths from the market. Then, input this data into an Excel spreadsheet in the order of length, width, and unit price for storage.
[0169] For stored data containing centipedes with the same length and width but corresponding to multiple different unit prices, the following processing should be performed: calculate the average of these unit prices and use this average unit price to replace the unit price of the centipede for that specific length and width.
[0170] Based on the above data, MATLAB was used to plot a three-dimensional image with length as the x-axis, width as the y-axis, and average unit price as the z-axis.
[0171] The drawn image is analyzed, and the interp3 function is used to interpolate the image to obtain a new image.
[0172] Scale the image along the Z-axis, denoted as Z' (scale Z-axis length). The calculation formula is:
[0173]
[0174] Using the least squares fitting algorithm, a function of Z' with respect to length x and width y is fitted. Its functional expression is:
[0175] Z′=g(x,y)
[0176] According to the Chinese Pharmacopoeia, the length of centipedes ranges from 9 to 15 cm. When calculating the length fraction of centipedes, a formula is used to calculate the length fraction for lengths greater than 9 cm. The formula is:
[0177] L=Z′=g(x,y)
[0178] If the length is less than 9cm, the length score is 0. The formula is:
[0179] L=0
[0180] Calculate the final score S end .include:
[0181] The influence weights of the above three aspects on the overall quality of the centipede were determined using expert evaluation. These weights are denoted as follows: And it satisfies the equation. The equation is:
[0182]
[0183] Define a function:
[0184]
[0185] The final score calculation formula is:
[0186]
[0187] S11. Based on the length score, composition score, and color score, obtain the final score, distribute the final score normally, and establish a centipede quality grade comparison table.
[0188] Specifically, centipedes with a final score of 0 are considered substandard. All centipedes with a final score greater than 0 are extracted, and a normality test is performed on these scores.
[0189] If the data conforms to a normal distribution, no box-cox transformation is performed. If the data does not conform to a normal distribution, a box-cox transformation is performed to obtain a new score that conforms to a normal distribution.
[0190] Let μ and σ be the mean and standard deviation for both cases. Determine the centipede quality grade comparison table based on the 3σ principle, as shown in the table below. Figure 1 As shown.
[0191] S12. The feature image is converted to grayscale to obtain the processed centipede image.
[0192] Specifically, in the above steps, photographs of the characteristic parts of the giant centipede (posterior end of the basal lateral plate, lateral and medial ventral surfaces of the forefeet of the last pair of walking legs, and medial dorsal surface of the forefeet of the last pair of walking legs), as well as photographs of the color of the centipede on both sides and the corresponding centipede quality grade were obtained, and qualified samples were numbered.
[0193] Enter the sample images of the feature parts, the color sample images of both sides, and the quality grade information in the order of their numbers.
[0194] Since only information on the spiny giant centipede species has been entered so far, information on other centipede species needs to be entered.
[0195] Other species of centipedes were numbered, and photos of their characteristic parts were taken (the method of taking photos of their characteristic parts was the same as that of the giant spiny centipede). The images of the characteristic parts of other species of centipedes were entered into a visual database in the order of their numbers.
[0196] Implement security and integrity constraints on the visual database and construct an indexing mechanism.
[0197] The completed visual database can provide data for training convolutional neural networks.
[0198] S13. Preprocess the centipede image to obtain a preprocessed image.
[0199] Specifically, extract characteristic photos of all centipedes from the visual database.
[0200] All extracted images are converted to grayscale. An averaging algorithm is used, and the R, G, B values of the image at this point satisfy the following formula: [Formula omitted for brevity]
[0201]
[0202] The grayscale image is rotated and scaled to better highlight the feature areas, and the image resolution is set to 400×400 pixels.
[0203] The image is processed using the closing operation in morphological preprocessing, which involves dilation and erosion to highlight the feature areas of the image, resulting in a preprocessed image.
[0204] S14. Extract features by performing deformable convolution on the preprocessed image.
[0205] To improve the accuracy of feature extraction, deformable convolution is used instead of ordinary convolution. Deformable convolution, by introducing learnable offsets, can better capture complex and varied features in images. The deformable convolution kernel does not change the way the convolution kernel is calculated. Taking a 3×3 ordinary convolution kernel as an example, let the input feature map be X, the output feature map be Y, and R = ...
[0206] 1,1),(1,0),…,(-1,0),(-1,-1)} represent the positions of sampling points relative to the sampling center point, ω is the weight of the corresponding position in the convolution kernel, and Y p This represents the value at point p in the output feature map, for each Y. p The output of each sample must be taken from 9 positions on X, and these 9 positions fall within the feature map X with corresponding X values. p Within the square region centered at X, (1,1) represents X. p In the top right corner, (-1, -1) represents X. pThe bottom left corner, and others are similar. The calculation for ordinary convolution can be obtained, and its formula is:
[0207]
[0208] (Output a specific location in the feature map Y) Corresponding to a point in the input feature map X Through different p n Select traversable Nine points within the central square, each point corresponding to a coefficient in its convolution kernel. After multiplying, add all the product terms together to get the result. )
[0209] For deformable convolutions, this is achieved by adding learnable offsets. Sampling points are allowed to spread out in a non-square pattern. This represents the lateral offset on the input feature map X. The vertical offset on the input feature map X is shown, where ρ1 and ρ2 are learning factors used to learn the most suitable offset and control the points after the offset. Still within the input feature map X. Its formula is:
[0210]
[0211] From the above, we can obtain the formula for calculating deformable convolution, which is:
[0212]
[0213] To ensure These are the actual pixels that can be found on the input feature map. The formula for bilinear interpolation is:
[0214]
[0215] (q represents all pixels in the input feature map X)
[0216] The preprocessed image is subjected to deformable convolution to obtain the following extracted features:
[0217] Set the offset.
[0218] Select several sampling points on the preprocessed image.
[0219] The actual offset is obtained based on the sampling point and the offset.
[0220] Based on the actual offset and the deformable convolution formula, the extracted features are obtained.
[0221] The deformable convolution formula is:
[0222]
[0223] in, This is the offset. This is the actual offset. These are the convolution kernel coefficients.
[0224] S15. Input the extracted features into the category convolutional neural network for training to obtain the centipede category training network.
[0225] Specifically, the accuracy of the convolutional neural network (CNN) recognition is calculated using the last 20% of the image set. Research indicates that CNNs achieve approximately 90% accuracy in classifying and recognizing different animal species. Referring to the accuracy rates for classifying and recognizing different animal species, and considering the specific problem, if the recognition accuracy is above 80%, the remaining 10% of the data is also used to assess the algorithm's accuracy. If the recognition rate is below 80%, it is used for further optimization of the algorithm.
[0226] S16. Obtain the color sample images corresponding to the remaining centipedes as the category training set images.
[0227] S17. Normalize the images in the training set of the category to obtain normalized images, and crop the normalized images to obtain a cropped image set.
[0228] S18. Input the cropped image set and the centipede quality grade comparison table into the graded convolutional neural network for training to obtain the centipede quality grade training network.
[0229] S19. Input the actual feature images into the category training network, and input the actual color images corresponding to the centipede category of Giant Centipede with Lesser Spinach into the centipede quality level training network to obtain the centipede quality level corresponding to the actual images.
[0230] Extract the color of both sides of the *Gymnocyprini spicata* photograph from the visual database and the corresponding quality level of the photograph.
[0231] The images in the database are normalized. Normalized images can eliminate the influence of lighting on pixels. The normalization formula is:
[0232]
[0233] Nowadays, most mainstream mobile phones have rear cameras with a resolution of 13 megapixels or higher, capable of capturing images with a 1:1 aspect ratio. Under these conditions, a 20cm x 20cm background image would have a resolution of approximately 3600 x 3600 pixels. Using the Smart Image Cropping API, the normalized image is cropped, and the entire centipede is extracted. The cropped image is then set to a resolution of 3600 x 1200 pixels, resulting in a pre-processed color image.
[0234] The preprocessed color image is input into the convolutional layer in the form of an image in RGB space, and the size of the convolutional kernel is selected as 3×3.
[0235] The ReLU function is selected as the activation function between the convolutional layer and the pooling layer.
[0236] The maximum pooling layer size is 5×5, which effectively reduces the computational load while ensuring feature extraction.
[0237] Figure 1 The quality level of the centipede has been given, and the final output layer is set to the quality level of the centipede.
[0238] 80% of the preprocessed images were selected as the training set, and the remaining 20% were selected as the validation set. The convolutional neural network was then trained to obtain a convolutional neural network algorithm for judging the quality level of centipedes.
[0239] Add a conditional statement after the convolutional neural network algorithm used to determine whether the centipede is a *Scolopendra subspinipes*: If it is determined to be a *Scolopendra subspinipes*, proceed to determine the quality level of the centipede, call the convolutional neural network algorithm used to determine the centipede's quality level, and finally output the quality level of the *Scolopendra subspinipes*. If it is determined not to be a *Scolopendra subspinipes*, directly output: This centipede is not a *Scolopendra subspinipes*, therefore its quality is unqualified, thus constructing a complete convolutional neural network.
[0240] Specifically, the actual images are pictures taken of centipedes whose quality needs to be determined.
[0241] A centipede quality identification system, comprising:
[0242] The first acquisition module is used to acquire sample images of characteristic parts of the giant centipede with few spines;
[0243] The first extraction module is used to extract a color matrix based on the color sample image, the color matrix including a head color matrix, a back color matrix and an abdomen color matrix;
[0244] The first calculation module is used to select two quantiles, form an acceptance region based on the two quantiles, filter the elements in the color matrix based on the acceptance region to obtain the filtered elements, and calculate the mean vector based on the filtered elements.
[0245] The transformation module is used to transform the mean vector using the HIS model to obtain a transformed vector;
[0246] The second calculation module is used to filter centipedes according to the transformation vector and color constraints to obtain filtered centipedes, and to obtain the color score of the centipedes according to the transformation vector and color formula of the filtered centipedes.
[0247] The second acquisition module is used to acquire the content of test components in the centipedes being screened;
[0248] The screening module is used to generate a component matrix based on the content of the test component, and to screen the centipedes according to the component matrix and component constraints to obtain the remaining centipedes, to number the remaining centipedes to obtain a numbering matrix, and to scale the numbering matrix to obtain a filling matrix.
[0249] The third acquisition module is used to acquire the penalty coefficient;
[0250] The third calculation module is used to obtain the component scores based on the filling matrix, the penalty coefficient, and the weight constraints.
[0251] The fourth calculation module is used to calculate the length fraction based on the centipede's length;
[0252] A module is established to obtain a final score based on the length score, the component score, and the color score, and to establish a centipede quality grade comparison table by performing a normal distribution on the final score.
[0253] The grayscale processing module is used to perform grayscale processing on the feature image to obtain a processed centipede image;
[0254] The second extraction module is used to extract features from the preprocessed image through deformable convolution.
[0255] The first training module is used to input the extracted features into the category convolutional neural network for training, thereby obtaining the centipede category training network;
[0256] The fourth acquisition module is used to acquire color sample images corresponding to the remaining centipedes as category training set images;
[0257] The preprocessing module is used to normalize the images in the category training set to obtain normalized images, and to crop the normalized images to obtain a cropped image set.
[0258] The second training module is used to input the cropped image set and the centipede quality level comparison table into the graded convolutional neural network for training, so as to obtain the centipede quality level training network.
[0259] The recognition module is used to input actual feature images into the category training network, and input the actual color image corresponding to the centipede category of Giant Centipede with Lesser Spinach into the centipede quality level training network to obtain the centipede quality level corresponding to the actual image.
[0260] This application also discloses a terminal device, including a memory and a processor. The memory stores a computer program that can run on the processor. When the processor loads and executes the computer program, a centipede quality identification method is used.
[0261] The terminal device can be a computer device such as a desktop computer, a laptop computer, or a cloud server. The terminal device includes, but is not limited to, a processor and a memory. For example, the terminal device may also include input / output devices, network access devices, and buses.
[0262] The processor can be a central processing unit (CPU). Of course, depending on the actual use, it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), off-the-shelf programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc., and this application does not limit it in this regard.
[0263] The memory can be an internal storage unit of the terminal device, such as a hard disk or RAM of the terminal device, or an external storage device of the terminal device, such as a plug-in hard disk, smart memory card (SMC), secure digital card (SD), or flash memory card (FC) equipped on the terminal device. Furthermore, the memory can be a combination of internal storage units and external storage devices of the terminal device. The memory is used to store computer programs and other programs and data required by the terminal device. The memory can also be used to temporarily store data that has been output or will be output. This application does not limit this.
[0264] In this terminal device, a centipede quality identification method from the above embodiments is stored in the terminal device's memory and loaded and executed on the terminal device's processor for convenient use.
[0265] This application also discloses a computer-readable storage medium, which stores a computer program, wherein when the computer program is executed by a processor, it employs a centipede quality identification method described in the above embodiments.
[0266] The computer program can be stored in a computer-readable medium. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or certain middleware. The computer-readable medium includes any entity or device capable of carrying computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the computer-readable medium includes, but is not limited to, the above-mentioned components.
[0267] The centipede quality identification method described in the above embodiments is stored in the computer-readable storage medium and loaded and executed on the processor to facilitate the storage and application of the method.
[0268] Those skilled in the art should understand that the discussion of any of the above embodiments is merely exemplary and is not intended to imply that the scope of protection of this application is limited to these examples. Within the framework of this application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and many other variations exist regarding different aspects of one or more embodiments of this application as described above, which are not provided in detail for the sake of brevity.
[0269] One or more embodiments in this application are intended to cover all such substitutions, modifications, and variations that fall within the broad scope of this application. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of one or more embodiments in this application should be included within the protection scope of this application.
Claims
1. A method for identifying the quality of centipedes, characterized in that, include: Obtain sample images of characteristic parts and color samples of the spiny giant centipede; Based on the color sample image, a color matrix is extracted, which includes a head color matrix, a back color matrix, and an abdomen color matrix. Two quantiles are selected, and a receptive field is formed based on the two quantiles. The elements in the color matrix are filtered according to the receptive field to obtain the filtered elements. The mean vector is calculated based on the filtered elements. The mean vector is transformed using the HIS model to obtain the transformed vector; Based on the transformation vector and color constraints, centipedes are screened to obtain screened centipedes. Based on the transformation vector and color formula of the screened centipedes, the color score of the centipedes is obtained. Obtain the content of test components in the centipedes being screened; A component matrix is generated based on the content of the tested components. The centipedes are then screened according to the component matrix and the component constraints to obtain the remaining centipedes. The remaining centipedes are numbered to obtain a numbering matrix. The numbering matrix is then scaled to obtain a filling matrix. Obtain the penalty coefficient; The component scores are obtained based on the filling matrix, the penalty coefficient, and the weight constraints. Calculate the length fraction based on the centipede's length; Based on the length score, the component score, and the color score, the final score is obtained. The final score is then distributed normally to establish a centipede quality grade comparison table. The sample images of the aforementioned feature regions are converted to grayscale to obtain the processed centipede image; The centipede image is preprocessed to obtain a preprocessed image; The preprocessed image is subjected to deformable convolution to extract features; The extracted features are input into a category convolutional neural network for training to obtain a centipede category training network. Obtain color sample images corresponding to the remaining centipedes as category training set images; The training set images of the aforementioned categories are normalized to obtain normalized images, and the normalized images are cropped to obtain a cropped image set. The cropped image set and the centipede quality grade comparison table are input into the graded convolutional neural network for training to obtain the centipede quality grade training network. The actual feature images are input into the category training network, and the actual color images corresponding to the centipede category of Giant Centipede with Lesser Spinach are input into the centipede quality level training network to obtain the centipede quality level corresponding to the actual images.
2. The centipede quality identification method as described in claim 1, characterized in that, The steps of selecting two quantiles, forming a receptive field based on the two quantiles, filtering the elements in the color matrix based on the receptive field to obtain filtered elements, and calculating the mean vector based on the filtered elements include: Each column of the head color matrix, back color matrix, and abdomen color matrix is analyzed separately, and the elements within the receiving domain are selected to obtain the head screening elements, back screening elements, and abdomen screening elements. The mean values of the head, back, and abdomen screening elements are calculated respectively to obtain the head mean vector, abdomen mean vector, and back mean vector. The mean vectors of the color values of different parts are then formed based on the head mean vector, abdomen mean vector, and back mean vector.
3. The centipede quality identification method as described in claim 1, characterized in that, The process of generating a component matrix based on the content of the tested components, filtering centipedes according to the component matrix and component constraints to obtain remaining centipedes, numbering the remaining centipedes to obtain a numbering matrix, and scaling the numbering matrix to obtain a filling matrix includes: The tested component contents include moisture content, total ash content, aflatoxin content, and extract content. The aflatoxin content includes aflatoxin B1, aflatoxin G2, aflatoxin G1, and aflatoxin B2. A component matrix is constructed with the moisture content as the first column, the total ash content as the second column, the aflatoxin B1 content as the third column, the total content of aflatoxin G2, aflatoxin G1, aflatoxin B2 and aflatoxin B1 as the fourth column, and the extract content as the fifth column. Based on the component matrix and component constraints, the centipedes are screened to obtain the remaining centipedes, and the remaining centipedes are numbered to obtain the numbering matrix. For each element in the numbering matrix represented in scientific notation, find the maximum element in each column of the numbering matrix and sort them. The elements in each column are numerically scaled according to column order to obtain new elements, forming a filled matrix.
4. The centipede quality identification method as described in claim 1, characterized in that, The process of obtaining the component scores based on the filling matrix, the penalty coefficient, and the weight constraints includes: The influence weights of different component contents on the content fractions of medicinal chemical components in centipede were obtained; The component score is obtained based on the filling matrix, the influence weight, the penalty coefficient, and the component score formula. The formula for the component fraction is expressed as follows: ; Where S is the component score, and W is the weight matrix influencing the composition of the weights. The penalty coefficient, C is the test component content matrix extracted from the component matrix and corresponding to the filling matrix, where C is the filling matrix and T is the transpose matrix.
5. The centipede quality identification method as described in claim 1, characterized in that, The calculation of length fraction based on the centipede's length includes: Obtain the prices of giant spiny centipedes of different lengths and widths, and calculate the average unit price; Draw with length as shaft, width is Shaft, average unit price is The three-dimensional image of the axis is obtained and interpolated to obtain the interpolated image; The Z-axis of the interpolated image is scaled to obtain the scaled Z-axis length; Using a least squares fitting algorithm, fit the scaled Z-axis length with respect to the length. and width The correlation function; The length fraction is obtained based on the correlation function and the length of the spiny giant centipede.
6. The centipede quality identification method as described in claim 1, characterized in that, The step of extracting features from the preprocessed image through deformable convolution includes: Set the offset; Select several sampling points on the preprocessed image; Based on the sampling points and the offset, the actual offset is obtained; Based on the actual offset and the deformable convolution formula, the extracted features are obtained.
7. The centipede quality identification method as described in claim 6, characterized in that, The deformable convolution formula is: ; in, This is the offset. This is the actual offset. These are the convolution kernel coefficients.
8. A centipede quality identification system, applied to the centipede quality identification method as described in any one of claims 1 to 7, characterized in that, include: The first acquisition module is used to acquire sample images of characteristic parts of the giant centipede with few spines; The first extraction module is used to extract a color matrix based on the color sample image. The color matrix includes a head color matrix, a back color matrix, and an abdomen color matrix. The first calculation module is used to select two quantiles, form an acceptance region based on the two quantiles, filter the elements in the color matrix based on the acceptance region to obtain the filtered elements, and calculate the mean vector based on the filtered elements. The transformation module is used to transform the mean vector using the HIS model to obtain a transformed vector; The second calculation module is used to filter centipedes according to the transformation vector and color constraints to obtain filtered centipedes, and to obtain the color score of the centipedes according to the transformation vector and color formula of the filtered centipedes. The second acquisition module is used to acquire the content of test components in the centipedes being screened; The screening module is used to generate a component matrix based on the content of the test component, and to screen the centipedes according to the component matrix and component constraints to obtain the remaining centipedes, to number the remaining centipedes to obtain a numbering matrix, and to scale the numbering matrix to obtain a filling matrix. The third acquisition module is used to acquire the penalty coefficient; The third calculation module is used to obtain the component scores based on the filling matrix, the penalty coefficient, and the weight constraints. The fourth calculation module is used to calculate the length fraction based on the centipede's length; A module is established to obtain a final score based on the length score, the component score, and the color score, and to establish a centipede quality grade comparison table by performing a normal distribution on the final score. The grayscale processing module is used to perform grayscale processing on the sample image of the feature part to obtain the processed centipede image; The second extraction module is used to extract features from the preprocessed image through deformable convolution; The first training module is used to input the extracted features into the category convolutional neural network for training, thereby obtaining the centipede category training network; The fourth acquisition module is used to acquire color sample images of the remaining centipedes as category training set images; The preprocessing module is used to normalize the images in the category training set to obtain normalized images, and to crop the normalized images to obtain a cropped image set. The second training module is used to input the cropped image set and the centipede quality level comparison table into the graded convolutional neural network for training, so as to obtain the centipede quality level training network. The recognition module is used to input actual feature images into the category training network, and input the actual color image corresponding to the centipede category of Giant Centipede with Lesser Spinach into the centipede quality level training network to obtain the centipede quality level corresponding to the actual image.
9. A terminal device, comprising a memory and a processor, characterized in that, The memory stores a computer program that can run on a processor, and when the processor loads and executes the computer program, it employs the identification method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is loaded and executed by the processor, the identification method as described in any one of claims 1 to 7 is employed.
Citation Information
Patent Citations
Strawberry growth state pest identification and growth vigor evaluation method based on PP-YOLOv2 improved model
CN118736564A
Sick juvenile fish identification method based on improved YOLOv10 model
CN119479010A