Dairy product quality detection method based on image processing

By mapping and dichotomizing the grayscale characteristic values ​​and parameter values ​​of dairy products' surface grayscale images, the problem of difficult detection of mold on dairy products is solved, and more accurate and efficient detection is achieved.

CN119250643AInactive Publication Date: 2025-01-03SHAANXI YOUAIBEITE DAIRY CO LTD

Patent Information

Application Number
CN202411734670.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-01-03
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, it is difficult to detect molds on the surface of dairy products, mainly because of the need to collect a large number of dairy products, resulting in a complex detection process.

Method used

By obtaining the grayscale image of the dairy product surface, determining the grayscale characteristic value and parameter value of the target pixel point, mapping it to the target plane rectangular coordinate system, performing binary classification clustering, distinguishing the mold area from the dairy product area, reducing the difficulty of detection.

Benefits of technology

It realizes more accurate detection of whether there is mold on the surface of dairy products, avoids the need to acquire a large number of images, simplifies the detection process, and improves the accuracy and efficiency of the detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119250643A_ABST
    Figure CN119250643A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image data processing, in particular to a dairy product quality detection method based on image processing. The method comprises the following steps: acquiring a surface grayscale image of a dairy product to be detected in a dairy product container; obtaining a gray feature value of a target pixel point in the surface gray image, and determining a first parameter value of the target pixel point; mapping all the pixel points in the surface grayscale image to a target plane rectangular coordinate system by taking the grayscale feature values of the pixel points in the surface grayscale image and the first parameter values as coordinates; determining a second parameter value of the target pixel point; according to the second parameter value of the target pixel point, the position of the target position point in the target plane rectangular coordinate system is adjusted, and dichotomy is carried out on all the adjusted target position points to obtain abnormal position points; and detecting the quality of the to-be-detected dairy product according to the abnormal position point. According to the technical scheme, the detection of the mould possibly existing in the dairy product can be more accurately realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of image data processing, and in particular to a dairy product quality detection method based on image processing. Background Art

[0002] Dairy products refer to foods made from the milk of animals such as cows, sheep, and horses. Dairy products can be in the form of liquid milk, cream, and cheese. During the production, storage, and sales of dairy products, they may be contaminated by mold due to insufficient sterilization during the production process or poor storage conditions. Dairy products with mold will pose a threat to human health.

[0003] In order to kill the mold that may exist in dairy products and avoid the presence of mold in dairy products, it is possible to detect whether there is mold in dairy products. In order to detect the mold present in foods such as dairy products, in the relevant technology, for example, in the Chinese patent application document with publication number CN117649407A, a food quality detection method is provided, including: obtaining a first image of a food sample corresponding to the food to be detected by pre-scanning with a low-power microscope; inputting the first image into a trained first food quality detection model, and outputting a corresponding first microbial detection result; determining at least one target area to be re-scanned in the first image; re-scanning each target area with a low-power microscope to obtain microbial detection information, wherein the microbial detection information includes the coordinate position of the microorganism; scanning the food sample with a high-power microscope according to the microbial detection information to obtain at least one corresponding second image; inputting at least one second image into a trained second food quality detection model, and outputting a corresponding second microbial detection result; obtaining the quality inspection result of the food to be detected according to the first microbial detection result and the second microbial detection result.

[0004] In the related art, images of food samples are detected through a pre-trained food quality detection model. However, the training process of the food quality detection model requires a large and diverse number of food samples. When detecting mold that may exist on the surface of dairy products, it is difficult to collect a large and diverse number of dairy product surface images, which makes it difficult to detect mold that may exist on the surface of dairy products. Summary of the invention

[0005] In order to overcome the problem in the related art that it is difficult to detect mold that may exist on the surface of dairy products, the present application provides a dairy product quality detection method based on image processing, comprising: Obtain a surface grayscale image of the dairy product to be tested in the dairy product container, and use any pixel point in the surface grayscale image as a target pixel point; Obtain the grayscale eigenvalue of the target pixel point and determine the first parameter value of the target pixel point; the first parameter value is used to characterize the degree of difference in grayscale eigenvalue between the target pixel point and other pixels within the neighborhood; use the grayscale eigenvalue of the pixel point in the surface grayscale image and the first parameter value as coordinates to map all the pixels in the surface grayscale image to the target plane rectangular coordinate system; Determine a second parameter value of the target pixel point; the second parameter value is used to characterize the degree of difference between the target position point and other adjacent position points in the first parameter value, and the target position point is the position point corresponding to the target pixel point in the rectangular coordinate system of the target plane; According to the second parameter value of the target pixel point, the position of the target position point in the rectangular coordinate system of the target plane is adjusted to perform binary classification on all the adjusted target position points, and the abnormal position point is determined from all the position points in the rectangular coordinate system of the target plane; The area composed of the pixel points corresponding to the abnormal position points in the surface grayscale image is used as the mold area of ​​the dairy product to be tested, so as to use the mold area to perform quality inspection on the dairy product to be tested.

[0006] In this way, a surface grayscale image of the dairy product to be tested in the dairy container is obtained, and the grayscale eigenvalue of the target pixel in the surface grayscale image is obtained, and the first parameter value of the target pixel is determined; the first parameter value is used to characterize the degree of difference in grayscale eigenvalue between the target pixel and other pixels in the neighborhood; with the grayscale eigenvalue of the pixel in the surface grayscale image and the first parameter value as coordinates, all pixels in the surface grayscale image are mapped to the rectangular coordinate system of the target plane; since the coordinates of the position points in the rectangular coordinate system of the target plane correspond to the grayscale eigenvalue of the pixel in the surface grayscale image and the first parameter value, and the dairy product that does not contain mold mainly appears milky white, by performing binary classification on the position points in the rectangular coordinate system of the target plane, clustering of the grayscale eigenvalue of the pixel in the surface grayscale image and the first parameter value can be achieved, thereby more accurately determining whether there is mold on the surface of the dairy product, and avoiding the collection of a large number and variety of dairy product images, which can reduce the difficulty of detecting mold that may exist on the surface of the dairy product.

[0007] Optionally, the grayscale feature value of the target pixel is determined by: , where W is the grayscale feature value of the target pixel, R is the number of other pixels whose grayscale value is greater than the target pixel in the gradient direction of the target pixel, and norm is the normalization function; as well as are the grayscale values ​​of the j-th and j+1-th pixels whose grayscale values ​​in the gradient direction of the target pixel are greater than the grayscale values ​​of the target pixel, and M is the grayscale value of the target pixel.

[0008] Optionally, the first parameter value of the target pixel is determined by: ,in, is the first parameter value of the target pixel, m is the number of other pixels in the neighborhood of the target pixel, is the grayscale eigenvalue of the target pixel, is the grayscale eigenvalue of the i-th pixel in the neighborhood of the target pixel.

[0009] Optionally, the second parameter value of the target pixel is determined by: , Z is the second parameter value of the target pixel, E is the number of other position points adjacent to the target position point, is the first parameter value corresponding to the target position point, is the first parameter value of the qth other position point adjacent to the target position point, F is the number of other pixels in the neighborhood of the target pixel point whose grayscale eigenvalue is the same as that of the target pixel point, and N is the number of pixels in the neighborhood of the target pixel point.

[0010] In this way, through the second parameter value of the target pixel point, the characteristics of the target pixel point in the neighborhood range and the characteristics of the target position point corresponding to the target pixel point in the rectangular coordinate system of the target plane can be combined, so that the second parameter value of the target pixel point can more accurately characterize the probability that the target pixel point belongs to the edge of the mold area.

[0011] Optionally, the position of the target position point in the target plane rectangular coordinate system is adjusted according to the second parameter value corresponding to the target pixel point, including: determining a straight line passing through the target position point and the origin of the target plane rectangular coordinate system; taking the position point on the straight line whose distance from the target position point before adjustment is equal to the second parameter value as the target position point after the target position point is adjusted; the origin of the target plane rectangular coordinate system and the adjusted target position point are located on different sides of the target position point before adjustment.

[0012] In this way, by adjusting the position of the target position point, it is possible to avoid classifying the pixels located at the edge of the mold area into the category of the pixels of the dairy product itself, thereby facilitating the distinction between mold pixels and non-mold pixels in dairy products.

[0013] Optionally, all the adjusted target position points are subjected to binary classification, and abnormal position points are determined from all the position points in the rectangular coordinate system of the target plane, including: all the adjusted target position points are subjected to binary clustering, and all the position points in the rectangular coordinate system of the target plane are divided into a first position point set and a second position point set; according to the average value of the first parameter value corresponding to the included position points, the position point set with the largest average value in the first position point set and the second position point set is taken as the abnormal position point set, so as to obtain all abnormal position points.

[0014] In this way, all the adjusted target position points are subjected to binary classification clustering. Since the first parameter value of the pixel point of the dairy product is smaller than the first parameter value of the pixel point of the mold area, the dairy product area itself and the mold area in the surface grayscale image can be better distinguished.

[0015] Optionally, the mold area is used to perform quality inspection on the dairy product to be tested, including: when the area of ​​the mold area is larger than a preset area threshold, outputting prompt information; the prompt information is used to indicate that the dairy product to be tested is abnormal.

[0016] In this way, when the area of ​​the mold region is larger than the preset area threshold, the user can be notified of the abnormality of the dairy product in a timely manner by outputting a prompt message.

[0017] Optionally, the method further includes: when the area of ​​the mold area is greater than a preset area threshold, sending the image data of the mold area to a terminal device, so that the terminal device displays the image data of the mold area.

[0018] In this way, sending the image data of the mold area to the terminal device can facilitate the user of the terminal device to observe the mold condition of the dairy product to be tested, so that the user can determine whether to further process the dairy product to be tested.

[0019] Optionally, the surface grayscale image of the dairy product to be tested in the dairy product container is obtained by: obtaining the surface grayscale image of the dairy product to be tested by an image acquisition device provided in the dairy product container; or, selecting a dairy product sample of the dairy product to be tested from the dairy product container, and obtaining the surface grayscale image of the dairy product sample by using the image acquisition device.

[0020] The technical solution provided by the embodiments of the present application may include the following beneficial effects: obtaining a surface grayscale image of the dairy product to be tested in a dairy product container, and obtaining the grayscale feature value of the target pixel in the surface grayscale image, and determining the first parameter value of the target pixel; the first parameter value is used to characterize the degree of difference in grayscale feature value between the target pixel and other pixels in the neighborhood; using the grayscale feature value of the pixel in the surface grayscale image and the first parameter value as coordinates, all pixels in the surface grayscale image are mapped to the rectangular coordinate system of the target plane; since the coordinates of the position points in the rectangular coordinate system of the target plane correspond to the grayscale feature value and the first parameter value of the pixel in the surface grayscale image, and the dairy product that does not contain mold mainly appears milky white, by performing binary classification on the position points in the rectangular coordinate system of the target plane, the grayscale feature value and the first parameter value of the pixel in the surface grayscale image can be clustered, thereby more accurately determining whether there is mold on the surface of the dairy product, and avoiding the collection of a large number and variety of dairy product images, which can reduce the difficulty of detecting mold that may exist on the surface of the dairy product.

[0021] At the same time, by determining the second parameter value of the target pixel point, the second parameter value is used to characterize the degree of difference between the target position point and other adjacent position points in the first parameter value, and the target position point is the position point corresponding to the target pixel point in the target plane rectangular coordinate system; according to the second parameter value of the target pixel point, the position of the target position point in the target plane rectangular coordinate system is adjusted to perform binary classification on all adjusted target position points, which can more accurately classify the position points in the target plane rectangular coordinate system. Therefore, since dairy products that do not contain mold appear milky white and have a high color consistency, it is possible to more accurately distinguish between mold areas and non-mold areas in the surface grayscale image of dairy products, thereby more accurately detecting the quality of dairy products.

[0022] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0024] Figure 1 The figure is a flow chart of a method for detecting dairy product quality based on image processing according to an exemplary embodiment. DETAILED DESCRIPTION

[0025] Here, exemplary embodiments are described in detail, and examples thereof are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application.

[0026] First, the application scenario of the embodiment of the present application is briefly introduced. In the application scenario of the present application, in order to realize the detection of mold that may exist in food, the food can be processed in time when mold exists in the food, such as sterilizing the food containing mold, or discarding the food containing mold.

[0027] In the related art, a pre-trained food quality detection model can be used to detect the surface image of food, so as to output the detection result through the food quality detection model. However, the training process of the food quality detection model requires a large and diverse number of food sample images. When detecting mold that may exist in dairy products, it is difficult to collect a large and diverse number of dairy product sample images, which makes it difficult to detect mold that may exist in dairy products.

[0028] In view of the above technical problems, the embodiment of the present application provides a dairy product quality detection method based on image processing, which can be applied to a detection device for detecting the quality of dairy products. Figure 1 is a flow chart of a method for detecting dairy product quality based on image processing according to an exemplary embodiment. Figure 1 As shown, the method includes the following steps.

[0029] In step S101, a surface grayscale image of the dairy product to be tested in the dairy product container is obtained, and any pixel point in the surface grayscale image is used as a target pixel point.

[0030] Within a period of time after the sterilization of dairy products is completed, it is possible to detect whether there are still insufficiently sterilized molds in the dairy products, so that the insufficiently sterilized dairy products can be sterilized again, or sterilized to a higher degree, so as to achieve sufficient sterilization of the dairy products. During the storage of dairy products, the dairy products may be contaminated by molds due to poor storage environment, such as air leakage in the dairy product container causing air to mix into the dairy products; or the storage temperature or humidity of dairy products is not good, which accelerates the deterioration of dairy products and causes the presence of molds in dairy products.

[0031] The embodiments of the present application can detect sterilized dairy products so as to fully sterilize the dairy products; and can also detect stored dairy products so as to promptly detect possible deterioration of the dairy products.

[0032] An image acquisition device may be provided in the dairy product container. For example, the image acquisition device may be sealed in the dairy product container to prevent possible air from mixing into the dairy product container during the image acquisition process and thereby contaminating the dairy product in the dairy product container.

[0033] Alternatively, the dairy product container may refer to the container where the dairy product sample is located, and a certain proportion or volume of the dairy product sample is extracted from the dairy product to be tested, and the surface grayscale image of the dairy product to be tested is acquired through an image acquisition device to achieve quality detection of the dairy product to be tested.

[0034] In order to avoid the influence of possible movement of dairy products on the quality inspection results of the dairy products to be tested, for example, flowing liquid dairy products may have certain ripples, the surface grayscale image of the dairy products to be tested can be obtained when the dairy products to be tested are in a static state; the dairy products to be tested can also be dairy products with relatively fixed shapes such as cheese and cream in a flat state.

[0035] The surface grayscale image of the dairy product to be tested in the dairy product container is obtained by: obtaining the surface grayscale image of the dairy product to be tested by an image acquisition device arranged in the dairy product container; or, selecting a dairy product sample of the dairy product to be tested from the dairy product container, and obtaining the surface grayscale image of the dairy product sample by using the image acquisition device.

[0036] In order to facilitate the detection of mold that may exist in dairy products, any pixel in the surface grayscale image can be used as a target pixel. By referring to the processing steps for the target pixel, the processing steps for all pixels in the surface grayscale image can be completed, which will not be repeated here.

[0037] In step S102, the grayscale feature value of the target pixel is obtained, and the first parameter value of the target pixel is determined; the grayscale feature value of the pixel in the surface grayscale image and the first parameter value are used as coordinates to map all the pixels in the surface grayscale image to the target plane rectangular coordinate system.

[0038] The grayscale feature value of the target pixel is used to characterize the grayscale feature of the target pixel, so as to compare the grayscale feature values ​​of the target pixel with those of other pixels in the neighborhood, reflecting the degree of difference in grayscale features between the target pixel and other pixels in the neighborhood; the neighborhood range can be, for example, a range of sizes such as 3×3, 5×5, and 7×7 centered on the target pixel.

[0039] In one embodiment, the grayscale feature value of the target pixel can be obtained by: , where W is the grayscale feature value of the target pixel, R is the number of other pixels whose grayscale value is greater than the target pixel in the gradient direction of the target pixel, and norm is the normalization function; is the gray value of the jth pixel whose gray value in the gradient direction of the target pixel is greater than the gray value of the target pixel. is the grayscale value of the j+1th pixel whose grayscale value in the gradient direction of the target pixel is greater than the grayscale value of the target pixel, and M is the grayscale value of the target pixel.

[0040] The gradient direction of the pixel point can be determined according to the gradient direction component of the pixel point in the horizontal direction and the gradient direction component in the vertical direction; since the color of the dairy product itself is milky white and has good consistency, the grayscale value of the color of the dairy product itself in the surface grayscale image of the dairy product is relatively high, and the grayscale values ​​of different areas of the dairy product have good consistency.

[0041] When mold exists on the surface of dairy products, the mold mainly appears in colors such as black, green, brown and yellow, so that the grayscale value of the mold in the grayscale image of the dairy product surface is usually smaller than the grayscale value of the dairy product itself; since the gradient direction of the pixel point can represent the direction of change of the grayscale value of the pixel point, in the grayscale image of the surface of dairy products where mold may exist, the change of the grayscale value mainly occurs at the edge of the mold area. Therefore, the pixel point with a greater difference from other pixel points in the corresponding gradient direction is more likely to be a pixel point located in the mold area in the surface grayscale image. By measuring the grayscale values ​​of other pixel points whose grayscale values ​​in the gradient direction of the target pixel point are greater than the target pixel point, it can be determined whether there is mold on the surface of the dairy product to be tested.

[0042] The pixel values ​​of other pixels whose grayscale values ​​are greater than the target pixel in the gradient direction are compared. The greater the difference between the pixel values ​​of other pixels whose grayscale values ​​are greater than the target pixel in the gradient direction, the more likely the target pixel belongs to mold on the surface of the dairy product.

[0043] Since the mold in dairy products mainly appears in colors such as black, green, brown and yellow, and the color of the dairy products themselves appears in milky white or white, the grayscale value of the pixel of the dairy products themselves in the grayscale image of the surface of the dairy products is larger than the grayscale value of other pixels except the dairy products; the pixel value of the target pixel is used as the denominator to calculate the grayscale eigenvalue, so that the larger the value of the grayscale eigenvalue, the more likely the target pixel is to be the edge of the mold that may exist in the dairy products, which is convenient for determining whether there is mold in the dairy products.

[0044] In this way, due to the difference in color between the mold in the dairy products and the dairy products themselves, the grayscale value of the mold in the surface grayscale image of the dairy products is different from the grayscale value of the dairy products themselves, and the grayscale value of the mold in the surface grayscale image changes faster. By comparing the grayscale values ​​of the pixels whose grayscale values ​​are greater than the target pixel points in the gradient direction of the target pixel points, the grayscale feature values ​​of the target pixel points can facilitate the distinction between the mold and the dairy products themselves.

[0045] The first parameter value of the target pixel is used to characterize the difference between the target pixel and other pixels in the neighborhood in terms of grayscale eigenvalues; the grayscale eigenvalues ​​of other pixels can refer to the grayscale eigenvalue acquisition process of the target pixel.

[0046] In one embodiment, the first parameter value of the target pixel is determined in the following manner: ,in, is the first parameter value of the target pixel, m is the number of other pixels in the neighborhood of the target pixel, is the grayscale eigenvalue of the target pixel, is the grayscale eigenvalue of the i-th pixel in the neighborhood of the target pixel.

[0047] Compared with the pixels of the dairy products themselves in the surface grayscale image, the grayscale feature values ​​of the mold pixels that may exist in the surface grayscale image are more diverse. When the target pixel is located in the mold area, the difference in grayscale feature values ​​between the target pixel and other pixels in the neighborhood is greater.

[0048] In this way, by comparing the grayscale eigenvalue of the target pixel with the grayscale eigenvalues ​​of other pixels in the neighborhood, since the difference between the pixels of the dairy product itself and other pixels in the neighborhood is smaller, the first parameter value helps to distinguish the pixels of the dairy product itself and the pixels belonging to mold in the surface grayscale image.

[0049] The horizontal axis of the target plane rectangular coordinate system can correspond to the grayscale eigenvalue, the target plane rectangular coordinate system can correspond to the first parameter value of the pixel point, and the target plane rectangular coordinate system and the surface grayscale image are independent of each other. For example, the target plane rectangular coordinate system can be the coordinate system of other images different from the surface grayscale image. The grayscale eigenvalue of the pixel point in the surface grayscale image can be used as the horizontal coordinate, and the first parameter value of the pixel point in the surface grayscale image can be used as the vertical coordinate to obtain the coordinates corresponding to the pixel point in the surface grayscale image in the target plane rectangular coordinate system.

[0050] According to the coordinates of all pixels in the surface grayscale image in the rectangular coordinate system of the target plane, the mapping of all pixels in the surface grayscale image to the rectangular coordinate system of the target plane can be realized. The position points in the rectangular coordinate system of the mapped target plane are presented in the form of a scatter plot, and different pixels in the surface grayscale image correspond to different coordinates in the rectangular coordinate system of the target plane.

[0051] In step S103, a second parameter value of the target pixel is determined.

[0052] The second parameter value is used to characterize the degree of difference between the target position point and other adjacent position points in the first parameter value. The target position point is the position point corresponding to the target pixel point in the target plane rectangular coordinate system.

[0053] The target position point is obtained by mapping the grayscale eigenvalue of the target pixel point and the first parameter value as coordinates to the target plane rectangular coordinate system; for example, the horizontal coordinate of the target position point is equal to the grayscale eigenvalue of the target pixel point, and the vertical coordinate of the target position point is equal to the first parameter value of the target pixel point.

[0054] The greater the difference between the target position point and other adjacent position points in the first parameter value, the different position points in the rectangular coordinate system of the target plane correspond to different pixel points in the surface grayscale image. Therefore, the greater the difference between the target pixel point and other pixel points in the first parameter value, the second parameter value helps to distinguish the pixel points of the dairy product itself and the mold pixel points in the surface grayscale image.

[0055] In one embodiment, the second parameter value of the target pixel is determined by: , Z is the second parameter value of the target pixel, E is the number of other position points adjacent to the target position point, is the first parameter value corresponding to the target position point, is the first parameter value of the qth other position point adjacent to the target position point, F is the number of other pixels in the neighborhood of the target pixel point whose grayscale eigenvalue is the same as that of the target pixel point, and N is the number of pixels in the neighborhood of the target pixel point.

[0056] Since the dairy product to be tested is a sterilized dairy product, or the dairy product to be tested is a dairy product stored after sterilization, there is usually not a large amount of mold in the dairy product to be tested. The mold present in the dairy product to be tested is usually dispersedly distributed in the dairy product to be tested, so that in the surface grayscale image of the dairy product to be tested, the number of possible mold pixels in the surface grayscale image is smaller than the pixel points of the dairy product itself.

[0057] The coordinates of the position point in the rectangular coordinate system of the target plane correspond to the grayscale feature values ​​of the target pixel point in the surface grayscale image and the first parameter value. Since the number of mold pixels that may exist in the surface grayscale image is less than the number of pixels of the dairy product itself, and the grayscale features of the pixels of the dairy product itself have higher consistency, the grayscale features of the mold pixels have higher diversity. Therefore, compared with the position points corresponding to the pixels of the dairy product itself in the surface grayscale image, the position points corresponding to the mold pixels that may exist in the surface grayscale image in the rectangular coordinate system of the target plane are more dispersed.

[0058] Since the position points corresponding to the mold pixels in the surface grayscale image in the rectangular coordinate system of the target plane are more dispersed, the difference between the position points corresponding to the mold pixels in the rectangular coordinate system of the target plane and other adjacent position points is greater among all the position points mapped from the surface grayscale image to the rectangular coordinate system of the target plane.

[0059] The position point in the target plane rectangular coordinate system is obtained by mapping the grayscale eigenvalues ​​of the pixel points in the surface grayscale image and the first parameter value as coordinates. There may be coordinates of the position point that do not correspond in the target plane rectangular coordinate system; for example, under a certain grayscale eigenvalue and a certain first parameter value, there is no corresponding pixel point in the surface grayscale image, so that the number of position points corresponding to the coordinates in the target plane rectangular coordinate system is 0.

[0060] In an embodiment of the present application, the multiple other position points adjacent to the target position point refer to the multiple other position points closest to the target position point in the rectangular coordinate system of the target plane, and the number of position points at the coordinates of the multiple other position points closest to the target position point is greater than 0.

[0061] Since there may also be multiple pixel points in the surface grayscale image whose grayscale characteristic values ​​and first parameter values ​​are equal, there may be multiple position points at the same coordinate in the rectangular coordinate system of the target plane. A specified number of other position points can be selected from multiple other position points closest to the target position point to participate in the calculation process of the second parameter value of the target pixel point.

[0062] Compared with the position points corresponding to the mold pixels in the target plane rectangular coordinate system, the grayscale features of the pixels of the dairy products themselves have higher consistency, so the position points corresponding to the pixels of the dairy products themselves in the target plane rectangular coordinate system are more concentrated, and the number of other position points around the position points corresponding to the pixels of the dairy products themselves is greater. Therefore, the more other position points adjacent to the target position point, the higher the probability that the target pixel point belongs to the pixel point of the dairy product itself, and the lower the probability that the target pixel point belongs to the pixel point of the mold.

[0063] On the contrary, the fewer the number of other position points adjacent to the target position point, the higher the probability that the target pixel point is a mold pixel point; and the higher the degree of difference between the target position point and other position points adjacent to the target position point in the first parameter value, the higher the probability that the pixel point corresponding to the target position point is a mold pixel point.

[0064] In the calculation formula of the second parameter value of the target pixel, the number of other pixels with the same grayscale eigenvalue as the target pixel in the neighborhood of the target pixel is also considered. Compared with the pixels of the dairy product itself in the surface grayscale image, the grayscale characteristics of the mold pixel are more diverse, making the grayscale eigenvalues ​​of the mold pixel more diverse, and the number of other pixels with the same grayscale eigenvalue as the mold pixel in the neighborhood of the mold pixel is smaller. Therefore, the fewer the number of other pixels with the same grayscale eigenvalue as the target pixel in the neighborhood of the target pixel, the greater the probability that the target pixel belongs to the mold pixel in the surface grayscale image.

[0065] When the target pixel is located at the edge of the mold area, the first parameter value of the pixel located at the edge of the mold area is larger than that of the pixel located inside the mold area, so that the difference in the first parameter value between the pixel located at the edge of the mold area and the pixel located inside the mold area is greater. Therefore, the larger the second parameter value of the target pixel is, the greater the probability that the target pixel is located at the edge of the mold area.

[0066] In this way, through the second parameter value of the target pixel point, the characteristics of the target pixel point in the neighborhood range and the characteristics of the target position point corresponding to the target pixel point in the rectangular coordinate system of the target plane can be combined, so that the second parameter value of the target pixel point can more accurately characterize the probability that the target pixel point belongs to the edge of the mold area.

[0067] In step S104, the position of the target position point in the target plane rectangular coordinate system is adjusted according to the second parameter value of the target pixel point, so as to perform binary classification on all the adjusted target position points and determine the abnormal position point from all the position points in the target plane rectangular coordinate system.

[0068] In order to distinguish between the mold area and the dairy product itself in the surface grayscale image, the surface grayscale image can be classified into two categories. However, when the surface grayscale image is classified into two categories, the pixels at the edge of the mold area are closer to the pixels of the dairy product itself than the pixels inside the mold area, so the edge of the mold area may be classified into the category of the dairy product itself, and some sub-areas of the mold area may be misjudged as the dairy product itself.

[0069] In order to more accurately realize the division of pixel points in the surface grayscale image, and the pixel points with different grayscale characteristics in the surface grayscale image are distributed at different positions in the rectangular coordinate system of the target plane, in order to avoid classifying the pixel points located at the edge of the mold area into the category where the pixel points of the dairy product itself are located, the position of the target position point in the rectangular coordinate system of the target plane can be adjusted so that the adjusted position point is close to the coordinates where the mold area is located.

[0070] In one embodiment, the position of the target position point in the target plane rectangular coordinate system is adjusted according to the second parameter value corresponding to the target pixel point, including: determining a straight line passing through the target position point and the origin of the target plane rectangular coordinate system; taking the position point on the straight line whose distance from the target position point before adjustment is equal to the second parameter value as the target position point after the target position point is adjusted; the origin of the target plane rectangular coordinate system and the adjusted target position point are located on different sides of the target position point before adjustment.

[0071] On the straight line passing through the target position point and the origin of the target plane rectangular coordinate system, the grayscale eigenvalue and the first parameter value corresponding to the side close to the origin are smaller, and the grayscale eigenvalue and the first parameter value of the pixel point of the dairy product itself in the surface grayscale image are smaller, so that the position point on the side close to the origin corresponds to the pixel point of the dairy product itself in the surface grayscale image.

[0072] The position point on the straight line whose distance from the target position point before adjustment is equal to the second parameter value is used as the target position point after adjustment, and the origin of the target plane rectangular coordinate system and the adjusted target position point are located on different sides of the target position point before adjustment. The position point with a larger second parameter value can be adjusted toward a position away from the origin of the target plane rectangular coordinate system. Since the target pixel point with a larger second parameter value has a higher probability of belonging to the edge of the mold area, the target position point corresponding to the target pixel point with a higher probability of belonging to the edge of the mold area can be adjusted toward the direction where the mold area is located, so as to avoid classifying the pixel points located at the edge of the mold area into the category where the pixel points of the dairy product itself are located.

[0073] For example, the coordinates of the target position point before adjustment in the target plane rectangular coordinate system may be (3, 0), and the coordinates of the origin of the target plane rectangular coordinate system are (0, 0). If the second parameter value corresponding to the target pixel point is 1, the straight line passing through the target position point before adjustment and the origin of the target plane rectangular coordinate system is the horizontal axis of the target plane rectangular coordinate system. In order to make the adjusted target position point away from the origin of the target plane rectangular coordinate system, (4, 0) may be used as the coordinates of the adjusted target position point in the target plane rectangular coordinate system.

[0074] In this way, by adjusting the position of the target position point, it is possible to avoid classifying the pixels located at the edge of the mold area into the category of the pixels of the dairy product itself, thereby facilitating the distinction between mold pixels and non-mold pixels in dairy products.

[0075] In one embodiment, all adjusted target position points are subjected to binary classification, and abnormal position points are determined from all position points in the rectangular coordinate system of the target plane, including: all adjusted target position points are subjected to binary classification clustering, and all position points in the rectangular coordinate system of the target plane are divided into a first position point set and a second position point set; according to the average value of the first parameter value corresponding to the included position points, the position point set with the largest average value in the first position point set and the second position point set is taken as the abnormal position point set to obtain all abnormal position points.

[0076] For example, the k-means clustering algorithm can be used to perform binary clustering on all the adjusted target position points, and all the adjusted target position points can be divided into two categories. Since the grayscale value of the pixel points of the dairy product itself is larger and the consistency of the grayscale value is higher, the position points corresponding to the pixel points of the dairy product itself in the rectangular coordinate system of the target plane are closer to the origin of the rectangular coordinate system of the target plane, and the average value of the first parameter values ​​corresponding to all the pixel points of the dairy product itself is smaller.

[0077] In this way, all the adjusted target position points are subjected to binary classification clustering. Since the first parameter value of the pixel point of the dairy product is smaller than the first parameter value of the pixel point of the mold area, the dairy product area itself and the mold area in the surface grayscale image can be better distinguished.

[0078] In step S105, the pixel point corresponding to the abnormal position point in the surface grayscale image is used as the mold area of ​​the dairy product to be tested, so as to use the mold area to perform quality inspection on the dairy product to be tested.

[0079] Since different position points in the rectangular coordinate system of the target plane correspond to different pixel points in the surface grayscale image, the pixel points corresponding to the abnormal position points in the surface grayscale image are more likely to be mold pixel points in the dairy product to be tested. By taking the pixel points corresponding to the abnormal position points in the surface grayscale image as the mold area of ​​the dairy product to be tested, the mold area in the surface grayscale image can be effectively determined, thereby realizing the detection of mold on the surface of the dairy product to be tested.

[0080] In one embodiment, the mold area is used to perform quality inspection on the dairy product to be tested, including: when the area of ​​the mold area is larger than a preset area threshold, outputting prompt information; the prompt information is used to indicate that the dairy product to be tested is abnormal.

[0081] When the area of ​​the mold region is larger than the preset area threshold, it means that the amount of mold present in the dairy product exceeds the allowed amount. For example, the preset area threshold may be 0. When a mold region exists in the dairy product, a prompt message is output to prevent dairy products with excessive mold from posing a threat to human health.

[0082] In this way, when the area of ​​the mold region is larger than the preset area threshold, the user can be notified of the abnormality of the dairy product in a timely manner by outputting a prompt message.

[0083] When the area of ​​the mold region is less than or equal to the preset area threshold, the next dairy product sample to be tested can be subjected to quality inspection. When the area of ​​the mold region in multiple consecutive quality inspection results of multiple dairy product samples is less than or equal to the preset area threshold, the quality inspection result of the dairy product can be determined to be qualified.

[0084] In one embodiment, when the area of ​​the mold region is greater than a preset area threshold, the image data of the mold region is sent to a terminal device, so that the terminal device displays the image data of the mold region.

[0085] When the area of ​​the mold region is larger than the preset area threshold, it at least indicates that mold exists in the dairy product to be tested. By sending the image data of the mold region to the terminal device, the user of the terminal device can observe the mold region in the dairy product to be tested to determine whether to discard the dairy product containing mold, or to perform further inspection or other processing on the dairy product to be tested.

[0086] In this way, sending the image data of the mold area to the terminal device can facilitate the user of the terminal device to observe the mold condition of the dairy product to be tested, so that the user can determine whether to further process the dairy product to be tested.

[0087] By using the image processing-based dairy product quality detection method provided in the embodiment of the present application, a surface grayscale image of the dairy product to be tested in the dairy product container is obtained, and the grayscale feature value of the target pixel in the surface grayscale image is obtained, and the first parameter value of the target pixel is determined; the first parameter value is used to characterize the degree of difference in grayscale feature value between the target pixel and other pixels in the neighborhood; with the grayscale feature value of the pixel in the surface grayscale image and the first parameter value as coordinates, all the pixels in the surface grayscale image are mapped to the rectangular coordinate system of the target plane; since the coordinates of the position points in the rectangular coordinate system of the target plane correspond to the grayscale feature value and the first parameter value of the pixel in the surface grayscale image, and the dairy product that does not contain mold mainly appears milky white, by performing binary classification on the position points in the rectangular coordinate system of the target plane, the grayscale feature value and the first parameter value of the pixel in the surface grayscale image can be clustered, thereby more accurately determining whether there is mold on the surface of the dairy product, and avoiding the collection of a large number and variety of dairy product images, which can reduce the difficulty of detecting mold that may exist on the surface of the dairy product.

[0088] At the same time, by determining the second parameter value of the target pixel point, the second parameter value is used to characterize the degree of difference between the target position point and other adjacent position points in the first parameter value, and the target position point is the position point corresponding to the target pixel point in the target plane rectangular coordinate system; according to the second parameter value of the target pixel point, the position of the target position point in the target plane rectangular coordinate system is adjusted to perform binary classification on all adjusted target position points, which can more accurately classify the position points in the target plane rectangular coordinate system. Therefore, since dairy products that do not contain mold appear milky white and have a high color consistency, it is possible to more accurately distinguish between mold areas and non-mold areas in the surface grayscale image of dairy products, thereby more accurately detecting the quality of dairy products.

[0089] It should be understood that the features of some embodiments of the various applications described herein may be combined with each other, unless specifically stated otherwise.

[0090] Although terms such as "first", "second", and "third" may be used herein to describe various components, parts, regions, layers, or sections, these components, parts, regions, layers, or sections are not limited to these terms. Instead, these terms are only used to distinguish one component, part, region, layer, or section from another component, part, region, layer, or section. Therefore, without departing from the teachings of the examples described herein, the first component, part, region, layer, or section mentioned in the examples may also be referred to as the second component, part, region, layer, or section.

[0091] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description herein, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0092] In addition, the word "exemplary" is used herein to mean serving as an example, instance, or diagram. Any aspect or design described herein as "exemplary" is not necessarily to be understood as being advantageous over other aspects or designs. Instead, the use of the word exemplary is intended to present concepts in a concrete manner. As used herein, the term "or" is intended to mean an inclusive "or" rather than an exclusive "or".

[0093] Likewise, although the present application has been shown and described with respect to one or more implementations, equivalent variations and modifications will occur to those skilled in the art upon reading and understanding this specification and the accompanying drawings. With particular regard to the various functions performed by the components (e.g., elements, resources, etc.) described above, unless otherwise noted, the terms used to describe such components are intended to correspond to any component (functionally equivalent) that performs the specific functions of the described components, even if not structurally equivalent to the disclosed structures.

[0094] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary technical means in the art that are not disclosed in the present application, and the specification and embodiments are only considered as exemplary.

[0095] It should be understood that the present application is not limited to the exact construction that has been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof.

Claims

1. A dairy product quality detection method based on image processing, characterized in that: include: Obtain a surface grayscale image of the dairy product to be tested in the dairy product container, and use any pixel point in the surface grayscale image as a target pixel point; Obtaining a grayscale characteristic value of a target pixel and determining a first parameter value of the target pixel; The first parameter value is used to characterize the difference between the target pixel and other pixels in the neighborhood in terms of grayscale feature value; Using the grayscale feature values ​​of the pixels in the surface grayscale image and the first parameter value as coordinates, all the pixels in the surface grayscale image are mapped to the target plane rectangular coordinate system; Determine a second parameter value of the target pixel; The second parameter value is used to characterize the degree of difference between the target position point and other adjacent position points in the first parameter value, and the target position point is the position point corresponding to the target pixel point in the rectangular coordinate system of the target plane; According to the second parameter value of the target pixel point, the position of the target position point in the rectangular coordinate system of the target plane is adjusted to perform binary classification on all the adjusted target position points, and the abnormal position point is determined from all the position points in the rectangular coordinate system of the target plane; The area composed of the pixel points corresponding to the abnormal position points in the surface grayscale image is used as the mold area of ​​the dairy product to be tested, so as to use the mold area to perform quality inspection on the dairy product to be tested.

2. The dairy product quality detection method based on image processing according to claim 1, characterized in that: The grayscale eigenvalue of the target pixel is determined in the following way: , where W is the grayscale feature value of the target pixel, R is the number of other pixels whose grayscale value is greater than the target pixel in the gradient direction of the target pixel, and norm is the normalization function; as well as are the grayscale values ​​of the j-th and j+1-th pixels whose grayscale values ​​in the gradient direction of the target pixel are greater than the grayscale values ​​of the target pixel, and M is the grayscale value of the target pixel.

3. The dairy product quality detection method based on image processing according to claim 1, characterized in that: The first parameter value of the target pixel is determined in the following way: ,in, is the first parameter value of the target pixel, m is the number of other pixels in the neighborhood of the target pixel, is the grayscale eigenvalue of the target pixel, is the grayscale eigenvalue of the i-th pixel in the neighborhood of the target pixel.

4. The dairy product quality detection method based on image processing according to claim 1, characterized in that: The second parameter value of the target pixel is determined in the following way: , Z is the second parameter value of the target pixel, E is the number of other position points adjacent to the target position point, is the first parameter value corresponding to the target position point, is the first parameter value of the qth other position point adjacent to the target position point, F is the number of other pixels in the neighborhood of the target pixel point whose grayscale eigenvalue is the same as that of the target pixel point, and N is the number of pixels in the neighborhood of the target pixel point.

5. The dairy product quality detection method based on image processing according to claim 1, characterized in that: According to the second parameter value corresponding to the target pixel point, the position of the target position point in the target plane rectangular coordinate system is adjusted, including: Determine a straight line passing through the target position point and the origin of the target plane rectangular coordinate system; The position point on the straight line whose distance from the target position point before adjustment is equal to the second parameter value is used as the target position point after adjustment; the origin of the target plane rectangular coordinate system and the adjusted target position point are located on different sides of the target position point before adjustment.

6. The dairy product quality detection method based on image processing according to claim 1, characterized in that: All adjusted target position points are classified into two categories, and abnormal position points are determined from all position points in the rectangular coordinate system of the target plane, including: Perform binary clustering on all adjusted target position points, and divide all position points in the target plane rectangular coordinate system into a first position point set and a second position point set; According to the average value of the first parameter corresponding to the included location points, the location point set with the largest average value in the first location point set and the second location point set is taken as the abnormal location point set to obtain all abnormal location points.

7. The dairy product quality detection method based on image processing according to claim 1, characterized in that: The mold area is used to test the quality of dairy products, including: When the area of ​​the mold region is larger than a preset area threshold, a prompt message is output; the prompt message is used to indicate that the dairy product to be tested is abnormal.

8. The dairy product quality detection method based on image processing according to claim 1, characterized in that: The method further comprises: When the area of ​​the mold region is greater than a preset area threshold, the image data of the mold region is sent to a terminal device, so that the terminal device displays the image data of the mold region.

9. The dairy product quality detection method based on image processing according to claim 1, characterized in that: The surface grayscale image of the dairy product to be tested in the dairy product container is obtained by: The surface grayscale image of the dairy product to be tested is obtained by an image acquisition device arranged in the dairy product container; or, a dairy product sample of the dairy product to be tested is selected from the dairy product container, and the surface grayscale image of the dairy product sample is obtained by using the image acquisition device.

Citation Information

Patent Citations

  • OCA film bubble detection method based on computer vision

    CN117557573A

  • Food quality detection method, equipment, system and storage medium

    CN117649407A

  • Furniture surface quality detection method based on machine vision

    CN118823029A

  • Image processing method and apparatus, processor, electronic device, and storage medium

    WO2022252737A1

Cited By

  • Quality detection method of mitochondrial nutrient goat milk powder based on image processing

    CN119861044A

  • A quality detection method for mitochondrial nutrient goat milk powder based on image processing

    CN119861044B

  • Milk product microstructure image analysis method and device

    CN119963550A