Image recognition-based automatic detection method and device for the number of surface molds on dairy products
Patent Information
- Application Number
- CN202511233870.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-01
- Publication Date
- 2026-08-18
- Estimated Expiration
- 2045-09-01
AI Technical Summary
[0002]在乳制品质量管控领域,表面霉菌的精准识别是防止污染扩散的核心环节,传统检测依赖人工感官评估,受限于人眼对微观结构的分辨能力,难以捕捉早期萌发的微小霉菌群落,且易受环境光干扰导致判断偏差,现有光学检测方案虽引入机器视觉技术,但乳制品表面的油脂膜与水分层会形成强烈镜面反射,使霉菌的漫反射特征被掩盖,导致图像中目标与背景的区分度急剧下降,不同品类乳制品的基质纹理差异显著,如奶酪的蜂窝结构、酸奶块的凝乳纹理等,与霉菌的视觉特征存在高度重叠,传统模型在跨品类检测时易将固有结构误判为霉菌,泛化性能受限
[0042] Compared with existing technologies, the beneficial effects of this invention are as follows: This technical solution addresses the problem of high reflection interference by employing a polarization differential imaging mechanism. It acquires parallel and perpendicular polarized images by controlling the polarization directions of the polarizer and analyzer. Utilizing the difference in specular and diffuse reflection characteristics between the two, the differential image is calculated, and the coefficient k is dynamically adjusted to maximize the contrast between the mold area and the background. Simultaneously, combined with low-magnification microscopic detail enhancement, it effectively removes reflection interference caused by oils and moisture on the surface of dairy products, allowing micron-level mold features to be clearly preserved, resulting in a higher signal-to-noise ratio compared to traditional imaging methods. Furthermore, to address the problem of poor cross-category generalization, a dual-domain adaptive network is constructed. The main path lightweight encoder-decoder network is embedded... The adaptive input module uses a gradient inversion layer to backpropagate the domain classification loss to the encoder, forcing the model to learn common mold features among different dairy product types and weakening the influence of matrix texture differences. The auxiliary classification network then performs secondary discrimination on suspected areas, accurately distinguishing between mold and the inherent structure of dairy products. The synergistic effect of both improves the model's detection accuracy for unknown dairy product types. To address the difficulty in tracing results, before generating the test report, the number and area of mold are compared with preset thresholds to mark unqualified products, and the test time and product number are automatically associated with the cloud traceability system. This enables full-chain data backtracking from test results to the production process, providing a basis for locating quality problems and improving traceability efficiency.
Smart Images

Figure CN121147589B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and more specifically, to an automatic detection method and device for the number of molds on the surface of dairy products based on image recognition. Background Technology
[0002] In the field of dairy product quality control, accurate identification of surface mold is a core step in preventing the spread of contamination. Traditional detection relies on human sensory evaluation, which is limited by the human eye's ability to distinguish microstructures, making it difficult to capture early-germinating microscopic mold communities. Furthermore, it is easily affected by ambient light, leading to judgment bias. Although existing optical detection solutions have introduced machine vision technology, the oil film and water layer on the surface of dairy products create strong specular reflections, which mask the diffuse reflection characteristics of molds, resulting in a sharp decrease in the distinction between the target and the background in the image. The matrix textures of different types of dairy products vary significantly, such as the honeycomb structure of cheese and the curd texture of yogurt blocks, which highly overlap with the visual characteristics of molds. Traditional models are prone to misidentifying inherent structures as molds when detecting across different product categories, thus limiting their generalization performance.
[0003] While polarization imaging technology can suppress reflection to some extent, the differential algorithm with fixed parameters cannot adapt to the optical characteristics of different dairy products, making it difficult to balance the relationship between reflection suppression and feature preservation. When processing, a single network model either suffers from computational delay due to the pursuit of segmentation accuracy or sacrifices detail capture capability due to the emphasis on speed, making it difficult to meet the real-time detection requirements of industrial production lines. In addition, the disconnect between the detection results and the quality traceability system also increases the difficulty of tracing the source of pollution.
[0004] In summary, existing technologies suffer from significant reflection interference, poor cross-category generalization, and difficulty in tracing results. Summary of the Invention
[0005] To overcome the problems of large reflection interference, poor cross-category generalization, and difficulty in tracing results in existing technologies, this invention discloses an automatic detection method and equipment for the number of molds on the surface of dairy products based on image recognition, which can effectively solve the above-mentioned technical problems.
[0006] To solve the above-mentioned technical problems, the technical solution of the present invention is as follows:
[0007] An automatic detection method for the number of molds on the surface of dairy products based on image recognition includes the following steps:
[0008] In each detection cycle, a polarization difference image and an original RGB image of the surface of the dairy product to be detected are acquired; wherein the polarization difference image is generated by a mathematical model of polarization difference imaging, including the difference result of a first image imaged parallel to the polarization direction and a second image imaged perpendicular to the polarization direction;
[0009] The polarization difference image is input into the main network of the dual-path adaptive network to obtain the segmentation results of the suspected mold region on the surface of the dairy product.
[0010] Based on the segmentation results of the suspected mold region, image blocks of the corresponding region are extracted from the original RGB image and input into the auxiliary network of the dual-path adaptive network for classification and discrimination to obtain the mold region confirmation result;
[0011] Based on the confirmation results of the mold area, the number and area of mold on the surface of the dairy products are counted, and a mold detection report is generated.
[0012] Preferably, acquiring the polarization difference image of the surface of the dairy product to be detected includes:
[0013] The polarizer in front of the control light source and the analyzer in front of the camera lens successively acquire the first image I with parallel polarization directions. parallel The second image I perpendicular to the polarization direction perpendicular ;
[0014] The polarization difference image is calculated using the image processing unit:
[0015] I diff =I perpendicular -k×I parallel , where k is the adjustment coefficient;
[0016] The polarization difference image is subjected to low-magnification microscopic detail enhancement processing to preserve micron-level mold features.
[0017] Preferably, the main network of the dual-domain adaptive network is a lightweight encoder-decoder network, and the step of inputting the polarization difference image into the main network of the dual-domain adaptive network to obtain the segmentation result of the suspected mold region on the surface of the dairy product includes:
[0018] The main network extracts features from the polarization difference image, compresses the image dimension and extracts multi-level features through the encoder;
[0019] The decoder upsamples and fuses the extracted multi-level features, and outputs a pixel-level segmentation mask for suspected mold regions;
[0020] The encoder incorporates a domain adaptation module, which uses a gradient inversion layer and a domain classifier to blur the distribution differences among different dairy product types.
[0021] Preferably, the auxiliary network of the dual-path adaptive network is a classification network, and the classification and discrimination performed by inputting the auxiliary network of the dual-path adaptive network to obtain the mold area confirmation result includes:
[0022] The auxiliary network extracts features from the captured image patch to determine whether the region is mold or an inherent structure of dairy products.
[0023] When the judgment result is mold, the area is marked as a valid mold area; when the judgment result is the inherent structure of dairy products, the area is marked as a false alarm area.
[0024] By summarizing all valid mold areas, the mold area confirmation results are obtained.
[0025] Preferably, the step of counting the number and area of mold on the surface of the dairy product based on the mold area confirmation results includes:
[0026] Connectivity analysis was performed on the valid mold regions in the mold region confirmation results to determine the number of independent mold communities.
[0027] The area of each effective mold region is calculated based on the mapping relationship between image pixels and actual size.
[0028] The total area of mold coverage on the surface of dairy products is obtained by summing the areas of all effective mold-infested regions.
[0029] Preferably, the method for determining the adjustment coefficient k includes:
[0030] Collect polarization parallel and polarization perpendicular images of standard dairy product samples;
[0031] Calculate the contrast between the mold region and the background in the difference image under different k values;
[0032] The k value corresponding to the maximum contrast is selected as the adjustment coefficient.
[0033] Preferably, the training method for the domain adaptation module includes:
[0034] Collect mold sample images of various dairy products and construct a training set containing different domains;
[0035] During the training of the main network, the domain classification loss is backpropagated to the encoder through a gradient inversion layer;
[0036] This allows the encoder to learn both mold segmentation features and domain-invariant features simultaneously, improving the model's generalization ability on unknown dairy product types.
[0037] Preferably, the process further includes the following steps before generating the mold detection report:
[0038] The number and area of mold are judged by threshold. When the threshold is exceeded, the dairy product is marked as unqualified.
[0039] Record the testing time, dairy product number, and testing results, and link them to the cloud-based quality traceability system.
[0040] Preferably, an electronic device includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement the detection method described above.
[0041] Preferably, a computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the detection method as described above.
[0042] Compared with existing technologies, the beneficial effects of this invention are as follows: This technical solution addresses the problem of high reflection interference by employing a polarization differential imaging mechanism. It acquires parallel and perpendicular polarized images by controlling the polarization directions of the polarizer and analyzer. Utilizing the difference in specular and diffuse reflection characteristics between the two, the differential image is calculated, and the coefficient k is dynamically adjusted to maximize the contrast between the mold area and the background. Simultaneously, combined with low-magnification microscopic detail enhancement, it effectively removes reflection interference caused by oils and moisture on the surface of dairy products, allowing micron-level mold features to be clearly preserved, resulting in a higher signal-to-noise ratio compared to traditional imaging methods. Furthermore, to address the problem of poor cross-category generalization, a dual-domain adaptive network is constructed. The main path lightweight encoder-decoder network is embedded... The adaptive input module uses a gradient inversion layer to backpropagate the domain classification loss to the encoder, forcing the model to learn common mold features among different dairy product types and weakening the influence of matrix texture differences. The auxiliary classification network then performs secondary discrimination on suspected areas, accurately distinguishing between mold and the inherent structure of dairy products. The synergistic effect of both improves the model's detection accuracy for unknown dairy product types. To address the difficulty in tracing results, before generating the test report, the number and area of mold are compared with preset thresholds to mark unqualified products, and the test time and product number are automatically associated with the cloud traceability system. This enables full-chain data backtracking from test results to the production process, providing a basis for locating quality problems and improving traceability efficiency. Attached Figure Description
[0043] To more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are merely exemplary. For those skilled in the art, other embodiments can be derived from the provided drawings without creative effort.
[0044] Figure 1 This is a diagram illustrating the steps of the method of the present invention;
[0045] Figure 2 This is a schematic diagram of the hardware structure of the present invention. Detailed Implementation
[0046] The accompanying drawings are for illustrative purposes only and should not be construed as limiting the scope of this patent.
[0047] To better illustrate this embodiment, some parts in the accompanying drawings may be omitted, enlarged, or reduced, and do not represent the actual product dimensions;
[0048] It will be understood by those skilled in the art that certain well-known structures and their descriptions may be omitted in the accompanying drawings.
[0049] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.
[0050] Example
[0051] Please see Figure 1-2 An automatic detection method for the number of molds on the surface of dairy products based on image recognition includes the following steps:
[0052] In each detection cycle, a polarization difference image and an original RGB image of the surface of the dairy product to be detected are acquired; wherein the polarization difference image is generated by a mathematical model of polarization difference imaging, including the difference result of a first image imaged parallel to the polarization direction and a second image imaged perpendicular to the polarization direction;
[0053] The polarization difference image is input into the main network of the dual-path adaptive network to obtain the segmentation results of the suspected mold region on the surface of the dairy product.
[0054] Based on the segmentation results of the suspected mold region, image blocks of the corresponding region are extracted from the original RGB image and input into the auxiliary network of the dual-path adaptive network for classification and discrimination to obtain the mold region confirmation result;
[0055] Based on the confirmation results of the mold area, the number and area of mold on the surface of the dairy products are counted, and a mold detection report is generated.
[0056] The process of acquiring the polarization difference image of the surface of the dairy product to be detected includes:
[0057] The polarizer in front of the control light source and the analyzer in front of the camera lens successively acquire the first image I with parallel polarization directions. parallel The second image I perpendicular to the polarization direction perpendicular ;
[0058] The polarization difference image is calculated using the image processing unit:
[0059] I diff =I perpendicular -k×I parallel , where k is the adjustment coefficient;
[0060] The polarization difference image is subjected to low-magnification microscopic detail enhancement processing to preserve micron-level mold features.
[0061] The main network of the dual-domain adaptive network is a lightweight encoder-decoder network. The step of inputting the polarization difference image into the main network of the dual-domain adaptive network to obtain the segmentation result of the suspected mold region on the surface of the dairy product includes:
[0062] The main network extracts features from the polarization difference image, compresses the image dimension and extracts multi-level features through the encoder;
[0063] The decoder upsamples and fuses the extracted multi-level features, and outputs a pixel-level segmentation mask for suspected mold regions;
[0064] The encoder incorporates a domain adaptation module, which uses a gradient inversion layer and a domain classifier to blur the distribution differences among different dairy product types.
[0065] The auxiliary network of the dual-domain adaptive network is a classification network. The classification and discrimination performed by the auxiliary network of the dual-domain adaptive network to obtain the mold area confirmation result includes:
[0066] The auxiliary network extracts features from the captured image patch to determine whether the region is mold or an inherent structure of dairy products.
[0067] When the judgment result is mold, the area is marked as a valid mold area; when the judgment result is the inherent structure of dairy products, the area is marked as a false alarm area.
[0068] By summarizing all valid mold areas, the mold area confirmation results are obtained.
[0069] The step of counting the number and area of mold on the surface of dairy products based on the mold area confirmation results includes:
[0070] Connectivity analysis was performed on the valid mold regions in the mold region confirmation results to determine the number of independent mold communities.
[0071] The area of each effective mold region is calculated based on the mapping relationship between image pixels and actual size.
[0072] The total area of mold coverage on the surface of dairy products is obtained by summing the areas of all effective mold-infested regions.
[0073] The method for determining the adjustment coefficient k includes:
[0074] Collect polarization parallel and polarization perpendicular images of standard dairy product samples;
[0075] Calculate the contrast between the mold region and the background in the difference image under different k values;
[0076] The k value corresponding to the maximum contrast is selected as the adjustment coefficient.
[0077] The training method for the domain adaptation module includes:
[0078] Collect mold sample images of various dairy products and construct a training set containing different domains (dairy product types);
[0079] During the training of the main network, the domain classification loss is backpropagated to the encoder through a gradient inversion layer;
[0080] This allows the encoder to learn both mold segmentation features and domain-invariant features simultaneously, improving the model's generalization ability on unknown dairy product types.
[0081] The process includes the following steps before generating the mold detection report:
[0082] The number and area of mold are judged by threshold. When the threshold is exceeded, the dairy product is marked as unqualified.
[0083] Record the testing time, dairy product number, and testing results, and link them to the cloud-based quality traceability system.
[0084] An electronic device includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements the detection method as described above.
[0085] A computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device on which the computer-readable storage medium is located to perform the detection method described above.
[0086] The hardware layer includes:
[0087] The polarization imaging unit consists of a high-stability surface light source, a polarizer, an analyzer, and a microscopic imaging component. The light source uses a continuous-spectrum LED, with high-level control over luminous uniformity to ensure stable illumination in the imaging area. The polarizer is a broadband linear polarizer fixed at the light source's output port, which can convert natural light into linearly polarized light. The analyzer is a polarizer of the same type, installed at the front of the camera lens, and driven by a stepper motor to achieve 0-180° rotation, with adjustment precision reaching the sub-micrometer level. The camera uses an industrial-grade CMOS sensor, with resolution meeting the requirements for capturing micron-level details. The lens integrates a low-magnification microscopic optical system, and the working distance is suitable for dairy product testing scenarios, clearly presenting the microscopic structure of hyphae and spores.
[0088] The sample processing unit includes an electric translation stage and an adaptive fixture. The translation stage has a stroke that covers common dairy product sizes and its positioning accuracy meets the testing requirements. It can achieve multi-directional scanning of samples through program control. The fixture is made of flexible material and can adapt to dairy products of different shapes, such as block cheese and cream butter, to avoid deformation of the sample surface due to pressure.
[0089] The computing and control unit is equipped with a processor and a graphics acceleration module, which has parallel computing capabilities and can run image processing and neural network inference algorithms in real time. The control module communicates with each hardware unit through the IO interface to realize the timing control of actions such as polarizer switching, image acquisition, and platform movement, with response latency controlled in the millisecond level.
[0090] The data transmission unit integrates wired and wireless communication modules, supporting real-time uploading of detection data to the cloud platform, while also having a local caching function to ensure data integrity.
[0091] The algorithm layer includes:
[0092] The polarization difference algorithm is based on the difference in polarization characteristics between specular reflection and diffuse reflection. It calculates the difference results from two images with different polarization directions, effectively suppressing the reflection interference formed by oil and water on the surface of dairy products.
[0093] The dual-domain adaptive network uses a lightweight encoder-decoder structure for the main path to segment suspected moldy areas; the auxiliary path is a classification network to perform secondary discrimination on suspected areas; the network embeds a domain adaptive module to improve the generalization ability across dairy product types.
[0094] The post-processing algorithm includes connected component analysis, area calculation, and quality judgment modules, which realize the quantitative statistics of mold quantity and area, and judge the product quality based on preset thresholds.
[0095] The application layer includes:
[0096] The testing management software provides a visual user interface, supports testing parameter configuration, process monitoring and result display, and has log recording and fault alarm functions.
[0097] The cloud-based traceability system stores testing data and product information, supports multi-dimensional queries and statistical analysis, and provides data support for production quality control.
[0098] System calibration includes:
[0099] Optical calibration uses a standard reflector and polarization calibrator to adjust the initial angles of the polarizer and analyzer to ensure that the polarization direction deviation is controlled within a very small range; the camera response curve is calibrated using a grayscale card to eliminate image grayscale deviation caused by uneven illumination; the focal length of the microscope head is adjusted to make the 200-500μm standard resolution plate pattern clearly distinguishable, ensuring the imaging quality of the microscopic features of mold.
[0100] The algorithm calibration selects standard samples of three typical dairy products (hard cheese, soft cheese, and fermented milk). Each sample includes positive samples with known mold concentration and negative samples without mold. The adjustment coefficient k of the polarization difference algorithm is calibrated by positive samples to achieve the best contrast between the mold area and the background. The network threshold parameters are optimized by using negative samples to reduce the false positive rate.
[0101] Sample preparation includes:
[0102] Samples are randomly selected from the batch to be tested, and the number of samples must meet statistical requirements to ensure the representativeness of the test results. The sample surface must be kept in its original state to avoid contamination or damage caused by human touch.
[0103] For dairy products with packaging, testing should be conducted immediately after removing the packaging to prevent environmental interference caused by prolonged exposure. For irregular samples, they should be fixed in a stable position using clamps to ensure complete imaging of the testing area.
[0104] Parameter configuration includes:
[0105] The imaging parameters are set according to the type of dairy product, including camera exposure time and gain, to ensure that the grayscale values of the image are distributed within a reasonable range and that there are no overexposed or underexposed areas. The polarizer switching interval is set to a fixed value to ensure that the acquisition conditions of the two polarized images are consistent.
[0106] The algorithm parameters are loaded with preset adjustment coefficients k for different dairy products; the confidence threshold for network inference is set, and the main path segmentation threshold and auxiliary path classification threshold are determined based on the previous calibration results; the mold quantity and area thresholds for quality judgment are configured, and the thresholds for different types of dairy products are set differently.
[0107] In practical implementation, taking the detection of hard cheese as an example, the cheese sample is placed on the sample stage, the software automatically identifies the sample edge, and controls the translation stage to move the detection area to the center of the field of view; the sample surface height is measured by the laser focusing system, and the lens focal length is adjusted to a clear imaging state.
[0108] The analyzer is rotated to a position parallel to the polarizer, and the camera acquires the first polarization image I. parallel At this point, the specular reflection component in the image is relatively strong; then the analyzer is rotated to a vertical position, and a second polarization image I is acquired. perpendicular At this point, the specular reflection component is significantly suppressed; during the two acquisition processes, the light source brightness and camera parameters remain unchanged to ensure the comparability of the images.
[0109] The original RGB image of the sample surface is acquired synchronously for classification and discrimination of the auxiliary network. The image resolution is consistent with that of the polarization image, and the acquisition area completely overlaps.
[0110] Polarization difference image generation involves denoising the acquired polarization images using an adaptive median filtering algorithm to remove random noise while preserving mold edge features. Histogram equalization is used to enhance image contrast and improve detail in low-light areas.
[0111] Call the preset adjustment coefficient k (the k value for hard cheese is determined through calibration), and follow formula I. diff =I perpendicular -k×I parallel The difference image is calculated, during which the gray values of the specular reflection area are significantly reduced, while the diffuse reflection characteristics of the mold are preserved, forming a high-contrast target area.
[0112] Multi-scale edge enhancement processing is performed on the difference image. Gaussian pyramid decomposition technology is used to enhance the edge information of mold hyphae at different scales to ensure that micron-level features are not masked by noise.
[0113] For main path segmentation, the polarization difference image is input into the main path network (an improved lightweight encoder-decoder). The network first extracts low-level features of the image, such as texture and edges, through convolutional layers, and then compresses the spatial dimension through pooling operations. The domain adaptation module embedded in the encoder backpropagates the domain classification loss through a gradient inversion layer, enabling the network to learn mold features while weakening the differences in matrices of different dairy products. The decoder fuses multi-level features through upsampling and skip connections, outputting a pixel-level segmentation mask to mark all suspected mold areas.
[0114] The auxiliary network classifies suspected regions by cropping image blocks from the original RGB image based on the segmentation mask output by the main network. Each image block contains the complete suspected target and a small amount of surrounding background. The image blocks are input into the auxiliary network (small classification network). The network extracts color and texture features through convolutional layers and outputs classification probabilities through fully connected layers to determine whether the region is mold or an inherent structure of cheese, such as calcium crystals or fermentation bubbles.
[0115] The areas on the auxiliary road identified as having mold were marked as valid areas, and the misidentified inherent structural areas were removed to form the final mold area confirmation result.
[0116] The effective mold region is labeled with 8-neighbor connected components, and each independent connected component is regarded as a mold community. Morphological operations are used to remove noise regions with too small an area (regions smaller than the set number of pixels) to ensure the accuracy of the statistical results.
[0117] Based on the pixel-to-actual-size mapping relationship calibrated by the camera (the actual size corresponding to each pixel is determined by calibration), the actual area of each connected region is calculated; the areas of all effective regions are summed to obtain the total area covered by mold.
[0118] The number of mold communities and the total area are compared with preset thresholds. If neither exceeds the threshold, it is considered qualified; if either exceeds the threshold, it is considered unqualified. The judgment results and key parameters, such as the maximum community area and the percentage of the total area, are recorded.
[0119] The system automatically generates a report containing sample information, testing parameters, mold quantity and area, and judgment results. The report includes thumbnails of the original image and segmentation results for easy manual review. The system links the test report, original image, product number, test time, and other information and uploads them to the cloud traceability system. The system encrypts and stores the data and supports queries by batch, time, product type, and other dimensions.
[0120] The testing environment must be kept clean and dry to prevent dust and moisture in the air from contaminating the sample surface or affecting the optical system; the equipment needs to be maintained regularly, and the polarizer surface needs to be cleaned regularly to prevent stains from affecting the polarization effect; the lens must be protected from collisions and scratches to ensure stable image quality; when the type of dairy product in the testing batch is changed, the corresponding algorithm parameters must be reloaded, and calibration verification should be performed if necessary to avoid detection errors caused by parameter mismatch; the testing data must be backed up regularly to ensure the integrity and security of the traceability system; for non-conforming products, the quality early warning process must be triggered to trace the production process in a timely manner and take corrective measures.
[0121] The same or similar labels correspond to the same or similar parts;
[0122] The terms used to describe positional relationships in the accompanying drawings are for illustrative purposes only and should not be construed as limiting this patent.
[0123] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the implementation of the present invention. For those skilled in the art, other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively list all implementation methods here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the claims of the present invention.
Claims
1. An automatic detection method of the number of mold on the surface of dairy products based on image recognition, characterized in that, Includes the following steps: In each detection cycle, a polarization difference image and an original RGB image of the surface of the dairy product to be detected are acquired; wherein the polarization difference image is generated by a mathematical model of polarization difference imaging, including the difference result of a first image imaged parallel to the polarization direction and a second image imaged perpendicular to the polarization direction; The polarization difference image is input into the main network of the dual-path adaptive network to obtain the segmentation results of the suspected mold region on the surface of the dairy product. Based on the segmentation results of the suspected mold region, image blocks of the corresponding region are extracted from the original RGB image and input into the auxiliary network of the dual-path adaptive network for classification and discrimination to obtain the mold region confirmation result; Based on the confirmation results of the mold area, the number and area of mold on the surface of the dairy product are counted, and a mold detection report is generated. The main network of the dual-domain adaptive network is a lightweight encoder-decoder network. The step of inputting the polarization difference image into the main network of the dual-domain adaptive network to obtain the segmentation result of the suspected mold region on the surface of the dairy product includes: The main network extracts features from the polarization difference image, compresses the image dimension and extracts multi-level features through the encoder; The decoder upsamples and fuses the extracted multi-level features, and outputs a pixel-level segmentation mask for suspected mold regions; The encoder incorporates a domain adaptation module, which uses a gradient inversion layer and a domain classifier to blur the distribution differences among different dairy product types.
2. The detection method according to claim 1, characterized in that, The process of acquiring the polarization difference image of the surface of the dairy product to be detected includes: The polarizer in front of the light source and the analyzer in front of the camera lens are controlled to acquire a first image Iparallel with parallel polarization direction and a second image Iperpendicular with perpendicular polarization direction in sequence. The polarization difference image is calculated using the image processing unit: Idiff = Iperpendicular - k × Iparallel, where k is the adjustment factor; The polarization difference image is subjected to low-magnification microscopic detail enhancement processing to preserve micron-level mold features.
3. The detection method according to claim 1, characterized in that, The auxiliary network of the dual-domain adaptive network is a classification network. The classification and discrimination performed by the auxiliary network of the dual-domain adaptive network to obtain the mold area confirmation result includes: The auxiliary network extracts features from the captured image patch to determine whether the region is mold or an inherent structure of dairy products. When the judgment result is mold, the area is marked as a valid mold area; when the judgment result is the inherent structure of dairy products, the area is marked as a false alarm area. By summarizing all valid mold areas, the mold area confirmation results are obtained.
4. The detection method according to claim 1, characterized in that, The step of counting the number and area of mold on the surface of dairy products based on the mold area confirmation results includes: Connectivity analysis was performed on the valid mold regions in the mold region confirmation results to determine the number of independent mold communities. The area of each effective mold region is calculated based on the mapping relationship between image pixels and actual size. The total area of mold coverage on the surface of dairy products is obtained by summing the areas of all effective mold-infested regions.
5. The detection method according to claim 2, characterized in that, The method for determining the adjustment coefficient k includes: Collect polarization parallel and polarization perpendicular images of standard dairy product samples; Calculate the contrast between the mold region and the background in the difference image under different k values; The k value corresponding to the maximum contrast is selected as the adjustment coefficient.
6. The detection method according to claim 1, characterized in that, The training method for the domain adaptation module includes: Collect mold sample images of various dairy products and construct a training set containing different domains; During the training of the main network, the domain classification loss is backpropagated to the encoder through a gradient inversion layer; This allows the encoder to learn both mold segmentation features and domain-invariant features simultaneously, improving the model's generalization ability on unknown dairy product types.
7. The detection method according to claim 1, characterized in that, The process includes the following steps before generating the mold detection report: The number and area of mold are judged by threshold. When the threshold is exceeded, the dairy product is marked as unqualified. Record the testing time, dairy product number, and testing results, and link them to the cloud-based quality traceability system.
8. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements the detection method as described in any one of claims 1-7.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device on which the computer-readable storage medium is located to perform the detection method as described in any one of claims 1-7.
Citation Information
Patent Citations
Grain fungal spore intelligent identification method based on microscopic spectrum image acquisition and image processing algorithm
CN113744212A