Black pig image segmentation method based on multi-feature fusion
Through the multi-feature fusion method, the accuracy and robustness of black pig image segmentation technology under posture changes and group behavior are solved, and high-precision black pig image segmentation is realized, supporting intelligent breeding monitoring and behavioral analysis.
Patent Information
- Application Number
- CN202510602408.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-12
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2045-05-12
AI Technical Summary
The existing black pig image segmentation technology has shortcomings in preprocessing enhancement, static feature extraction, shape constraints and timing information utilization, resulting in poor accuracy and robustness of segmentation results, especially in the group breeding environment, which is difficult to deal with the movement state and posture changes of black pigs.
Multi-feature fusion method is adopted, including contrast enhancement, residual convolutional neural network, curvature threshold segmentation, dual fitting strategy, spatial position prior probability map, dynamic behavior pattern map and group behavior model. Through multi-level constraints and iterative optimization, high-precision black pig image segmentation results are generated.
It significantly improves the accuracy and robustness of black pig image segmentation, can adapt to posture changes and group behavior, and improves the effect of intelligent breeding monitoring.
Smart Images

Figure CN120471941A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a black pig image segmentation method based on multi-feature fusion. Background Art
[0002] With the continuous improvement of the intelligent level of the livestock farming industry, black pig image segmentation technology plays an important role in livestock monitoring and behavioral analysis. Currently, mainstream black pig image segmentation methods typically use global histogram equalization or adaptive histogram equalization for image enhancement preprocessing. However, these methods have many shortcomings in practical applications: the enhancement process easily loses the detailed features of the fur area, the grayscale values of the background area and the target area are easily aliased, and the use of a unified enhancement strategy for areas of different texture complexity leads to poor processing results. These problems seriously affect the accuracy of subsequent segmentation.
[0003] Existing black pig image segmentation techniques rely too heavily on static feature extraction, making them incapable of addressing the dynamic and morphological variations of black pigs in real-world scenarios. This is particularly true in group-reared environments, where individual pigs experience significant morphological variations due to occlusion and overlap, as well as their diverse activity states. Traditional segmentation methods that rely on single shape templates and lack temporal information often struggle to ensure consistent and accurate segmentation results. These technical bottlenecks hinder the practical application of black pig image segmentation technology in the field of smart farming. Summary of the Invention
[0004] In view of the problems existing in the existing black pig image segmentation technology in preprocessing enhancement, static feature extraction, shape constraint and temporal information utilization, the present invention is proposed.
[0005] Therefore, the problem to be solved by the present invention is how to construct a black pig image segmentation method that can effectively maintain the target detail features, adapt to posture changes, consider the group behavior characteristics and have temporal consistency, so as to improve the accuracy and robustness of segmentation.
[0006] In order to solve the above technical problems, the present invention provides the following technical solutions: In the first aspect, an embodiment of the present invention provides a black pig image segmentation method based on multi-feature fusion, which includes obtaining a black pig image, calculating the grayscale distribution characteristics of the black pig image, and performing contrast enhancement processing on the black pig image according to the grayscale distribution characteristics to obtain an enhanced image; inputting the enhanced image into a residual convolutional neural network to generate a depth feature map, and at the same time extracting a local shape feature map through curvature threshold segmentation and a dual fitting strategy, fusing the local shape feature map with the depth feature map to generate a black pig feature map; establishing a spatial position prior probability map based on a black pig sample library, calculating the regional correlation between the black pig feature map and the prior probability map, and performing regional adaptive weighting on the black pig feature map according to the regional correlation to obtain a fused feature map; performing boundary segmentation on the fused feature map based on a dynamic behavior pattern map and posture constraint rules, and iteratively optimizing it through shape constraint conditions to generate an initial segmentation map; establishing a group behavior model, using the group behavior model as an optimization criterion, correcting the boundary of the initial segmentation map, and outputting the final segmentation result.
[0007] As a preferred solution of the black pig image segmentation method based on multi-feature fusion described in the present invention, the method comprises: performing contrast enhancement processing on the black pig image according to the grayscale distribution feature, comprising: collecting the original black pig image, performing grayscale conversion on the original black pig image, and obtaining a grayscale image; gridding the grayscale image, generating a regular sub-block image group, and calculating the grayscale distribution value of each sub-block image; merging and smoothing the grayscale distribution values of the sub-block images in sequence to obtain a smoothed histogram, detecting the bimodal characteristics of the smoothed histogram, and determining the valley point position; with the valley point position as the center, detecting the peak position of the background area to the left and the peak position of the fur area to the right, and using the peak position of the background area, the valley point position, and the peak position of the fur area as the three reference segmentation points of the nonlinear enhancement curve; constructing a piecewise enhancement function according to the three reference segmentation points; calculating the local texture features of each sub-block image in the regular sub-block image group, and calculating the adjustment coefficient of the piecewise enhancement function according to the local texture features; using the adjusted piecewise enhancement function to enhance the grayscale image, and performing smooth transition processing on the sub-block boundary to obtain an enhanced image.
[0008] As a preferred solution of the black pig image segmentation method based on multi-feature fusion described in the present invention, wherein: extracting a local shape feature map through curvature threshold segmentation and a dual fitting strategy includes the following steps: performing edge detection on the enhanced image, extracting an image contour point set, calculating the curvature value of the image contour point set, and generating a curvature heat map; extracting contour points with curvature values greater than a first preset threshold from the curvature heat map, constructing a circular fitting candidate point set, fitting the circular fitting candidate point set using the least squares method, and calculating the circularity metric value of the fitting circle; screening the candidate head area based on the circularity metric value, determining the optimal head area by combining the area of the area and the circularity metric value, extracting the boundary point sequence of the optimal head area to construct the head contour feature; extracting the contour point set from the curvature heat map, and constructing the circularity metric value of the fitting circle; The contour points whose curvature values are less than the first preset threshold are taken to construct an ellipse fitting candidate point set, the ellipse fitting candidate point set is fitted using a random consistency algorithm, and the ellipse metric value of the fitted ellipse is calculated; the trunk candidate area is screened based on the ellipse metric value, the optimal trunk area is determined by combining the area and the ellipse metric value, and the boundary point sequence of the optimal trunk area is extracted to construct the trunk contour feature; the position-aware encoder is used to perform spatial encoding conversion on the head contour feature and the trunk contour feature, and the head position feature vector and the trunk position feature vector are output respectively; the head position feature vector and the trunk position feature vector are spliced in the feature dimension, and the spliced feature is projected into the feature space matching the depth feature map through the feature mapping network to generate a shape feature map.
[0009] As a preferred solution of the black pig image segmentation method based on multi-feature fusion described in the present invention, the method includes the following steps: performing regional adaptive weighting on the black pig feature map according to regional correlation: performing hierarchical clustering on the target distribution in the black pig sample library, constructing a multi-level spatial position probability tree, and calculating the spatial distribution probability of each level node using an adaptive kernel function; performing a deep traversal of the level nodes of the probability tree, obtaining the topological relationship between the nodes, converting the topological relationship into a spatial constraint matrix, and generating a hierarchical spatial position prior probability map based on the spatial constraint matrix and the spatial distribution probability; inputting the black pig feature map into the receptive field adjustment module, and performing the multi-level clustering on the target distribution in the black pig sample library ... performing the multi-level clustering on the target distribution in the black pig sample library, and calculating the spatial distribution probability of each level node using an adaptive kernel function; performing a deep traversal of the level nodes of the probability tree, obtaining the topological relationship between the nodes, and converting the topological relationship into a spatial constraint matrix, and generating a hierarchical spatial position prior probability map based on the spatial constraint matrix and the spatial distribution probability; inputting the black pig feature map into the receptive field adjustment module, and performing the multi-level clustering on the target distribution in the black pig sample library, and performing the multi-level clustering on the target distribution in the black pig sample library, and performing the multi-level clustering on the target distribution in the black pig sample library, and performing the multi-level clustering on the target distribution in the black pig sample library, and calculating the spatial distribution probability of each level node using an adaptive kernel function; The receptive field scale parameters are calculated, and a multi-scale feature response map is generated based on the receptive field scale parameters; a feedback path is constructed between the levels of the spatial position prior probability map, and the mutual information value between the feature response map and the prior probability of each level is calculated to generate a hierarchical correlation index; the hierarchical correlation index is input into the time series modeling network to extract the spatiotemporal consistency characteristics of the black pig target and output the time series enhanced feature response value; the time series enhanced feature response value is input into the feature discriminator, and the regional discriminant features are extracted through the contrast loss function to generate a discriminant weight matrix; the discriminant weight matrix is used to weight the black pig feature map, and the weighted features are subjected to boundary preserving filtering to generate a fused feature map.
[0010] As a preferred solution of the black pig image segmentation method based on multi-feature fusion described in the present invention, wherein: performing boundary segmentation on the fusion feature map based on the dynamic behavior pattern map and posture constraint rules includes the following steps: inputting the continuous frame image sequence in the black pig sample library into the time-space dual attention feature extraction network, calculating the motion cycle features, posture change features and spatial displacement features; classifying the motion cycle features into activity states, performing weighted fusion operations on the posture change features and spatial displacement features according to different activity states, and outputting a dynamic behavior pattern map; dividing the black pig body structure into head, trunk, and limb regions, constructing an inter-region position constraint tree, calculating the relative position parameters and motion range parameters of each region under different activity states, and generating posture constraint rules ; Construct a multi-scale shape template library, where each template corresponds to a set of activity state parameters and posture parameters, and generate shape constraints through deformable convolution operations; establish a three-item combined loss function including feature response loss term, temporal continuity loss term and shape constraint loss term; perform boundary segmentation on the fused feature map based on the dynamic behavior pattern map, posture constraint rules and shape constraints; adopt the gradient weight adjustment algorithm to calculate the loss term weight based on the feature response intensity value and temporal continuity coefficient, and update the shape template library parameters; perform iterative optimization on the segmentation boundary, calculate the segmentation boundary difference of adjacent iterations, and when the segmentation boundary difference is less than the quality threshold, use the current segmentation boundary as the segmentation mask, perform region filling processing based on the fused feature map, and generate the initial segmentation map.
[0011] As a preferred solution of the black pig image segmentation method based on multi-feature fusion described in the present invention, wherein: taking the group behavior model as the optimization criterion, the boundary of the initial segmentation map is corrected, including the following steps: using the density clustering algorithm to perform regional clustering on the initial segmentation map, extracting the contour boundary point set of each black pig individual, and establishing a spatial geometric feature descriptor based on the contour boundary point set; constructing a spatiotemporal interactive feature network, inputting the spatial geometric feature descriptor into the spatiotemporal interactive feature network, extracting the relative position relationship and motion state parameters between individuals; calculating the minimum spanning tree between individuals based on the relative position relationship, extracting the topological connection relationship between the tree nodes, and combining The dynamic interaction matrix is constructed based on the motion state parameters; eigendecomposition is performed on the dynamic interaction matrix to obtain the eigenvalue sequence and eigenvector group, and the eigenvector group is projected into the spatial position domain to generate the group behavior potential field; the group behavior potential field is used to impose mechanical constraints on the segmentation boundary; the segmentation boundary is deformed under the mechanical constraints, the displacement vector of the boundary point is calculated, and the local shape preservation term is introduced to constrain the displacement size to obtain the actual displacement value of the boundary point; the segmentation boundary position is updated according to the actual displacement value of the boundary point, and the group behavior potential field is recalculated based on the updated boundary position. When the actual displacement values of all boundary points are less than the preset convergence threshold, the final segmentation result is output.
[0012] As a preferred solution of the black pig image segmentation method based on multi-feature fusion described in the present invention, the calculation formula of the ellipse metric value is as follows: in, is the weight coefficient, D is the average distance deviation, D max is the preset maximum allowable deviation, O is the direction consistency measurement value, and M is the shape regularity measurement value.
[0013] In the second aspect, an embodiment of the present invention provides a black pig image segmentation system based on multi-feature fusion, which includes a grayscale enhancement processing module for acquiring a black pig image, calculating the grayscale distribution characteristics of the black pig image, and performing contrast enhancement processing on the black pig image according to the grayscale distribution characteristics to obtain an enhanced image; a residual feature fusion module for inputting the enhanced image into a residual convolutional neural network to generate a depth feature map, extracting a local shape feature map through curvature threshold segmentation and a dual fitting strategy, and fusing the local shape feature map with the depth feature map to generate a black pig feature map; a priori correlation weighting module for establishing a spatial position prior probability map based on a black pig sample library, calculating the regional correlation between the black pig feature map and the prior probability map, and performing regional adaptive weighting on the black pig feature map according to the regional correlation to obtain a fused feature map; a posture constraint segmentation module for performing boundary segmentation on the fused feature map based on a dynamic behavior pattern map and posture constraint rules, and iteratively optimizing through shape constraint conditions to generate an initial segmentation map; a group model boundary correction module for establishing a group behavior model, using the group behavior model as an optimization criterion, correcting the boundary of the initial segmentation map, and outputting the final segmentation result.
[0014] The beneficial effects of the present invention are as follows: the present invention realizes differentiated enhancement of image preprocessing by constructing a piecewise enhancement function based on bimodal characteristics and an adaptive adjustment strategy for local texture features; effectively integrates deep features and local shape features by using a residual convolutional neural network and a dual fitting strategy with a feedback mechanism; improves the accuracy of feature fusion by combining spatial position prior probability and a regional adaptive weighting mechanism; enhances the accuracy of boundary positioning in motion by a segmentation scheme based on temporal-spatial dual attention features and multi-level constraints; and solves the problem of individual segmentation in dense scenes by introducing a group behavior model as an optimization criterion. This method significantly improves the accuracy, stability, and robustness of black pig image segmentation, providing effective technical support for intelligent farming monitoring. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0016] Figure 1 This is a framework flow chart of the black pig image segmentation method based on multi-feature fusion.
[0017] Figure 2 This is the contrast enhancement processing flow chart of the black pig image segmentation method based on multi-feature fusion.
[0018] Figure 3 This is the flowchart of local shape feature extraction for the black pig image segmentation method based on multi-feature fusion.
[0019] Figure 4 This is the boundary segmentation flowchart of the black pig image segmentation method based on multi-feature fusion. DETAILED DESCRIPTION
[0020] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0021] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0022] Secondly, the term "one embodiment" or "embodiment" herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in various places throughout this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive of other embodiments.
[0023] Example 1, with reference to Figures 1 to 4 , which is the first embodiment of the present invention, provides a black pig image segmentation method based on multi-feature fusion. The framework flow chart is as follows Figure 1 Shown, including, The present invention's multi-feature fusion-based black pig image segmentation method is primarily used in the field of intelligent farming, providing accurate individual identification, behavioral analysis, and intelligent monitoring technical support for pig farms. Through high-precision image segmentation, key applications such as pig group activity tracking, breeding pig selection and evaluation, and early warning of epidemics can be realized, promoting the digital transformation of the farming industry. Specifically, this method can be applied in the following scenarios: in the intelligent monitoring system of large-scale pig farms, to achieve accurate positioning and behavior tracking of black pig groups; in breeding pig selection and reproduction management, to provide technical support for the accurate measurement and evaluation of individual morphological characteristics of black pigs; and in the field of epidemic prevention and control, to help farmers promptly detect abnormal individuals.
[0024] S1: Acquire a black pig image, calculate the grayscale distribution characteristics of the black pig image, and perform contrast enhancement processing on the black pig image according to the grayscale distribution characteristics to obtain an enhanced image.
[0025] In black pig image segmentation, image contrast enhancement is a crucial preprocessing step for extracting effective features. Existing methods typically employ global histogram equalization (GHE) or adaptive histogram equalization (AHE). However, these methods suffer from the following drawbacks: First, while GHE improves overall contrast, it ignores the grayscale distribution characteristics of local regions, resulting in a loss of detail in the black pig's fur. Second, while AHE considers local features, it lacks analysis of the specific grayscale distribution characteristics of black pig images, which can easily cause grayscale aliasing between background and fur regions, complicating subsequent segmentation. Third, traditional methods employ a unified enhancement strategy for regions of varying texture complexity, failing to preserve the detailed features of complex texture regions while also introducing over-enhancement artifacts in simpler texture regions.
[0026] In order to solve the above problems, the present invention proposes a contrast enhancement scheme based on multiple features. The contrast enhancement process flow chart is as follows: Figure 2 As shown in FIG, the specific implementation steps are as follows: first, the original black pig image is collected, and the grayscale conversion is performed on the original black pig image to obtain a grayscale image; the grayscale image is grid-divided to generate a regular sub-block image group, and the grayscale distribution value of each sub-block image is calculated; the grayscale distribution values of the sub-block images are merged to construct a global grayscale histogram, where the global grayscale histogram reflects the grayscale distribution characteristics of the black pig fur area and the background area.
[0027] Next, the global grayscale histogram is smoothed to obtain a smoothed histogram, the bimodal characteristics of the smoothed histogram are detected, and the valley point position is determined; with the valley point position as the center, the peak position of the background area is detected to the left, and the peak position of the fur area is detected to the right, and the peak position of the background area, the valley point position and the peak position of the fur area are used as the three reference segmentation points of the nonlinear enhancement curve; a piecewise enhancement function is constructed based on the three reference segmentation points, and linear compression is used for the grayscale distribution value below the background area peak, nonlinear stretching is used for the grayscale distribution value between the background area peak and the fur area peak, and linear compression is used for the grayscale distribution value above the fur area peak.
[0028] Finally, the local texture features of each sub-block image in the regular sub-block image group are calculated, including the energy value, contrast value and entropy value of the gray-level co-occurrence matrix; the adjustment coefficient of the enhancement intensity is calculated according to the local texture features, and the adjustment coefficient is applied to the piecewise enhancement function, where the adjustment coefficient is negatively correlated with the texture complexity; the grayscale image is enhanced using the adjusted piecewise enhancement function, and a smooth transition is performed at the sub-block boundary to obtain an enhanced image; the enhanced image is fused with the color information of the original black pig image to output the final enhanced result image.
[0029] The present invention utilizes the above-mentioned technical solution, achieving the following beneficial effects: A piecewise enhancement function constructed based on bimodal characteristics employs differentiated enhancement strategies for different grayscale intervals, ensuring contrast in background areas while avoiding over-enhancement in fur areas. Furthermore, the enhancement strength is adaptively adjusted based on local texture features, resulting in smaller enhancement amplitudes in complex texture areas to preserve detail, and larger enhancement amplitudes in simple texture areas to improve contrast. This multi-level adaptive enhancement method not only improves image visual quality but also provides clearer feature information for subsequent segmentation processing, effectively overcoming the challenges of existing technologies.
[0030] S2: The enhanced image is input into the residual convolutional neural network to generate a deep feature map. At the same time, the local shape feature map is extracted through curvature threshold segmentation and a dual fitting strategy with a feedback mechanism. The local shape feature map is fused with the deep feature map to generate a black pig feature map.
[0031] Specifically, the local shape feature extraction flow chart is as follows: Figure 3 As shown, the following steps are included: S2.1: The enhanced image is input into the residual convolutional neural network, multi-scale features are generated through multi-layer convolution operations, and a skip connection structure is used to fuse shallow texture features and deep semantic features to output a deep feature map.
[0032] S2.2: Perform edge detection on the enhanced image, extract the image contour point set, calculate the curvature value of the image contour point set, and generate a curvature heat map.
[0033] S2.3: Extracting contour points whose curvature values are greater than a first preset threshold from the curvature heat map, constructing a circle fitting candidate point set, fitting the circle fitting candidate point set using the least squares method, and calculating the circularity metric value of the fitted circle.
[0034] The process for determining the first preset threshold is as follows: perform peak detection on the curvature heat map to generate a curvature peak sequence; perform cluster analysis on the curvature peak sequence to obtain high curvature value clusters and low curvature value clusters based on the clustering results; calculate the mean of the high curvature value cluster as the reference curvature upper limit, and calculate the mean of the low curvature value cluster as the reference curvature lower limit; set an adjustment factor based on the image resolution and the black pig size ratio, and calculate the first preset threshold based on the reference curvature upper limit, reference curvature lower limit, and the adjustment factor. The specific formula is as follows: Among them, T is the first preset threshold, K max is the upper limit of reference curvature, K min is the lower limit of the reference curvature, is the adjustment factor. The value of is related to the image resolution and target size. The specific calculation formula is as follows: Among them, S is the average pixel area of the black pig area in the image, R is the total number of pixels in the image, is the base coefficient.
[0035] It should be noted that the selection of the candidate fitting points using the first preset threshold is primarily based on the following considerations: First, this threshold effectively identifies morphological differences among black pigs. Since the head region exhibits distinct circular features, with large curvature values and a relatively concentrated distribution, while the torso region exhibits elliptical features, with smaller curvature values and a more even distribution, setting an appropriate curvature threshold can accurately distinguish between these two regions. Second, setting this threshold helps optimize algorithm performance. On the one hand, threshold screening retains the most representative feature points, significantly improving fitting accuracy; on the other hand, the pre-screening process reduces the number of points involved in the calculation, effectively reducing algorithm complexity.
[0036] In addition, the regulatory factor The design takes the following factors into consideration: First, The value determines the position of the curvature threshold between the upper and lower limits of the reference curvature. Too large or too small will affect the accuracy of feature extraction. Through experiments, it is found that when When , too many low curvature points are included in the head fitting, resulting in misrecognition; when When , some valid head contour points will be excluded, affecting the fitting accuracy. The value range of This not only ensures the robustness of the algorithm but also meets the accuracy requirements. The term represents the proportion of the black pig area in the image. The larger the proportion, the more obvious the target feature is. A higher curvature threshold should be used to improve the discrimination of feature points. On the contrary, when the target is small, the threshold needs to be lowered to ensure a sufficient number of feature points. The value of is determined by analyzing a large amount of experimental data. The experiment shows that when When , the algorithm can obtain stable feature extraction effects on images of different scales and has the best performance.
[0037] Furthermore, the circularity metric is calculated based on the distance deviation between the fitted circle and the candidate point set, the circularity, and the degree of match with the standard head size. Specifically, a weighted summation method is used to comprehensively evaluate each metric. When the fitting quality meets the requirements, the corresponding area is determined to be a valid head candidate.
[0038] S2.4: Filter candidate head regions based on circularity metrics, determine the optimal head region by combining the region area and circularity metrics, and extract the boundary point sequence of the optimal head region to construct head contour features.
[0039] S2.5: Extract contour points whose curvature values are less than a first preset threshold from the curvature heat map, construct an ellipse fitting candidate point set, fit the ellipse fitting candidate point set using a random consistency algorithm, and calculate the ellipse metric value of the fitted ellipse.
[0040] The ellipse metric calculation utilizes a multi-feature fusion evaluation method, focusing on addressing the ellipse deformation problem of the pig's trunk under different shooting angles. This method includes three components: a fitting error term, a shape regularity term, and a direction term. The fitting error term calculates the normalized mean distance deviation from the candidate point to the fitted ellipse, effectively addressing local deformation caused by changes in the pig's posture. The shape regularity term assesses the regularity of the fitted ellipse, addressing scale differences caused by pigs of different sizes. The direction term assesses the consistency of the ellipse's main axis direction with the reference direction, addressing fitting instability caused by changes in shooting angle.
[0041] Specifically, the calculation formula of the ellipse metric value is as follows: in, is the weight coefficient, D is the average distance deviation, D max is the preset maximum allowable deviation (5% of the image diagonal length), O is the direction consistency measure, and M is the shape regularity measure: Among them, r is the ratio of the major and minor axes of the current ellipse, r0 is the standard ratio of the major and minor axes obtained based on the statistics of the black pig's body characteristics, and r max is the maximum allowable ratio deviation, e is the ellipse eccentricity, e max is the maximum allowable eccentricity, is the direction angle of the ellipse's major axis, is the reference direction angle of the trunk determined based on the head position. Considering the stability characteristics of the black pig's trunk area, the weight coefficient adopts a fixed value: .
[0042] The ellipse metric evaluation method designed in this paper effectively solves the following problems through a multi-feature fusion strategy: First, it considers the deformation characteristics of black pigs in different postures, improving the accuracy of fitting; second, it designs morphological norms based on biological statistical characteristics, improving the adaptability of black pigs of different body sizes; and third, it introduces directional consistency constraints to enhance the robustness of the algorithm under different shooting angles. Compared with traditional ellipse fitting methods that only use geometric error evaluation, the metric method of this invention significantly improves the accuracy of feature extraction.
[0043] Furthermore, a fixed threshold strategy is used in the screening process. Elliptical regions with an ellipse metric value E greater than 0.8 are retained for subsequent processing. This threshold, determined through statistical analysis of extensive experimental data, effectively filters out anomalous fitting results while maintaining fitting accuracy.
[0044] S2.6: Filter candidate torso regions based on ellipse metrics, determine the optimal torso region by combining the region area and ellipse metrics, and extract the boundary point sequence of the optimal torso region to construct the torso contour feature.
[0045] S2.7: Use a position-aware encoder to perform spatial encoding conversion on the head contour features and the torso contour features, and output the head position feature vector and the torso position feature vector respectively.
[0046] S2.8: Concatenate the head position feature vector and the torso position feature vector in the feature dimension, project the concatenated features into the feature space that matches the depth feature map through the feature mapping network, and generate a shape feature map.
[0047] S2.9: Calculate the feature importance weights for the depth feature map and shape feature map based on the channel attention mechanism, perform element-by-element addition on the weighted feature map, and output the black pig feature map.
[0048] S3: Based on the black pig sample library, a spatial location prior probability map is established, the regional correlation between the black pig feature map and the prior probability map is calculated, and the black pig feature map is regionally adaptively weighted according to the regional correlation to obtain a fused feature map.
[0049] Specifically, the method includes the following steps: S3.1: Perform hierarchical clustering on the target distribution in the black pig sample library, construct a multi-level spatial location probability tree, and use the adaptive kernel function to calculate the spatial distribution probability of each level node.
[0050] It should be noted that the Black Pig Sample Library contains a large number of images and annotations of black pigs in different scenes, at different times, and in different postures. The images in the sample library cover a variety of scenes, such as individual pigs and groups, and record the location, posture, and behavior information of the black pigs.
[0051] S3.2: Perform a deep traversal of the hierarchical nodes of the probability tree to obtain the topological relationship between the nodes, convert the topological relationship into a spatial constraint matrix, and generate a hierarchical spatial location prior probability map based on the spatial constraint matrix and the spatial distribution probability.
[0052] S3.3: Input the black pig feature map into the receptive field adjustment module, calculate the receptive field scale parameter according to the local structural complexity of the feature, and generate a multi-scale feature response map based on the receptive field scale parameter.
[0053] Specifically, a gradient flow direction histogram is constructed, the gradient flow vector of the local area of the black pig feature map is calculated, and the main direction distribution characteristics of the gradient flow vector are extracted; based on the main direction distribution characteristics, an anisotropic covariance matrix is constructed, and the eigenvalue decomposition of the covariance matrix is calculated to obtain the shape description parameters of the local structure; an adaptive weight network is used to map the shape description parameters to receptive field deformation parameters, and an anisotropic receptive field adjustment function is constructed; the receptive field adjustment function is used to adaptively sample the black pig feature map to generate a shape-adaptive multi-scale feature response map.
[0054] Preferably, the receptive field shape is dynamically adjusted by analyzing the anisotropic characteristics of the features. This not only takes into account scale changes but also shape adaptability, allowing for better adaptation to the complex structures found in black pig images. This improves feature extraction accuracy, enhances adaptability to irregular shapes, and reduces the impact of background interference.
[0055] S3.4: Construct a feedback path between the levels of the spatial location prior probability map, calculate the mutual information value between the feature response map and the prior probability of each level, and generate a hierarchical correlation index.
[0056] S3.5: Input the hierarchical correlation index into the time series modeling network, extract the spatiotemporal consistency characteristics of the black pig target, and output the time series enhanced feature response value.
[0057] S3.6: Input the temporal enhancement feature response value into the feature discriminator, optimize the extracted regional discriminant features through the contrast loss function, and generate the discriminant weight matrix.
[0058] Specifically, a two-branch feature discriminant network is constructed, in which the first branch receives the temporally enhanced feature response value as the positive sample input, and the second branch receives the randomly enhanced feature response value as the negative sample input; a non-local attention module is embedded in the two-branch feature discriminant network to extract the context-related features of the positive and negative samples respectively; the cosine similarity between the context-related features of the positive samples and the context-related features of the negative samples is calculated to generate a feature similarity matrix; a contrast loss function is constructed, the feature similarity matrix is input into the temperature parameter adaptive adjustment module, and the contrast loss value is calculated based on the regional consistency criterion; the contrast loss value is used to guide the training process of the feature discriminant network to extract discriminative regional feature representations; the regional feature representations are input into the fully connected layer to generate a discriminant weight matrix.
[0059] S3.7: Use the discriminant weight matrix to weight the black pig feature map, perform boundary preserving filtering on the weighted features, and generate a fused feature map.
[0060] Preferably, the present invention adopts the following innovative strategies in the feature fusion process: First, a multi-level spatial position probability tree structure is proposed, which can effectively capture the spatial distribution characteristics of black pig targets at different scales; second, an adaptive receptive field adjustment mechanism is introduced to dynamically adjust the feature extraction range according to the local structural complexity of the feature, thereby achieving adaptability of feature extraction; third, an inter-level feedback path is constructed to achieve cross-scale optimization of features by calculating mutual information values; finally, a temporal modeling network is used to extract spatiotemporal consistency features, thereby improving the stability of feature extraction. These innovations are all designed for the specific task of black pig image segmentation, fully considering the characteristics of black pig targets in terms of spatial distribution, local structure, and temporal changes, and jointly serve the goal of improving segmentation accuracy.
[0061] S4: Perform boundary segmentation on the fused feature map based on the dynamic behavior pattern map and posture constraint rules, and iteratively optimize through shape constraints to generate an initial segmentation map.
[0062] Existing techniques for black pig image segmentation rely primarily on static features, failing to accurately handle posture changes during motion. Furthermore, black pigs exhibit significant morphological variations across different activity states, making a single shape template difficult to adapt. Furthermore, occlusion and overlap between individual black pigs, coupled with a lack of temporal information constraints, lead to inconsistent segmentation results between adjacent frames. To address these issues, the present invention proposes a segmentation scheme based on temporal-spatial dual attention features and multi-level constraints. This scheme significantly improves segmentation accuracy during motion, enhances temporal consistency, and improves boundary localization accuracy in occluded scenarios.
[0063] Specifically, the boundary segmentation flowchart is as follows: Figure 4 As shown, the following steps are included: S4.1: Input the continuous frame image sequence in the black pig sample library into the temporal-spatial dual attention feature extraction network to calculate the motion cycle features, posture change features and spatial displacement features.
[0064] S4.2: Classify the motion cycle features into activity states, perform weighted fusion operations on the posture change features and spatial displacement features according to different activity states, and output a dynamic behavior pattern diagram.
[0065] Activity state classification, based on cluster analysis of motion cycle characteristics, categorizes black pig behavior into typical states such as eating, walking, and resting. An adaptive weighting strategy is employed to integrate posture change and spatial displacement features for each activity state. The resulting dynamic behavior pattern diagram accurately reflects the behavioral characteristics and movement patterns of black pigs.
[0066] S4.3: Divide the black pig body structure into head, trunk, and limb regions, construct a position constraint tree between regions, calculate the relative position parameters and motion range parameters of each region under different activity states, and generate posture constraint rules.
[0067] Specifically, a skeleton extraction algorithm is used to locate key points in black pig sample images, extracting the head center, trunk axis point sequence, and limb joints. A relative coordinate system is established with the trunk axis as the reference, and the angular and distance ranges of the head center relative to the trunk front are calculated to construct head motion constraints. The limb joint point sequence is hierarchically grouped, and the motion amplitude parameters of each joint relative to the trunk axis are calculated to establish limb motion constraints. For different activity states, the relative position distribution of key points in each region is statistically analyzed to construct a spatial relationship graph between regions. This spatial relationship graph is converted into a tree structure, and dependency relationships between parent and child nodes are established to generate a position constraint tree. Based on the position constraint tree, the relative displacement vectors and angular variation ranges of each region under different activity states are calculated, and posture constraint rules are output. This design improves the rationality of segmentation results through biomechanical constraints and avoids unrealistic segmentation boundaries.
[0068] S4.4: Build a multi-scale shape template library, where each template corresponds to a set of activity state parameters and posture parameters, and generate shape constraints through deformable convolution operations.
[0069] S4.5: Establish a three-term combined loss function including feature response loss term, temporal continuity loss term and shape constraint loss term.
[0070] It should be noted that the feature response loss term calculates the matching error between the segmentation boundary and the image feature, the temporal continuity loss term calculates the deviation value of the segmentation results of adjacent frames, and the shape constraint loss term calculates the difference between the segmentation boundary and the deformed template.
[0071] S4.6: Perform boundary segmentation on the fused feature map based on the dynamic behavior pattern map, pose constraint rules, and shape constraint conditions.
[0072] The segmentation process involves initializing the segmentation region based on the dynamic behavior pattern graph, adjusting the region boundaries according to posture constraints, and finally refining the segmentation results using shape constraints. This hierarchical segmentation strategy can gradually improve segmentation accuracy.
[0073] S4.7: Use the gradient weight adjustment algorithm to calculate the loss term weight based on the characteristic response intensity value and the temporal continuity coefficient, and update the shape template library parameters.
[0074] Specifically, a self-attention matrix is constructed for the feature response intensity values, the relative importance scores of the features in each region are extracted, and the feature response weights are constructed based on the importance scores; the core-edge deformation coefficient of the target region is calculated based on the segmentation results of adjacent frames, and the temporal consistency weight is constructed using this coefficient; the feature response weights and the temporal consistency weights are input into a multi-layer perceptron to generate the dynamic weight coefficients of the three-item combined loss function; based on the dynamic weight coefficients, deformation optimization calculations are performed on the benchmark templates in the shape template library, and the template parameters are updated based on the deformation optimization results.
[0075] Among them, the deformation optimization calculation includes: selecting the corresponding reference template according to the posture constraint rules of the current frame; calculating the contour mapping relationship between the current segmentation area and the reference template; generating a deformation field based on the contour mapping relationship; regularizing the deformation field to generate the optimal deformation parameters; and updating the optimal deformation parameters to the shape template library.
[0076] Optimally, the present invention designs an adaptive weight adjustment mechanism based on feature response strength and temporal characteristics. By establishing a dynamic weight calculation model through a self-attention mechanism and deformation analysis, this method enables adaptive adjustment of loss function weights and online updating of shape templates, improving the adaptability of the segmentation model to different scenarios. Compared to existing methods that use fixed weights or empirical settings, the present invention's dynamic weight mechanism better balances the influence of feature response, temporal continuity, and shape constraints, resulting in more accurate and stable segmentation results.
[0077] S4.8: Perform iterative optimization on the segmentation boundary and calculate the segmentation boundary difference of adjacent iterations. When the segmentation boundary difference is less than the quality threshold, use the current segmentation boundary as the segmentation mask and perform region filling processing based on the fused feature map to generate an initial segmentation map.
[0078] The iterative process includes: calculating the feature response map and temporal continuity map of the current boundary; updating the shape template deformation parameters based on the feature response map and temporal continuity map; substituting the shape template deformation parameters into the three-term combined loss function; and revising the segmentation boundary based on the calculation results of the three-term combined loss function. This iterative optimization process ensures the convergence and stability of the segmentation results and significantly improves the accuracy of the boundary.
[0079] S5: Establish a group behavior model, use the group behavior model as an optimization criterion, correct the boundaries of the initial segmentation map, and output the final segmentation result.
[0080] Specifically, a density clustering algorithm is used to perform regional clustering on the initial segmentation map, extract the contour boundary point set of each black pig individual, and establish a spatial geometric feature descriptor based on the contour boundary point set; construct a spatiotemporal interaction feature network, input the spatial geometric feature descriptor into the spatiotemporal interaction feature network, and extract the relative position relationship and motion state parameters between individuals; calculate the minimum spanning tree between individuals based on the relative position relationship, extract the topological connection relationship between the tree nodes, and construct a dynamic interaction matrix based on the motion state parameters; perform eigendecomposition on the dynamic interaction matrix to obtain the eigenvalue sequence and eigenvector group, and project the eigenvector group into the spatial position domain to generate the group behavior potential field.
[0081] Furthermore, the group behavior potential field is used to impose mechanical constraints on the segmentation boundary, where the magnitude of the constraint force is proportional to the potential field gradient and the direction is perpendicular to the equipotential lines of the potential field; the segmentation boundary is deformed under the mechanical constraint, the displacement vector of the boundary point is calculated, and a local shape preservation term is introduced to constrain the displacement size to obtain the actual displacement value of the boundary point; the segmentation boundary position is updated according to the actual displacement value of the boundary point, and the group behavior potential field is recalculated based on the updated boundary position. When the actual displacement values of all boundary points are less than the preset convergence threshold, the final segmentation result is output.
[0082] Optimally, this boundary correction scheme based on a group behavior model provides stable constraints for segmentation boundary optimization by transforming the relative positional relationships and motion states between individuals into a group behavior potential field. Particularly in complex scenarios where black pigs are densely distributed or mutually occluded, the additional constraints provided by the group behavior potential field can effectively overcome the segmentation errors caused by relying solely on image features. By using a minimum spanning tree to describe the topological relationships between individuals and combining it with a dynamic interaction matrix to capture group motion patterns, the segmentation results are consistent with both the morphological characteristics of individual black pigs and the statistical laws of group behavior, significantly improving segmentation accuracy and robustness.
[0083] Furthermore, this embodiment also provides a black pig image segmentation system based on multi-feature fusion, including a grayscale enhancement processing module for acquiring a black pig image, calculating the grayscale distribution characteristics of the black pig image, and performing contrast enhancement processing on the black pig image according to the grayscale distribution characteristics to obtain an enhanced image; a residual feature fusion module for inputting the enhanced image into a residual convolutional neural network to generate a depth feature map, extracting a local shape feature map through curvature threshold segmentation and a dual fitting strategy, and fusing the local shape feature map with the depth feature map to generate a black pig feature map; a priori correlation weighting module for establishing a spatial position prior probability map based on a black pig sample library, calculating the regional correlation between the black pig feature map and the prior probability map, and performing regional adaptive weighting on the black pig feature map according to the regional correlation to obtain a fused feature map; a posture constraint segmentation module for performing boundary segmentation on the fused feature map based on a dynamic behavior pattern map and posture constraint rules, and iteratively optimizing through shape constraint conditions to generate an initial segmentation map; a group model boundary correction module for establishing a group behavior model, using the group behavior model as an optimization criterion, correcting the boundary of the initial segmentation map, and outputting the final segmentation result.
[0084] In summary, the present invention achieves differentiated enhancement of image preprocessing by constructing a segmented enhancement function based on bimodal characteristics and an adaptive adjustment strategy for local texture features; effectively integrates deep features and local shape features by using a residual convolutional neural network and a dual fitting strategy with a feedback mechanism; improves the accuracy of feature fusion by combining spatial position prior probability and regional adaptive weighting mechanism; enhances the accuracy of boundary positioning in motion by using a segmentation scheme based on temporal-spatial dual attention features and multi-level constraints; and solves the problem of individual segmentation in dense scenes by introducing a group behavior model as an optimization criterion. This method significantly improves the accuracy, stability, and robustness of black pig image segmentation, and provides effective technical support for intelligent farming monitoring.
[0085] Example 2, reference Figures 1 to 4 This is the second embodiment of the present invention. This embodiment provides a black pig image segmentation method based on multi-feature fusion. In order to verify the beneficial effects of the present invention, scientific demonstration is carried out through economic benefit calculation and simulation experiments.
[0086] To validate the effectiveness of this invention, a three-month field test was conducted at a pig farm in a certain city. The test environment consisted of an indoor piggery and an outdoor playground, with 200 adult black pigs as test subjects. The image acquisition equipment used an industrial-grade high-definition camera with a resolution of 1920×1080 pixels, a frame rate of 30 fps, an installation height of 3 meters, and a 30-degree pitch angle. Image acquisition spanned 24 hours a day, encompassing various lighting and weather conditions.
[0087] Regarding hardware configuration, the proposed black pig image segmentation system recommends the following computer hardware configuration: a server-grade Intel Xeon Gold processor, an NVIDIA Tesla professional graphics card for the graphics processing unit (GPU), enterprise-grade ECC server memory, and high-speed solid-state drives (SSDs) for storage. This configuration meets the performance requirements of real-time image processing, deep learning model training, and multi-feature fusion computing. It supports processing 30 frames per second of black pig images at a resolution of 1920×1080, enabling stable and efficient image segmentation in complex farming scenarios.
[0088] In the image preprocessing stage, the collected original image is first grayscale converted and gridded, with the grid size set to 32×32 pixels. By calculating the grayscale distribution characteristics, the multi-feature-based contrast enhancement scheme proposed in this invention is used for image enhancement. Experimental results show that under complex lighting conditions, this scheme improves the average contrast of the image by 23.5% compared to the traditional histogram equalization method, and while maintaining the fur texture details, it increases the grayscale difference between the background area and the target area by 31.2%. In particular, in scenes with insufficient lighting, the signal-to-noise ratio of the image is improved by 2.8dB, laying a good foundation for subsequent feature extraction.
[0089] During the feature extraction and fusion stages, the residual convolutional neural network adopts a five-layer convolutional structure. In curvature threshold segmentation, the first preset threshold is dynamically calculated, with an average value of 0.085 and an adjustment factor of 0.65. Experimental data show that the multi-feature fusion strategy proposed in this paper increases the average response strength of the feature map by 18.7% and the feature discrimination by 25.3%. When processing 1,000 test images, the average detection accuracy of the head region reached 94.8%, and the ellipse fitting accuracy of the torso region reached 92.3%, which are superior to existing single feature extraction methods.
[0090] Based on an established spatial location prior probability map and a regional adaptive weighting mechanism, the black pig feature map was optimized. The experiment constructed a sample library containing 10,000 annotated images, using a three-layer hierarchical clustering structure with a kernel bandwidth parameter set to 0.45. Spatiotemporal consistency features were extracted using a temporal modeling network with a depth of four layers and 256 hidden nodes. Experimental results show that even in complex scenarios with object occlusion rates reaching 40%, segmentation accuracy remains above 89.5%, and the temporal consistency error is reduced to 0.06, significantly outperforming traditional methods.
[0091] In the final segmentation optimization stage, boundary correction is performed by combining the dynamic behavior pattern diagram and the group behavior model. In the experiment, behavioral data covering five typical activity states were collected, and a template library containing 200 basic shape templates was established. Through iterative optimization, the average number of convergence times was 12 times, and the boundary point displacement threshold was set to 0.5 pixels. The final evaluation results on 2,000 test images showed that the average segmentation accuracy of this scheme reached 91.2%, the boundary positioning error was reduced to 1.8 pixels, and the segmentation accuracy in dense group scenes was improved by 15.6%. As shown in Table 1, the performance comparison results of the present invention and the prior art methods fully demonstrate the superiority of this method.
[0092] Table 1 Performance comparison between the present invention and the prior art The comparative data in Table 1 demonstrates that the method of the present invention significantly outperforms existing methods across all key performance indicators. In the comparative experiments, the traditional segmentation method employed a combination of the Otsu thresholding method and the watershed algorithm, while the deep learning method employed an integrated model of U-Net and FCN networks. However, the deep learning method of the present invention, based on multi-feature fusion, not only improves segmentation accuracy but also reduces computational overhead. In particular, the method exhibits greater robustness and adaptability when processing complex scenarios, fully demonstrating its innovativeness and practical value.
[0093] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. A black pig image segmentation method based on multi-feature fusion, characterized by: include, Acquire a black pig image, calculate a grayscale distribution feature of the black pig image, and perform contrast enhancement processing on the black pig image according to the grayscale distribution feature to obtain an enhanced image; Inputting the enhanced image into the residual convolutional neural network to generate a depth feature map, extracting a local shape feature map through curvature threshold segmentation and a dual fitting strategy, and fusing the local shape feature map with the depth feature map to generate a black pig feature map; Establishing a spatial location prior probability map based on a black pig sample library, calculating the regional correlation between the black pig feature map and the prior probability map, and performing regional adaptive weighting on the black pig feature map according to the regional correlation to obtain a fused feature map; Perform boundary segmentation on the fused feature map based on the dynamic behavior pattern map and the posture constraint rules, and perform iterative optimization through shape constraint conditions to generate an initial segmentation map; A group behavior model is established, and the group behavior model is used as an optimization criterion to correct the boundary of the initial segmentation map and output a final segmentation result.
2. The black pig image segmentation method based on multi-feature fusion according to claim 1 is characterized in that: Performing contrast enhancement processing on the black pig image according to the grayscale distribution characteristics includes: Collecting an original black pig image, and performing grayscale conversion on the original black pig image to obtain a grayscale image; Dividing the grayscale image into grids to generate a regular sub-block image group, and calculating the grayscale distribution value of each sub-block image; Merging and smoothing the grayscale distribution values of the sub-block images in sequence to obtain a smoothed histogram, detecting a bimodal characteristic of the smoothed histogram, and determining a valley point position; With the valley point as the center, the peak position of the background area is detected to the left, and the peak position of the fur area is detected to the right, and the peak position of the background area, the valley point and the peak position of the fur area are used as three reference segmentation points of the nonlinear enhancement curve; Constructing a piecewise enhancement function according to the three reference segmentation points; calculating a local texture feature for each sub-block image in the regular sub-block image group, and calculating an adjustment coefficient of the piecewise enhancement function according to the local texture feature; The grayscale image is enhanced using the adjusted piecewise enhancement function, and a smooth transition process is performed on the sub-block boundary to obtain an enhanced image.
3. The black pig image segmentation method based on multi-feature fusion according to claim 1 is characterized in that: The method of extracting the local shape feature map by using curvature threshold segmentation and dual fitting strategy comprises the following steps: Performing edge detection on the enhanced image, extracting an image contour point set, calculating a curvature value of the image contour point set, and generating a curvature heat map; Extracting contour points whose curvature values are greater than a first preset threshold from the curvature heat map, constructing a circle fitting candidate point set, fitting the circle fitting candidate point set using the least squares method, and calculating a circularity metric value of the fitted circle; Screening candidate head regions based on the circularity metric, determining an optimal head region based on the region area and the circularity metric, and extracting a boundary point sequence of the optimal head region to construct a head contour feature; Extracting contour points whose curvature values are less than a first preset threshold from the curvature heat map, constructing an ellipse fitting candidate point set, fitting the ellipse fitting candidate point set using a random consistency algorithm, and calculating an ellipse metric value of the fitted ellipse; Based on the ellipse measurement value, candidate trunk regions are screened, the optimal trunk region is determined by combining the region area and the ellipse measurement value, and a boundary point sequence of the optimal trunk region is extracted to construct a trunk contour feature; Using a position-aware encoder to perform spatial encoding conversion on the head contour features and the torso contour features, and outputting a head position feature vector and a torso position feature vector respectively; The head position feature vector and the torso position feature vector are spliced in the feature dimension, and the spliced features are projected into a feature space that matches the depth feature map through a feature mapping network to generate a shape feature map.
4. The black pig image segmentation method based on multi-feature fusion according to claim 1 is characterized in that: Performing regional adaptive weighting on the black pig feature map according to the regional correlation comprises the following steps: Hierarchical clustering is performed on the target distribution in the black pig sample library to construct a multi-level spatial location probability tree, and the adaptive kernel function is used to calculate the spatial distribution probability of each level node; Performing a depth traversal of the hierarchical nodes of the probability tree to obtain a topological relationship between the nodes, converting the topological relationship into a spatial constraint matrix, and generating a hierarchical spatial position prior probability map based on the spatial constraint matrix and the spatial distribution probability; Inputting the black pig feature map into a receptive field adjustment module, calculating a receptive field scale parameter according to the local structural complexity of the feature, and generating a multi-scale feature response map based on the receptive field scale parameter; Constructing a feedback path between the levels of the spatial position prior probability map, calculating the mutual information value between the feature response map and the prior probability of each level, and generating a hierarchical correlation index; Input the hierarchical correlation index into the time series modeling network, extract the spatiotemporal consistency features of the black pig target, and output the time series enhanced feature response value; Inputting the temporal enhancement feature response value into a feature discriminator, optimizing and extracting regional discriminant features through a contrast loss function, and generating a discriminant weight matrix; The black pig feature map is weighted using the discriminant weight matrix, and a boundary-preserving filter is performed on the weighted features to generate a fused feature map.
5. The black pig image segmentation method based on multi-feature fusion according to claim 1 is characterized in that: The performing boundary segmentation on the fused feature map based on the dynamic behavior pattern map and the posture constraint rule comprises the following steps: The continuous frame image sequence in the black pig sample library is input into the temporal-spatial dual attention feature extraction network to calculate the motion cycle feature, posture change feature and spatial displacement feature; Classifying the motion cycle features into activity states, performing weighted fusion operations on posture change features and spatial displacement features according to different activity states, and outputting a dynamic behavior pattern diagram; The black pig's body structure is divided into the head, trunk, and limbs. A position constraint tree is constructed between the regions. The relative position parameters and motion range parameters of each region under different activity states are calculated to generate posture constraint rules. Construct a multi-scale shape template library, where each template corresponds to a set of activity state parameters and posture parameters, and generate shape constraints through deformable convolution operations; Establish a three-term combined loss function including feature response loss term, temporal continuity loss term and shape constraint loss term; Perform boundary segmentation on the fused feature map based on the dynamic behavior pattern map, posture constraint rules and shape constraint conditions; Adopting the gradient weight adjustment algorithm, the loss term weight is calculated based on the characteristic response intensity value and the temporal continuity coefficient, and the shape template library parameters are updated; Iterative optimization is performed on the segmentation boundary, and the segmentation boundary difference of adjacent iterations is calculated. When the segmentation boundary difference is less than the quality threshold, the current segmentation boundary is used as the segmentation mask, and region filling processing is performed based on the fused feature map to generate an initial segmentation map.
6. The black pig image segmentation method based on multi-feature fusion according to claim 1, characterized in that: Using the group behavior model as an optimization criterion, modifying the boundary of the initial segmentation map includes the following steps: Using a density clustering algorithm to perform regional clustering on the initial segmentation map, extracting a contour boundary point set of each black pig individual, and establishing a spatial geometric feature descriptor based on the contour boundary point set; Constructing a spatiotemporal interactive feature network, inputting the spatial geometric feature descriptor into the spatiotemporal interactive feature network, and extracting the relative position relationship and motion state parameters between individuals; Calculating a minimum spanning tree between individuals based on the relative position relationship, extracting the topological connection relationship between tree nodes, and constructing a dynamic interaction matrix in combination with the motion state parameters; Performing eigendecomposition on the dynamic interaction matrix to obtain an eigenvalue sequence and an eigenvector group, projecting the eigenvector group into a spatial position domain to generate a group behavior potential field; applying mechanical constraints to the segmentation boundary using the group behavior potential field; Deforming the segmentation boundary under the mechanical constraint, calculating the displacement vector of the boundary point, and introducing a local shape preservation term to constrain the displacement magnitude, thereby obtaining the actual displacement value of the boundary point; The segmentation boundary position is updated according to the actual displacement value of the boundary point, and the group behavior potential field is recalculated based on the updated boundary position. When the actual displacement values of all boundary points are less than the preset convergence threshold, the final segmentation result is output.
7. The black pig image segmentation method based on multi-feature fusion according to claim 3 is characterized in that: The calculation formula of the ellipse measurement value is as follows: in, is the weight coefficient, D is the average distance deviation, D max is the preset maximum allowable deviation, O is the direction consistency measurement value, and M is the shape regularity measurement value.
8. A black pig image segmentation system based on multi-feature fusion, based on the black pig image segmentation method based on multi-feature fusion according to any one of claims 1 to 7, characterized in that: Also includes, a grayscale enhancement processing module, configured to obtain a black pig image, calculate grayscale distribution characteristics of the black pig image, and perform contrast enhancement processing on the black pig image according to the grayscale distribution characteristics to obtain an enhanced image; A residual feature fusion module is used to input the enhanced image into a residual convolutional neural network to generate a depth feature map, extract a local shape feature map through curvature threshold segmentation and a dual fitting strategy, and fuse the local shape feature map with the depth feature map to generate a black pig feature map; A priori association weighting module is used to establish a spatial location prior probability map based on a black pig sample library, calculate the regional correlation between the black pig feature map and the prior probability map, and perform regional adaptive weighting on the black pig feature map according to the regional correlation to obtain a fused feature map; A posture constraint segmentation module is used to perform boundary segmentation on the fused feature map based on the dynamic behavior pattern map and the posture constraint rules, and to iteratively optimize the shape constraint conditions to generate an initial segmentation map; The group model boundary correction module is used to establish a group behavior model, use the group behavior model as an optimization criterion, correct the boundary of the initial segmentation map, and output the final segmentation result.
Citation Information
Patent Citations
Lactating sow image segmentation method integrated with FCN and threshold segmentation
CN107527351A
Dairy cow individual identity recognition method fusing multi-region depth features
CN111259978A
Image semantic segmentation method based on multi-task deep learning
CN112950645A
Efficient segmentation of tumours from lung ct
US20250061682A1
Transfer learning-based method for improved VGG16 network pig identity recognition
WO2022252272A1
Cited By
Chromatic aberration threshold-based black pig counting method, device and equipment
CN120708166A
Self-adaptive image segmentation method and system based on visual template engine
CN121392289A
High-density blind and buried hole PCB laser drilling method, device and equipment
CN121551874A
Ceramic packaging device X-ray image preprocessing method and system
CN121616570A
Livestock identity verification method and system based on multi-modal image analysis
CN121789252A