Pig carcass size measurement method based on image recognition
Through the improved Gaussian filtering and noise reduction algorithm and edge detection algorithm, combined with the minimum external rectangle algorithm, the problem of low measurement accuracy of pig carcass size in the prior art is solved, and higher measurement accuracy and stability are achieved.
Patent Information
- Application Number
- CN202510002029.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-02
- Publication Date
- 2025-02-07
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing deep learning-based pig carcass size measurement methods have low measurement accuracy when facing complex environments and high noise, making it difficult to adapt to diverse and complex environments.
The improved Gaussian filtering and noise reduction algorithm is used to calculate Gaussian weights and grayscale characteristics, and the weights are adaptively allocated to suppress the influence of Gaussian noise. Combined with edge detection and minimum external rectangle algorithm, the size of pig carcass is accurately extracted.
It significantly improves the accuracy and stability of pig carcass size measurement, reduces measurement deviations caused by noise interference, and improves measurement reliability in complex environments.
Smart Images

Figure CN119399255A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image data processing, and more specifically, to a method for measuring pig carcass dimensions based on image recognition. Background Art
[0002] In modern animal husbandry production, the size measurement of pig carcasses is one of the important indicators for evaluating the growth status, production performance and carcass quality of pigs. Traditional size measurement methods mostly rely on manual operations, such as using measuring tools to directly measure the length, width or other key parameters of pig carcasses. This method is not only time-consuming and labor-intensive, but also easily affected by human factors, and the measurement results may have large deviations. In addition, in large-scale pig slaughterhouses or farms, due to the large number of pig carcasses, manual measurement is inefficient and difficult to meet the needs of industrial production. Therefore, it is of great practical significance to seek an efficient, accurate and automated method for measuring the size of pig carcasses.
[0003] In recent years, with the rapid development of computer vision and image processing technology, measurement methods based on image recognition have gradually become a research hotspot. By collecting images of pig carcasses and using image processing technology to identify and analyze the key features of the carcasses, non-contact size measurement can be achieved. This method not only reduces manual intervention and improves efficiency, but also reduces measurement errors, providing reliable data support for large-scale farming. However, existing image recognition technology still faces many challenges in practical applications. For example, there may be complex background noise, uneven lighting or other interference factors in the image, which affects the accurate extraction of the contour of the pig carcass. In addition, the morphology of the pig carcass is complex, and size measurement requires accurate identification of the boundaries and features of key parts, which places high demands on the robustness and accuracy of the image processing algorithm.
[0004] The patent application document with application publication number CN118967771A discloses a method and system for intelligent real-time measurement of carcass length at the slaughter line based on deep learning. The patent application document realizes intelligent real-time measurement of carcass length at the slaughter line by introducing advanced deep learning models and efficient system integration, significantly reducing problems caused by human errors, such as subjective errors of measurement personnel and inconsistent measurement standards.
[0005] However, the above technical solution only measures the pig carcass size based on the existing deep learning model, and does not fully consider the impact of image noise and texture features on the measurement results in specific scenarios. It is difficult to adapt to diverse and complex environments, resulting in low accuracy in measuring the pig carcass size. Summary of the invention
[0006] In order to solve the problem of low precision in measuring pig carcass dimensions raised in the above background technology, the present invention provides solutions in the following aspects.
[0007] The present invention provides a method for measuring the size of a pig carcass based on image recognition, comprising: collecting an image of a pig carcass; eliminating the Gaussian noise of the pig carcass image by using an improved Gaussian filtering denoising algorithm, and extracting the size of the pig carcass after obtaining the image after the Gaussian noise is eliminated; wherein the improved Gaussian filtering denoising algorithm includes Gaussian weights, Gaussian weight of pixels , where For the The noise impact value of each pixel, For the first The pixel point is the center of the setting window. The noise impact value of each pixel, To set the total number of pixels in the window, The natural constant An exponential function with base ; The noise impact value of each pixel , where For the The gray value of a pixel, For the first The grayscale mean of all pixels in the set window centered at a pixel point. For the The grayscale characteristics of each pixel, For the first The pixel point in the setting window The grayscale characteristics of each pixel, is a normalization function; the grayscale characteristic represents the clutter degree of the pixel points.
[0008] The above technical solution significantly improves the accuracy of pig carcass size measurement by introducing an improved Gaussian filter noise reduction algorithm. In the improved algorithm, the pixel processing based on Gaussian weights can adaptively allocate weights, giving pixels with less noise a higher influence, while weakening the interference of pixels with severe noise, thereby effectively suppressing the influence of Gaussian noise; by calculating the noise influence value and grayscale characteristics of each pixel, the grayscale difference and local complexity between the pixel and its neighborhood are fully considered, so that noise suppression and detail retention are dynamically balanced. The details and edge features of the denoised image can be accurately retained, providing a high-quality image foundation for subsequent edge detection and size extraction, improving the accuracy and stability of pig carcass size measurement, and avoiding measurement deviations caused by noise interference.
[0009] Furthermore, the Grayscale characteristics of pixels , where For the first The pixel point is the center of the setting window. The gradient amplitude of each pixel, For the first The grayscale variance of all pixels in the set window centered at a pixel point, Sets the total number of pixels in the window.
[0010] The above technical solution further optimizes detail extraction and noise suppression in images by introducing grayscale characteristic calculation. By comprehensively considering the brightness changes between pixels and local grayscale fluctuations, it can accurately capture structural features such as edges and textures in images, thereby retaining more detail information while removing noise.
[0011] Furthermore, the Grayscale characteristics of pixels , where For the The gray value of a pixel, For the first The pixel point is the center of the setting window. The gray value of a pixel, Sets the total number of pixels in the window.
[0012] The above technical solution can effectively measure the degree of change in the local area of the image by calculating the grayscale difference between each pixel and its neighboring pixels. This method helps to identify the edges and details in the image, so that important structural features can be captured more accurately during the image processing process. By quantifying the grayscale difference, the algorithm can adaptively adjust the image processing strategy to avoid over-smoothing in complex areas, thereby retaining more details.
[0013] Furthermore, the extraction of the size of the pig carcass is specifically as follows: edge detection is performed on the image after Gaussian noise is eliminated to obtain the edge contour of the pig carcass; the edge contour of the pig carcass is fitted using a minimum circumscribed rectangle algorithm, and the length and width of the circumscribed rectangle are determined; and the size of the pig carcass is calculated based on the length and width of the circumscribed rectangle.
[0014] The above technical solution accurately extracts the size of the pig carcass through the combination of edge detection and minimum circumscribed rectangle algorithm, avoiding the contour blur or size estimation deviation that may occur in traditional methods, thereby improving the accuracy and stability of size extraction, especially when dealing with complex shapes and high-noise images, and can significantly improve the reliability of measurement results.
[0015] Furthermore, the edge detection is specifically: Sobel algorithm or Canny algorithm.
[0016] Furthermore, the image of the pig carcass is captured using a CCD camera or a CMOS camera.
[0017] Furthermore, the method also includes grayscale processing of the image of the pig carcass.
[0018] Furthermore, the method also includes performing corrosion and expansion operations on the image after the Gaussian noise is eliminated.
[0019] The above technical solution effectively optimizes the structure and morphology of the image by performing erosion and dilation operations on the image after removing Gaussian noise. The erosion operation helps to remove small noise points and discontinuous edges, enhancing the main structure in the image, while the dilation operation helps to fill the gaps at the edges and strengthen the outline and integrity of the target object. This combined operation can smooth the effects of noise in the image while retaining key information, which is especially important for edge contour extraction and size measurement. Through these morphological operations, the details of the image are clearer, the interference of noise is effectively suppressed, and ultimately the accuracy and robustness of pig carcass size extraction are improved.
[0020] The beneficial effects of the present invention are: The present invention significantly improves the accuracy and robustness of pig carcass size measurement through a series of precise image processing steps. By using a high-precision CCD or CMOS camera to capture images and combining grayscale processing, the complexity and noise interference of the image are effectively reduced, laying the foundation for subsequent processing. By adopting advanced edge detection algorithms, such as the Sobel or Canny algorithm, the edge contour of the pig carcass is accurately extracted to ensure the accuracy of size extraction. Furthermore, the corrosion and expansion operations maintain the integrity of the image while removing noise and enhancing the edges, making the carcass contour clearer and improving the stability and consistency of the measurement results. By fitting the edge contour and calculating the length and width through the minimum circumscribed rectangle algorithm, this method can accurately calculate the size of the pig carcass, reduce the errors in traditional methods, and improve the feasibility and accuracy in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] 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: Figure 1 is a flow chart schematically showing a method for measuring pig carcass size based on image recognition according to an embodiment of the present invention; Figure 2 Schematically shows a grayscale image of a pig carcass according to an embodiment of the present invention. DETAILED DESCRIPTION
[0022] 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.
[0023] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0024] An embodiment of a method for measuring pig carcass dimensions based on image recognition.
[0025] like Figure 1 As shown, a flow chart of a method for measuring pig carcass size based on image recognition according to an embodiment of the present invention comprises the following steps: S1: Collect images of pig carcasses.
[0026] In one embodiment, in order to achieve high-precision and efficient pig carcass detection, a CCD camera or a CMOS camera is first used for image acquisition. With their excellent imaging capabilities, CCD and CMOS cameras can provide high-resolution, high-quality image data under different lighting conditions. These cameras perform well in capturing details and can accurately record the contours, sizes and subtle surface features of pig carcasses, providing rich visual information for subsequent analysis. The acquired images contain a large amount of pixel data, which may contain redundant or unnecessary color information, which may increase the computational burden of subsequent processing and affect the accuracy and efficiency of the detection results.
[0027] Therefore, in order to further optimize the image processing process, the image of the pig carcass is grayed after image acquisition. By converting the color image into a grayscale image, the interference of color information can be effectively eliminated and the brightness distribution of the image can be focused on. Image graying can not only reduce the consumption of computing resources, but also enhance the contrast of the image, making the details, edges and textures of the carcass surface more prominent.
[0028] like Figure 2 As shown, a grayscale image of a pig carcass according to an embodiment of the present invention.
[0029] This series of processing steps combines the camera's high-performance imaging with the image grayscale processing technology, which not only greatly improves the quality of image data, but also provides a clearer and more concise data basis for subsequent image analysis. Through efficient grayscale processing, the subsequent automated analysis system can significantly improve the detection accuracy, processing speed and reliability of pig carcasses, thereby promoting the automation and intelligence of pig carcass detection and segmentation technology, and providing more accurate and efficient solutions for related industries.
[0030] S2: Use the improved Gaussian filter denoising algorithm to eliminate the Gaussian noise of the pig carcass image, and then extract the pig carcass size after obtaining the image after the Gaussian noise is eliminated.
[0031] In one embodiment, in order to achieve accurate extraction of pig carcass size, an improved Gaussian filter noise reduction algorithm is first used to process the pig carcass image to eliminate Gaussian noise in the image. Since the image acquisition process is often disturbed by environmental noise, especially Gaussian noise, it will seriously affect the accuracy of subsequent image analysis, resulting in blurred or distorted edge information. In order to ensure the quality of the image and enhance the effect of subsequent processing, the improved Gaussian filter algorithm can better balance noise suppression and image detail retention.
[0032] The image after Gaussian noise removal is subjected to corrosion and expansion operations, which can effectively improve the image quality and enhance the accuracy of subsequent analysis. The corrosion operation removes small objects or noise points in the image, eliminates the errors caused by noise or discontinuous parts, and further corrects the edge morphology in the image, making the outline of the pig carcass more compact. Especially after Gaussian noise is removed, corrosion can further remove the residual small noise and reduce the interference caused by noise. The expansion operation further expands the target area in the image after corrosion, enhances the coherence of the target object, and makes the edge of the pig carcass clearer and more complete, especially in some areas with blurred edges or breaks. Dilation can fill the blank areas in the image and correct the local area loss caused by noise or noise removal, thereby improving the coherence and recognizability of the target outline.
[0033] After obtaining the image after eliminating Gaussian noise, edge detection is performed next to extract the edge contour of the pig carcass. Edge detection is a key step in image analysis, which can help us accurately identify the contour and shape of an object. In this embodiment, a classic and efficient edge detection algorithm is selected, such as the Sobel algorithm or the Canny algorithm, which can accurately detect the edge of the pig carcass while retaining the image details. After edge detection, the external contour of the pig carcass is clearly presented, which is convenient for further analysis and processing.
[0034] Subsequently, the minimum enclosing rectangle algorithm is used to fit the extracted edge contour to obtain the rectangular frame that best surrounds the carcass contour. The minimum enclosing rectangle algorithm calculates the limit value of the edge points and finds the rectangle that can completely surround the carcass contour, thereby accurately extracting the length and width of the pig carcass. This algorithm has the advantages of high computational efficiency and strong robustness, and can adapt to carcass images of different shapes and sizes to ensure the accuracy of the extraction results.
[0035] Finally, the actual size of the pig carcass is calculated based on the length and width of the circumscribed rectangle. This process converts the pixel size into the actual physical size based on the known information of the image resolution, thereby achieving accurate size measurement. This series of technical processes not only ensures the high quality of image data through efficient noise removal, accurate edge detection and robust fitting algorithms, but also can stably extract the size data of pig carcasses in complex environments, greatly improving the accuracy and reliability of the automated detection system.
[0036] S3: Among them, the improved Gaussian filtering noise reduction algorithm includes Gaussian weights.
[0037] In one embodiment, Gaussian weight of pixels , where For the The noise impact value of each pixel, For the first The pixel point in the setting window The noise impact value of each pixel, To set the total number of pixels in the window, The natural constant An exponential function with base ; By calculating the noise difference between a pixel and its neighboring pixels, a Gaussian weight is assigned to each pixel based on these differences. The Gaussian weight reflects the degree of noise impact, so that pixels with less noise or greater differences are retained first during image processing. This helps to reduce the loss of useful information during the denoising process. The exponential decay characteristics of the Gaussian function make pixels with large noise impact values receive lower weights, while pixels with less noise receive higher weights, thereby reducing the interference of noise on the image and improving image quality.
[0038] No. The noise impact value of each pixel , where For the The gray value of a pixel, For the first The grayscale mean of all pixels in the set window centered at a pixel point. For the The grayscale characteristics of each pixel, For the first The pixel point in the setting window The grayscale characteristics of each pixel, is the normalization function, To set the total number of pixels in the window; By calculating the grayscale difference and grayscale characteristic difference of each pixel, the noise impact value of the pixel is comprehensively obtained. The noise impact value reflects the abnormality of the pixel in the image, that is, the grayscale difference and grayscale characteristic difference between it and the surrounding pixels. The normalization function is used to ensure that the calculation of the noise impact value remains consistent under different images and window sizes. This can effectively identify noise points in the image, especially in areas with complex image details and textures, further enhancing the accuracy of noise removal.
[0039] No. Grayscale characteristics of pixels , where For the first The pixel point is the center of the setting window. The gradient amplitude of each pixel, For the first The grayscale variance of all pixels in the set window centered at a pixel point, Sets the total number of pixels in the window.
[0040] The grayscale characteristic formula takes into account the local changes and texture characteristics of the image by introducing the gradient amplitude and grayscale variance. The gradient amplitude reflects the intensity of the brightness change in the image, while the grayscale variance measures the distribution of the pixel grayscale values in the local area. These two factors combined can accurately describe the complexity of the image details and texture. By combining the above three formulas, the noise in the image, especially Gaussian noise, can be effectively identified and removed. The calculation of Gaussian weights and noise influence values allows pixels with larger noise to be assigned lower weights, thereby reducing their impact on the image.
[0041] In another embodiment, the Grayscale characteristics of pixels , where For the The gray value of a pixel, For the first The pixel point is the center of the setting window. The gray value of a pixel, Sets the total number of pixels in the window.
[0042] By calculating the mean of the grayscale differences, the algorithm can quantify the relationship between each pixel and the surrounding pixels. If the grayscale difference between a pixel and its neighboring pixels is large, it means that the pixel may be located at the edge of the image or in an area with strong texture, and may contain more information; if the difference is small, it may be a flat area or an area with less noise. Through this metric, the algorithm can effectively identify important details in the image, such as edges, textures, etc.
[0043] The scheme of the present invention significantly improves the accuracy and reliability of pig carcass size measurement by combining image recognition technology and a series of optimization processing steps. By using a high-quality CCD or CMOS camera to collect images, the clarity and accuracy of the original data are ensured. After the image is grayed, unnecessary color interference is removed, further improving the analysis accuracy of the image. Subsequently, the improved Gaussian filter noise reduction algorithm is used to effectively remove the noise in the image, ensuring the retention of details. Combined with the edge detection algorithm, the outline of the pig carcass is accurately outlined, and the image morphology is optimized through corrosion and expansion operations, making the carcass outline more obvious and coherent. Finally, the size of the carcass is extracted by the minimum circumscribed rectangle algorithm, ensuring the stability and accuracy of the size measurement. This scheme can automatically adjust the processing strategy in a complex image environment, reduce noise interference, and ensure high-precision size measurement results.
[0044] In the description of this specification, "plurality" or "several" means at least two, such as two, three or more, etc., unless otherwise clearly and specifically defined.
[0045] Although this specification has shown and described a number of embodiments of the present invention, 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 will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.
Claims
1. A method for measuring pig carcass size based on image recognition, characterized in that: include: Collect images of pig carcasses; The improved Gaussian filtering denoising algorithm is used to eliminate the Gaussian noise of the pig carcass image, and the pig carcass size is extracted after the image after the Gaussian noise is eliminated. Among them, the improved Gaussian filtering denoising algorithm includes Gaussian weights, Gaussian weight of pixels , where For the The noise impact value of each pixel, For the first The pixel point is the center of the setting window. The noise impact value of each pixel, To set the total number of pixels in the window, The natural constant An exponential function with base ; No. The noise impact value of each pixel , where For the The gray value of a pixel, For the first The grayscale mean of all pixels in the set window centered at a pixel point. For the The grayscale characteristics of each pixel, For the first The pixel point is the center of the setting window. The grayscale characteristics of each pixel, is the normalization function; The grayscale characteristic represents the disorder degree of the pixel points.
2. The method for measuring pig carcass size based on image recognition according to claim 1, characterized in that: The said Grayscale characteristics of pixels , where For the first The pixel point is the center of the setting window. The gradient amplitude of each pixel, For the first The grayscale variance of all pixels in the set window centered at a pixel point, Sets the total number of pixels in the window.
3. The method for measuring pig carcass size based on image recognition according to claim 1, characterized in that: The said Grayscale characteristics of pixels , where For the The gray value of a pixel, For the first The pixel point is the center of the setting window. The gray value of a pixel, Sets the total number of pixels in the window.
4. The method for measuring pig carcass size based on image recognition according to claim 1, characterized in that: The extracted pig carcass size is specifically: Perform edge detection on the image after eliminating Gaussian noise to obtain the edge contour of the pig carcass; Use the minimum bounding rectangle algorithm to fit the edge contour of the pig carcass and determine the length and width of the bounding rectangle; The size of the pig carcass is calculated based on the length and width of the circumscribed rectangle.
5. The method for measuring pig carcass size based on image recognition according to claim 4, characterized in that: The edge detection is specifically: Sobel algorithm or Canny algorithm.
6. The method for measuring pig carcass size based on image recognition according to claim 1, characterized in that: The images of pig carcasses are captured using a CCD camera or a CMOS camera.
7. The method for measuring pig carcass size based on image recognition according to claim 1, characterized in that: It also includes grayscale processing of the image of the pig carcass.
8. The method for measuring pig carcass size based on image recognition according to claim 1, characterized in that: It also includes erosion and expansion operations on the image after removing the Gaussian noise.
Citation Information
Patent Citations
Slaughter line carcass length intelligent real-time measurement method and system based on deep learning
CN118967771A
Cited By
Community video optimization acquisition method based on artificial intelligence
CN119991503A
Intelligent diagnosis and monitoring system for otolaryngology department based on multi-modal data fusion
CN120107271A