Method for detecting meat quality edibility based on x-ray image
By preprocessing X-ray images and applying a meat structure segmentation model, the problem of inaccurate meat tissue classification was solved, enabling accurate calculation of meat edibility and improving the accuracy and stability of detection.
Patent Information
- Application Number
- CN202610325518.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-17
- Publication Date
- 2026-06-16
AI Technical Summary
Existing technologies cannot achieve precise pixel-level classification of different meat tissues and are unable to eliminate interference from bone attachment points, resulting in inaccurate identification of edible tissue areas and affecting the accuracy and reliability of edible rate calculation.
An X-ray image-based method for detecting the edible rate of meat is adopted. The method removes noise and enhances the contrast of tissue edges through preprocessing. A pre-trained meat structure segmentation model is used for pixel-level classification to generate masks of bone tissue, muscle tissue and fat tissue. Non-pure muscle areas at bone attachment points are removed, and the edible rate is calculated by combining the edible tissue density threshold.
It achieves precise differentiation of bone, muscle, and adipose tissue, clearly defines tissue range, effectively eliminates interference from bone attachment points, and improves the accuracy and reliability of edible rate calculation, making it suitable for various meat testing scenarios.
Smart Images

Figure CN122222967A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of meat inspection technology, specifically a method for detecting the edible rate of meat quality based on X-ray images. Background Technology
[0002] Edible meat percentage is an important indicator for evaluating meat quality. Currently, the industry mainly uses manual segmentation or conventional image recognition technology to detect edible meat percentage. Manual segmentation requires workers to manually separate bone, muscle, and fat tissues from the meat, and then calculate the edible percentage by weighing. Conventional image recognition technology mostly uses common image segmentation algorithms to segment the X-ray image of the meat as a whole, distinguish between edible and inedible parts, and then calculate the edible percentage.
[0003] Manual segmentation and inspection is inefficient, labor-intensive, and its accuracy is greatly affected by the experience of the staff, making it prone to omissions and missegments, leading to deviations in the calculation of edible rate. Conventional image recognition technology uses general segmentation rules, which cannot accurately identify the specific image features of different tissues in meat, making it difficult to effectively distinguish the boundaries between bone, muscle, and fat tissues. In particular, it cannot identify non-pure muscle areas at bone attachment points, easily including non-pure muscle areas in the edible portion. At the same time, it does not specifically consider the density characteristics of edible tissues, further reducing the accuracy of edible rate detection.
[0004] Existing technologies cannot achieve precise pixel-level classification of different tissues in meat and are unable to eliminate interference from bone attachment points, resulting in inaccurate identification of edible tissue areas. This affects the reliability of edible rate calculation and fails to meet the requirements for precision and efficiency in meat quality testing. Summary of the Invention
[0005] This invention aims to solve at least one of the technical problems existing in the prior art;
[0006] Therefore, this invention proposes a method for detecting the edible rate of meat based on X-ray images, comprising:
[0007] An X-ray transmission image of the target meat is acquired, and the X-ray transmission image is preprocessed to remove image noise caused by X-ray scattering and enhance the edge contrast of bone and muscle tissue to generate a preprocessed X-ray transmission image.
[0008] The pre-trained meat structure segmentation model is used to perform pixel-level classification on the preprocessed X-ray transmission image to generate segmentation results including bone tissue mask, muscle tissue mask and adipose tissue mask. The bone tissue mask is obtained by identifying high-density linear projection features in the X-ray image, the muscle tissue mask is obtained by identifying blocky region features with medium gray values, and the adipose tissue mask is obtained by identifying diffuse texture features in low-density regions.
[0009] Based on the intersection calculation result of the bone tissue mask and the muscle tissue mask, non-pure muscle regions containing bone attachment points in the segmentation result are removed to generate a pure muscle tissue mask;
[0010] Based on the union operation result of the pure muscle tissue mask and the fat tissue mask, and combined with the preset edible tissue density threshold, the edibility rate of the target meat is calculated. The edibility rate is the ratio of the sum of the pixel areas covered by the pure muscle tissue mask and the fat tissue mask to the pixel area of the overall outline of the target meat.
[0011] Furthermore, the X-ray transmission image is preprocessed to remove image noise caused by X-ray scattering and enhance the edge contrast of bone and muscle tissue, including:
[0012] The X-ray transmission image contains bone tissue projection information, muscle tissue grayscale information, and adipose tissue texture information of the target meat.
[0013] The X-ray transmission image is converted into a grayscale histogram distribution map, and low-frequency background peaks caused by scattering noise in the grayscale histogram are identified.
[0014] An adaptive median filtering algorithm is used to suppress the low-frequency background peaks in the grayscale histogram distribution map while preserving high-frequency edge details to generate a denoised grayscale image.
[0015] Gaussian difference edge enhancement processing is performed on the denoised grayscale image. By calculating the second derivative of the grayscale values of adjacent pixels, the grayscale jump amplitude at the junction of bone tissue edge and muscle tissue is amplified.
[0016] The pixel regions with grayscale jump amplitude greater than a preset threshold are marked as candidate edge regions, and the grayscale values of the candidate edge regions are stretched to the full grayscale range to generate a preprocessed X-ray transmission image.
[0017] Furthermore, the step of using an adaptive median filtering algorithm to suppress low-frequency background peaks in the grayscale histogram distribution while preserving high-frequency edge details to generate a denoised grayscale image includes:
[0018] An initial filtering window is constructed with each pixel to be processed in the X-ray transmission image as the center, and the size of the initial filtering window is a preset minimum window size;
[0019] Calculate the median, minimum, and maximum gray levels of all pixels within the initial filtering window;
[0020] Determine whether the gray value of the pixel to be processed is between the minimum and maximum gray values. If yes, proceed to step A; otherwise, proceed to step B.
[0021] Step A: Determine whether the median gray value is between the minimum and maximum gray values. If yes, use the median gray value as the output gray value of the pixel to be processed in the denoised grayscale image. If no, use the original gray value of the pixel to be processed as its output gray value.
[0022] Step B: Increase the size of the filtering window by a preset increment;
[0023] Determine whether the enlarged filter window size exceeds the preset maximum window size. If it does not exceed the maximum window size, repeat the calculation and determination process with the enlarged filter window until the condition of step A is met or the window size exceeds the maximum window size. If the window size exceeds the maximum window size, use the gray median as the output gray value of the pixel to be processed in the denoised grayscale image.
[0024] By traversing all pixels in the X-ray transmission image, the adaptive median filtering process is completed to generate a denoised grayscale image.
[0025] Furthermore, the pre-trained meat structure segmentation model is used to perform pixel-level classification processing on the preprocessed X-ray transmission image to generate segmentation results including bone tissue masks, muscle tissue masks, and adipose tissue masks, including:
[0026] The preprocessed X-ray transmission image is input into the encoder part of the meat structure segmentation model to extract multi-scale feature vectors, which include shallow texture features and deep semantic features.
[0027] The multi-scale feature vectors are input into the decoder part of the meat structure segmentation model. The image resolution is gradually restored through deconvolution operation, and a skip connection mechanism is introduced at each decoding level to fuse the shallow texture features output by the encoder.
[0028] Three independent classification channels are set at the output of the decoder, corresponding to bone tissue, muscle tissue and adipose tissue respectively, and the probability distribution of each pixel belonging to each category is calculated respectively;
[0029] The final category of each pixel is determined based on the maximum value of the probability distribution. Pixels belonging to bone tissue are marked as white to generate the bone tissue mask, pixels belonging to muscle tissue are marked as gray to generate the muscle tissue mask, and pixels belonging to adipose tissue are marked as black to generate the adipose tissue mask.
[0030] Furthermore, three independent classification channels are set at the output of the decoder, corresponding to bone tissue, muscle tissue, and adipose tissue categories, respectively. The probability distribution of each pixel belonging to each category is calculated, including:
[0031] For the classification channel of the bone tissue category, extract the feature channels related to high-density linear structures from the multi-scale feature vector, calculate the response intensity of the feature channels in the image space, and normalize the response intensity into a bone tissue probability value;
[0032] For the classification channel of the muscle tissue category, extract the feature channels related to medium gray block structure in the multi-scale feature vector, calculate the area of the connected region of the feature channel in the image space, and normalize the area of the connected region to the probability value of muscle tissue.
[0033] For the classification channel of the adipose tissue category, extract the feature channels related to low-density diffuse texture from the multi-scale feature vector, calculate the entropy value of the feature channels in the image space, and normalize the entropy value into adipose tissue probability value.
[0034] The probability vector is formed by combining the probability values of bone tissue, muscle tissue, and adipose tissue at the same pixel location to complete the probability distribution calculation for pixel-level classification.
[0035] Further, based on the intersection calculation result of the bone tissue mask and the muscle tissue mask, non-pure muscle regions containing bone attachment points in the segmentation result are removed to generate a pure muscle tissue mask, including:
[0036] The bone tissue mask is subjected to morphological expansion to increase the coverage of the bone tissue so that it includes the connective tissue area around the bone, thereby generating an expanded bone tissue mask.
[0037] The intersection operation of the extended bone tissue mask and the muscle tissue mask is performed to extract the muscle region that overlaps with the extended bone tissue mask and mark it as the bone attachment region.
[0038] The bone attachment area is subtracted from the muscle tissue mask, and the muscle pixels that do not directly contact the bone are retained to generate a preliminary pure muscle tissue mask.
[0039] The preliminary purified muscle tissue mask is then subjected to a pore-filling process to fill the internal voids caused by blood vessels or fascia, thereby generating the final purified muscle tissue mask.
[0040] Furthermore, based on the union operation result of the pure muscle tissue mask and the adipose tissue mask, and combined with a preset edible tissue density threshold, the edibility of the target meat is calculated, including:
[0041] The pure muscle tissue mask and the adipose tissue mask are logically ORed to merge them into a whole edible tissue mask. All regions in the edible tissue mask with non-zero pixel values are defined as edible parts.
[0042] Traverse each pixel in the edible tissue mask and read the gray value of the pixel in the original X-ray transmission image as the density feature value of the pixel;
[0043] The density feature value is compared with the preset edible tissue density threshold, and low-density foreign object areas with gray values lower than the threshold are removed to generate a screened edible tissue mask.
[0044] The total number of pixels contained in the filtered edible tissue mask is counted, and the ratio of the total number of pixels contained in the mask to the total number of pixels contained in the overall outline mask of the target meat is calculated. The ratio is then multiplied by 100% to obtain the edibility of the target meat.
[0045] Further, the density feature value is compared with the preset edible tissue density threshold, and low-density foreign matter regions with gray values below the threshold are removed, including:
[0046] The overall grayscale mean and standard deviation of the original X-ray transmission image are obtained, and the result of subtracting twice the standard deviation from the overall grayscale mean is used as the preset edible tissue density threshold.
[0047] Traverse each pixel in the edible tissue mask. If the gray value of the pixel is less than the preset edible tissue density threshold, then the pixel is determined to belong to a low-density foreign object region.
[0048] All pixels identified as low-density foreign matter areas are marked in the edible tissue mask and their pixel values are set to zero.
[0049] Furthermore, it also includes a step to verify the accuracy of the segmentation results:
[0050] Several regions of interest are extracted from the preprocessed X-ray transmission image. These regions of interest include typical bone tissue intersections, areas with dense muscle texture, and areas with fat interlayers.
[0051] The region of interest is input into the meat structure segmentation model for inference, and the confusion matrix between the segmentation result and the true annotation is obtained.
[0052] The three indicators of bone tissue recall, muscle tissue accuracy, and adipose tissue crossover ratio are calculated based on the confusion matrix.
[0053] If any one of the three indicators is lower than the preset performance threshold, the model retraining process is triggered, and the parameters of the meat structure segmentation model are fine-tuned using labeled samples containing the region of interest until all three indicators meet the preset performance threshold requirements.
[0054] Furthermore, the region of interest is input into the meat structure segmentation model for inference to obtain a confusion matrix between the segmentation result and the true annotation, including:
[0055] A certain number of real labeled samples of known categories are collected to construct a standard dataset. Each sample in the standard dataset contains an X-ray image of the region of interest and its corresponding pixel-level annotations of bone, muscle and adipose tissue.
[0056] The region of interest is paired with samples in the standard dataset and input into the meat structure segmentation model to obtain the predicted segmentation mask;
[0057] The predicted segmentation mask is compared pixel by pixel with the real labeled mask in the standard dataset, and the number of real positives, false positives, real negatives and false negatives are counted.
[0058] The number of true positives, false positives, true negatives, and false negatives are filled into the corresponding cells of the confusion matrix to generate a confusion matrix for evaluating segmentation performance.
[0059] Compared with the prior art, the beneficial effects of the present invention are:
[0060] A pre-trained meat structure segmentation model performs pixel-level classification on pre-processed X-ray transmission images, identifying specific image features for bone, muscle, and adipose tissue. Specifically, it identifies bone tissue using high-density linear projection features and generates a bone tissue mask, identifies muscle tissue using medium-grayscale blocky region features and generates a muscle tissue mask, and identifies adipose tissue using low-density diffuse texture features and generates an adipose tissue mask. This enables accurate differentiation of the three tissues, avoiding the problems of blurred tissue boundaries, misclassification, and omissions caused by conventional general segmentation algorithms. It makes the mask generation for each tissue more targeted, significantly improving the accuracy of tissue segmentation, clearly defining the range of different tissues, and providing accurate basic data for edible rate calculation.
[0061] First, by performing an intersection operation between the bone tissue mask and the muscle tissue mask, non-pure muscle regions containing bone attachment points in the segmentation result are eliminated, generating a pure muscle tissue mask. Then, by performing a union operation between the pure muscle tissue mask and the fat tissue mask, combined with a preset edible tissue density threshold, the edible rate is calculated. That is, the edible rate is obtained by the ratio of the sum of the pixel areas covered by the pure muscle tissue and fat tissue masks to the pixel area of the overall outline of the target meat. This can effectively eliminate the interference of bone attachment points on edible tissue recognition, ensuring the purity of the edible tissue region. At the same time, the edible tissue density threshold is combined to further standardize the judgment criteria of edible tissue, avoiding the result deviation caused by conventional techniques directly using the original muscle and fat masks to calculate the edible rate. This makes the edible rate calculation more in line with the actual edible part, improves the reliability and stability of the detection results, and is suitable for edible rate detection scenarios of various meats. Attached Figure Description
[0062] Figure 1 This is a flowchart illustrating the steps of the meat quality edibility detection method based on X-ray images described in this invention.
[0063] Figure 2 Flowchart for X-ray transmission image preprocessing;
[0064] Figure 3 A flowchart for pixel-level classification using a meat structure segmentation model;
[0065] Figure 4 A graph showing the grayscale distribution and density threshold analysis of X-ray images of pork ribs;
[0066] Figure 5 A comparison of grayscale distribution at each stage of X-ray image preprocessing. Detailed Implementation
[0067] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0068] See Figure 1An X-ray transmission image of the target meat sample is acquired. This image is formed after X-ray equipment penetrates the meat sample, where bone tissue appears as a high-density linear projection, muscle tissue as a blocky region with medium gray values, and adipose tissue as a diffuse texture of low-density regions. The X-ray transmission image is preprocessed to remove image noise caused by X-ray scattering and enhance the edge contrast of bone and muscle tissue, generating a preprocessed X-ray transmission image. A meat structure segmentation model pre-trained on a dataset containing various meat X-ray images and pixel-level annotations is used to perform pixel-level classification on the preprocessed X-ray transmission image. This model outputs three independent binary mask images: a bone tissue mask, a muscle tissue mask, and adipose tissue masks. An intersection operation is performed between the bone tissue mask and the muscle tissue mask to identify non-pure muscle regions in the segmentation result that are directly connected to bones or contain bone attachment points. These regions are then removed from the muscle tissue mask, generating a pure muscle tissue mask. Based on the union operation result of the pure muscle tissue mask and the adipose tissue mask, combined with the preset edible tissue density threshold, the edibility of the target meat is calculated. Specifically, the sum of the pixel areas covered by the pure muscle tissue mask and the adipose tissue mask is calculated, and then the sum is compared with the total pixel area covered by the overall outline of the target meat. The ratio obtained is multiplied by 100% to obtain the final edibility.
[0069] In one embodiment of the present invention, the method for detecting the edible rate of meat based on X-ray images preprocesses the acquired X-ray transmission image of the target meat. Taking pork tenderloin as an example, the X-ray transmission image of pork tenderloin shows high-density linear projection of bone tissue, medium-grayscale blocky areas of muscle tissue, and low-density diffuse texture of adipose tissue. The preprocessing operation removes image noise caused by X-ray scattering and enhances the edge contrast of bone and muscle tissue. For specific implementation details, please refer to... Figure 2The X-ray transmission image of pork tenderloin was converted into a grayscale histogram. The grayscale histogram showed low-frequency background peaks corresponding to scattering noise, while high-frequency components corresponded to tissue edge details. The low-frequency background peaks caused by scattering noise were identified in the grayscale histogram. An adaptive median filtering algorithm was used to suppress the low-frequency background peaks in the grayscale histogram while preserving high-frequency edge details, generating a denoised grayscale image. The adaptive median filtering algorithm constructs an initial filtering window centered on each pixel in the X-ray transmission image. The size of the initial filtering window is set to a minimum window size of three pixels. The median, minimum, and maximum grayscale values of all pixels within the initial filtering window are calculated. The algorithm determines whether the grayscale value of the pixel to be processed is between its minimum and maximum grayscale values. If it is, it further determines whether the median grayscale value is between these values. If the median is between these values, it is used as the output grayscale value of the pixel in the denoised grayscale image. If the median is not between these values, the original grayscale value of the pixel is used as its output grayscale value. If the grayscale value is not between these values, the size of the filtering window is increased by a preset increment, such as two pixels, resulting in a five-by-five pixel size. The algorithm then checks whether the increased window size exceeds a preset maximum window size of seven by seven pixels. If it does not exceed the maximum window size, the algorithm repeats the calculation of the median, minimum, and maximum grayscale values using the increased window size, and continues this process until the output condition is met or the window size exceeds the maximum window size. If the window size exceeds the maximum window size, the median gray value within the current window is used as the output gray value of the pixel to be processed in the denoised grayscale image. Adaptive median filtering is performed on all pixels in the X-ray transmission image to generate a denoised grayscale image. A comparison between the denoised grayscale image and the original image shows that low-frequency background noise is suppressed while tissue edges are preserved.
[0070] In some embodiments, Gaussian difference edge enhancement processing is applied to the denoised grayscale image. This process amplifies the grayscale jump amplitude at the boundary between bone and muscle tissue by calculating the second derivative of the grayscale values of adjacent pixels.
[0071]
[0072] in: This represents the magnitude of the grayscale jump at pixel position (x, y). This represents the grayscale value at pixel location (x, y) in the denoised grayscale image. The symbol * indicates a two-dimensional convolution operation. This represents a Gaussian kernel with a standard deviation of σ1. A Gaussian kernel with a standard deviation of σ² is used, where σ₁ is less than σ² to highlight edge details. The convolution operation is performed in the image spatial domain, and the Gaussian kernel size is set to 5x5 pixels based on the image resolution. Pixel regions with gray-level jumps greater than a preset threshold are marked as candidate edge regions. The preset threshold is set to 20% of the overall gray-level dynamic range based on the overall image gray-level distribution. Candidate edge regions include the boundary between bone and muscle tissue. The gray-level values of the candidate edge regions are stretched to the full gray-level range of 0 to 255 to generate a preprocessed X-ray transmission image. The contrast between bone and muscle tissue edges is significantly improved in the preprocessed X-ray transmission image.
[0073] Optionally, in the adaptive median filtering algorithm, the initial minimum and maximum window sizes are adjusted according to the image noise level. The minimum window size can be set to 3 x 3 pixels, and the maximum window size can be set to 7 x 7 pixels. In some embodiments, the grayscale histogram distribution map is generated using 256 grayscale levels, with low-frequency background peaks corresponding to the range of lower grayscale values. Optionally, the standard deviations σ1 and σ2 in the Gaussian difference edge enhancement processing are preset experimentally, with σ1 being one pixel and σ2 being two pixels. In a specific implementation, a comparison between the denoised grayscale image and the original X-ray transmission image shows that the uniformity of the muscle tissue region is improved, while the contour of the bone tissue is clearer.
[0074] In one embodiment of the present invention, a pre-trained meat structure segmentation model is used to perform pixel-level classification processing on the pre-processed X-ray transmission image. Taking pork tenderloin as an example, the pre-processed X-ray transmission image has an image size of 512 pixels by 512 pixels. The pre-processed X-ray transmission image is input into the encoder part of the meat structure segmentation model. The encoder part consists of 5 convolutional blocks, each containing a convolutional layer, a batch normalization layer, and an activation function. Multi-scale feature vectors are extracted. The multi-scale feature vectors contain shallow texture features and deep semantic features. The shallow texture features correspond to edge and gradient information, while the deep semantic features correspond to an abstract representation of tissue categories. For specific implementation, please refer to [reference needed]. Figure 3 The multi-scale feature vectors are input into the decoder part of the meat structure segmentation model. The decoder part gradually restores the feature map resolution to 512 pixels by 512 pixels through 5 deconvolution operations. After each deconvolution operation, a skip connection mechanism is introduced. The skip connection mechanism performs channel concatenation between the shallow texture features output by the encoder at the corresponding stage and the feature map after upsampling by the decoder, and fuses the shallow texture features output by the encoder to supplement spatial detail information.
[0075] In some embodiments, three independent classification channels are set at the output of the decoder. These three channels correspond to bone tissue, muscle tissue, and adipose tissue categories, respectively. The probability distribution of each pixel belonging to each category is calculated. For the bone tissue classification channel, feature channels related to high-density linear structures are extracted from the multi-scale feature vector. The number of feature channels is 64. The response intensity of these feature channels in the image space is calculated using a 1x1 convolutional layer, and the response intensity is normalized to a bone tissue probability value. For the muscle tissue classification channel, feature channels related to medium-grayscale block structures are extracted from the multi-scale feature vector. The number of feature channels is 64. The connected component area of these feature channels in the image space is calculated. The connected component area is obtained by statistically analyzing continuous regions with pixel values greater than a threshold in each feature map, and the connected component area is normalized to a muscle tissue probability value. For the adipose tissue classification channel, feature channels related to low-density diffuse textures are extracted from the multi-scale feature vector. The number of feature channels is 64. The entropy value of these feature channels in the image space is calculated to quantify texture randomness.
[0076] in: Let N represent the entropy value of feature channel c, and let N represent the number of gray levels in feature channel c. This represents the probability of gray level i appearing, and the entropy value is normalized to the probability value of adipose tissue. It can be understood that the probability values of bone tissue, muscle tissue, and adipose tissue at the same pixel location form a three-dimensional probability vector, completing the probability distribution calculation for pixel-level classification.
[0077] Optionally, the kernel size of the encoder part of the meat structure segmentation model is uniformly 3x3 with a stride of 1, and the kernel size of the deconvolution part of the decoder part is 2x2 with a stride of 2. It can be understood that the skip connection mechanism performs a concatenation operation along the channel dimension, adding the number of channels of the shallow features of the encoder to the number of channels of the current layer features of the decoder. In some embodiments, probability normalization is implemented using the softmax function, transforming the three-dimensional probability vector into three independent class probability values, with the sum of the three probability values being 1. Optionally, the high-density linear structure-related feature channels are automatically learned through the training process and are reflected in the model parameters as a specific weight matrix. In a specific implementation, the final category of each pixel is determined based on the maximum value of the probability distribution. Pixels belonging to bone tissue are marked as white (grayscale value 255) to generate a bone tissue mask; pixels belonging to muscle tissue are marked as gray (grayscale value 128) to generate a muscle tissue mask; and pixels belonging to adipose tissue are marked as black (grayscale value 0) to generate an adipose tissue mask.
[0078] In one embodiment of the present invention, non-pure muscle regions containing bone attachment points in the segmentation result are removed based on the intersection operation result of the bone tissue mask and the muscle tissue mask. The bone tissue mask and the muscle tissue mask are derived from the segmentation result of a pre-trained model of X-ray transmission images of pig rib samples. The two mask images are of the same size and are binary images, where white pixels in the bone tissue mask represent bones and white pixels in the muscle tissue mask represent muscles. Morphological dilation processing is performed on the bone tissue mask. A cross-shaped structuring element with a preset size of 3x3 pixels is used to perform a convolution operation on the bone tissue mask. The center of the structuring element traverses every white pixel in the bone tissue mask, and all background pixels within the coverage area of the structuring element are set to foreground white, thus expanding the coverage area of the bone tissue to include the connective tissue and attachment point areas around the bones, generating an extended bone tissue mask. Compared with the original bone tissue mask, the extended bone tissue mask is uniformly expanded outward by three pixels at each bone contour edge. In practice, the extended bone tissue mask and the muscle tissue mask are logically ANDed, and the values of the corresponding positions of the two masks are compared pixel by pixel. Only when the pixel values of both positions are white, representing the foreground, is white retained in the result. The muscle region that overlaps with the spatial position of the extended bone tissue mask is extracted. This overlapping region is marked as the bone attachment region. The bone attachment region appears as a ring-shaped or sheet-like white region around the edge of the bone in the image.
[0079] In some embodiments, the bone attachment region is subtracted from the muscle tissue mask using logical subtraction. This logical subtraction operation is a pixel-by-pixel comparison. If a pixel in the muscle tissue mask is white and the corresponding pixel in the bone attachment region is black, the result is retained as white. If a pixel in the muscle tissue mask is white and the corresponding pixel in the bone attachment region is also white, the result is set to black, retaining muscle pixels that are not in direct contact with the bone, thus generating a preliminary clean muscle tissue mask. It can be understood that muscle pixels originally adjacent to the bone in the preliminary clean muscle tissue mask are removed, creating a gap between the muscle and bone regions. Optionally, the shape of the structural element used in the morphological dilation process is not limited to a cross shape; square or circular structural elements can also be used. The size of the structural element is adjusted according to the estimated width of the actual bone attachment tissue, with a preset size range from 3x3 pixels to 7x7 pixels. In a specific implementation, the preliminary clean muscle tissue mask undergoes hole-filling processing. The preliminary clean muscle tissue mask is scanned to identify closed white areas completely surrounded by black background pixels, i.e., internal voids. Internal voids are often caused by blood vessels, fascia, or segmentation errors within the muscle. Hole filling follows the region filling logic:
[0080]
[0081] in: This indicates the filling result. This represents a set of seed points within the initial hole. This represents a 3x3 pixel structuring element. The background complement representing the initial purified muscle tissue mask, symbolized by... Represents morphological dilation operation, symbol This represents a logical AND operation. It can be understood that the iterative process starts from a point inside the hole, gradually filling the entire hole region through dilation and intersection with the background complement, ultimately generating a pure muscle tissue mask. The muscle regions in the pure muscle tissue mask are continuous white blocky regions without any black holes inside.
[0082] In one embodiment of the present invention, the edibility of the target meat is calculated based on the union operation result of the pure muscle tissue mask and the adipose tissue mask, combined with a preset edible tissue density threshold. Taking a pork rib sample containing bone, muscle, fat, and a small amount of connective tissue as an example, the pure muscle tissue mask and the adipose tissue mask are generated by the aforementioned steps and are both binary images. White pixels represent the target tissue. A logical OR operation is performed on the pure muscle tissue mask and the adipose tissue mask, comparing the two masks pixel by pixel. If any mask pixel at a corresponding position is white, white is output, and the two masks are merged into a single edible tissue mask. All white areas with non-zero pixel values in the edible tissue mask are defined as edible portions. In a specific implementation, each pixel in the edible tissue mask is traversed, and the grayscale value of the corresponding coordinate point in the original X-ray transmission image of the pork rib sample is read. The grayscale value ranges from zero to 255. This grayscale value serves as the density feature value of the pixel. In the original X-ray transmission image, high grayscale values correspond to high-density tissues such as bone, and low grayscale values correspond to low-density tissues such as fat or cavities.
[0083] In some embodiments, the density feature value is compared with a preset edible tissue density threshold, and low-density foreign matter regions with gray values below the threshold are removed. These low-density foreign matter regions may include a small number of poorly segmented air cavities or extremely low-density connective tissue. The preset edible tissue density threshold is obtained by calculating the overall gray-level mean and standard deviation of the original X-ray transmission image. The gray-level mean represents the average brightness of the image, and the standard deviation represents the dispersion of the gray-level values. The preset edible tissue density threshold is:
[0084]
[0085] in: This indicates the preset threshold for edible tissue density. This represents the overall grayscale mean of the original X-ray transmission image. This represents the overall grayscale standard deviation of the original X-ray transmission image. It can be understood that subtracting twice the standard deviation from the grayscale mean sets the threshold at the low end of the grayscale distribution, filtering out low-density pixels that are significantly deviated from the main tissue. In a specific implementation, each pixel in the edible tissue mask is iterated. If the pixel's grayscale value is less than the preset edible tissue density threshold, the pixel is determined to belong to a low-density foreign object region. If the pixel's grayscale value is greater than or equal to the preset edible tissue density threshold, the pixel is retained as white in the edible tissue mask. All pixels determined to be low-density foreign object regions are marked in the edible tissue mask, and their pixel values are changed from white to zero (black), thereby generating the filtered edible tissue mask. Optionally, the calculation of the grayscale mean and standard deviation is based on all pixels of the entire original X-ray transmission image, without region selection. In some embodiments, the threshold comparison process records the determination of some example pixels in tabular form, see Table 1.
[0086] Table 1: Comparison and Judgment Results of Gray Values of Example Pixels
[0087] Table 1 shows the grayscale values of four pixels at different coordinates, the calculated density thresholds, the comparison results, and the final state in the processed mask. Pixels (150, 300) and (300, 100) were discarded because their grayscale values were below the density thresholds. The total number of pixels contained in the filtered edible tissue mask was counted, and the ratio of the total number of pixels to the total number of pixels contained in the overall contour mask of the target meat was calculated. The overall contour mask of the target meat was a binary mask of the overall shape of the pork rib sample obtained through image segmentation. The ratio was multiplied by 100% to obtain the edibility of the target meat. Optionally, the overall contour mask can be obtained by thresholding or edge detection of the original X-ray image during the preprocessing stage.
[0088] See Figure 4 This is an X-ray image of pork ribs, showing the grayscale distribution and density threshold analysis. It's used to assist in screening for low-density foreign objects during edibility detection. The mean grayscale value is 156.0, representing the average brightness level of the entire X-ray image. The density threshold is 67.5, calculated using the formula: threshold = mean grayscale value - 2 × standard deviation, used to eliminate low-density foreign object areas. High-density areas with grayscale values >200 have fewer pixels and mainly correspond to bone tissue. Low-density areas with grayscale values <67.5 are identified as low-density foreign objects and will be removed from the edible tissue mask. The density threshold of 67.5 filters out the low-end areas of the grayscale distribution, preventing air cavities and extremely low-density connective tissue from being mistakenly identified as edible parts. The mean grayscale value of 156.0 serves as a reference benchmark, helping to distinguish the grayscale ranges of different tissue types. This distribution provides pixel-level screening criteria for subsequent edibility calculations, ensuring the accuracy of edible tissue statistics.
[0089] In one embodiment of the present invention, the method for detecting the edible rate of meat quality based on X-ray images includes a step of verifying the accuracy of the segmentation results. Taking a preprocessed X-ray transmission image of a pork tenderloin sample as an example, the image size is 512 pixels by 512 pixels. Three regions of interest (ROIs) are extracted from the preprocessed X-ray transmission image of the pork tenderloin sample: ROI 1 is a 100-pixel by 100-pixel image block containing typical bone tissue intersections; ROI 2 is a 100-pixel by 100-pixel image block containing areas with dense muscle texture; and ROI 3 is a 100-pixel by 100-pixel image block containing areas with fat interlayers. In a specific implementation, ROI 1, ROI 2, and ROI 3 are input into a meat structure segmentation model for inference to obtain a confusion matrix between the segmentation results and the actual annotations. A standard dataset is constructed by collecting 100 known-category actual annotation samples. Each sample in the standard dataset contains an X-ray image of the ROI and its corresponding pixel-level annotations of bone, muscle, and fat tissues. The pixel-level annotations are generated by professionals manually outlining different tissue boundaries on the image and filling in the corresponding labels.
[0090] In some embodiments, the region of interest (ROI) is paired with samples in a standard dataset based on the similarity of the image content's tissue structure. Five sample images from the standard dataset that intersect with the ROI and contain bone tissue are simultaneously input into the meat structure segmentation model to obtain five sets of predicted segmentation masks. These predicted segmentation masks are essentially binary image sets output by the model after classifying each pixel of the input image. The predicted segmentation masks are then compared pixel-by-pixel with the ground truth labeled masks in the standard dataset. For the bone tissue category, the number of pixels predicted as bone tissue and also labeled as bone tissue are counted as true positives; the number of pixels predicted as bone tissue but labeled as non-bone tissue are counted as false positives; the number of pixels predicted as non-bone tissue but labeled as bone tissue are counted as false negatives; and the number of pixels predicted as non-bone tissue and also labeled as non-bone tissue are counted as true negatives. The number of true positives, false positives, true negatives, and false negatives are then filled into the corresponding cells of the confusion matrix to generate a confusion matrix for evaluating segmentation performance. The rows of the confusion matrix represent the true categories, and the columns represent the predicted categories.
[0091] Optionally, the construction of the standard dataset is independent of the dataset used for model training to ensure the objectivity of the validation. In some embodiments, three metrics—bone tissue recall, muscle tissue accuracy, and adipose tissue intersection-union ratio (IUU)—are calculated based on the confusion matrix. The bone tissue recall is calculated by dividing the number of true positives in bone tissue by the sum of the number of true positives and false negatives in bone tissue. The muscle tissue accuracy is calculated by dividing the sum of the number of true positives and false negatives in muscle tissue by the total number of pixels. The adipose tissue IUU is calculated by dividing the number of true positives in adipose tissue by the sum of the number of true positives, false positives, and false negatives in adipose tissue. The formula for calculating the adipose tissue IUU is:
[0092]
[0093] in: Indicates the crossover ratio of adipose tissue. Indicates the true number of cases of adipose tissue type. This indicates the number of false positives for adipose tissue type. This represents the number of false negatives for the adipose tissue category. The intersection-over-union ratio (IoU) is an important indicator of the accuracy of segmentation region overlap. If any of the three indicators falls below a preset performance threshold (0.85 for bone tissue recall, 0.92 for muscle tissue accuracy, and 0.78 for adipose tissue IoU), a model retraining process is triggered. This involves fine-tuning the parameters of the meat structure segmentation model using labeled samples containing regions of interest (ROIs) 1, 2, and 3. In practice, parameter fine-tuning employs backpropagation and a gradient descent optimizer, continuing training for 50 iterations based on the original model weights until all three indicators—bone tissue recall, muscle tissue accuracy, and adipose tissue IoU—meet the preset performance threshold requirements after re-verification. Optionally, the confusion matrix can be calculated separately for each ROI, and the average of each indicator can be used as the final verification result.
[0094] See Figure 5This is a comparison chart of grayscale distribution at different stages of X-ray image preprocessing, showing the changes in grayscale probability distribution of pork rib X-ray images in the three stages of original → denoising → edge enhancement, intuitively demonstrating the optimization effect of preprocessing on image features. The original image has a scattered grayscale distribution with low and flat peaks, and noise is mixed with effective signals, resulting in weak feature differentiation. After denoising, low-frequency noise is significantly suppressed, the distribution is more concentrated, the main peak is clear, and high-frequency edge details are preserved. After edge enhancement, the grayscale transitions between bone and muscle edges are further amplified on the basis of denoising, the main peak is sharper, and a secondary peak is formed at approximately 200 grayscale values, enhancing the grayscale differences between different tissues. The noise suppression region has grayscale values in the range of 0–90, corresponding to low-frequency background noise generated by X-ray scattering. After adaptive median filtering, the probability in this region is significantly reduced, effectively removing image noise. The edge enhancement region has grayscale values in the range of 180–240. After Gaussian difference edge enhancement, the probability in this region is significantly increased, highlighting high-contrast edge features such as bone tissue.
[0095] The above embodiments are only used to illustrate the technical methods of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical methods of the present invention without departing from the spirit and scope of the technical methods of the present invention.
Claims
1. A method for detecting the edible rate of meat based on X-ray images, characterized in that, The method includes: Obtain an X-ray transmission image of the target meat, preprocess the X-ray transmission image to remove image noise caused by X-ray scattering, and enhance the edge contrast of bone and muscle tissue to generate a preprocessed X-ray transmission image. The pre-trained meat structure segmentation model is used to perform pixel-level classification on the preprocessed X-ray transmission image to generate segmentation results including bone tissue mask, muscle tissue mask and adipose tissue mask. The bone tissue mask is obtained by identifying high-density linear projection features in the X-ray image, the muscle tissue mask is obtained by identifying blocky region features with medium gray values, and the adipose tissue mask is obtained by identifying diffuse texture features in low-density regions. Based on the intersection calculation result of the bone tissue mask and the muscle tissue mask, non-pure muscle regions containing bone attachment points in the segmentation result are removed to generate a pure muscle tissue mask; Based on the union operation result of the pure muscle tissue mask and the fat tissue mask, and combined with the preset edible tissue density threshold, the edibility rate of the target meat is calculated. The edibility rate is the ratio of the sum of the pixel areas covered by the pure muscle tissue mask and the fat tissue mask to the pixel area of the overall outline of the target meat.
2. The method for detecting the edible rate of meat based on X-ray images according to claim 1, characterized in that, The X-ray transmission image is preprocessed to remove image noise caused by X-ray scattering and to enhance the edge contrast of bone and muscle tissue, including: The X-ray transmission image contains bone tissue projection information, muscle tissue grayscale information, and adipose tissue texture information of the target meat. The X-ray transmission image is converted into a grayscale histogram distribution map, and low-frequency background peaks caused by scattering noise in the grayscale histogram are identified. An adaptive median filtering algorithm is used to suppress the low-frequency background peaks in the grayscale histogram distribution map while preserving high-frequency edge details to generate a denoised grayscale image. Gaussian difference edge enhancement processing is performed on the denoised grayscale image. By calculating the second derivative of the grayscale values of adjacent pixels, the grayscale jump amplitude at the junction of bone tissue edge and muscle tissue is amplified. The pixel regions with grayscale jump amplitude greater than a preset threshold are marked as candidate edge regions, and the grayscale values of the candidate edge regions are stretched to the full grayscale range to generate a preprocessed X-ray transmission image.
3. The method for detecting the edible rate of meat based on X-ray images according to claim 2, characterized in that, The process of using an adaptive median filtering algorithm to suppress low-frequency background peaks in the grayscale histogram distribution while preserving high-frequency edge details to generate a denoised grayscale image includes: An initial filtering window is constructed with each pixel to be processed in the X-ray transmission image as the center, and the size of the initial filtering window is a preset minimum window size; Calculate the median, minimum, and maximum gray levels of all pixels within the initial filtering window; Determine whether the gray value of the pixel to be processed is between the minimum and maximum gray values. If yes, proceed to step A; otherwise, proceed to step B. Step A: Determine whether the median gray value is between the minimum and maximum gray values. If yes, use the median gray value as the output gray value of the pixel to be processed in the denoised grayscale image. If no, use the original gray value of the pixel to be processed as its output gray value. Step B: Increase the size of the filtering window by a preset increment; Determine whether the enlarged filter window size exceeds the preset maximum window size. If it does not exceed the maximum window size, repeat the calculation and determination process with the enlarged filter window until the condition of step A is met or the window size exceeds the maximum window size. If the window size exceeds the maximum window size, use the gray median as the output gray value of the pixel to be processed in the denoised grayscale image. By traversing all pixels in the X-ray transmission image, the adaptive median filtering process is completed to generate a denoised grayscale image.
4. The method for detecting the edible rate of meat based on X-ray images according to claim 3, characterized in that, The pre-trained meat structure segmentation model is used to perform pixel-level classification processing on the preprocessed X-ray transmission image to generate segmentation results including bone tissue masks, muscle tissue masks, and adipose tissue masks, including: The preprocessed X-ray transmission image is input into the encoder part of the meat structure segmentation model to extract multi-scale feature vectors, which include shallow texture features and deep semantic features. The multi-scale feature vectors are input into the decoder part of the meat structure segmentation model. The image resolution is gradually restored through deconvolution operation, and a skip connection mechanism is introduced at each decoding level to fuse the shallow texture features output by the encoder. Three independent classification channels are set at the output of the decoder, corresponding to bone tissue, muscle tissue and adipose tissue respectively, and the probability distribution of each pixel belonging to each category is calculated respectively; The final category of each pixel is determined based on the maximum value of the probability distribution. Pixels belonging to bone tissue are marked as white to generate the bone tissue mask, pixels belonging to muscle tissue are marked as gray to generate the muscle tissue mask, and pixels belonging to adipose tissue are marked as black to generate the adipose tissue mask.
5. The method for detecting the edible rate of meat based on X-ray images according to claim 4, characterized in that, Three independent classification channels are set at the output of the decoder, corresponding to bone tissue, muscle tissue, and adipose tissue categories, respectively. The probability distribution of each pixel belonging to each category is calculated, including: For the classification channel of the bone tissue category, extract the feature channels related to high-density linear structures from the multi-scale feature vector, calculate the response intensity of the feature channels in the image space, and normalize the response intensity into a bone tissue probability value; For the classification channel of the muscle tissue category, extract the feature channels related to medium gray block structure in the multi-scale feature vector, calculate the area of the connected region of the feature channel in the image space, and normalize the area of the connected region to the probability value of muscle tissue. For the classification channel of the adipose tissue category, extract the feature channels related to low-density diffuse texture from the multi-scale feature vector, calculate the entropy value of the feature channels in the image space, and normalize the entropy value into adipose tissue probability value. The probability vector is formed by combining the probability values of bone tissue, muscle tissue, and adipose tissue at the same pixel location to complete the probability distribution calculation for pixel-level classification.
6. The method for detecting the edible rate of meat based on X-ray images according to claim 5, characterized in that, Based on the intersection calculation result of the bone tissue mask and the muscle tissue mask, non-pure muscle regions containing bone attachment points in the segmentation result are removed to generate a pure muscle tissue mask, including: The bone tissue mask is subjected to morphological expansion to increase the coverage of the bone tissue so that it includes the connective tissue area around the bone, thereby generating an expanded bone tissue mask. The intersection operation of the extended bone tissue mask and the muscle tissue mask is performed to extract the muscle region that overlaps with the extended bone tissue mask and mark it as the bone attachment region. The bone attachment area is subtracted from the muscle tissue mask, and the muscle pixels that do not directly contact the bone are retained to generate a preliminary pure muscle tissue mask. The preliminary purified muscle tissue mask is then subjected to a pore-filling process to fill the internal voids caused by blood vessels or fascia, thereby generating the final purified muscle tissue mask.
7. The method for detecting the edible rate of meat based on X-ray images according to claim 6, characterized in that, Based on the union of the pure muscle tissue mask and the adipose tissue mask, and combined with a preset edible tissue density threshold, the edibility of the target meat is calculated, including: The pure muscle tissue mask and the adipose tissue mask are logically ORed to merge them into a whole edible tissue mask. All regions in the edible tissue mask with non-zero pixel values are defined as edible parts. Traverse each pixel in the edible tissue mask and read the gray value of the pixel in the original X-ray transmission image as the density feature value of the pixel; The density feature value is compared with the preset edible tissue density threshold, and low-density foreign object areas with gray values lower than the threshold are removed to generate a screened edible tissue mask. The total number of pixels contained in the filtered edible tissue mask is counted, and the ratio of the total number of pixels contained in the mask to the total number of pixels contained in the overall outline mask of the target meat is calculated. The ratio is then multiplied by 100% to obtain the edibility of the target meat.
8. The method for detecting the edible rate of meat based on X-ray images according to claim 7, characterized in that, The density feature value is compared with the preset edible tissue density threshold, and low-density foreign matter regions with gray values below the threshold are removed, including: The overall grayscale mean and standard deviation of the original X-ray transmission image are obtained, and the result of subtracting twice the standard deviation from the overall grayscale mean is used as the preset edible tissue density threshold. Traverse each pixel in the edible tissue mask. If the gray value of the pixel is less than the preset edible tissue density threshold, then the pixel is determined to belong to a low-density foreign object region. All pixels identified as low-density foreign matter areas are marked in the edible tissue mask and their pixel values are set to zero.
9. The method for detecting the edible rate of meat based on X-ray images according to claim 8, characterized in that, It also includes a step to verify the accuracy of the segmentation results: Several regions of interest are extracted from the preprocessed X-ray transmission image. These regions of interest include typical bone tissue intersections, areas with dense muscle texture, and areas with fat interlayers. The region of interest is input into the meat structure segmentation model for inference, and the confusion matrix between the segmentation result and the true annotation is obtained. The three indicators of bone tissue recall, muscle tissue accuracy, and adipose tissue crossover ratio are calculated based on the confusion matrix. If any one of the three indicators is lower than the preset performance threshold, the model retraining process is triggered, and the parameters of the meat structure segmentation model are fine-tuned using labeled samples containing the region of interest until all three indicators meet the preset performance threshold requirements.
10. The method for detecting the edible rate of meat based on X-ray images according to claim 9, characterized in that, The region of interest is input into the meat structure segmentation model for inference, and the confusion matrix between the segmentation result and the true annotation is obtained, including: A certain number of real labeled samples of known categories are collected to construct a standard dataset. Each sample in the standard dataset contains an X-ray image of the region of interest and its corresponding pixel-level annotations of bone, muscle and adipose tissue. The region of interest is paired with samples in the standard dataset and input into the meat structure segmentation model to obtain the predicted segmentation mask; The predicted segmentation mask is compared pixel by pixel with the real labeled mask in the standard dataset, and the number of real positives, false positives, real negatives and false negatives are counted. The number of true positives, false positives, true negatives, and false negatives are filled into the corresponding cells of the confusion matrix to generate a confusion matrix for evaluating segmentation performance.