Image extraction method, meat color recognition model training method and related products
By removing the fascial area in the livestock meat image and training the meat color recognition model, the problem of inaccurate meat color recognition in the prior art is solved, and a more accurate meat color recognition effect is achieved.
Patent Information
- Application Number
- CN202411497747.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2025-02-28
AI Technical Summary
The existing meat color recognition technology in the process of identifying the flesh color in livestock meat is inaccurate due to the existence of fascia, and the trained model cannot accurately recognize the flesh color.
By obtaining the livestock meat image, determining and removing the fascia area in the image, the target livestock meat image is obtained. Then, the flesh color recognition model is trained using the target image, and the Lab color space and specific conditions are used to determine whether the pixel points are located in the fascial region, thereby performing accurate flesh color recognition.
After removing the fascia area, the flesh-colored surface in the livestock meat image is more pure, improving the accuracy of flesh-color recognition, and the trained model is also more accurate in flesh-color recognition.
Smart Images

Figure CN119540943A_ABST
Abstract
Description
Technical Field
[0001] The present invention generally relates to the field of image processing technology. More specifically, the present invention relates to an image extraction method, a meat color recognition model training method, an electronic device, and a non-transitory computer-readable storage medium. Background Art
[0002] In the pork food industry, especially in the field of meat processing and quality control, the meat color (the color characteristics of the meat surface, usually determined by the content and state of myoglobin and other pigments in the muscle) of livestock (such as pork) is an important quality parameter. Meat color not only affects consumers' purchasing decisions, but is also closely related to the quality, freshness and sensory characteristics of meat.
[0003] In current meat color recognition technology, livestock meat usually contains fascia, which makes the results inaccurate when using models to identify its color, and models trained using such images cannot accurately identify meat color.
[0004] In view of this, the present invention aims to provide a method for image extraction, a method for training a meat color recognition model, an electronic device and a non-transitory computer-readable storage medium. When the present solution is used for image extraction, the fascia area in the livestock meat image is removed, so that the meat color surface in the livestock meat target area of the livestock meat image is purer, thereby making its color recognition more accurate, and the result of meat color recognition using the meat color recognition model trained thereby is also more accurate. Summary of the invention
[0005] In order to at least solve one or more of the technical problems mentioned above, the present invention proposes an image extraction method, a meat color recognition model training method, an electronic device and a non-transitory computer-readable storage medium.
[0006] In a first aspect, the present invention provides an image extraction method, comprising: acquiring a livestock meat image, wherein the livestock meat image includes a livestock meat target area; acquiring the value of each RGB channel of each pixel point in the livestock meat target area and the position information of each pixel point; determining the pixel points in the fascia area of the livestock meat target area according to the value of each RGB channel of each pixel point; and removing the fascia area in the livestock meat image according to the position information of each pixel point in the fascia area to obtain a target livestock meat image.
[0007] In some embodiments, determining the pixel points in the fascia area on the livestock meat target area based on the values of the RGB channels of the pixel points includes: converting the values of the RGB channels of the pixel points to the Lab color space to obtain the brightness value and the value of the a channel of each pixel point; and determining whether the pixel points are located in the fascia area based on the values of the RGB channels of the pixel points, the brightness value and the value of the a channel to determine all the pixel points in the fascia area.
[0008] In some embodiments, determining whether each pixel point is located in the fascia area according to the values of each RGB channel, the brightness value, and the value of the a channel of each pixel point includes: determining whether the values of each RGB channel, the brightness value, and the value of the a channel of each pixel point meet the following four conditions:
[0009] The brightness value is less than the first value;
[0010] The value of channel a is greater than the second value;
[0011] The value of the R channel minus the value of the G channel is greater than the third value; and
[0012] The value of the R channel minus the value of the B channel is greater than the fourth value;
[0013] In response to the values of the RGB channels, the brightness value and the value of the a channel of the pixel point not satisfying at least one of the above four conditions, it is determined that the pixel point is located in the fascia area; and in response to the values of the RGB channels, the brightness value and the value of the a channel of the pixel point satisfying the above four conditions, it is determined that the pixel point is not located in the fascia area.
[0014] In some embodiments, the method further comprises: segmenting the livestock meat image by a target segmentation model to obtain a livestock meat target area, wherein the target segmentation model is trained by an integrated model consisting of two image segmentation models.
[0015] In some embodiments, the two image segmentation models include a Segment Anything model and a Yolov5 model, which are integrated using an averaging method to obtain the target segmentation model.
[0016] In a second aspect, the present invention further provides a method for training a meat color recognition model, comprising: obtaining a plurality of livestock meat image samples, wherein each livestock meat image sample is a target livestock meat image obtained by the method described in any one of the embodiments of the first aspect, and includes a livestock meat target area; obtaining an image array of the livestock meat target area of each livestock meat image sample and a meat color score of the livestock meat image sample, wherein the image array includes brightness data, a channel data, and b channel data of the livestock meat target area in a Lab color space; and performing regression model training based on the image arrays of the livestock meat target area of the plurality of livestock meat image samples and the meat color scores of the livestock meat image samples to obtain a livestock meat color scoring model.
[0017] In some embodiments, obtaining an image array of the livestock meat target area of each livestock meat image sample includes: obtaining the brightness value, a channel value, and b channel value of each pixel point of the livestock meat target area of each livestock meat image sample in the Lab color space; and determining the brightness mean, a channel mean, and b channel mean of the livestock meat target area of each livestock meat image sample based on the brightness value, a channel value, and b channel value of each pixel point of the livestock meat target area of each livestock meat image sample in the Lab color space, so as to obtain the brightness data, a channel data, and b channel data of the livestock meat target area of each livestock meat image sample in the Lab color space.
[0018] In some embodiments, the method further includes: inputting the multiple livestock meat image samples into the livestock meat color scoring model to obtain meat color score prediction values of the multiple livestock meat image samples; calculating the loss value using the minimum mean square error loss function based on the meat color score prediction values of the multiple livestock meat image samples and the meat color scores of the multiple livestock meat image samples; and calculating the partial derivative of the loss function to update the parameters of the livestock meat color scoring model to obtain the optimal parameters of the livestock meat color scoring model.
[0019] In a third aspect, the present invention further provides an electronic device, comprising: a processor; and a memory storing program instructions executable by the processor, wherein when the program instructions are executed by the processor, the device executes the image extraction method as described in any embodiment of the first aspect and the meat color recognition model training method as described in any embodiment of the second aspect.
[0020] In a fourth aspect, the present invention further provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions enable the computer to execute the image extraction method as described in any embodiment of the first aspect and the meat color recognition model training method as described in any embodiment of the second aspect.
[0021] By using the above-provided image extraction solution, the fascia region in the livestock meat image is removed, so that the meat color surface in the livestock meat target region of the livestock meat image is purer, thereby obtaining more accurate results when identifying the meat color. In addition, the meat color recognition model trained using such images will also have more accurate results for meat color recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0023] Figure 1 A schematic flow chart showing a method for image extraction according to some embodiments of the present invention is shown;
[0024] Figure 2 A schematic diagram showing an image of livestock meat according to the present invention;
[0025] Figure 3 A comparison diagram of a livestock meat image before the fascia area is removed and a target livestock meat image after the fascia area is removed is shown;
[0026] Figure 4 The network structure diagram of Yolov5 is shown;
[0027] Figure 5 A comparison diagram of livestock meat images before and after the target is extracted is shown;
[0028] Figure 6 A schematic diagram showing a flow chart of a method for training a meat color recognition model according to some embodiments of the present invention;
[0029] Figure 7 A functional block diagram of an electronic device according to some embodiments of the present invention is shown. DETAILED DESCRIPTION
[0030] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0031] It should be understood that the terms "include" and "comprising" used in the description and claims of the present invention indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0032] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the claims, the singular forms of "a", "an" and "the" are intended to include the plural forms unless the context clearly indicates otherwise. It should also be further understood that the term "and / or" used in the specification of the present invention and the claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.
[0033] As used in this specification and claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0034] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0035] Figure 1 A schematic flow chart of an image extraction method 100 according to some embodiments of the present invention is shown.
[0036] like Figure 1 As shown in , method 100 may include, at step S101, obtaining a livestock meat image, wherein the livestock meat image may include a livestock meat target area. The livestock meat image in this embodiment may be obtained by photographing with a high-resolution industrial camera, and environmental changes are avoided during photographing. The lighting selection should try to restore the color of the livestock meat to ensure a clear foreground. Figure 2 The schematic diagram of a livestock meat image of the present invention is shown, wherein the area in the dotted line frame is the livestock meat target area. The livestock in this embodiment may include pigs, sheep, cattle, horses, etc.
[0037] Next, at step S102, method 100 may obtain the values of each RGB channel of each pixel point in the livestock meat target area and the position information of each pixel point. In one embodiment, the position information of the pixel point may include the coordinates of the pixel point, and the coordinates may be, for example, horizontal and vertical coordinates.
[0038] After obtaining the values of the RGB channels of each pixel point in the livestock meat target area, at step S103, the method 100 can determine the pixel points in the fascia area of the livestock meat target area according to the values of the RGB channels of each pixel point.
[0039] In one implementation, the pixel points in the fascia region on the livestock meat target region may be determined by the following method:
[0040] The values of the RGB channels of the above-mentioned pixels are converted to the Lab color space to obtain the brightness value of each pixel and the value of the a channel. The Lab color space, also known as CIE LAB, is a color representation method defined by the International Commission on Illumination (CIE). The color space consists of three components: L: brightness, a: chromaticity component from green to red, and b: chromaticity component from blue to yellow.
[0041] Next, whether each pixel point is located in the fascia area can be determined according to the values of each RGB channel, the brightness value and the value of the a channel of each pixel point, so as to determine all the pixels in the fascia area.
[0042] In one implementation, the following method can be used to determine whether each pixel point is located in the fascia area:
[0043] Determine whether the values of the RGB channels, the brightness value, and the a channel value of each pixel meet the following four conditions:
[0044] The brightness value is less than a first value; in one example, the first value may be 70, for example.
[0045] The value of the a channel is greater than the second value; in one example, the second value may be, for example, zero.
[0046] The value of the R channel minus the value of the G channel is greater than a third value; in one example, the third value may be 20, for example.
[0047] The value of the R channel minus the value of the B channel is greater than a fourth value; in one example, the fourth value may be 20, for example.
[0048] In response to the pixel point's RGB channel values, brightness value, and a channel value not satisfying at least one of the above four conditions, the pixel point is determined to be located in the fascia region. For example, if the pixel point's brightness value is 71, the a channel value is -0.1, the R channel value minus the G channel value is 18, and the R channel value minus the B channel value is 17, the pixel point is considered to be located in the fascia region.
[0049] In response to the values of the RGB channels, the brightness value, and the value of the a channel of the pixel point satisfying the above four conditions, it is determined that the pixel point is not located in the fascia area.
[0050] It can be understood that the specific numerical values of the first value, second value, third value and fourth value listed above are merely illustrative and not restrictive. Those skilled in the art may also select other numerical values as needed, for example, the first value is 65, the second value is 0.1, the third value is 22, the fourth value is 21, etc.
[0051] After determining all the pixels in the fascia region on the livestock meat target region, the method 100 may proceed to step S104, and remove the fascia region from the livestock meat image according to the position information of each pixel in the fascia region to obtain the target livestock meat image. Since the fascia region in the livestock meat image is removed, the meat color surface in the livestock meat target region of the livestock meat image is purer, so that a more accurate result can be obtained when the meat color is recognized.
[0052] Figure 3 A comparison diagram of a livestock meat image before removing the fascia area and a target livestock meat image after removing the fascia area is shown. The left diagram is the livestock meat image before removing the fascia area, and the right diagram is the target livestock meat image after removing the fascia area. The dotted boxes in the two diagrams are the target livestock meat areas. The white thin strip area in the dotted box in the left diagram is the fascia area, and the black thin strip area corresponding to the position of the white thin strip area in the dotted box in the right diagram is the area where the fascia area is removed.
[0053] Traditional meat color detection usually relies on manual visual evaluation or a simple colorimeter (an instrument used to measure the color of an object, usually by capturing light reflection and analyzing its spectral components to determine the color value of the object). By tracing back the RFID (identification) of livestock, the meat color is traced and measured with RFID. These methods have problems such as strong subjectivity, low efficiency, and susceptibility to ambient light, making it difficult to meet the needs of modern large-scale production and refined quality control.
[0054] With the rapid development of deep learning and computer vision technology, automated detection solutions based on image processing and machine learning have gradually become mainstream. By using high-resolution image acquisition equipment and advanced image processing algorithms, it is possible to quickly, accurately and consistently detect the color of livestock meat, which can not only improve production efficiency and reduce labor costs, but also ensure the quality stability of meat products.
[0055] There are already some meat color detection devices based on colorimeters and simple image processing, but these devices often cannot cope with complex actual production environments, such as lighting changes, irregular shapes of meat pieces, different surface humidity, etc. In addition, these devices also have certain limitations in detection accuracy and speed, and it is difficult to meet the needs of large-scale, continuous production lines.
[0056] Therefore, this solution adopts a more superior model to identify meat color. In the process of training the meat color recognition model, it is necessary to first segment the livestock meat targets in the livestock meat image samples. In one embodiment, the livestock meat image can be segmented by a target segmentation model to obtain a livestock meat target area, wherein the target segmentation model can be trained by an integrated model composed of two image segmentation models. In one implementation, the two image segmentation models may include a Segment Anything (visual segmentation large model) model and a Yolov5 model, which can be integrated using an averaging method to obtain a target segmentation model. The Segment Anything model can segment objects other than the background, and the contour edge effect is better. Therefore, determining the segmentation of the meat target based on the intersection of the segmentation contours (masks) of the Segment Anything model and the Yolov5 model can effectively improve the accuracy of the segmentation.
[0057] The following scheme explains the training method of the target segmentation model.
[0058] First, multiple livestock meat image samples are collected. In one embodiment, the livestock meat image samples can be obtained by shooting with a high-resolution industrial camera. When shooting, avoid environmental changes. The lighting selection needs to restore the color of livestock meat as much as possible to ensure a clear foreground. Livestock can include pigs, sheep, cattle, horses, etc. Then, for example, opencv (an open source cross-platform computer vision and machine learning software library) can be used to read each livestock meat image sample, and the values of each RGB channel of each pixel in each livestock meat image sample can be obtained, thereby forming an image array corresponding to each livestock meat image sample. Then, pytorch (an open source deep learning framework) is used to convert each image array into a tensor, and the data is converted into a float32-bit value, and then the data can be sent to the GPU (Graphics Processing Unit) to prepare for the training of the target segmentation model. Before training the target segmentation model, the torchvision module in pytorch can also be called to complete data enhancement operations such as flipping and / or adding noise to the data in each image array, and then the model training can be waited for.
[0059] This embodiment can generate new training samples by randomly transforming, distorting and deforming the original data through data enhancement. The randomness and diversity introduced by data enhancement can effectively reduce the segmentation model's dependence on training data, prevent the model from overfitting on the training set, and improve the performance of the model on the test set. In addition, data enhancement can generate a large number of training samples based on a small amount of labeled data, thereby saving the cost and time of data annotation and speeding up model development and iteration.
[0060] When labeling sample data, this solution can use Segment Anything for interactive data labeling. Segment Anything is a large visual model that can be trained using, for example, one billion masks and ten million images, so it can achieve comparable results for unseen samples. It is understandable that training a flesh-colored segmentation model (the target segmentation model of this solution) requires a large amount of data to label the segmentation contours. This solution uses the Segment Anything model to construct an interactive labeling method. Segment Anything can provide a coarse segmentation mask, which can then be manually modified on this basis, thereby increasing the labeling efficiency several times. The labeling information can include category information about whether the pixel is located in the target area or background area.
[0061] After preparing the training data, you can build the Yolov5 model. Yolov5 is a model based on a single-stage target detection method. It uses a simple and efficient architecture with high accuracy and high inference speed. It is often used in industrial detection due to its good characteristics. Figure 4 The network structure diagram of Yolov5 is shown. As shown in the figure, the network structure of Yolov5 includes three parts: Backbone, Neck and Head. The Backbone network is responsible for extracting features from the input image in Yolov5. It gradually reduces the spatial resolution of the image through a series of convolutional layers and pooling layers, while increasing the number of channels of the feature map to capture the semantic information and spatial hierarchy of the image. The Neck network is located after the Backbone network and is used to further process and enhance the more abstract features extracted from the Backbone network. Its function is to introduce additional contextual information, strengthen the semantic information and spatial resolution of the feature map, and help more accurately locate and classify the target object. The Head network is the last few convolutional layers in Yolov5. It is responsible for generating the final detection box and category prediction. This solution can replace the detection head with the segmentation head to complete the extraction of the flesh-colored face.
[0062] Next, construct a loss function. In this solution, the IOU Loss (intersection-over-union loss function) and the Focal Loss (focal loss function) can be used to construct the loss function. For example, the final loss function can be constructed by adding the two. This loss function can improve the convergence speed during model training, thereby improving the final performance of the model.
[0063] In other embodiments, other loss functions may be used to construct the loss function of the present solution, such as multiple ones of L1loss, L2 loss, cross entropy and Dice Loss, and these loss functions may be added together to construct the loss function of the present embodiment. L1 loss measures the absolute difference between the model prediction value and the true value. It is a loss function used in regression tasks. It is less sensitive to outliers and is therefore more stable during the training process. Similar to L1 loss, L2 loss is also used for regression tasks. It calculates the absolute difference between the predicted value and the true value and is more robust to outliers than the square loss function. Cross entropy is often used in classification problems, especially multi-class classification problems. It measures the difference between the true probability distribution and the predicted probability distribution. Dice Loss is a loss function used in image segmentation tasks, especially in dealing with class imbalance. It measures the similarity between the predicted segmentation mask and the true segmentation mask.
[0064] At this point, the target segmentation model can be trained based on the above training data. This solution can use pytorch as the model training framework, the model can be the aforementioned Yolov5, the initial learning rate can be set to 0.01, the Cosine learning rate decay method can be used, the optimizer can use SGD, the maximum Epoch can be set to 200, the Batch_Size can be set to 64, and the hardware can be Nvidia A100 GPU.
[0065] During model training, the loss function constructed above can be used to optimize the parameters of the segmentation model to obtain the optimal target segmentation model.
[0066] Figure 5 A comparison diagram of livestock meat images before target extraction and livestock meat images after target extraction is shown, wherein the left diagram is the livestock meat image before target extraction, and the right diagram is the livestock meat image after target extraction, wherein the black dotted box is the outline of the extracted target, and the extracted target is within the black dotted box.
[0067] After performing target segmentation and removing the fascia area on the livestock meat image, the present solution can use the livestock meat image processed in this way to train a meat color recognition model. In some embodiments, the meat color recognition model can be a livestock meat color scoring model. The present solution will explain the training method of the livestock meat color scoring model in conjunction with an embodiment below.
[0068] Figure 6 A flowchart of a method 600 for training a meat color recognition model according to some embodiments of the present invention is shown.
[0069] like Figure 6As shown in , method 600 may include obtaining a plurality of livestock meat image samples at step S601. The livestock meat image samples in this embodiment may also be obtained by photographing with a high-resolution industrial camera. When photographing, environmental changes should be avoided. Light selection should restore the color of livestock meat as much as possible to ensure a clear foreground. The livestock in this embodiment may include pigs, sheep, cattle, horses, etc.
[0070] Each of the livestock meat image samples is a target livestock meat image obtained by the method described in any of the above embodiments, and includes a livestock meat target area. Since the meat color surface in the target livestock meat image is relatively pure (the fascia area is removed), the model trained using it will have a more accurate result in meat color recognition.
[0071] Next, the method 600 may proceed to step S602 to obtain an image array of the livestock meat target area of each livestock meat image sample and a meat color score of the livestock meat image sample, wherein the image array may include brightness data, a channel data, and b channel data of the livestock meat target area in the Lab color space. It is understandable that the meat color score of the livestock meat image sample here may be a manual score.
[0072] In some embodiments, acquiring an image array of a livestock meat target area for each livestock meat image sample may include:
[0073] Obtaining the brightness value, a channel value, and b channel value of each pixel point in the livestock meat target area of each livestock meat image sample in the Lab color space; and
[0074] According to the brightness value of each pixel point in the livestock meat target area of each livestock meat image sample in the Lab color space, the value of the a channel and the value of the b channel, the brightness mean, the a channel mean and the b channel mean of the livestock meat target area of each livestock meat image sample are determined to obtain the brightness data, the a channel data and the b channel data of the livestock meat target area of each livestock meat image sample in the Lab color space. That is, the image array corresponding to each livestock meat image sample includes three parameters: the brightness mean, the a channel mean and the b channel mean of the livestock meat target area.
[0075] After obtaining the above training data, method 600 may proceed to step S603 to perform regression model training based on the image array of the livestock meat target area of multiple livestock meat image samples and the meat color scores of the livestock meat image samples to obtain a livestock meat color scoring model.
[0076] In one embodiment, the above training data can be used to fit the linear equation using the linear regression module of sklearn (a popular open source Python library for machine learning that provides simple and efficient tools for data mining and data analysis). The least squares method is used to fit the equation. The fitting equation can be:
[0077] score=w1*l+w2*a+w3*b+w4
[0078] Among them, score is the meat color score, w1, w2, w3, and w4 are the parameters that need to be fitted for the livestock meat color scoring model, l is the brightness data in the image array (such as the brightness mean described above), a is the a channel data (such as the a channel mean described above), and b is the b channel data (such as the b channel mean described above).
[0079] In order to obtain the optimal model, parameter optimization can also be performed, which may include:
[0080] A plurality of livestock meat image samples are input into the livestock meat color scoring model to obtain meat color score prediction values of the plurality of livestock meat image samples.
[0081] Calculating a loss value using a minimum mean square error loss function according to the meat color score prediction values of the multiple livestock meat image samples and the meat color scores of the multiple livestock meat image samples mentioned above; and
[0082] The partial derivative of the loss function is calculated to update the parameters of the livestock meat color scoring model to obtain the optimal parameters of the livestock meat color scoring model.
[0083] This scheme optimizes the equation by minimizing the residual sum of squares between the actual value of the observed data and the model prediction value. It can be confirmed that the parameters when the derivative is 0 are the optimal parameters, thereby determining the final livestock meat color scoring model. For example, w1 is -0.195, w2 is 0.099, w3 is 0, and w4 is 12.33. At this time, the livestock meat color scoring model is
[0084] score=-0.195*l+0.099*a+12.33.
[0085] By optimizing the above parameters, the prediction results of the livestock meat color scoring model determined based on them can be more accurate.
[0086] According to the description of the above embodiments, this solution uses a deep learning algorithm to train the model, so that high-precision automatic detection of livestock meat color can be achieved in complex environments. This solution can not only overcome the limitations of traditional methods, but also has the characteristics of strong adaptability, fast detection speed and high accuracy.
[0087] Figure 7A functional block diagram of an electronic device 700 according to some embodiments of the present invention is shown.
[0088] like Figure 7 As shown in , the electronic device 700 of the present disclosure may include a processor 701 and a memory 702, wherein the processor 701 and the memory 702 communicate with each other via a bus 703. The memory 702 stores program instructions executable by the processor 701, and when the program instructions are executed by the processor 701, the electronic device 700 executes the method steps described above in conjunction with the accompanying drawings.
[0089] When performing image extraction, the electronic device 700 of this solution removes the fascia area in the livestock meat image, so that the meat color surface in the livestock meat target area of the livestock meat image is relatively pure, so that more accurate results can be obtained when performing meat color recognition. When the electronic device 700 performs meat color recognition model training, because the meat color surface in the target livestock meat image used is relatively pure (the fascia area is removed), the trained model will also have more accurate results when performing meat color recognition.
[0090] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a non-transitory computer-readable storage medium, which, when executed, executes the steps including the above method embodiments.
[0091] Although multiple embodiments of the present invention have been shown and described herein, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art may conceive of many changes, modifications, and alternatives without departing from the thought and spirit of the present invention. It should be understood that in the process of practicing the present invention, various alternatives to the embodiments of the present invention described herein may be adopted. The appended claims are intended to define the scope of protection of the present invention, and therefore cover equivalents or alternatives within the scope of these claims.
Claims
1. A method for image extraction, comprising: Acquire a livestock meat image, wherein the livestock meat image includes a livestock meat target area; Obtain the values of each RGB channel of each pixel point in the livestock meat target area and the position information of each pixel point; Determine the pixel points in the fascia area of the livestock meat target area according to the values of each RGB channel of each pixel point; as well as The fascia area is removed from the livestock meat image according to the position information of each pixel point in the fascia area to obtain a target livestock meat image.
2. The method according to claim 1, wherein determining the pixel points in the fascia area on the livestock meat target area according to the values of the RGB channels of the pixel points comprises: Convert the RGB values of each pixel into the Lab color space to obtain the brightness value of each pixel and the value of the a channel; as well as Whether each pixel point is located in the fascia area is determined according to the values of each RGB channel, the brightness value and the value of the a channel of each pixel point, so as to determine all the pixel points in the fascia area.
3. The method according to claim 2, wherein determining whether each pixel point is located in the fascia area according to the values of each RGB channel, the brightness value and the value of the a channel of each pixel point comprises: Determine whether the values of the RGB channels, the brightness value, and the a channel value of each pixel point meet the following four conditions: The brightness value is less than the first value; The value of channel a is greater than the second value; The value of the R channel minus the value of the G channel is greater than the third value; and The value of the R channel minus the value of the B channel is greater than the fourth value; In response to the values of the RGB channels, the brightness value, and the a channel value of the pixel not satisfying at least one of the above four conditions, determining that the pixel is located in the fascia area; as well as In response to the values of the RGB channels, the brightness value, and the value of the a channel of the pixel point satisfying the above four conditions, it is determined that the pixel point is not located in the fascia area.
4. The method according to any one of claims 1 to 3, further comprising: The livestock meat image is segmented by a target segmentation model to obtain a livestock meat target area, wherein the target segmentation model is trained by an integrated model consisting of two image segmentation models.
5. The method according to claim 4, wherein the two image segmentation models include a Segment Anything model and a Yolov5 model, which are integrated using an averaging method to obtain the target segmentation model.
6. A method for training a flesh color recognition model, comprising: Acquire a plurality of livestock meat image samples, wherein each livestock meat image sample is a target livestock meat image obtained by the method according to any one of claims 1 to 5, and includes a livestock meat target area; Obtaining an image array of a livestock meat target area and a meat color score of each livestock meat image sample, wherein the image array includes brightness data, a channel data, and b channel data of the livestock meat target area in a Lab color space; and A regression model is trained based on an image array of a livestock meat target area of a plurality of livestock meat image samples and meat color scores of the livestock meat image samples to obtain a livestock meat color scoring model.
7. The method according to claim 6, wherein acquiring an image array of a livestock meat target area of each livestock meat image sample comprises: Obtain the brightness value, a channel value, and b channel value of each pixel point in the livestock meat target area of each livestock meat image sample in the Lab color space; as well as The brightness mean, a channel mean and b channel mean of the livestock meat target area of each livestock meat image sample are determined according to the brightness value, a channel value and b channel value of each pixel in the livestock meat target area of each livestock meat image sample in the Lab color space to obtain the brightness data, a channel data and b channel data of the livestock meat target area of each livestock meat image sample in the Lab color space.
8. The method according to claim 6 or 7, further comprising: Inputting the plurality of livestock meat image samples into the livestock meat color scoring model to obtain meat color score prediction values of the plurality of livestock meat image samples; Calculating a loss value using a minimum mean square error loss function according to the meat color score prediction values of the multiple livestock meat image samples and the meat color scores of the multiple livestock meat image samples; as well as The partial derivative of the loss function is calculated to update the parameters of the livestock meat color scoring model to obtain the optimal parameters of the livestock meat color scoring model.
9. An electronic device, comprising: processor; as well as A memory storing program instructions executable by a processor, which, when executed by the processor, enables the electronic device to execute the image extraction method described in any one of claims 1 to 5 and the meat color recognition model training method described in any one of claims 6 to 8.
10. A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions enable the computer to execute the image extraction method described in any one of claims 1-5 and the meat color recognition model training method described in any one of claims 6-8.
Citation Information
Cited By
Meat product processing process control method and system
CN121143124A