A quality detection method for mitochondrial nutrient goat milk powder based on image processing
By processing the spectral image of mitochondrial nutrient goat milk powder, randomly selecting pixels for pre-processing and comparison, combined with machine learning models, the problem of not being able to obtain the concentration of the detection object in the existing technology is solved, and the accuracy of quality detection and the accuracy of component concentration are achieved.
Patent Information
- Application Number
- CN202510358972.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-25
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2045-03-25
AI Technical Summary
When the prior art recognizes food quality through spectral images, it is impossible to accurately obtain the specific concentration information of the detection object, and the relationship between spectral characteristics between ingredients is not considered.
By acquiring multiple first spectral images of the detection sample, randomly selecting M pixels for preprocessing, obtaining the second spectral image, and comparing them with the standard spectral image to judge the sample qualification; when failing, obtaining the target band with a reflectance difference greater than the threshold, and using spectral characteristics and machine learning models to obtain the concentration information of the detection object.
The accuracy of the quality detection of mitochondrial nutrient goat milk powder is achieved, and the specific concentration information of unqualified ingredients can be obtained, and production adjustment can be supported.
Smart Images

Figure CN119861044B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and more particularly to a quality detection method for mitochondrial nutrient goat milk powder based on image processing. Background Art
[0002] Detecting food quality through spectral images is a non-destructive, fast, and effective technology, which has been widely applied in the field of food quality control. Similar prior arts include a Chinese patent with the publication number CN118674954B, which proposes a quality detection system for traditional Chinese medicine based on image recognition, relating to the technical field of image recognition, effectively improving the accuracy of detecting the quality of traditional Chinese medicine. A three-dimensional image model of traditional Chinese medicine is generated according to the training image data set in each state, several detection areas are respectively set on the three-dimensional image model of traditional Chinese medicine, and then several pixel value jump vectors and abnormal pixel areas are set in each detection area. The abnormal pixel areas generated when different model pixels are used as the first starting pixel are overlapped and mapped, and then several abnormal condition areas are divided within the detection areas in different states. A target three-dimensional image model is generated according to the detection image data set, several target detection areas are set on the target three-dimensional image model, and then the detection pixel value jump vectors of the target detection areas are obtained. The quality of the target traditional Chinese medicine is evaluated according to the matching condition between the detection pixel value jump vectors and the abnormal condition areas. In addition, a similar prior art is a US patent with the publication number US20240265673A1, which proposes a system and method for detecting gases in the atmosphere from a multi-spectral image including a plurality of pixels, each pixel having a spectral feature including a set of electromagnetic (EM) energy intensities reflected in each band. The method includes: clustering a plurality of pixels based on a spectral feature channel indicating the presence of a gas to generate a first set of clusters; clustering a plurality of pixels based on a spectral feature channel not indicating the presence of a gas to generate a second set of clusters; matching the clusters from the first set of clusters and the second set of clusters; and marking the clusters present in the first set of clusters but not in the second set of clusters as suspected of containing a gas. The above two patents both solve the problem of identifying abnormal states through spectral images, but neither further obtains the specific details of the abnormal states based on the spectral images, such as the specific concentration of the components of the detection object, nor considers the relationship between the spectral features of the components. Summary of the Invention
[0003] In order to better solve the above problems, the present invention provides a quality detection method for mitochondrial nutrient goat milk powder based on image processing, which is used to detect the quality of the mitochondrial nutrient goat milk powder. The method includes the following steps:
[0004] Step S1: Obtain a detection sample. Use an imaging unit to obtain multiple first spectral images of the detection sample, randomly select M pixels at different positions from the multiple first spectral images, and preprocess the initial spectral maps of the M pixels to obtain M second spectral images;
[0005] Step S2: Based on the M second spectral images, obtain a spectral image to be detected, compare the spectral image to be detected with a standard spectral image to obtain a comparison result, and determine whether the detection sample is qualified according to the comparison result;
[0006] Step S3: When the detection sample is unqualified, based on the comparison result, obtain a target band where the reflectance difference between the spectral image to be detected and the standard spectral image is greater than a second threshold, obtain a first object according to the spectral characteristics corresponding to the target detection object of the detection sample and the target band, and obtain the concentration information of the first object according to the first object and a first model;
[0007] Step S4: According to the spectral characteristics of each target detection object in the target band, the first object, the concentration information of the first object, and a second model, obtain the concentration information of each target detection object corresponding to the target band.
[0008] As a preferred technical solution of the present invention, step S1 includes the following steps:
[0009] Step S11: Obtain the mitochondrial goat milk powder sample to be detected as the detection sample, and place the detection sample in a detection container, wherein a stirring device is arranged in the detection container;
[0010] Step S12: Stir in different directions through the stirring device at a preset time interval, and during the time interval when the stirring stops, use the imaging unit to obtain multiple first spectral images of the detection sample;
[0011] Step S13: Randomly select M pixels at different positions from the multiple first spectral images as target pixels, obtain the initial spectral map corresponding to each target pixel, preprocess the initial spectral map, and obtain M second spectral images.
[0012] As a preferred technical solution of the present invention, in step S1, the preprocessing of the spectral image includes:
[0013] Step S130: Obtain the reflectance data of light with different wavelengths in each initial spectral map, sort the reflectance data of the light with different wavelengths from short to long according to the wavelength to obtain a spectral data sequence;
[0014] Step S131: Slide a sliding window of a preset size from the starting position of the spectral data sequence, select N minimum reflectivity data within the sliding window, obtain the average value of the N minimum reflectivity data, and replace the reflectivity data corresponding to the center position of the sliding window with the average value;
[0015] Step 132: Slide the sliding window with a sliding step of 1, and repeat the method of Step S131 to correct the reflectivity data corresponding to the center position of the sliding window. Repeat this step until the number of the remaining reflectivity data is less than the size of the sliding window.
[0016] As a preferred technical solution of the present invention, in Step S1, the preprocessing of the spectral image further includes:
[0017] When the number of the reflectivity data at the head of the spectral data sequence is less than half of the size of the sliding window and the number of the remaining reflectivity data at the tail of the spectral data sequence is less than the size of the sliding window, use the reflectivity data as the data to be processed. Compare each data to be processed with at least two adjacent reflectivity data continuously, obtain the maximum comparison result. When the maximum comparison result is less than or equal to the first threshold, the data to be processed does not need to be corrected. When the maximum comparison result is greater than the first threshold, calculate the average value of the data to be processed and at least two adjacent reflectivity data continuously, and replace the data to be processed with the obtained average value.
[0018] As a preferred technical solution of the present invention, Step S2 includes:
[0019] Step S21: Calculate the average value of M second spectral images to obtain the spectral image to be detected. Also, place the spectral image to be detected and the standard spectral image in the same coordinate system for comparison to obtain the comparison result, where the standard spectral image is the spectral image corresponding to a detection sample that meets the detection standard;
[0020] Step S22: When the maximum difference between the corresponding reflectivities of the spectral image to be detected and the standard spectral image in the same band in the comparison result is less than or equal to the second threshold, the detection sample is qualified; otherwise, the detection sample is unqualified.
[0021] As a preferred technical solution of the present invention, Step S3 includes:
[0022] Step S31: When the detection sample is unqualified, obtain the target band where the difference between the reflectivities of the standard spectral image and the spectral image to be detected corresponding to the light of the same wavelength is greater than the second threshold through the comparison result;
[0023] Step S32: Obtain the spectral features of the target detection object corresponding to the detection sample, and based on the spectral features, obtain the first target sub-band corresponding to only the target detection object in the target band, and use the target detection object as the first object. Then, input the first sub-image corresponding to the first target sub-band in the spectral image to be detected and the first object into the first model to obtain the concentration of the first object.
[0024] As a preferred technical solution of the present invention, the step S4 includes:
[0025] Step S41: Use the remaining band of the target band after removing the first target sub-band corresponding to the first object as the second target sub-band. According to the spectral features of each target detection object, obtain the second object that only overlaps with the main reflection band of the first object in the target detection object corresponding to the second target sub-band, and obtain the third sub-image corresponding to the third target sub-band in the second target sub-band where the main reflection bands of the first object and the second object overlap.
[0026] Step S42: Input the third target sub-band, the first object, the concentration information of the first object, the second object, and the third sub-image into the second model to obtain the concentration information of the second object.
[0027] Step S43: Repeat the methods of step S41 and step S42 to obtain the concentration information of each target detection object corresponding to the target band.
[0028] As a preferred technical solution of the present invention, the second model is a machine learning model trained with spectral images, the target detection objects, and the concentration information of the target detection objects obtained by mixing different numbers of target detection objects according to different concentration ratios as training data.
[0029] As a preferred technical solution of the present invention, the first spectral image and the second spectral image are images with reflectance as the y-axis and wavelength as the x-axis.
[0030] Compared with the prior art, the beneficial effects of the present invention are at least as follows:
[0031] In the present invention, M pixels are randomly selected from different positions in multiple first spectral images as target pixels. Since the reflectance data of different wavelengths are superimposed in each target pixel to form a complete spectral curve, in order to filter out the noise in the spectral curve, a spectral data sequence is first obtained. A sliding window of a preset size slides from the starting position of the spectral data sequence. By selecting N minimum reflectance values in the sliding window and taking the mean of the N minimum reflectance data values as the reflectance data corresponding to the wavelength at the middle position of the sliding window, when the head of the spectral data sequence is less than half of the position of the sliding window and the number of remaining data to be processed is less than the length of the sliding window, the data to be processed is compared with at least two adjacent consecutive reflectance data, and the maximum comparison result is obtained and used to correct the data to be processed, so as to realize the correction of each spectral data. The spectral image to be detected and the standard spectral image are also placed in the same coordinate system for comparison, and the comparison result is obtained to determine whether the detection sample is qualified. When it is unqualified, the target band where the reflectance difference between the spectral image to be detected and the standard spectral image corresponding to the same wavelength of light is greater than the second threshold is obtained, the first object and the concentration information of the first object are obtained, and the concentration information of the second object is also obtained based on the second object, the corresponding second target sub-band, the first object, the concentration information of the first object and the second model. Similarly, the concentration information of each target detection object in the target band is obtained. Through the mutual cooperation of the above technical solutions, not only the quality detection result of the detection sample can be obtained, but also the concentration information of each unqualified target detection object can be accurately obtained, which is convenient for adjusting the production information according to the concentration information of the unqualified target detection object. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 FIG. is a flowchart of a quality detection method for mitochondrial nutrient milk powder based on image processing according to the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0033] In order to make the objectives, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0034] The present invention provides a quality detection method for mitochondrial nutrient goat milk powder based on image processing. The components of the mitochondrial nutrient goat milk powder include: whole-fat goat milk powder, inulin, epigallocatechin gallate, olive fruit powder, powdered plant sterol ester, fish oil, L-carnitine tartrate, bamboo leaf flavonoids, Bifidobacterium animalis subsp. lactis - Bb-12, Dendrobium officinale powder, and milk mineral salts; wherein, the olive fruit powder contains hydroxytyrosol. Specifically, the mitochondrial nutrients in the formula of the above-mentioned mitochondrial nutrient goat milk powder include epigallocatechin gallate, olive fruit powder, powdered plant sterol ester, fish oil, and L-carnitine tartrate. The above-mentioned mitochondrial nutrients can protect the mitochondrial structure and function or promote the exertion of mitochondrial function, and assist in improving blood sugar and blood lipids. As Figure 1 shown, for detecting the quality of the mitochondrial nutrient goat milk powder, the method includes the following steps:
[0035] Step S1: Obtain a test sample, obtain multiple first spectral images of the test sample through an imaging unit, randomly select M pixels at different positions from the multiple first spectral images, and preprocess the initial spectral images among the M pixels to obtain M second spectral images;
[0036] Specifically, by placing the above-mentioned detection sample into the above-mentioned detection container and stirring it in different directions at the above-mentioned preset time intervals, the uniformity of the above-mentioned detection sample is ensured. And during the interval time between two stirrings, the above-mentioned first spectral image is collected by the above-mentioned imaging unit. The above-mentioned imaging unit is a hyperspectral camera, and the above-mentioned first spectral image is a hyperspectral image. Each pixel in the above-mentioned first spectral image corresponds to a spectral diagram formed by the reflection of different wavelengths of light by each component in the above-mentioned detection sample, that is, the above-mentioned target spectral diagram. The above-mentioned different wavelengths of light are near-infrared light. And M pixels are randomly selected from different positions in multiple above-mentioned first spectral images as target pixels, so that the above-mentioned initial spectral diagram corresponding to the above-mentioned target pixels is closest to the true spectral image of the above-mentioned detection sample. Since the reflectivity data of different wavelengths of light are superimposed in each above-mentioned target pixel and form a complete spectral curve, in order to filter out the noise in the above-mentioned spectral curve and obtain a more accurate spectral curve within the above-mentioned target pixel, first, the reflectivity data of different wavelengths of light in the above-mentioned target pixel are sorted according to the wavelength. Among them, the above-mentioned reflectivity data of different wavelengths are selected at a preset wavelength interval, and the above-mentioned different wavelengths of light are light waves related to the detection object of the above-mentioned detection sample. The obtained above-mentioned reflectivity data are also used to form the above-mentioned spectral data sequence. A sliding window of a preset size slides from the starting position of the above-mentioned spectral data sequence. Since the reflectivity of the same substance to different wavelengths of light is different, but for light waves with relatively close wavelengths, the reflectivities are also relatively close. Therefore, the reflectivities of the above-mentioned light waves within the above-mentioned sliding window are also relatively close. By selecting the minimum values of N reflectivity data in the above-mentioned sliding window and taking the mean of the above-mentioned N minimum values of reflectivity data as the reflectivity data corresponding to the wavelength at the middle position of the above-mentioned sliding window, and the moving step of the above-mentioned sliding window is 1 above-mentioned reflectivity data, denoising of other reflectivity data except the reflectivity data at the head and tail parts in the above-mentioned spectral data sequence is achieved. When the position at the head of the above-mentioned spectral data sequence is less than 1 / 2 of the above-mentioned sliding window and the number of remaining data to be processed is less than the length of the above-mentioned sliding window, when the above-mentioned sliding window is 5, that is, the first and second reflectivity data and the penultimate first, second, third, and fourth reflectivity data in the above-mentioned spectral data sequence cannot be corrected by the above-mentioned sliding window. Therefore, the above-mentioned uncorrected reflectivity data are used as the above-mentioned data to be processed, and the above-mentioned data to be processed are compared with at least two adjacent consecutive above-mentioned reflectivity data, and the maximum comparison result is obtained and used to correct the above-mentioned data to be processed. Through the above technical solution, the above-mentioned initial spectral image can be accurately corrected, laying a foundation for obtaining an accurate spectral image to be detected within the above-mentioned target pixel.
[0037] Step S2: Obtain the spectral image to be detected based on the M second spectral images, compare the spectral image to be detected with the standard spectral image to obtain a comparison result, and determine whether the test sample is qualified according to the comparison result;
[0038] Specifically, by calculating the mean value of the M above-mentioned second spectral images, the above-mentioned spectral image to be detected is obtained. The above-mentioned spectral image to be detected and the above-mentioned standard spectral image are also placed in the same coordinate system for comparison, and a comparison result is obtained. Among them, the above-mentioned standard spectral image is the spectral image corresponding to the above-mentioned mitochondrial nutrient goat milk powder standard product, that is, the spectral image of the test sample that meets the detection standard. And the maximum difference between the spectral image to be detected corresponding to the main band of the detection object, that is, the detected component, and the standard spectral image is obtained through the above-mentioned comparison result. When the above-mentioned maximum difference is less than the second threshold, it is considered that the difference between the two is small, and the corresponding test sample is qualified. On the contrary, when the above-mentioned maximum difference is greater than the second threshold, that is, the reflectance corresponding to the light of at least one wavelength is greater than the second threshold, that is, the concentration difference between the corresponding at least one detected object and the standard concentration is large. Therefore, it is considered that the above-mentioned test sample is unqualified. Through the above technical solution, it is possible to accurately determine whether the above-mentioned test sample is qualified, laying a foundation for further determining the concentration of the unqualified detected object, that is, the component.
[0039] Step S3: When the test sample is unqualified, obtain the target band where the reflectance difference between the spectral image to be detected and the standard spectral image is greater than the second threshold based on the comparison result, obtain the first object according to the spectral characteristics of the target detected object of the test sample and the target band, and obtain the concentration information of the first object according to the first object and the first model;
[0040] Specifically, when the above detection sample is unqualified, based on the above comparison result, obtain the target band where the reflectivity difference of the light corresponding to the same wavelength in the above to-be-detected spectral image and the above standard spectral image is greater than the second threshold. That is, the wavelength of the light corresponding to the wavelength in the above target band may be the wavelength of the main reflected light corresponding to the target detection object that does not meet the standard. Also, through the spectral characteristics of the above target detection object corresponding to the above detection sample, that is, the main reflected wave wavelength corresponding to the target detection component, that is, the wavelength of the light wave with a relatively large reflectivity corresponding to the above target detection component. Since there is more than one main reflected wave corresponding to the same above target detection object, and the main reflected waves between different above target detection objects may overlap. Therefore, first, through the spectral characteristics of each above target detection object, the spectral characteristics are the wavelength information of the main reflected wave corresponding to the above target detection object, and obtain the light wave corresponding to only one above target detection object in the above target band. That is, only the spectral characteristics of one target detection object include the above first sub-target band in the above target band, and regard the above target detection object as the first object. Also, input the first sub-image corresponding to the above first sub-target band in the above to-be-detected spectral image into the above first model to obtain the concentration information of the above first object. Wherein, the above first model is a machine learning model trained with learning data of the above first object and corresponding different spectral images. Through the above technical solution, the concentration information of the above first object can be accurately obtained, and it lays a foundation for further obtaining the concentration information of other unqualified target detection objects.
[0041] Step S4: Obtain the concentration information of each target detection object corresponding to the target band according to the spectral characteristics of each target detection object in the target band, the first object, the concentration information of the first object, and the second model.
[0042] Specifically, by removing the first target sub-band in the above-mentioned target band to obtain the remaining second target sub-band, since the concentration information of the first object is known, therefore, the second object that only overlaps with the main reflection band of the first object in the above-mentioned target detection object corresponding to the above-mentioned second target sub-band is obtained through the spectral characteristics of each of the above-mentioned target detection objects, and the third sub-image in the above-mentioned to-be-detected spectral image corresponding to the overlapping main reflection band of the above-mentioned second object and the above-mentioned first object is also obtained. Since the above-mentioned first object and the concentration of the above-mentioned first object are known, therefore, the above-mentioned third target sub-band, the above-mentioned second object, the above-mentioned third sub-image, and the above-mentioned first object and the concentration of the first object are input into the above-mentioned second model to obtain the concentration information of the above-mentioned second object. Wherein, the above-mentioned second model is a machine learning model trained with the spectral images obtained by mixing different target detection objects in different concentration ratios and the concentrations of the above-mentioned target detection objects as training data. Therefore, by inputting the above-mentioned parameters into the above-mentioned second model, the concentration information of the above-mentioned second object can be obtained. Similarly, the concentration information of other target detection objects corresponding to the above-mentioned target band can also be obtained. Through the above technical solution, the concentration information of each of the above-mentioned target detection objects corresponding to the above-mentioned target band can be accurately obtained.
[0043] Further, step S1 includes the following steps:
[0044] Step S11: Obtain the mitochondrial goat milk powder sample to be detected as the detection sample, and place the detection sample into the detection container, wherein a stirring device is provided in the detection container;
[0045] Step S12: Stir in different directions through the stirring device at the preset time interval, and during the time gap when the stirring stops, obtain multiple first spectral images of the detection sample through the imaging unit;
[0046] Step S13: Randomly select M pixels at different positions from the multiple first spectral images as target pixels, obtain the initial spectral map corresponding to each target pixel, preprocess the initial spectral map, and obtain M second spectral images.
[0047] Specifically, by placing the above detection sample into the above detection container and stirring it in different directions at the above preset time intervals, the uniformity of the above detection sample is ensured, and the above first spectral image is collected by the above imaging unit during the interval time between two stirrings. The above imaging unit is a hyperspectral camera, the above first spectral image is a hyperspectral image, and each pixel in the above first spectral image corresponds to a spectral map formed by the reflection of different wavelengths of light by each component in the above detection sample. The above different wavelengths of light are near-infrared light, and multiple pixels are randomly selected from different positions in multiple above first spectral images as the above target pixels, so that the initial spectral map corresponding to the above target pixels can be closest to the true spectral image of the above detection sample. Further, preprocessing is performed on the initial spectral map corresponding to the above target pixels with respect to the above detection sample to obtain the above second spectral map. Among them, the above preprocessing is denoising processing. Through the above technical solution, not only can the initial spectral image corresponding to the most representative above target pixels be obtained, but also a more accurate above second spectral image can be obtained by preprocessing the above initial spectral image, laying a foundation for further obtaining the component content of the above detection sample through the above second spectral image.
[0048] Further, in step S1, the preprocessing of the spectral image includes:
[0049] Step S130: Obtain the reflectivity data of different wavelengths of light within each of the above target pixels, and sort the reflectivity data of the different wavelengths of light from short to long according to the wavelength to obtain a spectral data sequence;
[0050] Step S131: Slide a sliding window of a preset size from the starting position of the spectral data sequence, select N minimum reflectivity data within the sliding window, and obtain the average value of the N minimum reflectivity data. Replace the reflectivity data of the wavelength at the center position of the sliding window with the average value;
[0051] Step 132: Slide the sliding window with a sliding step of 1, and repeat the method of step S131 to correct the reflectivity data corresponding to the center position of the sliding window. Repeat this step until the number of the remaining reflectivity data is less than the size of the sliding window.
[0052] Specifically, since the reflectivity data of lights with different wavelengths are superimposed in each of the above-mentioned target pixels to form a complete spectral curve, in order to filter out the noise in the above spectral curve and obtain a more accurate spectral curve within the above target pixel, first, the reflectivity data of lights with different wavelengths within the above target pixel are sorted according to the wavelength. Among them, the reflectivity data of the above different wavelengths are selected at a preset wavelength interval, and the above lights with different wavelengths are light waves related to the detection object of the above detection sample. The obtained reflectivity data are also formed into the above spectral data sequence, and a sliding window with a preset size slides from the starting position of the above spectral data sequence. Among them, the preset size of the above sliding window is 5. Since the reflectivity of the same substance to lights with different wavelengths is different, but for light waves with relatively close wavelengths, the reflectivities are also relatively close. Therefore, the reflectivities of the light waves within the above sliding window are also relatively close. By selecting the minimum values of N reflectivity data in the above sliding window, where the value of N is less than or equal to the size of the above sliding window, and taking the average value of the above N minimum reflectivity data as the reflectivity data corresponding to the wavelength at the middle position of the above sliding window, the moving step of the above sliding window is 1 of the above reflectivity data, and by repeating the above step S131, denoising of other reflectivity data except the reflectivity data at the head and tail parts in the above spectral data sequence is achieved. Through the above technical solution, when a noise spike appears at the center position of the above sliding window, effective denoising can be performed, so as to obtain a more accurate above spectral curve in the above target pixel.
[0053] Further, in step S1, the preprocessing of the spectral image further includes:
[0054] When the number of the remaining reflectivity data at the head of the spectral data sequence is less than half of the sliding window and the number of the remaining reflectivity data at the tail of the spectral data sequence is less than the size of the sliding window, the reflectivity data are used as the data to be processed. Each of the data to be processed is compared with at least two of its continuously adjacent reflectivity data to obtain the maximum comparison result. When the maximum comparison result is less than or equal to the first threshold, the data to be processed does not need to be corrected. When the maximum comparison result is greater than the first threshold, the data to be processed is averaged with at least two of its continuously adjacent reflectivity data, and the obtained average value replaces the data to be processed.
[0055] Specifically, at a position where the head of the above spectral data sequence is less than half of the above sliding window, when the above sliding window is 5, that is, the first and second reflectivity data and the last first, second, third, and fourth reflectivity data of the above spectral data sequence cannot be corrected by the above sliding window. Therefore, the above uncorrected reflectivity data is used as the above data to be processed, and the above data to be processed is compared with at least two adjacent consecutive above reflectivity data. For example: the first data to be processed needs to be compared with the second and third above reflectivity data, the second data to be processed needs to be compared with the first corrected above data to be processed and the third above reflectivity data, and the first comparison result and the second comparison result are obtained. The larger of the above first comparison result and the above second comparison result is used as the above maximum comparison result. When the above maximum comparison result is less than or equal to the above first threshold, it indicates that the difference among the three is not significant, and it can be determined that the reflectivity data at this position has not introduced noise. Therefore, the above data to be processed at this position does not need to be processed. On the contrary, when the above maximum comparison result is greater than the above first threshold, noise may be introduced at this position. Therefore, the average value of the above data to be processed and at least two adjacent consecutive above reflectivity data is calculated and the average result replaces the above data to be processed. Through the above technical solution, the above un-denoised data to be processed can be accurately corrected, laying a foundation for obtaining the above spectral curve within the above target pixel.
[0056] Further, the step S2 includes:
[0057] Step S21: Calculate the average value of the M second spectral images to obtain the spectral image to be detected, and also place the spectral image to be detected and the standard spectral image in the same coordinate system for comparison to obtain the comparison result, where the standard spectral image is the spectral image corresponding to the detection sample that meets the detection standard;
[0058] Step S22: When the maximum difference between the corresponding reflectivities of the spectral image to be detected and the standard spectral image in the same wavelength band in the comparison result is less than or equal to the second threshold, the detection sample is qualified; otherwise, the detection sample is unqualified.
[0059] Specifically, by calculating the mean value of M of the above-mentioned second spectral images, the above-mentioned spectral image to be detected is obtained. The above-mentioned spectral image to be detected and the above-mentioned standard spectral image are also placed in the same coordinate system for comparison, and a comparison result is obtained. Among them, the above-mentioned standard spectral image is the spectral image corresponding to the above-mentioned mitochondrial nutrient goat milk powder standard product, that is, the spectral image of the test sample that meets the detection standard. And the maximum difference between the spectral image to be detected corresponding to the main waveband of the detection object, that is, the detection component, and the standard spectral image is obtained through the above-mentioned comparison result. When the above-mentioned maximum difference is less than the above-mentioned second threshold, it is considered that the difference between the two is small, and the corresponding test sample is qualified. On the contrary, when the above-mentioned maximum difference is greater than the above-mentioned second threshold, that is, the reflectance corresponding to the light of at least one wavelength is greater than the above-mentioned second threshold, that is, the concentration difference between the corresponding at least one detection object and the standard concentration is large. Therefore, it is considered that the above-mentioned test sample is unqualified. Through the above technical solution, it is possible to accurately judge whether the above-mentioned test sample is qualified, laying a foundation for further judging the concentration of the unqualified detection object, that is, the component.
[0060] Further, step S3 includes:
[0061] Step S31: When the test sample is unqualified, through the comparison result, obtain the target waveband where the reflectance difference of the light corresponding to the same wavelength in the standard spectral image and the spectral image to be detected is greater than the second threshold;
[0062] Step S32: Obtain the spectral characteristics of the target detection object corresponding to the test sample, and based on the spectral characteristics, obtain the first target sub-band corresponding to the only target detection object in the target waveband. And use the target detection object as the first object, and input the first sub-image corresponding to the first target sub-band in the spectral image to be detected and the first object into the first model to obtain the concentration of the first object.
[0063] Specifically, when the above detection sample is unqualified, based on the above comparison result, obtain the target band where the reflectivity difference of the light corresponding to the same wavelength in the above to-be-detected spectral image and the above standard spectral image is greater than the second threshold. That is, the wavelength of the light corresponding to the wavelength in the above target band may be the wavelength of the main reflected light corresponding to the unqualified target to be detected. Also, through the spectral characteristics of the above target to be detected corresponding to the above detection sample, that is, the main reflected wave wavelength corresponding to the target detection component, that is, the wavelength of the light wave corresponding to the larger reflectivity of the above target detection component. Since there is more than one main reflected wave corresponding to the same above target to be detected, and the main reflected waves between different above target to be detected may overlap. Therefore, first, through the spectral characteristics of each above target to be detected, the spectral characteristics are the wavelength information of the main reflected wave corresponding to the above target to be detected, and obtain the light wave corresponding to only one above target to be detected in the above target band. That is, only the spectral characteristics of one target to be detected include the above first sub-target band in the above target band, and regard the above target to be detected as the first object. Also, input the first sub-image corresponding to the above first sub-target band in the above to-be-detected spectral image into the above first model to obtain the concentration information of the above first object. Wherein, the above first model is a machine learning model trained with learning data of the above first object and corresponding different spectral images. Through the above technical solution, the concentration information of the above first object can be accurately obtained, and it lays a foundation for further obtaining the concentration information of other unqualified target detection objects.
[0064] Further, the step S4 includes:
[0065] Step S41: Use the remaining band of the target band after removing the first target sub-band corresponding to the first object as the second target sub-band. According to the spectral characteristics of each target detection object, obtain the second object that only overlaps with the main reflected band of the first object in the target detection object corresponding to the second target sub-band, and obtain the third sub-image corresponding to the third target sub-band where the main reflected bands of the first object and the second object overlap in the second target sub-band in the to-be-detected spectral image;
[0066] Step S42: Input the third target sub-band, the first object and the concentration information of the first object, the second object and the third sub-image into the second model to obtain the concentration information of the second object;
[0067] Step S43: Repeat the methods of step S41 and step S42 to obtain the concentration information of each target detection object corresponding to the target band.
[0068] Specifically, by removing the first target sub-band in the above-mentioned target band to obtain the remaining second target sub-band, since the concentration information of the first object is known, therefore, the second object that only overlaps with the main reflection band of the first object in the above-mentioned target detection object corresponding to the above-mentioned second target sub-band is obtained through the spectral characteristics of each of the above-mentioned target detection objects, and the third sub-image in the to-be-detected spectral image corresponding to the overlapping main reflection band of the second object and the first object is also obtained. Since the first object and the concentration of the first object are known, therefore, the third target sub-band, the second object, the third sub-image, the first object, and the concentration of the first object are input into the second model to obtain the concentration information of the second object, where the second model is a machine learning model trained with the spectral images obtained by mixing different target detection objects according to different concentration ratios and the concentrations of the target detection objects as training data. Therefore, by inputting the above parameters into the second model, the concentration information of the second object can be obtained. Similarly, the concentration information of the fourth object that only overlaps with the main reflection band of the second object or the first object and the second object in the fourth target sub-band remaining after removing the third target sub-band from the second target sub-band can be obtained by repeating the above steps S41 and S42, and until the concentration information of all the above-mentioned target detection objects corresponding to the target band is obtained. Through the above technical solution, the concentration information of each of the above-mentioned target detection objects corresponding to the target band can be accurately obtained.
[0069] Further, the second model is a machine learning model trained with the spectral images obtained by mixing different numbers of the above-mentioned target detection objects according to different concentration ratios, the above-mentioned target detection objects, and the concentration information of the above-mentioned target detection objects as training data.
[0070] Specifically, by mixing different target detection objects according to different concentration ratios and obtaining the corresponding spectral images, the above-mentioned spectral images and the concentration information of each of the above-mentioned target detection objects are used as the above-mentioned training data, and the second model is obtained by training the above-mentioned machine learning model with the above-mentioned training data. By inputting the spectral image to be analyzed and the above-mentioned target detection object corresponding to the spectral image into the second model, the concentration information of the above-mentioned target detection object can be accurately obtained. In order to further improve the output accuracy of the second model, the concentration of the above-mentioned target detection object with known concentration in the spectral image to be analyzed can also be input. Through the above technical solution, the concentration information of the above-mentioned target detection objects with overlapping main reflection bands in the above-mentioned target band can be accurately obtained.
[0071] Further, the first spectral image and the second spectral image are images with the reflectance as the y-axis and the wavelength as the x-axis.
[0072] In summary, the present invention randomly selects M pixels from different positions in multiple first spectral images as target pixels. Since the reflectance data of different wavelengths are superimposed in each target pixel to form a complete spectral curve, in order to filter out the noise in the spectral curve, a spectral data sequence is first obtained, and a sliding window of a preset size slides from the starting position of the spectral data sequence. By selecting the minimum values of N reflectance data in the sliding window and taking the mean of the N minimum reflectance data as the reflectance data corresponding to the wavelength at the middle position of the sliding window, when the position less than half of the sliding window at the head of the spectral data sequence and the number of remaining data to be processed is less than the length of the sliding window, the data to be processed is compared with at least two adjacent consecutive reflectance data, and the maximum comparison result is obtained and used to correct the data to be processed, so as to realize the correction of each spectral data. The spectral image to be detected and the standard spectral image are also obtained and placed in the same coordinate system for comparison, and the comparison result is obtained to judge whether the detection sample is qualified. When it is unqualified, the target band where the reflectance difference between the spectral image to be detected and the standard spectral image corresponding to the same wavelength of light is greater than the second threshold is obtained, the first object and the concentration information of the first object are obtained, and the concentration information of the second object is also obtained based on the second object, the corresponding second target sub-band, the first object, the concentration information of the first object and the second model. Similarly, the concentration information of each target detection object in the target band is obtained. Through the mutual cooperation of the above technical solutions, not only the quality detection result of the detection sample can be obtained, but also the concentration information of each unqualified target detection object can be accurately obtained, which is convenient for adjusting the production information according to the concentration information of the unqualified target detection object.
[0073] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0074] The above embodiments only represent several implementation manners of the present invention, and the description is relatively specific and detailed, but it cannot be understood as a limitation to the scope of the patent of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present invention, several deformations and improvements can be made, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention should be subject to the appended claims.
[0075] The above is only the preferred embodiment of the present invention and is not intended to limit the present invention. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A quality detection method for mitochondrial nutrient goat milk powder based on image processing, characterized in that, For detecting the quality of the mitochondrial nutrient goat milk powder, the method includes the following steps: Step S1: Obtain a test sample, obtain multiple first spectral images of the test sample through an imaging unit, randomly select M pixels at different positions from the multiple first spectral images, and preprocess the initial spectral images among the M pixels to obtain M second spectral images; Step S2: Obtain a spectral image to be detected based on the M second spectral images, compare the spectral image to be detected with a standard spectral image, and judge whether the test sample is qualified according to the comparison result; Step S3: When the test sample is unqualified, obtain a target band where the reflectance difference between the spectral image to be detected and the standard spectral image is greater than a second threshold based on the comparison result, obtain a first object according to the spectral characteristics of the target detection object corresponding to the test sample and the target band, and obtain the concentration information of the first object according to the first object and a first model; Step S4: Obtain the concentration information of each target detection object corresponding to the target band according to the spectral characteristics of each target detection object in the target band, the first object, the concentration information of the first object, and a second model; The said Step S3 includes: Step S31: When the test sample is unqualified, obtain a target band where the reflectance difference of the light corresponding to the same wavelength in the standard spectral image and the spectral image to be detected is greater than the second threshold through the comparison result; Step S32: Obtain the spectral characteristics of the target detection object corresponding to the test sample, and based on the spectral characteristics, obtain a first target sub-band corresponding to the only target detection object in the target band, and use the target detection object as the first object, and input the first sub-image and the first object corresponding to the first target sub-band in the spectral image to be detected into the first model to obtain the concentration of the first object; Step S4 includes: Step S41: Use the remaining band after removing the first target sub-band corresponding to the first object from the target band as the second target sub-band, obtain a second object that only overlaps with the main reflection band of the first object in the target detection object corresponding to the second target sub-band according to the spectral characteristics of each target detection object, and obtain the third sub-image corresponding to the spectral image to be detected in the third target sub-band where the main reflection bands of the first object and the second object overlap in the second target sub-band; Step S42: Input the third target sub-band, the first object and the concentration information of the first object, the second object, and the third sub-image into the second model to obtain the concentration information of the second object; Step S43: Repeat the methods of Step S41 and Step S42 to obtain the concentration information of each target detection object corresponding to the target band.
2. The method according to claim 1, wherein The said Step S1 includes the following steps: Step S11: Obtain a mitochondrial goat milk powder sample to be detected as the test sample, and place the test sample in a detection container, wherein a stirring device is arranged in the detection container; Step S12: Stir in different directions through the stirring device at a preset time interval, and during the time gap when the stirring stops, obtain multiple said first spectral images of the test sample through the imaging unit; Step S13: Randomly select M pixels from the multiple first spectral images at different positions as target pixels, obtain the initial spectral map corresponding to each target pixel, preprocess the initial spectral map, and obtain M second spectral images.
3. The method according to claim 1, wherein In step S1, the preprocessing of the initial spectral image includes: Step S130: Obtain the reflectance data of light with different wavelengths in each initial spectral map, sort the reflectance data of the light with different wavelengths from short to long according to the wavelength, and obtain a spectral data sequence; Step S131: Slide a sliding window with a preset size from the starting position of the spectral data sequence, select N minimum reflectance data within the sliding window, obtain the average value of the N minimum reflectance data, and replace the reflectance data corresponding to the center position of the sliding window with the average value; Step 132: Slide the sliding window with a sliding step of 1, and repeat the method in step S131 to correct the reflectance data corresponding to the center position of the sliding window. Repeat this step until the number of the remaining reflectance data is less than the size of the sliding window.
4. The method according to claim 3, wherein In step S1, the preprocessing of the initial spectral image further includes: When the position of the head of the spectral data sequence is less than 1 / 2 of the sliding window and the number of the remaining reflectance data at the tail of the spectral data sequence is less than the size of the sliding window, regard the reflectance data as the data to be processed. Compare each data to be processed with at least two consecutive adjacent reflectance data thereof to obtain the maximum comparison result. When the maximum comparison result is less than or equal to the first threshold, the data to be processed does not need to be corrected. When the maximum comparison result is greater than the first threshold, calculate the average value of the data to be processed and at least two consecutive adjacent reflectance data thereof, and replace the data to be processed with the obtained average value.
5. The method according to claim 1, wherein Step S2 includes: Step S21: Calculate the average value of the M second spectral images to obtain the spectral image to be detected. Also, place the spectral image to be detected and the standard spectral image in the same coordinate system for comparison to obtain the comparison result, where the standard spectral image is the spectral image corresponding to the detection sample that meets the detection standard; Step S22: When the maximum difference between the corresponding reflectances of the spectral image to be detected and the standard spectral image in the same band in the comparison result is less than or equal to the second threshold, the detection sample is qualified; otherwise, the detection sample is unqualified.
6. The method according to claim 1, characterized in that, The second model is a machine learning model trained with the spectral images obtained by mixing different numbers of the target detection objects according to different concentration ratios, the target detection objects, and the concentration information of the target detection objects as training data.
7. The method according to claim 1, wherein The first spectral image and the second spectral image are images with the reflectance as the y-axis and the wavelength as the x-axis.
Citation Information
Patent Citations
A quality inspection system for traditional Chinese medicine based on image recognition
CN118674954B
System and method for detection of gas in the atmosphere from a multispectral image
US20240265673A1
Bamboo shoot quality detection method and system based on hyperspectral image and medium
CN119147480A
Dairy product quality detection method based on image processing
CN119250643A