Visual inspection method and system for goat milk powder quality
Through the gradient correction and gradient curve clustering of goat milk powder images, the abnormal score of the pixel point is calculated to solve the problem of inaccurate quality testing of goat milk powder in existing technologies, and achieve efficient and accurate quality test results.
Patent Information
- Application Number
- CN202411908668.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-01-24
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, the goat milk powder quality detection method based on a convolutional neural network is difficult to accurately obtain quality detection results, and the data acquisition cost is high and the training is difficult.
By subtract the gradient value of the gradient values of each pixel point in the milk powder image, the number of gradient values is obtained; the gradient curve of each pixel point is constructed, and the category operation is performed to determine the standard curve; then compare the standard curve and a pixel point point The gradient curve, calculate the abnormal score of the abnormality of the pixel point in each scale or in the region, and finally mark the abnormal score than the pixels greater than the threshold as an abnormal point.
The accurate testing of the quality of goat milk powder can be achieved, and the quality test results of sheep milk powder can be accurately obtained according to milk powder images, reducing the difficulty of data collection and training.
Smart Images

Figure CN119359708A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method and system for visually inspecting the quality of goat milk powder. Background Art
[0002] Goat milk powder refers to milk powder made from goat milk. It is rich in nutrients such as protein, calcium, vitamins, etc. It has the effects of improving sleep quality, relieving fatigue, and aiding digestion. In the production process of goat milk powder, there are many processes including milk purification, sterilization, concentration, and drying. In order to ensure that there are no impurities in the produced goat milk powder and to ensure product quality, the goat milk powder needs to be quality tested before packaging.
[0003] At present, the patent application document with application publication number CN117522838A discloses a milk powder quality detection method and system based on convolutional neural network, wherein the method includes: preprocessing the milk powder image to be detected by image processing technology; constructing a convolutional neural network model, and training the convolutional neural network model using a training set; passing the preprocessed milk powder image to be detected into the trained convolutional neural network model for detection; and obtaining the milk powder quality assessment result according to the analysis result of the convolutional neural network model. During the training process, the gap between the network output and the data set is first obtained through the forward propagation loss function, and then the parameters of the model are continuously updated through the back-propagation algorithm, so that the model can better fit the training set data.
[0004] The above method uses a convolutional neural network model to extract image features of the milk powder to be tested to obtain the milk powder quality assessment results. However, the convolutional neural network model needs to collect a large amount of image data, the data collection cost is high, and the training of the convolutional neural network model is difficult, and it is impossible to accurately obtain the quality inspection results of goat milk powder. Summary of the invention
[0005] In order to solve the technical problem of being unable to accurately obtain the quality inspection results of goat milk powder, the present application provides a method and system for visual inspection of goat milk powder quality, which can accurately obtain the quality inspection results of goat milk powder based on milk powder images.
[0006] In a first aspect, the present application provides a method for visually detecting the quality of goat milk powder, the detection method comprising: subtracting the gradient value mode from the gradient value of each pixel in the milk powder image to obtain a corrected gradient; constructing a gradient curve for each pixel, clustering the gradient curve, and using the cluster center of the largest cluster as a standard curve, wherein the gradient curve includes the distribution characteristic differences of the corrected gradient at multiple scales, and the pixel points In the gradient curve Differences in distribution characteristics of different scales for: , is the maximum value of the distribution characteristic, Pixel No. Distribution characteristics within the neighborhood of each scale The frequency, Pixel No. Distribution characteristics within the neighborhood of each scale The frequency, is a logarithmic function with e as the base; by comparing the standard curve and the gradient curve of any pixel point, the abnormal score of the pixel point in the XOR area of each pixel point is obtained. The XOR region of the scale is located at scale neighborhood range, and is not located in the The average of multiple abnormal scores of the pixel point is taken as the final score, and the pixel point with a final score greater than the abnormal threshold is marked as an abnormal point to obtain the detection result; the pixel point No. The abnormality score of the pixel point in the XOR region of the scale for: , Pixel The number of gradient curves in the cluster to which it belongs, The first The distribution characteristics of different scales.
[0007] The gradient value of each pixel in the milk powder image is subtracted from the gradient value mode to obtain a corrected gradient, which can remove the gradient information generated by the accumulation of milk powder particles; a gradient curve of each pixel is constructed, and the gradient curve includes the distribution characteristics of the corrected gradient at multiple scales. The gradient curve of a pixel can reflect the change law of the distribution characteristics of the corrected gradient of the pixel in the neighborhood range of multiple scales; a clustering operation is performed on the gradient curve, and the cluster center of the largest cluster is used as the standard curve. By comparing the standard curve and the gradient curve of the pixel, the abnormal score of the pixel in the XOR area of each scale is obtained. The abnormal score is negatively correlated with the number of gradient curves in the cluster to which the pixel belongs, and is positively correlated with the absolute value of the difference in distribution characteristics between the gradient curve and the standard curve. The abnormal score of each pixel in the XOR area of each scale is accurately quantified, and the average of multiple abnormal scores of the pixel is used as the final score. The pixel with a final score greater than the abnormal threshold is marked as an abnormal point, and an accurate quality detection result is obtained.
[0008] Preferably, the pixel The corrected gradient for: , Pixel The gradient value of is the mode of gradient values.
[0009] The milk powder image contains many milk powder particles. The accumulation of milk powder particles will produce gradient information in the milk powder image. The mode of the gradient values in the milk powder image can represent the gradient information generated by the accumulation of milk powder particles. The corrected gradient after removing the gradient information can accurately reflect the edge information of goat milk powder.
[0010] Preferably, before subtracting the gradient value mode from the gradient value of each pixel in the milk powder image, the detection method further comprises: performing a filtering operation on the milk powder image to obtain a preprocessed milk powder image, wherein the filtering operation is median filtering, Gaussian filtering or bilateral filtering.
[0011] Preferably, the distribution feature is the mean value of the corrected gradient within eight neighborhoods of the pixel point, or the extreme value of the gradient direction.
[0012] Preferably, the method for acquiring the multiple scales includes: selecting multiple sample pixel points, and acquiring the inflection point of the sample gradient curve corresponding to each sample pixel point; for any inflection point, calculating the variance of the portion of the curve after the inflection point in each sample gradient curve, and taking the mean of all variances as the stability index of the inflection point; calculating the selection score of each inflection point, and taking the inflection point with the largest selection score as the target inflection point, the selection score is negatively correlated with the preset size corresponding to the inflection point, and is positively correlated with the stability index; the target inflection point and the preset size before the target inflection point correspond to the multiple scales.
[0013] The larger the stability index of an inflection point, the more stable the sample gradient curve is after the inflection point, and the less the changing law of the modified gradient distribution characteristics contained in the part of the curve after the inflection point; the larger the preset size corresponding to an inflection point, the more preset sizes there are before the inflection point, and the longer the length of the sample gradient curve; selecting an inflection point with a smaller preset size and a larger stability index as the target inflection point can ensure that the gradient curve can accurately reflect the changing law of the modified gradient distribution characteristics and reduce the amount of calculation.
[0014] Preferably, the milk powder image is divided into a plurality of image blocks of equal size, and the center point of each image block is used as a sample pixel point.
[0015] It can ensure that multiple sample pixel points are distributed in various areas of the milk powder image, and ensure that the gradient curve of each pixel point in the milk powder image can reflect the changing law of the corrected gradient distribution characteristics.
[0016] Preferably, the selection is made into a ratio of a stability index and a preset size.
[0017] Preferably, the clustering operation on the gradient curves includes: taking the Euclidean distance between the gradient curves as the clustering distance, performing a clustering operation on the gradient curves using a Kmeans clustering algorithm to obtain a plurality of clusters, and taking the cluster with the largest number of gradient curves as the largest cluster.
[0018] The existence of quality defects in milk powder images is a low-probability event. The larger the number of gradient curves in the cluster, the more the gradient curves in the cluster are close to normal. The cluster center of the largest cluster is used as the standard curve, and the standard curve is the change law of the corrected gradient distribution characteristics of pixels in the neighborhood range of multiple scales under normal circumstances.
[0019] In a second aspect of the present application, a system for visual inspection of goat milk powder quality is provided, comprising a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the method for visual inspection of goat milk powder quality according to the first aspect of the present application is implemented.
[0020] The technical solution of this application has the following beneficial technical effects: The gradient value of each pixel in the milk powder image is subtracted from the gradient value mode to obtain a corrected gradient, which can remove the gradient information generated by the accumulation of milk powder particles; a gradient curve of each pixel is constructed, the gradient curve includes the distribution feature differences of the corrected gradient at multiple scales, and the gradient curve of a pixel can reflect the change law of the corrected gradient distribution feature of the pixel in the neighborhood range of multiple scales; a clustering operation is performed on the gradient curve, and the cluster center of the largest cluster is used as the standard curve. By comparing the standard curve and the gradient curve of the pixel, the abnormal score of the pixel in the XOR area of each scale is obtained, and the abnormal score is negatively correlated with the number of gradient curves in the cluster to which the pixel belongs, and is positively correlated with the absolute value of the difference in distribution features between the gradient curve and the standard curve. The abnormal score of each pixel in the XOR area of each scale is accurately quantified, and the average of multiple abnormal scores of the pixel is used as the final score. The pixel with a final score greater than the abnormal threshold is marked as an abnormal point, and the quality detection of goat milk powder is realized, so as to accurately obtain the quality detection result of goat milk powder based on the milk powder image. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] By reading the detailed description below with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of the present application will become easy to understand. In the accompanying drawings, several embodiments of the present application are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein: Figure 1 is a flow chart of a method for visually detecting goat milk powder quality according to an embodiment of the present application; Figure 2A schematic diagram of a milk powder image according to an embodiment of the present application; Figure 3 is a schematic diagram of a modified gradient map corresponding to the median filter according to an embodiment of the present application; Figure 4 is a schematic diagram of a modified gradient map corresponding to Gaussian filtering according to an embodiment of the present application; Figure 5 is a schematic diagram of a modified gradient map corresponding to bilateral filtering according to an embodiment of the present application; Figure 6 is a pixel point according to an embodiment of the present application Schematic diagram of the differences in the distribution characteristics of the corrected gradient at the third scale; Figure 7 is a pixel point according to an embodiment of the present application Schematic diagram of the gradient curve; Figure 8 It is a structural block diagram of a visual inspection system for goat milk powder quality according to an embodiment of the present application. DETAILED DESCRIPTION
[0022] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0023] It should be understood that when the terms "first", "second", etc. are used in the claims, specification and drawings of the present application, they are only used to distinguish different objects, rather than to describe a specific order. The terms "include" and "comprise" used in the specification and claims of the present application indicate the presence of the described features, wholes, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or their collections.
[0024] According to the first aspect of the present application, the present application provides a method for visually inspecting the quality of goat milk powder. Figure 1 Flow chart of the method for visually inspecting the quality of goat milk powder according to an embodiment of the present application. Figure 1 As shown, the method for visually inspecting the quality of goat milk powder includes steps S101 to S104, which are described in detail below.
[0025] S101, subtracting the gradient value mode from the gradient value of each pixel in the milk powder image to obtain a corrected gradient.
[0026] In one embodiment, after the production of goat milk powder is completed, a milk powder image of the goat milk powder is collected, and the milk powder image is a grayscale image. The milk powder image contains many milk powder particles, and the accumulation of milk powder particles will generate gradient information in the milk powder image. Therefore, the mode of the gradient value in the milk powder image can represent the gradient information generated by the accumulation of milk powder particles, and the corrected gradient after removing the gradient information can accurately reflect the edge information of the goat milk powder.
[0027] Specifically, the pixel The corrected gradient for: , Pixel The gradient value of is the mode of gradient values.
[0028] In one embodiment, in order to avoid the influence of noise on the corrected gradient, before subtracting the gradient value mode from the gradient value of each pixel in the milk powder image, the detection method also includes: performing a filtering operation on the milk powder image to obtain a preprocessed milk powder image, and the filtering operation is median filtering, Gaussian filtering or bilateral filtering.
[0029] Among them, median filtering and Gaussian filtering are both used to smooth the milk powder image to remove the noise data in the milk powder image; bilateral filtering smoothes the milk powder image while retaining the gradient information in the milk powder image to ensure the accuracy of the corrected gradient. Figure 2 , a schematic diagram of a milk powder image according to an embodiment of the present application; when the filtering operation adopts median filtering, the corrected gradient of each pixel in the milk powder image after median filtering is calculated, and the following is obtained: Figure 3 The corrected gradient map corresponding to the median filter is shown in ; similarly, the corrected gradient map corresponding to the Gaussian filter is shown in Figure 4 As shown, the corrected gradient map corresponding to the bilateral filtering is as follows Figure 5 As shown; by comparison, it can be seen that bilateral filtering can well preserve the gradient information in the milk powder image.
[0030] In this way, the gradient information generated by the accumulation of milk powder particles is removed, so that the corrected gradient can accurately reflect the edge information in the milk powder image, which may be caused by quality defects (agglomeration or color difference) or traces left during the mixing process of goat milk powder.
[0031] It should be noted that the produced goat milk powder will be placed in a container, and the container will be captured from a top-down perspective. The captured milk powder image is the image features of the goat milk powder located at the top of the container. To ensure accurate quality inspection results, it is necessary to use a stirring rod to stir the goat milk powder in the container to avoid inaccurate quality inspection due to the inability to collect the image features of the goat milk powder at the bottom of the container. Therefore, the milk powder image includes not only edge information caused by quality defects (caking or color difference), but also edge information left by the stirring rod during the stirring process of the goat milk powder.
[0032] S102, constructing a gradient curve for each pixel point, performing a clustering operation on the gradient curve, and taking the cluster center of the largest cluster as a standard curve, wherein the gradient curve includes distribution feature differences of the corrected gradient at multiple scales.
[0033] In one embodiment, the gradient curve of a pixel point can reflect the change law of the modified gradient distribution characteristics of the pixel point within the neighborhood range of multiple scales; In terms of the distribution characteristics of the modified gradient, the difference is used to reflect the The scale and The change in the gradient distribution characteristics within the neighborhood of a scale is corrected.
[0034] Specifically, the pixel No. Differences in distribution characteristics of corrected gradients at different scales for: , is the maximum value of the distribution characteristic, Pixel No. Distribution characteristics within the neighborhood of each scale The frequency, Pixel No. Distribution characteristics within the neighborhood of each scale The frequency, is the logarithmic function with base e. Indicates that Output of the base e logarithm function.
[0035] The distribution feature is the mean value of the corrected gradient within the eight neighborhoods of the pixel point, or the extreme value of the gradient direction. It can be understood that the extreme value of the gradient direction within the eight neighborhoods of the pixel point can reflect the direction of the edge within the eight neighborhoods.
[0036] Among them, the pixel No. The neighborhood range of each scale is pixel point Centered at The plurality of scales include a plurality of preset sizes, and the preset sizes are 3×3, 5×5, 7×7, 9×9, 11×11, 13×13, 15×15, 17×17 and 19×19.
[0037] Understandably, see Figure 6 , is a pixel point according to an embodiment of the present application Schematic diagram of the difference in distribution characteristics of the corrected gradient at the third scale; the neighborhood range of the third scale is a 7×7 rectangular area, and the pixel point Differences in distribution characteristics of corrected gradients at the third scale The larger the value, the greater the change in the distribution characteristics of the corrected gradient compared to the neighborhood range of the second scale. These changes are due to the pixels located in the neighborhood range of the third scale but not in the neighborhood range of the second scale (corresponding to Figure 6 Therefore, according to the pixel point Differences in distribution characteristics of corrected gradients at the third scale , which can reflect the normality or abnormality of the corrected gradient of each pixel point located in the third scale neighborhood range but not in the second scale neighborhood range, thereby realizing the quality detection of goat milk powder.
[0038] See also Figure 7 , is a pixel point according to an embodiment of the present application Schematic diagram of gradient curve; calculating pixel points By correcting the difference in the distribution characteristics of the gradient at each scale, the pixel points can be constructed The gradient curve of the gradient curve is a plurality of scales, and the ordinate is the distribution characteristic difference corresponding to each scale. The gradient curve of each pixel point in the milk powder image can be constructed by the same method.
[0039] In another embodiment, the number of preset sizes is 9, which means that each pixel point needs to calculate the distribution feature differences under 9 scales, and the length of the gradient curve is 9. The calculation amount of the subsequent clustering operation is large. In order to ensure that the gradient curve can accurately reflect the changing law of the modified gradient distribution characteristics, the calculation amount can be reduced. The method for obtaining the multiple scales includes: selecting multiple sample pixel points, obtaining the inflection point of the sample gradient curve corresponding to each sample pixel point; for any inflection point, calculating the variance of the part of the curve after the inflection point in each sample gradient curve, and taking the mean of all variances as the stability index of the inflection point; calculating the selection score of each inflection point, and taking the inflection point with the largest selection score as the target inflection point, the selection score is negatively correlated with the preset size corresponding to the inflection point, and positively correlated with the stability index, and the preset size before the target inflection point and the target inflection point corresponds to the multiple scales.
[0040] Among them, the larger the stability index of an inflection point, the more stable the sample gradient curve is after the inflection point, and the less the change law of the modified gradient distribution characteristics contained in the part of the curve after the inflection point; the larger the preset size corresponding to an inflection point, the more preset sizes there are before the inflection point, and the longer the sample gradient curve is; in order to reduce the length of the sample gradient curve and the amount of calculation while making the sample gradient curve contain the change law of distribution characteristics, an inflection point with a smaller preset size and a larger stability index is selected as the target inflection point. Specifically, the ratio of the stability index and the preset size is selected; the inflection point Selection score for: , Inflection point The stability index of Inflection point It can be understood that the preset size of the preset size 7×7 is 7.
[0041] The plurality of sample pixel points may be randomly selected, or the milk powder image may be first divided into a plurality of image blocks of equal size, and the center point of each image block may be used as the sample pixel point. In this way, it is ensured that the plurality of sample pixel points are distributed in various areas of the milk powder image, and it is ensured that the gradient curve of each pixel point in the milk powder image can reflect the changing law of the modified gradient distribution feature.
[0042] In one embodiment, after obtaining the gradient curve of each pixel point, the gradient curve is clustered, and the cluster center of the largest cluster is used as the standard curve. Specifically, the clustering operation on the gradient curve includes: using the Euclidean distance between the gradient curves as the cluster distance, using the Kmeans clustering algorithm to cluster the gradient curve to obtain multiple clusters, and using the cluster with the largest number of gradient curves as the largest cluster. Among them, the number of clusters is greater than or equal to 2, and is determined by the elbow method, which will not be repeated in this application.
[0043] The cluster center of the largest cluster is used as the standard curve, which is the changing law of the corrected gradient distribution characteristics of pixels in the neighborhood range of multiple scales under normal circumstances.
[0044] S103, comparing the standard curve with the gradient curve of any pixel point, and obtaining the abnormality score of the pixel point in the XOR region of each scale of the pixel point, wherein the first The XOR region of the scale is located at scale neighborhood range, and is not located in the The area of the scale neighborhood range.
[0045] In one embodiment, on the one hand, the existence of quality defects in a milk powder image is a low-probability event. Therefore, for a gradient curve, the smaller the number of gradient curves in the cluster to which it belongs, the greater the probability that the pixel corresponding to the gradient curve has a quality defect. Therefore, the smaller the number of gradient curves in the cluster to which the gradient curve of a pixel belongs, the greater the abnormality score of the pixel in the XOR region of each scale of the pixel.
[0046] On the other hand, a pixel gradient curve includes the distribution characteristics of the correction gradient at multiple scales; For each scale, the absolute value of the difference between the distribution characteristics of the gradient curve and the standard curve is calculated. The larger the absolute value of the difference, the higher the pixel point is in the first The larger the abnormality score of the pixel in the XOR region of each scale, the larger the abnormality score of the pixel in the XOR region of each scale.
[0047] In summary, pixel No. The abnormality score of the pixel point in the XOR region of the scale for: , Pixel The number of gradient curves in the cluster to which it belongs, Pixel In the gradient curve The distribution characteristics of the scales are different. The first The distribution characteristics of different scales.
[0048] For example, the pixel Abnormal score of pixels in the XOR region at the third scale , then in Figure 6 In the 3rd scale neighborhood, but not in the 2nd scale neighborhood, each pixel (pixel The XOR region of the third scale corresponds to Figure 6 The gray area in the figure has anomaly scores of .
[0049] In this way, all pixels in the milk powder image are traversed to obtain the abnormality score of each pixel in the XOR area of each scale, that is, one pixel will correspond to multiple abnormality scores.
[0050] S104, taking the average of multiple abnormal scores of the pixel points as the final score, marking the pixel points with the final score greater than the abnormal threshold as abnormal points, and obtaining the detection result; achieving the quality detection of goat milk powder.
[0051] In one embodiment, for a pixel, a pixel corresponds to multiple anomaly scores, the average of the multiple anomaly scores is used as the final score of the pixel, and the pixel whose final score is greater than the anomaly threshold is marked as an anomaly to obtain a quality detection result. The value of the anomaly threshold is 0.5.
[0052] The technical principle and implementation details of the method for visually detecting the quality of goat milk powder of the present application are introduced above through specific embodiments. The gradient value of each pixel in the milk powder image is subtracted from the gradient value mode to obtain a corrected gradient, which can remove the gradient information generated by the accumulation of milk powder particles; a gradient curve of each pixel is constructed, the gradient curve includes the distribution feature differences of the corrected gradient at multiple scales, and the gradient curve of a pixel can reflect the change law of the corrected gradient distribution feature of the pixel in the neighborhood range of multiple scales; a clustering operation is performed on the gradient curve, and the cluster center of the largest cluster is used as the standard curve. By comparing the standard curve and the gradient curve of the pixel, the abnormal score of the pixel in the XOR area of each scale is obtained, and the abnormal score is negatively correlated with the number of gradient curves in the cluster to which the pixel belongs, and is positively correlated with the absolute value of the difference in distribution features between the gradient curve and the standard curve. The abnormal score of each pixel in the XOR area of each scale is accurately quantified, and the average of multiple abnormal scores of the pixel is used as the final score. The pixel with a final score greater than the abnormal threshold is marked as an abnormal point, and the quality detection of goat milk powder is realized, so as to accurately obtain the quality detection result of goat milk powder based on the milk powder image.
[0053] According to the second aspect of the present application, the present application also provides a visual inspection system for goat milk powder quality. Figure 8 : is a structural block diagram of a visual inspection system for goat milk powder quality according to an embodiment of the present application. Figure 8 As shown, the system 50 includes a processor and a memory, and the memory stores computer program instructions. When the computer program instructions are executed by the processor, the method for visually detecting the quality of goat milk powder according to the first aspect of the present application is implemented. The system also includes other components well known to those skilled in the art, such as a communication bus and a communication interface, and their settings and functions are known in the art, so they are not described here.
[0054] In the present application, the aforementioned memory may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. For example, a computer-readable storage medium may be any suitable magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc., or any other medium that can be used to store the required information and can be accessed by an application, a module, or both. Any such computer storage medium may be part of a device or accessible or connectable to a device. Any application or module described in this application may be implemented using computer-readable / executable instructions that may be stored or otherwise maintained by such a computer-readable medium.
[0055] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0056] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the patent application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent application shall be subject to the attached claims.
Claims
1. A method for visually detecting the quality of goat milk powder, characterized in that: The detection method comprises: Subtract the gradient value mode from the gradient value of each pixel in the milk powder image to obtain the corrected gradient; Construct a gradient curve for each pixel point, perform clustering on the gradient curve, and use the cluster center of the largest cluster as the standard curve. The gradient curve includes the distribution characteristics of the corrected gradient at multiple scales. In the gradient curve Differences in distribution characteristics of different scales for: , is the maximum value of the distribution characteristic, Pixel No. Distribution characteristics within the neighborhood of each scale The frequency, Pixel No. Distribution characteristics within the neighborhood of each scale The frequency, is the logarithmic function with base e; Compare the standard curve and the gradient curve of any pixel point to obtain the abnormal score of the pixel point in the XOR area of each pixel point. The XOR region of the scale is located at scale neighborhood range, and is not located in the The area of the scale neighborhood range; The average of multiple abnormal scores of the pixel point is taken as the final score, and the pixel point with a final score greater than the abnormal threshold is marked as an abnormal point to obtain the detection result; the pixel point No. The abnormality score of the pixel point in the XOR region of the scale for: , Pixel The number of gradient curves in the cluster to which it belongs, The first The distribution characteristics of different scales.
2. The method for visually detecting goat milk powder quality according to claim 1, characterized in that: Pixels The corrected gradient for: , Pixel The gradient value of is the mode of gradient values.
3. The method for visually detecting goat milk powder quality according to claim 1, characterized in that: Before subtracting the gradient value mode from the gradient value of each pixel in the milk powder image, the detection method further comprises: A filtering operation is performed on the milk powder image to obtain a preprocessed milk powder image, wherein the filtering operation is median filtering, Gaussian filtering or bilateral filtering.
4. The method for visually detecting goat milk powder quality according to claim 1, characterized in that: The distribution feature is the mean value of the corrected gradient within the eight neighborhoods of the pixel point, or the extreme value of the gradient direction.
5. The method for visually detecting goat milk powder quality according to claim 1, characterized in that: The method for obtaining the multiple scales includes: Select multiple sample pixel points and obtain the inflection point of the sample gradient curve corresponding to each sample pixel point; For any inflection point, the variance of the portion of the curve after the inflection point in each sample gradient curve is calculated, and the mean of all variances is used as the stability index of the inflection point; Calculate the selection score of each inflection point, and select the inflection point with the largest selection score as the target inflection point, wherein the selection score is negatively correlated with the preset size corresponding to the inflection point and positively correlated with the stability index; The target inflection point and the preset size before the target inflection point correspond to the multiple scales.
6. The method for visually detecting goat milk powder quality according to claim 5, characterized in that: The milk powder image is divided into multiple image blocks of equal size, and the center point of each image block is used as the sample pixel point.
7. The method for visually detecting goat milk powder quality according to claim 5, characterized in that: The selection is divided into a stability index and a ratio of a preset size.
8. The method for visually detecting goat milk powder quality according to claim 1, characterized in that: The clustering operation on the gradient curve includes: The Euclidean distance between gradient curves is used as the clustering distance, and the Kmeans clustering algorithm is used to cluster the gradient curves to obtain multiple clusters. The cluster with the largest number of gradient curves is taken as the largest cluster.
9. The visual inspection system for goat milk powder quality is characterized by: It comprises a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the method for visually inspecting the quality of goat milk powder according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Milk powder quality detection method and system based on convolutional neural network
CN117522838A
Alloy surface detection system based on image recognition
CN115690387A
Memory bank damage rapid detection method based on machine vision
CN116664559A
Image recognition-based vision detection method and apparatus, and computer device
WO2021068486A1
Cited By
Milk powder quality detection method and system based on image processing
CN120147306A