A method for detecting adulteration of fermented sausages based on microscopic image analysis
By combining optical microscopy imaging technology and image processing algorithms with support vector machines and cluster analysis, the problem of extracting meat fiber and connective tissue features in sausage detection was solved, enabling efficient identification and accurate classification of adulterated fermented sausages and improving the automation and reliability of detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NANTONG HUITEXIANG FOOD CO LTD
- Filing Date
- 2026-03-03
- Publication Date
- 2026-05-15
AI Technical Summary
Existing sausage quality testing methods struggle to accurately capture the characteristics of meat fibers and connective tissue at the microscopic level. In particular, when faced with complex adulterants, the testing efficiency and accuracy drop significantly, making it impossible to effectively distinguish between different meat sources and identify adulterants.
Microscopic images of fermented sausage samples were obtained using optical microscopy imaging technology. Noise was removed by grayscale conversion and Gaussian filtering. Meat fiber regions were extracted using a threshold segmentation algorithm. The connective tissue content was quantified by combining morphological operations. Adulteration components were identified by a support vector machine classification model. Abnormal features of the groups were analyzed by clustering. Finally, an adulteration identification report was generated, and detection parameters were optimized by neural network.
It enables precise analysis of the microstructure of meat products and efficient identification of adulteration types, significantly improving the automation and reliability of detection. It can accurately distinguish between meat fibers and connective tissue, identify adulteration types, and improve detection accuracy.
Smart Images

Figure CN121767360B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of food testing technology, and in particular to a method for detecting adulteration in fermented sausages based on microscopic image analysis. Background Technology
[0002] Fermented sausages, a popular meat product, are directly related to food safety and consumer health. Researching scientific methods to test their quality is crucial not only for ensuring food authenticity but also for maintaining market fairness and consumer trust. Currently, sausage quality testing is a major focus due to frequent adulteration, which severely impacts product quality and industry reputation. Microscopic image analysis-based detection methods, capable of deeply analyzing the microstructure of ingredients, have become a key direction for solving this problem. However, limitations and technical difficulties in existing technologies mean this field still faces numerous challenges and urgently requires innovative breakthroughs. Current sausage quality testing methods largely rely on chemical analysis or sensory evaluation, which have significant limitations in detecting adulteration. Chemical analysis typically quantitatively detects specific components, such as protein or fat content, but struggles to comprehensively capture complex adulteration methods, such as the addition of plant proteins or inferior meats. Sensory evaluation is influenced by subjective factors, lacking objectivity and repeatability. A common problem with these methods is their inability to reveal the true composition of sausages at the microscopic level, especially when facing novel adulterants, where detection efficiency and accuracy significantly decrease. This makes microstructure-based detection methods a research hotspot. At the microscopic level, sausage quality is closely related to the microstructure of meat fibers, fat globules, and additives. The core technical challenge lies in accurately acquiring and analyzing these microstructural features. The diameter distribution and arrangement patterns of meat fibers in sausages vary depending on the meat source; for example, pork and inferior meat show significant differences in muscle fiber thickness and arrangement. However, acquiring high-resolution microscopic images requires complex and expensive imaging techniques, increasing detection costs and operational difficulty. More importantly, even with clear microscopic images, extracting key features from complex image data, such as the diameter distribution of muscle fibers or the content of connective tissue, and converting them into quantifiable indicators remains an unsolved problem. The extraction and comparison of these features directly affect the accuracy of adulteration detection. Therefore, accurately extracting the features of meat fibers and connective tissue from the microscopic images of sausage samples, and using these features to distinguish different meat sources or identify adulterants, has become a key issue in the field of quality inspection. For example, in actual testing, technicians may need to extract microscopic images from sausage samples, only to find that the distribution characteristics of muscle fiber diameters from different meat sources are difficult to clearly distinguish in the images. This is especially true when the sample is mixed with plant protein or inferior meat, as subtle differences in fiber structure are easily masked by background noise. This situation makes it difficult to accurately determine whether adulteration exists, even when using high-resolution microscopic imaging equipment. Furthermore, the quantitative analysis of connective tissue content is also a major challenge, as its uneven distribution and intertwining with meat fibers increase the complexity of feature extraction. These technical difficulties mean that existing detection methods often fail to provide reliable results when faced with complex adulteration scenarios.Therefore, how to accurately extract and quantify the microscopic features of meat fibers and connective tissue based on high-resolution microscopic images, and effectively distinguish adulterated ingredients from pure meat through these features, has become a key issue in the field of fermented sausage quality testing. Summary of the Invention
[0003] This invention provides a method for detecting adulteration in fermented sausages based on microscopic image analysis, mainly comprising:
[0004] By collecting fermented sausage samples and using optical microscopy imaging technology, initial microscopic image data were obtained from the samples, resulting in a raw image set containing the distribution of meat fibers and connective tissue.
[0005] The original image set is subjected to grayscale conversion and edge enhancement processing, and Gaussian filtering is used to remove noise to obtain an enhanced and clear image set for subsequent feature separation.
[0006] Meat fiber regions are extracted from the enhanced clear image set. A threshold segmentation algorithm is used to separate the fiber structure from the background to obtain a fiber region mask and determine the fiber diameter distribution characteristics.
[0007] If the standard deviation of the diameter distribution in the fiber region mask exceeds the preset threshold, it is marked as a potential adulteration region, and the connective tissue boundary is refined through morphological operations to obtain the quantified connective tissue content index.
[0008] A combined vector of quantified connective tissue content index and fiber diameter distribution characteristics is obtained, and a support vector machine classification model is used to classify the vector to determine whether there are adulterants.
[0009] If the classification result is determined to be adulterated, then an abnormal distribution subset is extracted from the combination vector, and the abnormal features of the group are analyzed by clustering to obtain the detailed results of the adulteration type.
[0010] The adulteration type subdivision results are compared and matched with the preset pure meat micro-feature database. Areas with a matching degree lower than the threshold are identified to obtain the final adulteration identification report.
[0011] High-risk feature subsets are extracted from the final adulteration identification report, and detection parameters are adjusted using a neural network optimization model to obtain an optimized microstructure analysis framework, which is used to improve the accuracy of the next detection.
[0012] The technical solutions provided by the embodiments of the present invention may include the following beneficial effects:
[0013] This invention discloses a method for detecting adulteration in fermented sausages based on microscopic image analysis. Addressing the technical challenge of accurately distinguishing meat fibers from connective tissue and identifying adulteration types in traditional meat product adulteration detection, this invention proposes a solution integrating image processing, feature extraction, and intelligent classification. The invention acquires microscopic images of fermented sausage samples using an optical microscope. Grayscale conversion, Gaussian filtering, and edge enhancement are used to generate a clear image set. A threshold segmentation algorithm is used to extract meat fiber regions and generate a mask, analyzing the fiber diameter distribution characteristics. When the standard deviation of the diameter distribution exceeds the standard, potential adulteration areas are marked, and morphological operations are used to refine the connective tissue boundaries and quantify its content. Combining the combined vector of fiber features and connective tissue content, a support vector machine classification model is applied to determine adulteration components. If adulteration is confirmed, cluster analysis is used to further subdivide the adulteration type, and the results are compared with a feature library of pure meat to generate an adulteration identification report. Finally, detection parameters are optimized based on a neural network to improve subsequent detection accuracy. This invention achieves precise analysis of the microstructure of meat products and efficient identification of adulteration types, significantly improving the automation and reliability of the detection process. Attached Figure Description
[0014] Figure 1 This is a flowchart of a method for detecting adulteration in fermented sausages based on microscopic image analysis according to the present invention.
[0015] Figure 2 This is a schematic diagram of a method for detecting adulteration in fermented sausages based on microscopic image analysis according to the present invention.
[0016] Figure 3 This is another schematic diagram of a method for detecting adulteration in fermented sausages based on microscopic image analysis according to the present invention. Detailed Implementation
[0017] The technical solutions of the embodiments of the present invention will be clearly and thoroughly described below with reference to the accompanying drawings. The described embodiments are merely some embodiments of the present invention.
[0018] like Figure 1-3 This embodiment of a method for detecting adulteration in fermented sausages based on microscopic image analysis may specifically include:
[0019] Step S101: By collecting fermented sausage samples and using optical microscopy imaging technology, initial microscopic image data is obtained from the samples to obtain an original image set containing the distribution of meat fibers and connective tissue.
[0020] Uniformly distributed sample slices were obtained from fermented sausages using a sample acquisition device. Optical microscopy was used to obtain a set of microscopic images containing the distribution of meat fibers and connective tissue. Image preprocessing algorithms were employed to denoise and enhance the microscopic image set, resulting in clear images of meat fibers and connective tissue. Image segmentation algorithms, based on grayscale values and edge detection, separated the meat fiber and connective tissue regions from the clear images, yielding segmented tissue structure images. If the pixel proportion of the meat fiber region in the segmented tissue structure image exceeded a preset threshold, a feature extraction algorithm was used to calculate the texture features and distribution density of the meat fibers, resulting in a fiber feature dataset. Based on the fiber feature dataset, a clustering analysis algorithm was used to group the meat fibers according to their distribution density, obtaining fiber distribution classification results. By comparing the fiber distribution classification results with a preset tissue structure template, it was determined whether the tissue structure of the fermented sausage met the standard, resulting in a structural consistency judgment result. Based on the structural consistency judgment result, data storage technology was used to save the fiber feature dataset and consistency judgment result to a database, generating tissue structure analysis data.
[0021] For example, 0.5 mm thick slices were collected from fermented sausage samples using automated sampling equipment. A high-precision cutter ensured uniform slices. Immediately after slicing, the slices were placed on glass slides and fixed with a fixative (such as 4% formaldehyde solution) for 10 minutes to maintain the integrity of the tissue structure. Next, the samples were imaged using an optical microscope (400x magnification, 0.2 μm / pixel resolution) with an exposure time of 50 ms. Ten images of different regions were acquired, each 2048 × 2048 pixels, generating a raw image set containing the distribution of meat fibers and connective tissue. This set was saved in TIFF format for lossless storage. The image preprocessing stage used a MATLAB-based image processing algorithm. First, the images were converted to grayscale, from RGB images to 8-bit grayscale. Then, Gaussian filtering (standard deviation σ = 1.5) was applied to remove noise and enhance image clarity. Finally, the Otsu thresholding algorithm was used to automatically determine the threshold.
[0022] For example, with a grayscale threshold of 0.4, meat fibers (high grayscale areas) and connective tissue (low grayscale areas) are separated to generate a binarized image. Morphological operations (such as opening operations, with structuring elements of 3×3 pixel rectangles) are then used to remove noise in small areas while preserving the main tissue structure. The analysis process calculates the pixel proportions of meat fibers and connective tissue in the binarized image to determine the fiber area proportion (e.g., 60%) and the connective tissue proportion (e.g., 30%), and combines this with connected component analysis (based on an 8-neighborhood algorithm) to identify the average fiber length.
[0023] To ensure accuracy, cross-validation was employed, statistically averaging the analysis results from 10 images and calculating the standard deviation (e.g., fiber length standard deviation ±10 micrometers). Fiber orientation was analyzed using Fourier transform to obtain the principal orientation angle (e.g., 45° ± 5°). All steps were automated using scripts, and the data was stored in a database and correlated with fermentation process parameters (e.g., fermentation time 48 hours, temperature 25°C), forming a complete technology chain from sampling to analysis, ensuring traceability and reproducibility. The final image set and analysis data can be used for subsequent process optimization, such as adjusting the fermentation time to improve fiber distribution uniformity.
[0024] Step S102: Perform grayscale conversion and edge enhancement processing on the original image set, and use Gaussian filtering to remove noise to obtain an enhanced clear image set for subsequent feature separation.
[0025] The pixel intensity distribution is obtained from the second image set and histogram equalization is applied to obtain the third image set. Texture features are extracted from the third image set, and texture parameters are calculated using the gray-level co-occurrence matrix to generate a texture feature set. If the feature values in the texture feature set exceed a preset threshold, K-means clustering is used to group the features, resulting in feature classification. Based on the feature classification results, a region growing algorithm is used to separate the target region, generating a segmented image set. Morphological features are extracted from the segmented image set and skeletonization is applied to obtain a morphological feature set. If the morphological feature set matches a preset template with a degree higher than a threshold, data storage technology is used to save the morphological feature set to a database, generating a feature analysis dataset. Based on the feature analysis dataset, statistical analysis methods are used to calculate distribution characteristics and determine the final image structure determination result.
[0026] For example, starting with the original image set of fermented sausages, the OpenCV library in Python is used for grayscale conversion, transforming the 2048×2048 pixel RGB images into 8-bit grayscale images using the `cv2.cvtColor` function, preserving pixel values between 0-255 to ensure complete grayscale information. Next, Gaussian filtering is applied to remove noise, with a filter kernel size of 5×5 pixels and a standard deviation σ=2.0. This is then processed using the `cv2.GaussianBlur` function to generate a smooth image set, reducing the interference of random noise on subsequent feature separation. To enhance edge features, the Canny edge detection algorithm is used, setting a low threshold of 50 and a high threshold of 150 to detect edge contours in the grayscale image, generating a binarized image containing meat fibers and connective tissue edges. Edge pixel values are set to 255, and non-edge values to 0. To further improve image clarity, Laplacian sharpening was performed using a 3×3 pixel kernel. The second derivative was calculated using the cv2.Laplacian function to enhance the boundary contrast between fibers and connective tissue, outputting a sharpened image set. All processed images were saved in PNG format to ensure lossless storage. During analysis, the pixel distribution of the edge detection images was calculated, and the proportion of edge pixels to total pixels was statistically analyzed (e.g., 10%). Hough transform was used to identify the linear features of fibers, with an angular resolution of 1° and a minimum detection line length of 100 pixels, yielding the principal direction angle of fiber distribution (e.g., 30°±3°). To ensure the reliability of the results, the edge features of 10 images were statistically analyzed, and the standard deviation of edge density (e.g., ±0.5%) was calculated. The results were correlated with fermentation process parameters (e.g., pH 5.5) and stored in a MySQL database. Data traceability was achieved through automated scripts, ensuring that subsequent feature separation algorithms could directly call upon the enhanced image set.
[0027] Step S103: Extract the meat fiber region from the enhanced clear image set, use a threshold segmentation algorithm to separate the fiber structure from the background, obtain the fiber region mask, and determine the fiber diameter distribution characteristics;
[0028] The specific algorithm is as follows:
[0029]
[0030] Where T(x,y) represents the adaptive threshold, W(x,y) represents the local window centered at (x,y), I(u,v) represents the gray value of the image pixel, and |W| represents the number of pixels in the window, which is used to separate the fiber region from the background to obtain a preliminary fiber region mask;
[0031] Pixel grayscale values are obtained from a set of clear images. An adaptive threshold segmentation algorithm is used to separate the meat fiber region from the background, resulting in a preliminary fiber region mask. Based on the preliminary fiber region mask, morphological closing operations are applied to process the fiber region boundaries to eliminate small-area noise, resulting in an optimized fiber region mask. Fiber diameters are extracted from the optimized fiber region mask, and the width of the fiber region is calculated using Euclidean distance transformation, resulting in a set of fiber diameters.
[0032]
[0033] D(p) represents the fiber diameter, and p represents the number of pixels within the fiber region. This indicates the boundary of the optimized fiber region mask. This represents the Euclidean distance, used to calculate the width of the fiber region to obtain the set of fiber diameters.
[0034] For the fiber diameter set, histogram statistics are used to calculate the diameter distribution characteristics, obtaining fiber diameter distribution parameters. If the fiber diameter distribution parameters match a preset template distribution better than a threshold, principal component analysis is used to extract the main trends in fiber diameter variation, obtaining a fiber diameter feature set. Based on the fiber diameter feature set, the mean-shift algorithm is used to group the fiber diameters, obtaining fiber diameter classification results. From the fiber diameter classification results, the spatial distribution characteristics of fiber regions are extracted, and a grid partitioning method is used to calculate the density distribution of fiber regions, obtaining a spatial feature set of fiber structures.
[0035] For example, starting with an enhanced, clear image set, the Otsu thresholding algorithm is used to automatically determine the optimal threshold, separating the fiber structure from the background and generating a binary mask. The pixel value of the fiber region is set to 255, and the background is set to 0. The image used is a 2048×2048 pixel PNG grayscale image. Otsu segmentation is implemented using the OpenCV function `cv2.threshold`, automatically calculating the threshold (e.g., 180) to ensure maximum contrast between the fiber region and the background. Next, morphological closing operations are performed on the binary mask, using 7×7 pixel elliptical structuring elements. The `cv2.morphologyEx` function is used to eliminate noise in small areas and fill in tiny holes within the fiber region, maintaining the continuity of the fiber structure. Then, the fiber region is extracted based on connected component analysis. The `cv2.connectedComponentsWithStats` function is applied to label each connected component, calculate its area, filter out non-fiber regions with an area less than 500 pixels, retain the main fiber structure, and generate the final fiber region mask. To analyze the fiber diameter distribution characteristics, a distance transformation algorithm is employed. The `cv2.distanceTransform` function calculates the Euclidean distance from each fiber pixel in the mask to its nearest background pixel, yielding a thickness map of the fiber region. The maximum distance value (e.g., 20 pixels) reflects the peak fiber diameter. Further statistical analysis of the diameter distribution is performed, constructing a histogram with a bin width of 2 pixels. The mean (e.g., 15.5 pixels) and standard deviation (e.g., ±2.3 pixels) of the diameter distribution are calculated, and the results are stored in a MySQL database. SQLINSERT statements are used to record the fiber diameter statistics for each image, which are then correlated with fermentation process parameters (e.g., fermentation time of 48 hours) to generate a unique identifier for subsequent traceability. The entire process is automated using a Python script. After processing 10 images, the average standard deviation of the fiber diameter distribution (e.g., ±0.8 pixels) is calculated to ensure the stability of feature extraction. All output masks are saved in PNG format to a specified path.
[0036] Step S104: If the standard deviation of diameter distribution in the fiber region mask exceeds a preset threshold, it is marked as a potential adulteration region, and the connective tissue boundary is refined through morphological operations to obtain the quantified connective tissue content index.
[0037] If the standard deviation of the diameter distribution in the fiber region mask exceeds a preset threshold, a region labeling algorithm is used to identify potential adulterant regions, resulting in a labeled region set. Based on this set, morphological thinning operations are applied to the connective tissue boundaries, yielding a thinned boundary image. Connective tissue regions are extracted from the thinned boundary image, and the connective tissue content is calculated using pixel counting, resulting in content distribution data. Histogram analysis is used to statistically analyze the content distribution characteristics, resulting in a content distribution parameter set. If the mean of the content distribution parameter set deviates from a preset range, a mean-shifting algorithm is used to group the content distribution, resulting in grouped content categories. Based on these grouped content categories, a grid partitioning method is used to calculate the spatial density of the connective tissue regions, resulting in spatial density distribution data. Local density peaks are extracted from the spatial density distribution data, and cluster analysis is used to determine the spatial distribution characteristics of adulterant regions, resulting in a set of adulterant region features.
[0038] For example, starting with a 2048×2048 pixel PNG grayscale image, for the fiber region mask, firstly, a histogram of fiber diameter distribution is generated, with the bin width set to 1.5 pixels. The standard deviation is calculated, assuming a standard deviation of 3.2 pixels, and a preset threshold of 2.5 pixels. Regions exceeding the threshold are marked as potential adulteration regions. The marking process is automated using a Python script, using NumPy's std function to calculate the standard deviation of the diameter distribution, and setting the pixel value of connected components exceeding the threshold to 128 to distinguish normal regions (255) from the background (0). Next, morphological refinement is performed on the regions marked as potential adulteration regions. A 3×3 pixel cross-shaped structuring element is used, and the refinement operation (MORPH_THIN) is performed using OpenCV's cv2.morphologyEx function, iterating 3 times to sharpen the connective tissue boundary, retaining a boundary pixel width of 1 pixel, and generating a refined binary mask. Next, the connective tissue content was quantified based on the refined mask. The `cv2.countNonZero` function was used to count the total number of non-zero pixels in the mask. Assuming a total pixel count of 150,000, combined with the total image area (2048×2048 pixels), the connective tissue percentage was calculated to be 3.58%. To ensure logical rigor, the quantification result was correlated with production batch parameters (e.g., batch number A123, processing temperature 65°C). The percentage data, standard deviation (3.2 pixels), and batch information were stored in a PostgreSQL database using an SQL INSERT statement, generating a unique identifier (e.g., UUID8f7b3a2c). Finally, the refined mask was saved as a PNG file to a specified path, with the filename being a combination of the batch number and timestamp (e.g., A123_20251013). The entire process was executed using a Python automated script. After processing 15 images, the average connective tissue percentage (e.g., 3.62%) was calculated and recorded for subsequent quality traceability.
[0039] Step S105: Obtain the combined vector of the quantified connective tissue content index and fiber diameter distribution characteristics, and use the support vector machine classification model to classify the vector to determine whether there are any adulterants.
[0040] A fiber region mask is obtained, and fiber diameter distribution data is extracted. The mean and variance of the diameter are calculated to obtain a statistical feature set. If the variance of the statistical feature set exceeds a preset threshold, principal component analysis is used to reduce the dimensionality of the diameter distribution data, resulting in a dimensionality-reduced feature vector. The dimensionality-reduced feature vector is then classified using a support vector machine (SVM) classification model to obtain preliminary classification results. Based on the preliminary classification results, regions classified as adulterated are extracted, and the spatial distribution characteristics of fiber diameter within these regions are calculated to obtain a spatial distribution vector. If the local density of the spatial distribution vector exceeds a preset threshold, the mean-shift algorithm is used to cluster the spatial distribution vector, resulting in clustering results.
[0041]
[0042] This represents the update point of the cluster center due to mean drift. Represents the neighborhood points in the spatial distribution vector. K represents the kernel window neighborhood, K represents the kernel function, and h represents the bandwidth parameter, used for clustering and grouping adulterated regions.
[0043] By analyzing the clustering results, the area proportion of each fiber region is calculated to obtain proportion distribution data. Based on this distribution data, histogram analysis is used to statistically analyze the proportion distribution characteristics, providing the final basis for adulteration judgment.
[0044] For example, starting with a 2048×2048 pixel PNG grayscale image, a fiber region mask is first generated. The Otsu thresholding method is used, and the fiber region is automatically segmented using OpenCV's `cv2.threshold` function to obtain a binary mask, where the fiber region pixel value is 255 and the background is 0. Next, the fiber diameter distribution characteristics are calculated. Euclidean distance transform (`cv2.distanceTransform`) is used to determine the distance of each fiber pixel to the nearest background, generating a diameter distribution histogram. The bin width is set to 2.0 pixels, and the skewness of the distribution is calculated (using SciPy's `stats.skew` function). Assuming a skewness of 0.85, it characterizes the asymmetry of the fiber diameter distribution. Simultaneously, connective tissue content indicators are extracted. Connected components are analyzed using the `cv2.connectedComponentsWithStats` function, and the area of each connected component is calculated. Assuming an average area of 12000 pixels, combined with the total image area (2048×2048 pixels), the connective tissue proportion is calculated to be 2.86%. The skewness (0.85), average area (12000 pixels), and connective tissue percentage (2.86%) were used to construct a feature vector, which was then used to construct a 3D vector [0.85, 12000, 2.86] using NumPy's array function. Subsequently, a Support Vector Machine (SVM) classification model was employed, using the SVC class from Scikit-learn (kernel function RBF, C=1.0, gamma=0.1) to classify the feature vector. The training data consisted of 1000 labeled samples (500 normal, 500 adulterated). A classification result of 1 indicated adulteration, and 0 indicated normality; the predicted result was assumed to be 1. The classification results were correlated with production batch parameters (batch number B456, processing humidity 75%). The feature vector, classification results, and batch information were stored in a MySQL database using an SQL INSERT statement, generating a unique identifier (e.g., UUID9c4d5e6f). Finally, the feature vectors and classification results were saved in JSON format to the path / data / B456_20251013.json. An automated script processed 10 images, calculated the average connective tissue percentage to be 2.90%, and stored them in the database to support quality analysis.
[0045] Step S106: If the classification result is determined to be an adulterated component, then extract the abnormal distribution subset from the combination vector, and obtain the adulteration type subdivision result by cluster analysis of the abnormal group characteristics.
[0046] Anomaly subsets are obtained from the combined vector data. Density clustering is used to group these subsets, yielding preliminary grouping results. Based on these preliminary groupings, anomaly feature sets are extracted for each group, and the statistical mean of each feature set is calculated, resulting in feature mean data. If the feature mean data exceeds a preset threshold, principal component analysis is used to reduce the dimensionality of the anomaly feature sets, resulting in dimensionality-reduced feature vectors. Based on these dimensionality-reduced feature vectors, a support vector machine (SVM) classification model is used to classify the vectors, resulting in categorical feature subsets. Spatial distribution characteristics are extracted from these categorical feature subsets, and local density values between characteristics are calculated, resulting in density distribution data. If the local density values of the density distribution data exceed a preset threshold, a mean-shift algorithm is used to perform secondary clustering on the density distribution data, resulting in final adulteration type groupings. Based on these final adulteration type groupings, the proportion of spatial distribution characteristics in each group is statistically analyzed, yielding the adulteration type distribution results.
[0047] For example, after extracting feature vectors from a 2048×2048 pixel PNG grayscale image, if the support vector machine classification result is 1 (indicating adulteration), an anomalous subset is selected from the feature vector set. Assume the feature vectors contain the mean fiber length (e.g., 150.5 pixels), fiber density (e.g., 0.012 fibers / pixel^2), and mean connective tissue strength (e.g., 180.0, based on grayscale value). Using NumPy's `where` function, vectors with a mean fiber length greater than 145 pixels or a fiber density less than 0.015 fibers / pixel^2 are selected, resulting in an anomalous subset; assuming 200 anomalous vectors are selected. Next, the K-means clustering algorithm (using Scikit-learn's `KMeans` class, setting the number of clusters k=3 and the random seed to 42) is used to group the anomalous subset, generating three clusters based on the three-dimensional spatial distance of the feature vectors, each representing a different type of adulteration.
[0048] For example, additive types A, B, and C. After clustering, the coordinates of the center point of each cluster are calculated. Assume the center of cluster 1 is [160.2, 0.010, 185.5], the center of cluster 2 is [148.7, 0.013, 178.2], and the center of cluster 3 is [155.0, 0.009, 190.1]. To determine the adulteration type, a predefined adulteration type mapping table (stored in a MySQL database, table name `adulteration_map`) is used. The cluster centers are matched with the feature ranges in the mapping table using an SQL SELECT statement. Assume cluster 1 corresponds to additive type A (starch-based adulteration, feature range: fiber length > 158, density < 0.011). The clustering results are associated with production batch parameters (batch number C789, processing temperature 22℃) to generate a unique identifier (e.g., UUID 7a8b9c0d), which is then stored in the database table `results_cluster` using an SQL INSERT statement, containing the cluster center, adulteration type, and batch information. Finally, the clustering results are saved in JSON format to the path / data / C789_20251013_cluster.json. An automated script processes the five images, calculates the average fiber density as 0.011 fibers / pixel^2, and stores it in the database to support adulteration traceability analysis.
[0049] Step S107: Compare and match the adulteration type subdivision results with the preset pure meat microscopic feature library, determine the matching degree below the threshold area, and obtain the final adulteration identification report.
[0050] Anomaly subsets are extracted from the adulteration identification data. The cosine similarity method is used to calculate the similarity between these subsets and a pure meat database, yielding similarity distribution data. If the average value of the similarity distribution data is below a preset threshold, the anomalous feature subsets are grouped using k-means clustering, resulting in anomalous feature grouping data. Based on these groupings, the variance of each feature group is calculated, yielding variance distribution data. If the maximum value of the variance distribution data exceeds a preset threshold, principal component analysis is used to reduce the dimensionality of the anomalous feature groupings, yielding dimensionality-reduced feature data. The Manhattan distance between each feature group and the pure meat database is calculated using the dimensionality-reduced feature data, resulting in a distance distribution set. If the mean of the distance distribution set is below a preset threshold, the dimensionality-reduced feature data is classified using a logistic regression model, yielding final adulteration classification data. Based on the final adulteration classification data, the proportion of each type of adulteration feature is statistically analyzed, yielding adulteration feature distribution data.
[0051] For example, a feature vector set extracted from a 2048×2048 pixel PNG grayscale image includes fiber texture complexity (e.g., 0.85, based on the gray-level co-occurrence matrix), mean intercellular space (e.g., 12.3 pixels), and collagen fiber strength (e.g., 175.6, based on grayscale value). First, the feature vector set is compared with a pre-defined pure meat microscopic feature library (stored in a PostgreSQL database, table name `pure_meat_features`). The feature library contains standard value ranges, such as fiber texture complexity 0.90-1.00, intercellular space 10.0-11.5 pixels, and collagen fiber strength 180.0-190.0. Using the `cosine_similarity` function from Python's SciPy library, the cosine similarity between each feature vector and its corresponding standard vector in the feature library is calculated; assuming a similarity of 0.92 for a given vector. A matching threshold of 0.95 is set. If the similarity is lower than 0.95, it is marked as an anomaly, resulting in an anomaly vector set. Assume 150 vectors are selected. Next, based on the anomaly vector set, density clustering is performed using the DBSCAN algorithm (using the DBSCAN class in Scikit-learn, with eps=0.5 and min_samples=5) to generate clusters. Assume two clusters are obtained, with center points [0.83, 12.8, 172.3] and [0.87, 11.9, 178.5], respectively. Using an SQLSELECT statement, the feature range of the cluster centers is matched from the `adulteration_types` table in the database. Assume the first cluster matches protein adulteration (feature range: texture complexity < 0.85, intercellular space > 12.5), and the second cluster matches plant fiber adulteration (feature range: collagen fiber strength < 175.0). The results are associated with the production batch information (batch number D456, processing humidity 65%) to generate a unique identifier (e.g., UUID8e9f0a1b). This identifier is then stored in the database table `adulteration_report` via an SQL INSERT statement, containing cluster centers, adulteration type, and batch information. Finally, the report is saved in JSON format to ` / data / D456_20251013_report.json`. An automated script processes 10 images, calculates an average texture complexity of 0.86, and stores the results in the database to support quality traceability.
[0052] Step S108: Extract a subset of high-risk features from the final adulteration identification report, and use a neural network optimization model to adjust the detection parameters to obtain an optimized microstructure analysis framework, which is used to improve the accuracy of the next detection.
[0053] High-risk feature subsets are extracted from the final adulteration identification report. A convolutional neural network (CNN) model is used for initial classification of these subsets to obtain preliminary classification data. If the confidence level of the preliminary classification data is lower than a preset threshold, a support vector machine (SVM) model is used for secondary classification of the high-risk feature subsets to obtain optimized classification data. Based on the optimized classification data, the microstructure vector representation of each feature subset is calculated to obtain a set of structure vectors. Using the structure vector set, the cosine similarity method is used to calculate the similarity between each vector and a preset pure sample library to obtain similarity distribution data. If the mean of the similarity distribution data is lower than a preset threshold, the structure vector set is restructured to obtain restructured feature data. Based on the restructured feature data, the detection parameters of the CNN are adjusted to obtain an optimized parameter configuration. Using the optimized parameter configuration, the microstructure analysis framework is updated to obtain the final analysis framework data.
[0054] For example, when extracting a high-risk feature subset from an adulteration identification report, the process first uses an SQL SELECT statement to query the report with batch number D789 from the `adulteration_report` table in the database to obtain a JSON file containing anomalous feature vectors. Assuming 200 anomalous vectors are extracted, each vector contains fiber distribution uniformity of 0.78 (based on grayscale gradient statistics), cell boundary sharpness of 15.2 pixels (based on edge detection), and protein density of 160.8 (based on optical density analysis). Next, the Pandas library in Python is used to filter out the high-risk feature subset, setting thresholds: fiber distribution uniformity < 0.80, cell boundary sharpness > 14.5 pixels, and protein density < 165.0, resulting in 80 high-risk vectors. Based on these vectors, a three-layer feedforward neural network was constructed (using the TensorFlow framework, with 128 hidden layer nodes, ReLU activation function, and a learning rate of 0.001). The input was a high-risk feature vector, and the output was the adjusted weights for the detection parameters. After training for 100 epochs, the loss function (mean squared error) converged to 0.015, resulting in an optimized parameter set. For example, the fiber distribution weights were adjusted from 0.5 to 0.62. To generate an optimized microstructure analysis framework, the adjusted parameters were applied to the feature extraction algorithm. The kernel size for grayscale gradient statistics was updated from 5x5 to 7x7, and the Sobel threshold for edge detection was increased from 0.1 to 0.15. For validation, 10 2048×2048 pixel PNG images were processed, and the average fiber distribution uniformity was calculated to be 0.79. Compared with historical data (stored in the PostgreSQL table `historical_features`, with an average value of 0.77), an improvement of 2.6% was confirmed. The optimized framework uses SQLINSERT statements to store new parameters into the database table detection_params, generating a record with UUID 9a2b7f4c, and saving it in JSON format to the path / data / D789_20251013_params.json to support automated invocation and quality traceability for the next detection.
[0055] The above description is merely an example and illustration of the structure of the present invention. Those skilled in the art can make various modifications or additions to the specific embodiments described, or use similar methods to replace them, as long as they do not deviate from the structure of the invention or exceed the scope defined in the claims, all of which should fall within the protection scope of the present invention.
Claims
1. A method for detecting adulteration in fermented sausages based on microscopic image analysis, characterized in that, The method includes: By collecting fermented sausage samples and using optical microscopy imaging technology, initial microscopic image data were obtained from the samples, resulting in a raw image set containing the distribution of meat fibers and connective tissue. The original image set is subjected to grayscale conversion and edge enhancement processing, and Gaussian filtering is used to remove noise to obtain an enhanced and clear image set for subsequent feature separation. Meat fiber regions are extracted from the enhanced clear image set. A threshold segmentation algorithm is used to separate the fiber structure from the background to obtain a fiber region mask and determine the fiber diameter distribution characteristics. The specific algorithm is as follows: ; Where T(x,y) represents the adaptive threshold, W(x,y) represents the local window centered at (x,y), I(u,v) represents the gray value of the image pixel, and |W| represents the number of pixels in the window, which is used to separate the fiber region from the background to obtain a preliminary fiber region mask; This includes: obtaining pixel grayscale values from a set of clear images, using an adaptive threshold segmentation algorithm to separate the meat fiber region from the background, and obtaining a preliminary fiber region mask; Based on the preliminary fiber region mask, morphological closing operations are used to process the fiber region boundaries to eliminate small-area noise and obtain an optimized fiber region mask. The fiber diameters are extracted from the optimized fiber region mask, and the width of the fiber region is calculated using Euclidean distance transformation to obtain the set of fiber diameters. ; D(p) represents the fiber diameter, and p represents the number of pixels within the fiber region. This indicates the boundary of the optimized fiber region mask. Represents the Euclidean distance, used to calculate the width of the fiber region to obtain the set of fiber diameters; Indicates the most recent background pixels; For a set of fiber diameters, the histogram statistical method is used to calculate the diameter distribution characteristics and obtain the fiber diameter distribution parameters. If the standard deviation of the diameter distribution in the fiber region mask exceeds the preset threshold, it is marked as a potential adulteration region, and the connective tissue boundary is refined through morphological operations to obtain the quantified connective tissue content index. A combined vector of quantified connective tissue content index and fiber diameter distribution characteristics is obtained, and a support vector machine classification model is used to classify the vector to determine whether there are adulterants. If the classification result is determined to be adulterated, then an abnormal distribution subset is extracted from the combination vector, and the abnormal features of the group are analyzed by clustering to obtain the detailed results of the adulteration type. The adulteration type subdivision results are compared and matched with the preset pure meat micro-feature database. Areas with a matching degree lower than the threshold are identified to obtain the final adulteration identification report. High-risk feature subsets are extracted from the final adulteration identification report, and detection parameters are adjusted using a neural network optimization model to obtain an optimized microstructure analysis framework, which is used to improve the accuracy of the next detection.
2. The method for detecting adulteration in fermented sausages based on microscopic image analysis according to claim 1, characterized in that, The process involves collecting fermented sausage samples and using optical microscopy imaging technology to obtain initial microscopic image data from the samples, resulting in a raw image set containing the distribution of meat fibers and connective tissue, including: Using a sample collection device, uniformly distributed sample slices were obtained from fermented sausages, and optical microscopy imaging technology was used to obtain a set of microscopic images containing the distribution of meat fibers and connective tissue. Image preprocessing algorithms were used to denoise and enhance the microscopic image set, resulting in clear images of meat fibers and connective tissue. Using an image segmentation algorithm based on grayscale values and edge detection, meat fibers and connective tissue regions are separated from a clear image to obtain a segmented tissue structure image. If the percentage of pixels in the meat fiber region in the segmented tissue structure image exceeds a preset threshold, a feature extraction algorithm is used to calculate the texture features and distribution density of the meat fiber to obtain a fiber feature dataset. Based on the fiber feature dataset, a clustering analysis algorithm was used to group meat fibers according to their distribution density, resulting in fiber distribution classification results. By comparing the fiber distribution classification results with the preset tissue structure template, it is determined whether the tissue structure of the fermented sausage meets the standard, and the structural consistency judgment result is obtained. Based on the structural consistency determination results, data storage technology is used to save the fiber feature dataset and consistency determination results to the database, generating tissue structure analysis data.
3. The method for detecting adulteration in fermented sausages based on microscopic image analysis according to claim 1, characterized in that, The process involves grayscale conversion and edge enhancement of the original image set, followed by Gaussian filtering to remove noise, resulting in an enhanced, clear image set for subsequent feature separation. The pixel intensity distribution is obtained from the second image set, and histogram equalization is applied to obtain the third image set; Texture features are extracted from the third image set, and texture parameters are calculated using the gray-level co-occurrence matrix to generate a texture feature set. If the feature values in the texture feature set exceed the preset threshold, the K-means clustering algorithm is used to group the features to obtain the feature classification results. Based on the feature classification results, the target region is separated using a region growing algorithm to generate a segmented image set; Morphological features are extracted from the segmented image set, and skeletonization is performed to obtain the morphological feature set; If the matching degree between the morphological feature set and the preset template is higher than the threshold, the morphological feature set is saved to the database using data storage technology to generate a feature analysis dataset. Based on the feature analysis dataset, statistical analysis methods are used to calculate the distribution characteristics and determine the final image structure determination result.
4. The method for detecting adulteration in fermented sausages based on microscopic image analysis according to claim 1, characterized in that, The process involves extracting meat fiber regions from the enhanced clear image set, using a threshold segmentation algorithm to separate the fiber structure from the background, obtaining a fiber region mask, and determining the fiber diameter distribution characteristics. If the fiber diameter distribution parameters match the preset template distribution better than the threshold, then principal component analysis is used to extract the main trend of fiber diameter variation and obtain the fiber diameter feature set. Based on the fiber diameter feature set, the fiber diameter is grouped using the mean shift algorithm to obtain the fiber diameter classification results; The spatial distribution characteristics of fiber regions are extracted from the fiber diameter classification results, and the density distribution of fiber regions is calculated using a grid division method to obtain a set of spatial features of fiber structure.
5. The method for detecting adulteration in fermented sausages based on microscopic image analysis according to claim 1, characterized in that, If the standard deviation of the diameter distribution in the fiber region mask exceeds a preset threshold, it is marked as a potential adulteration region. The connective tissue boundary is then refined through morphological operations to obtain a quantified connective tissue content index, including: If the standard deviation of the diameter distribution in the fiber region mask is greater than a preset threshold, the region labeling algorithm is used to identify potential adulterated regions and obtain a set of labeled regions. Based on the marked region set, morphological thinning operations are used to process the connective tissue boundaries to obtain a thinned boundary image; The connective tissue region is extracted from the refined boundary image, and the connective tissue content is calculated using the pixel counting method to obtain the content distribution data; For the content distribution data, histogram analysis was used to statistically analyze the content distribution characteristics and obtain a set of content distribution parameters; If the mean value in the set of content distribution parameters deviates from the preset range, the mean drift algorithm is used to group the content distribution to obtain the content categories after grouping. Based on the content categories after grouping, the spatial density of the connective tissue region is calculated using a grid division method to obtain spatial density distribution data. Local density peaks are extracted from spatial density distribution data, and cluster analysis is used to determine the spatial distribution characteristics of adulterated regions, thus obtaining a set of adulterated region features.
6. The method for detecting adulteration in fermented sausages based on microscopic image analysis according to claim 1, characterized in that, The process involves obtaining a combined vector of quantified connective tissue content indicators and fiber diameter distribution characteristics, and then using a support vector machine classification model to classify the vector to determine whether adulteration exists. This includes: Obtain the fiber region mask, extract fiber diameter distribution data, calculate the diameter mean and variance, and obtain the statistical feature set; If the variance of the statistical feature set exceeds a preset threshold, principal component analysis is used to reduce the dimensionality of the diameter distribution data to obtain the dimensionality-reduced feature vector. The reduced-dimensional feature vectors are classified using a support vector machine classification model to obtain preliminary classification results; Based on the preliminary classification results, regions classified as adulterated are extracted, and the spatial distribution characteristics of fiber diameter within these regions are calculated to obtain the spatial distribution vector. If the local density of the spatial distribution vector exceeds a preset threshold, the mean shift algorithm is used to cluster the spatial distribution vector to obtain the clustering results. ; This represents the update point of the cluster center due to mean drift. Represents the neighborhood points in the spatial distribution vector. K represents the kernel window neighborhood, K represents the kernel function, and h represents the bandwidth parameter, used for clustering and grouping adulterated regions; Based on the clustering results, the area proportion of each fiber region is calculated to obtain the proportion distribution data. Based on the percentage distribution data, histogram analysis is used to statistically analyze the percentage distribution characteristics and obtain the final basis for judging adulteration.
7. The method for detecting adulteration in fermented sausages based on microscopic image analysis according to claim 1, characterized in that, If the classification result determines that it is an adulterated component, then an abnormal distribution subset is extracted from the combination vector, and the abnormal features are grouped through cluster analysis to obtain the adulteration type subdivision result, including: Anomaly subsets are obtained from the combined vector data, and density clustering is used to group the anomaly subsets to obtain preliminary grouping results. Based on the preliminary grouping results, extract the abnormal feature set for each group, calculate the statistical mean of the features for each group, and obtain the feature mean data; If the mean value of the features exceeds the specified range compared to the preset threshold, the dimensionality of the abnormal feature set is reduced by principal component analysis to obtain the dimensionality-reduced feature vector. Based on the dimensionality-reduced feature vectors, a support vector machine classification model is used to classify the vectors, resulting in a subset of classification features. Spatial distribution characteristics are extracted from the subset of classification features, and local density values between characteristics are calculated to obtain density distribution data; If the local density value of the density distribution data exceeds the preset threshold, the density distribution data will be clustered twice using the mean shift algorithm to obtain the final adulteration type group. Based on the final adulteration type grouping, the spatial distribution characteristics of each group are statistically analyzed to obtain the adulteration type distribution results.
8. The method for detecting adulteration in fermented sausages based on microscopic image analysis according to claim 1, characterized in that, The step of comparing and matching the adulteration type subdivision results with a preset pure meat microscopic feature database, determining areas with a matching degree below a threshold, and obtaining a final adulteration identification report includes: An abnormal feature subset is extracted from the adulteration identification data, and the cosine similarity method is used to calculate the similarity between the abnormal feature subset and the pure meat database to obtain similarity distribution data. If the average value of the similarity distribution data is lower than the preset threshold, the abnormal feature subset is grouped by the k-means clustering algorithm to obtain abnormal feature group data. Based on the abnormal features, the data are grouped, and the variance value of each feature group is calculated to obtain the variance distribution data. If the maximum value of the variance distribution data exceeds the preset threshold, principal component analysis is used to reduce the dimensionality of the abnormal feature grouping data to obtain dimensionality-reduced feature data. By using the dimensionality-reduced feature data, the Manhattan distance between each set of features and the pure meat database is calculated to obtain the distance distribution set. If the mean of the distance distribution set is lower than the preset threshold, the dimensionality reduction feature data is classified by a logistic regression model to obtain the final adulterated classification data. Based on the final adulteration classification data, the proportion of each type of adulteration feature is calculated to obtain the adulteration feature distribution data.
9. The method for detecting adulteration in fermented sausages based on microscopic image analysis according to claim 1, characterized in that, The process of extracting a high-risk feature subset from the final adulteration identification report, adjusting detection parameters using a neural network optimization model, and obtaining an optimized microstructure analysis framework to improve the accuracy of subsequent detections includes: High-risk feature subsets are extracted from the final adulteration identification report, and a convolutional neural network model is used to perform initial classification of the feature subsets to obtain preliminary classification data. If the confidence level of the initial classification data is lower than the preset threshold, a support vector machine model is used to perform secondary classification on the high-risk feature subset to obtain optimized classification data. Based on the optimized classification data, the microstructure vector representation of each feature subset is calculated to obtain the structure vector set; By using a set of structural vectors, the cosine similarity method is used to calculate the similarity between each vector and a pre-set pure sample library, thus obtaining similarity distribution data. If the mean of the similarity distribution data is lower than a preset threshold, the structure vector set is reorganized to obtain reorganized feature data. Based on the reconstructed feature data, the detection parameters of the convolutional neural network are adjusted to obtain an optimized parameter configuration; By optimizing the parameter configuration, the microstructure analysis framework is updated to obtain the final analysis framework data.