A black pig image segmentation method based on multi-feature fusion
By employing a multi-feature fusion method, the problems of preprocessing enhancement, static feature extraction, and temporal information utilization in black pig image segmentation technology were solved, achieving high-precision segmentation in motion and group occlusion scenarios, and supporting intelligent breeding monitoring.
Patent Information
- Application Number
- CN202510602408.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-12
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2045-05-12
AI Technical Summary
Existing black pig image segmentation techniques have problems in preprocessing enhancement, static feature extraction, shape constraints, and utilization of temporal information, resulting in insufficient accuracy and robustness of segmentation results. In particular, they are difficult to cope with the movement status and posture changes of black pigs in a group-housed environment.
A multi-feature fusion-based approach is adopted, which extracts local shape features through gray-scale distribution feature enhancement, residual convolutional neural network, curvature threshold segmentation and dual fitting strategy. Boundary segmentation is performed by combining spatial location prior probability and dynamic behavior pattern map, and the segmentation results are optimized by group behavior model.
It significantly improves the accuracy, stability, and robustness of black pig image segmentation, effectively handles pose changes during movement and group occlusion scenarios, and enhances the effectiveness of intelligent breeding monitoring.
Smart Images

Figure CN120471941B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, and particularly relates to a black pig image segmentation method based on multi-feature fusion. BACKGROUND
[0002] With the continuous improvement of the intelligent level of the breeding industry, the black pig image segmentation technology plays an important role in breeding monitoring and behavior analysis. The current mainstream black pig image segmentation method usually adopts global histogram equalization or adaptive histogram equalization for image enhancement preprocessing, but these methods have many deficiencies in actual application: the details of the skin and fur area are easily lost in the enhancement process, the gray values of the background area and the target area are prone to aliasing, and the uniform enhancement strategy for regions with different texture complexities leads to poor processing results, which seriously affects the accuracy of subsequent segmentation.
[0003] The existing black pig image segmentation technology excessively relies on static feature extraction and is difficult to cope with the motion state and posture changes of black pigs in actual scenes. Especially in a group breeding environment, due to the occlusion and overlap between black pig individuals, combined with the diversity of their activity states, the traditional single shape template and segmentation method lacking temporal information constraint often cannot guarantee the continuity and accuracy of the segmentation results. These technical bottlenecks restrict the practical application effect of the black pig image segmentation technology in the field of intelligent breeding. SUMMARY
[0004] In view of the problems of the existing black pig image segmentation technology in preprocessing enhancement, static feature extraction, shape constraint and temporal information utilization, the present application is proposed.
[0005] Therefore, the problem to be solved by the present application is how to construct a black pig image segmentation method that can effectively maintain target details, adapt to posture changes, consider group behavior characteristics and have temporal consistency, so as to improve the accuracy and robustness of segmentation.
[0006] To solve the above technical problems, the present application provides the following technical scheme:
[0007] In a first aspect, the embodiment of the present application provides a black pig image segmentation method based on multi-feature fusion, which comprises the following steps: acquiring a black pig image; calculating a gray distribution feature of the black pig image; performing contrast enhancement processing on the black pig image according to the gray distribution feature to obtain an enhanced image; inputting the enhanced image into a residual convolutional neural network to generate a deep feature map, extracting a local shape feature map through curvature threshold segmentation and a double fitting strategy, fusing the local shape feature map and the deep feature map to generate a black pig feature map; establishing a spatial position prior probability map based on a black pig sample library, calculating a region correlation between the black pig feature map and the prior probability map, performing region adaptive weighting on the black pig feature map according to the region correlation to obtain a fused feature map; performing boundary segmentation on the fused feature map based on a dynamic behavior mode map and a posture constraint rule, and iteratively optimizing through a shape constraint condition to generate an initial segmentation map; establishing a group behavior model, taking the group behavior model as an optimization criterion to correct the boundary of the initial segmentation map, and outputting a final segmentation result.
[0008] As a preferred scheme of the black pig image segmentation method based on multi-feature fusion, the contrast enhancement processing on the black pig image according to the gray distribution feature comprises the following steps: acquiring an original black pig image, performing gray scale conversion on the original black pig image to obtain a gray scale image; performing grid division on the gray scale image to generate a regular sub-block image group, and calculating a gray distribution value of each sub-block image; sequentially merging and smoothing the gray distribution values of the sub-block images to obtain a smooth histogram, detecting a double-peak feature of the smooth histogram to determine a valley point position; taking the valley point position as the center, detecting a background region peak value position to the left and a fur region peak value position to the right, and taking the background region peak value position, the valley point position and the fur region peak value position as three reference segmentation points of a nonlinear enhancement curve; constructing a segmented enhancement function according to the three reference segmentation points; calculating a local texture feature of each sub-block image in the regular sub-block image group, calculating an adjustment coefficient of the segmented enhancement function according to the local texture feature; and performing enhancement processing on the gray scale image by using the adjusted segmented enhancement function, and performing smooth transition processing at the sub-block boundary to obtain an enhanced image.
[0009] As a preferred scheme of the black pig image segmentation method based on multi-feature fusion of the application, wherein: the local shape feature map extracted by curvature threshold segmentation and double fitting strategy comprises the following steps: performing edge detection on the enhanced image, extracting the image contour point set, calculating the curvature value of the image contour point set, and generating a curvature heat map; extracting contour points with a curvature value 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 circular metric value of the fitted circle; screening the head candidate region based on the circular metric value, determining the optimal head region by combining the area and the circular metric value, extracting the boundary point sequence of the optimal head region to construct the head contour feature; extracting contour points with a curvature value less than the first preset threshold from the curvature heat map, constructing an elliptical fitting candidate point set, fitting the elliptical fitting candidate point set using the random consistency algorithm, and calculating the elliptical metric value of the fitted ellipse; screening the torso candidate region based on the elliptical metric value, determining the optimal torso region by combining the area and the elliptical metric value, extracting the boundary point sequence of the optimal torso region to construct the torso contour feature; using a position-aware encoder to spatially encode and convert the head contour feature and the torso contour feature, and outputting a head position feature vector and a torso position feature vector, respectively; concatenating the head position feature vector and the torso position feature vector in the feature dimension, projecting the concatenated features to a feature space matching the depth feature map through a feature mapping network, and generating a shape feature map.
[0010] As a preferred scheme of the black pig image segmentation method based on multi-feature fusion of the application, wherein: the region adaptive weighting of the black pig feature map according to the region correlation comprises the following steps: performing hierarchical clustering division 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 depth 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 a receptive field adjustment module, calculating the receptive field scale parameter according to the local structure 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 of the feature response map and each level prior probability, and generating a hierarchical correlation index; inputting the hierarchical correlation index into a time series modeling network, extracting the spatiotemporal consistency feature of the black pig target, and outputting a time series enhanced feature response value; inputting the time series enhanced feature response value into a feature discriminator, extracting a region discrimination feature through contrast loss function optimization, and generating a discrimination weight matrix; weighting the black pig feature map using the discrimination weight matrix, performing boundary preservation filtering on the weighted feature, and generating a fusion feature map.
[0011] As a preferred scheme of the black pig image segmentation method based on multi-feature fusion according to the application, wherein: the boundary segmentation on the fusion feature map based on the dynamic behavior mode graph and the posture constraint rule comprises the following steps: inputting the continuous frame image sequence in the black pig sample library into the time-space double attention feature extraction network, calculating the motion cycle feature, the posture change feature and the spatial displacement feature; performing activity state classification on the motion cycle feature, performing weight fusion operation on the posture change feature and the spatial displacement feature according to different activity states, and outputting the dynamic behavior mode graph; dividing the black pig body structure into head, trunk and limb regions, constructing the inter-regional position constraint tree, calculating the relative position parameters and the motion range parameters of each region under different activity states, and generating the posture constraint rule; constructing a multi-scale shape template library, wherein each template corresponds to a group of activity state parameters and posture parameters, and generating a shape constraint condition through deformable convolution operation; establishing a three-item combined loss function including a feature response loss item, a time sequence continuity loss item and a shape constraint loss item; performing boundary segmentation on the fusion feature map based on the dynamic behavior mode graph, the posture constraint rule and the shape constraint condition; using a gradient weight adjustment algorithm, calculating the loss item weight based on the feature response intensity value and the time sequence continuity coefficient, updating the shape template library parameters; performing iterative optimization on the segmentation boundary, calculating the segmentation boundary difference value of adjacent iterations, and when the segmentation boundary difference value is less than the quality threshold, taking the current segmentation boundary as the segmentation mask, performing region filling processing based on the fusion feature map, and generating an initial segmentation graph.
[0012] As a preferred scheme of the black pig image segmentation method based on multi-feature fusion according to the application, wherein: the boundary segmentation on the fusion feature map based on the dynamic behavior mode graph and the posture constraint rule comprises the following steps: inputting the continuous frame image sequence in the black pig sample library into the time-space double attention feature extraction network, calculating the motion cycle feature, the posture change feature and the spatial displacement feature; performing activity state classification on the motion cycle feature, performing weight fusion operation on the posture change feature and the spatial displacement feature according to different activity states, and outputting the dynamic behavior mode graph; dividing the black pig body structure into head, trunk and limb regions, constructing the inter-regional position constraint tree, calculating the relative position parameters and the motion range parameters of each region under different activity states, and generating the posture constraint rule; constructing a multi-scale shape template library, wherein each template corresponds to a group of activity state parameters and posture parameters, and generating a shape constraint condition through deformable convolution operation; establishing a three-item combined loss function including a feature response loss item, a time sequence continuity loss item and a shape constraint loss item; performing boundary segmentation on the fusion feature map based on the dynamic behavior mode graph, the posture constraint rule and the shape constraint condition; using a gradient weight adjustment algorithm, calculating the loss item weight based on the feature response intensity value and the time sequence continuity coefficient, updating the shape template library parameters; performing iterative optimization on the segmentation boundary, calculating the segmentation boundary difference value of adjacent iterations, and when the segmentation boundary difference value is less than the quality threshold, taking the current segmentation boundary as the segmentation mask, performing region filling processing based on the fusion feature map, and generating an initial segmentation graph.
[0013] As a preferred scheme of the black pig image segmentation method based on multi-feature fusion provided in the application, wherein the calculation formula of the elliptical metric value is as follows:
[0014]
[0015] wherein, is a weight coefficient, D is an average distance deviation, D max is a preset maximum allowable deviation, O is a direction consistency metric value, and M is a shape regularity metric value.
[0016] In a second aspect, the embodiments of the application provide a black pig image segmentation system based on multi-feature fusion, which comprises a gray scale enhancement processing module, a residual feature fusion module, a priori correlation weighting module, a posture constraint segmentation module and a group mode boundary correction module.
[0017] The application has the following beneficial effects: by constructing a segmented enhancement function based on bimodal characteristics and a local texture feature adaptive adjustment strategy, the application realizes differentiated enhancement of image preprocessing; by using a residual convolutional neural network and a double fitting strategy with a feedback mechanism, the application effectively fuses deep features and local shape features; by combining spatial position prior probability and a region adaptive weighting mechanism, the application improves the accuracy of feature fusion; by using a segmentation scheme based on time-space double attention features and multi-level constraints, the application enhances the boundary positioning accuracy in a motion state; by introducing a group behavior model as an optimization criterion, the application solves the individual segmentation problem in a dense scene. The method significantly improves the accuracy, stability and robustness of black pig image segmentation, and provides effective technical support for intelligent breeding monitoring. BRIEF DESCRIPTION OF DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort on the basis of these drawings.
[0019] Figure 1 A framework flowchart of the black pig image segmentation method based on multi-feature fusion.
[0020] Figure 2 A contrast enhancement processing flowchart of the black pig image segmentation method based on multi-feature fusion.
[0021] Figure 3 A local shape feature extraction flowchart of the black pig image segmentation method based on multi-feature fusion.
[0022] Figure 4 A boundary segmentation flowchart of the black pig image segmentation method based on multi-feature fusion. DETAILED DESCRIPTION
[0023] In order to make the above-mentioned objects, features and advantages of the present application more apparent and understandable, the specific embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0024] In the following description, many specific details are set forth in order to provide a thorough understanding of the present application. However, the present application can be practiced without the specific details, which are not described in the present application, and the present application can be practiced in other manners different from the description. Therefore, the present application is not limited to the specific embodiments disclosed below.
[0025] Secondly, the "one embodiment" or "embodiment" referred to herein can include specific features, structures or characteristics contained in at least one implementation of the present application. "In one embodiment" appearing in different places in the specification does not mean the same embodiment, nor is it an independent or alternative embodiment that excludes other embodiments.
[0026] Embodiment 1, refer to Figures 1-4 , the first embodiment of the present application, the embodiment provides a black pig image segmentation method based on multi-feature fusion, the framework flowchart as shown in Figure 1 , including,
[0027] The multi-feature fusion-based black pig image segmentation method of the application is mainly applied to the field of intelligent breeding, provides precise individual identification, behavior analysis and intelligent monitoring technical support for pig farms, realizes pig group activity tracking, sow selection and breeding evaluation, early warning of diseases and other key applications through high-precision image segmentation, and promotes the digital transformation of the breeding industry. Specifically, the method can be applied to the following scenarios: in the intelligent monitoring system of large-scale pig farms, precise positioning and behavior tracking of black pig groups are realized; in sow selection and breeding management, technical support is provided for precise measurement and evaluation of black pig individual morphological characteristics; in the field of disease prevention and control, it helps breeders to find abnormal individuals in time.
[0028] S1: Obtain a black pig image, calculate the gray scale distribution feature of the black pig image, and perform contrast enhancement processing on the black pig image according to the gray scale distribution feature to obtain an enhanced image.
[0029] In the black pig image segmentation technology, image contrast enhancement is an important preprocessing step for extracting effective features. In the prior art, methods such as global histogram equalization or adaptive histogram equalization are usually used to enhance the image, but these methods have the following defects: first, although global histogram equalization can improve the overall contrast, it ignores the gray scale distribution features of local regions, resulting in loss of details in the black pig fur area; second, although adaptive histogram equalization considers local features, it is easy to cause the gray values of the background area and the fur area to be mixed due to the lack of analysis of specific gray scale distribution features of the black pig image, increasing the difficulty of subsequent segmentation; third, the traditional method uses a unified enhancement strategy for different texture complexity regions, which cannot well preserve the detail features of complex texture regions and is easy to introduce over-enhanced artifacts in simple texture regions.
[0030] In order to solve the above problems, the application proposes a multi-feature-based contrast enhancement scheme, and a contrast enhancement processing flowchart is shown as Figure 2 The specific implementation steps are as follows: first, collect an original black pig image, perform gray scale conversion on the original black pig image to obtain a gray scale image; perform grid division on the gray scale image to generate a regular sub-block image group, and calculate the gray scale distribution value of each sub-block image; merge the gray scale distribution values of the sub-block images to construct a global gray scale histogram, wherein the global gray scale histogram reflects the gray scale distribution features of the black pig fur area and the background area.
[0031] Then, the global gray histogram is smoothed to obtain a smoothed histogram, a bimodal characteristic of the smoothed histogram is detected, and a valley point position is determined; taking the valley point position as a center, a left background region peak value position is detected, and a right fur region peak value position is detected, and the background region peak value position, the valley point position and the fur region peak value position are taken as three reference segmentation points of a nonlinear enhancement curve; a segmented enhancement function is constructed according to the three reference segmentation points, a linear compression is adopted for a gray distribution value below the background region peak value, a nonlinear stretching is adopted for a gray distribution value between the background region peak value and the fur region peak value, and a linear compression is adopted for a gray distribution value above the fur region peak value.
[0032] Finally, local texture features including energy values, contrast values and entropy values of a gray level co-occurrence matrix are calculated for each sub-block image in the rule sub-block image group, an adjustment coefficient of enhancement intensity is calculated according to the local texture features, the adjustment coefficient is applied to the segmented enhancement function, wherein the adjustment coefficient is negatively correlated with texture complexity, the segmented enhancement function after adjustment is used for enhancement processing of the gray image, and a smooth transition processing is performed at a sub-block boundary to obtain an enhanced image, and the enhanced image is fused with color information of the original black pig image to output a final enhanced result image.
[0033] By adopting the technical scheme, the following beneficial effects are achieved: the segmented enhancement function constructed based on the bimodal characteristic adopts differentiated enhancement strategies for different gray interval, which not only ensures the contrast of the background region, but also avoids over-enhancement of the fur region; the local texture features are combined to adaptively adjust the enhancement intensity, so that the complex texture region obtains a smaller enhancement amplitude to maintain details, and the simple texture region obtains a larger enhancement amplitude to improve the contrast. The multi-level adaptive enhancement method not only improves the visual quality of the image, but also provides clearer feature information for subsequent segmentation processing, and effectively overcomes the problems in the prior art.
[0034] S2: inputting the enhanced image into a residual convolutional neural network to generate a deep feature map, extracting a local shape feature map through a curvature threshold segmentation and a double fitting strategy with a feedback mechanism, fusing the local shape feature map and the deep feature map to generate a black pig feature map.
[0035] Specifically, the local shape feature extraction flowchart is as shown in Figure 3 The local shape feature extraction flowchart is as shown in
[0036] S2.1: inputting the enhanced image into a residual convolutional neural network, generating multi-scale features through multi-layer convolution operation, fusing shallow texture features and deep semantic features through a skip connection structure, and outputting a deep feature map.
[0037] S2.2: performing edge detection on the enhanced image, extracting an image contour point set, calculating curvature values of the image contour point set, and generating a curvature heat map.
[0038] S2.3: Extract contour points with curvature values greater than the first preset threshold from the curvature heat map, construct a circle fitting candidate point set, and use the least squares method to fit the circle fitting candidate point set, and calculate the circle metric value of the fitted circle.
[0039] Wherein, the determination process of the first preset threshold is as follows: performing peak detection on the curvature heat map to generate a curvature peak sequence; clustering analysis is performed on the curvature peak sequence, and based on the clustering result, a high curvature value cluster and a low curvature value cluster are obtained; the mean value of the high curvature value cluster is calculated as the reference curvature upper limit, and the mean value of the low curvature value cluster is calculated as the reference curvature lower limit; an adjustment factor is set in combination with the image resolution and the black pig size ratio, and the first preset threshold is calculated based on the reference curvature upper limit, the reference curvature lower limit and the adjustment factor, and the specific formula is as follows:
[0040]
[0041] Wherein, T is the first preset threshold, K max is the reference curvature upper limit, K min is the reference curvature lower limit, is the adjustment factor. The value of the adjustment factor is related to the image resolution and the target size, and the specific calculation formula is as follows:
[0042]
[0043] Wherein, S is the average pixel area of the black pig region in the image, R is the total number of pixels in the image, is the reference coefficient.
[0044] It should be noted that the selection of the fitting candidate point set by the first preset threshold is mainly based on the following considerations: first, the threshold can effectively identify the morphological differences of the black pig. Since the head region presents obvious circular characteristics, its curvature value is larger and the distribution is relatively concentrated, while the trunk region presents elliptical characteristics, the curvature value is smaller and the distribution is uniform, therefore, by setting a suitable curvature threshold, the two types of regions can be accurately distinguished. Secondly, the setting of the threshold helps to optimize the algorithm performance. On the one hand, the threshold screening can retain the most representative feature points, significantly improving the fitting accuracy; on the other hand, the pre-screening process reduces the number of points participating in the calculation, effectively reducing the algorithm complexity.
[0045] In addition, the design of the adjustment factor takes the following factors into account: first, The value determines the position of the curvature threshold between the reference curvature upper and lower limits, and too large or too small will affect the accuracy of feature extraction. Through experiments, it is found that when , too many low curvature points are included in the head fitting, causing misidentification; when However, this will exclude some valid head contour points, affecting the fitting accuracy. Therefore, setting... The range of values This ensures both the robustness of the algorithm and meets the accuracy requirements. Secondly, the formula... The term represents the proportion of the black pig region in the image. A larger proportion indicates a more prominent target feature, requiring a higher curvature threshold to improve the discriminative power of feature points; conversely, when the target is small, the threshold needs to be lowered to ensure a sufficient number of feature points. (Baseline coefficient) The value of was determined through analysis of a large amount of experimental data. Experiments show that when At that time, the algorithm can achieve stable feature extraction results on images of different scales, and its performance is optimal.
[0046] Furthermore, the circularity metric is calculated based on the distance deviation from the fitted circle to the candidate point set, roundness, and the degree of matching with the standard head size. Specifically, a weighted summation method is used to comprehensively evaluate various indicators, and when the fitting quality meets the requirements, the corresponding region can be identified as a valid head candidate region.
[0047] S2.4: Filter candidate head regions based on circularity measures, determine the optimal head region by combining the region area and circularity measures, and extract the boundary point sequence of the optimal head region to construct head contour features.
[0048] S2.5: Extract contour points with curvature values less than the first preset threshold from the curvature heatmap, construct an ellipse fitting candidate point set, use a random consistency algorithm to fit the ellipse fitting candidate point set, and calculate the elliptic metric value of the fitted ellipse.
[0049] The calculation of the elliptic metric employs a multi-feature fusion evaluation method, focusing on addressing the elliptic deformation problem of the black pig's torso region under different shooting angles. This includes three parts: a fitting error term, a shape regularity term, and a direction term. The fitting error term calculates the normalized average distance deviation from candidate points to the fitted ellipse, effectively addressing local deformation caused by changes in the black pig's posture. The shape regularity term assesses the regularity of the fitted ellipse, resolving scale differences caused by black pigs of different sizes. The direction term assesses the consistency between the ellipse's principal axis direction and the reference direction, addressing fitting instability caused by changes in shooting angle.
[0050] Specifically, the formula for calculating the ellipticity measure is as follows:
[0051]
[0052] in, Here, D is the weighting coefficient, and D is the average distance deviation. max The preset maximum allowable deviation is 5% of the image diagonal length, where O is the orientation consistency metric and M is the shape regularity metric.
[0053]
[0054]
[0055] wherein 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 based on the statistical characteristics of the body shape of black pigs, r max is the maximum allowable ratio deviation, e is the eccentricity of the ellipse, e max is the maximum allowable eccentricity, is the direction angle of the major axis of the ellipse, is the reference direction angle of the torso determined based on the head position. Considering the stability characteristics of the torso region of the black pig, the weight coefficient adopts a fixed value: .
[0056] The ellipse measurement evaluation method designed in the application effectively solves the following problems through a multi-feature fusion strategy: first, the deformation characteristics of the black pig in different postures are considered, which improves the fitting accuracy; second, the shape specification term is designed based on biological statistical characteristics, which improves the adaptability of black pigs of different body shapes; third, the direction consistency constraint is introduced, which enhances the robustness of the algorithm under different shooting angles. Compared with the traditional ellipse fitting method using single geometric error evaluation, the measurement method of the application significantly improves the accuracy of feature extraction.
[0057] In addition, the screening process adopts a fixed threshold strategy, and the ellipse region with an ellipse measurement value E greater than 0.8 is retained for subsequent processing. The threshold is determined through a large amount of experimental data statistical analysis, which can effectively filter out abnormal fitting results while ensuring the fitting accuracy.
[0058] S2.6: Screening the torso candidate region based on the ellipse measurement value, determining the optimal torso region by combining the area of the region and the ellipse measurement value, and extracting the boundary point sequence of the optimal torso region to construct the torso contour feature.
[0059] S2.7: Using a position-aware encoder to spatially encode and convert the head contour feature and the torso contour feature, and outputting a head position feature vector and a torso position feature vector, respectively.
[0060] S2.8: Splicing the head position feature vector and the torso position feature vector in the feature dimension, projecting the spliced feature to a feature space matching the depth feature map through a feature mapping network, and generating a shape feature map.
[0061] S2.9: Calculating the feature importance weight based on the channel attention mechanism for the depth feature map and the shape feature map, performing element-wise addition operation on the weighted feature map, and outputting a black pig feature map.
[0062] S3: Establish a spatial position prior probability map based on the black pig sample library, calculate the regional correlation of 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.
[0063] Specifically, the following steps are included:
[0064] S3.1: Perform hierarchical clustering division on the target distribution in the black pig sample library, construct a multi-level spatial position probability tree, and calculate the spatial distribution probability of each level node using an adaptive kernel function.
[0065] It should be noted that the black pig sample library contains a large number of black pig images and their labeled data under different scenes, different times, and different poses. The images in the sample library cover various scenes such as single and group, and record the position information, pose information, and behavior information of the black pigs.
[0066] S3.2: Perform depth 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 position prior probability map based on the spatial constraint matrix and the spatial distribution probability.
[0067] S3.3: Input the black pig feature map into the receptive field adjustment module, calculate the receptive field scale parameter according to the local structure complexity of the feature, and generate a multi-scale feature response map based on the receptive field scale parameter.
[0068] Specifically, a gradient flow direction histogram is constructed, the gradient flow vector of the local region of the black pig feature map is calculated, and the main direction distribution feature of the gradient flow vector is extracted; an anisotropic covariance matrix is constructed based on the main direction distribution feature, the eigenvalue decomposition of the covariance matrix is calculated to obtain the shape description parameter of the local structure; an adaptive weight network is used to map the shape description parameter to a receptive field deformation parameter, and an anisotropic receptive field adjustment function is constructed; the black pig feature map is adaptively sampled using the receptive field adjustment function to generate a shape-adaptive multi-scale feature response map.
[0069] Preferably, the receptive field shape is dynamically adjusted by analyzing the anisotropic features of the feature, which not only considers the scale change but also considers the shape adaptability, and can better adapt to the complex structure in the black pig image. This can improve the accuracy of feature extraction, enhance the adaptability to irregular shapes, and reduce the influence of background interference.
[0070] S3.4: Construct a feedback path between the levels of the spatial position prior probability map, calculate the mutual information value of the feature response map and each level prior probability, and generate a level correlation index.
[0071] S3.5: Input the level 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.
[0072] S3.6: input the time series enhanced feature response value into the feature discriminator, optimize the extraction area discriminant feature through the contrast loss function, and generate a discriminant weight matrix.
[0073] Specifically, a double-branch feature discriminant network is constructed, the first branch receives the time series enhanced feature response value as a positive sample input, and the second branch receives the randomly enhanced feature response value as a negative sample input; a non-local attention module is embedded in the double-branch feature discriminant network to extract the context correlation features of the positive sample and the negative sample respectively; the cosine similarity of the context correlation features of the positive sample and the context correlation features of the negative sample is calculated to generate a feature similarity matrix; a contrast loss function is constructed, the feature similarity matrix is input into a temperature parameter adaptive adjustment module, and the contrast loss value is calculated based on the region consistency criterion; the training process of the feature discriminant network is guided by the contrast loss value to extract the region feature representation with discriminability; the region feature representation is input into a fully connected layer to generate a discriminant weight matrix.
[0074] S3.7: the discriminant weight matrix is used to perform weighted processing on the black pig feature map, boundary preserving filtering is performed on the weighted feature to generate a fusion feature map.
[0075] Preferably, the following innovative strategies are adopted in the feature fusion process: first, a multi-level spatial position probability tree structure is proposed, which can effectively capture the spatial distribution features of the black pig target at different scales; second, an adaptive receptive field adjustment mechanism is introduced, which dynamically adjusts the feature extraction range according to the local structure complexity of the feature, realizing the adaptability of feature extraction; third, a hierarchical feedback channel is constructed, and the cross-scale optimization of the feature is realized by calculating the mutual information value; finally, a time series modeling network is used to extract the spatio-temporal consistency feature, improving the stability of feature extraction. These innovations are designed for the specific task of black pig image segmentation, fully considering the characteristics of black pig target in spatial distribution, local structure and time series change, etc., and serving the goal of improving the segmentation accuracy.
[0076] S4: perform boundary segmentation on the fusion feature map based on the dynamic behavior pattern graph and the posture constraint rule, and iteratively optimize through the shape constraint condition to generate an initial segmentation map.
[0077] In the prior art, black pig image segmentation mainly relies on static features, which cannot accurately process posture changes in a motion state. In different activity states, the morphology of black pigs is significantly different, and a single shape template is difficult to adapt. At the same time, there is occlusion and overlap between individual black pigs, and the lack of temporal information constraint leads to inconsistent segmentation results between adjacent frames. In view of these problems, the present application proposes a segmentation scheme based on temporal-spatial double attention features and multi-level constraints, which significantly improves the segmentation accuracy in the motion state, enhances the temporal consistency, and improves the boundary positioning accuracy in the occlusion scene.
[0078] Specifically, the boundary segmentation flowchart is as shown in Figure 4 The steps include the following steps:
[0079] S4.1: input the continuous frame image sequence in the black pig sample library into the temporal-spatial double attention feature extraction network, and calculate the motion period feature, posture change feature and spatial displacement feature.
[0080] S4.2: classify the motion period feature according to the activity state, perform weight fusion operation on the posture change feature and the spatial displacement feature according to different activity states, and output the dynamic behavior mode graph.
[0081] Among them, the activity state classification is based on the clustering analysis of the motion period feature, and the black pig behavior is divided into typical states such as eating, walking and resting. For different activity states, an adaptive weight strategy is used to fuse the posture change feature and the spatial displacement feature, and the generated dynamic behavior mode graph can accurately reflect the behavior characteristics and motion law of the black pig.
[0082] S4.3: divide the black pig body structure into head, trunk and limb regions, construct the inter-regional position constraint tree, calculate the relative position parameters and motion range parameters of each region in different activity states, and generate the posture constraint rule.
[0083] Specifically, the skeleton extraction algorithm is used to locate the key points of the black pig sample image, extract the head center point, trunk axis point sequence and limb joint point, establish a relative coordinate system based on the trunk axis, calculate the angle range and distance range of the head center point relative to the front end of the trunk, and construct the head activity constraint. The limb joint point sequence is hierarchically grouped, the motion amplitude parameters of each joint point relative to the trunk axis are calculated, and the limb motion constraint is established. For different activity states, the relative position distribution of the key points in each region is counted, and the inter-regional spatial relationship graph is constructed. The inter-regional spatial relationship graph is converted into a tree structure, the dependency relationship between parent and child nodes is established, and the position constraint tree is generated. Based on the position constraint tree, the relative displacement vector and angle change range of each region in different activity states are calculated, and the posture constraint rule is output. This design improves the rationality of the segmentation result through biomechanical constraint, and avoids the segmentation boundary that does not conform to the actual situation.
[0084] S4.4: Construct a multi-scale shape template library, where each template corresponds to a set of activity state parameters and pose parameters, and generate shape constraint conditions through deformable convolution operation.
[0085] S4.5: Establish a three-item combined loss function including a feature response loss term, a temporal continuity loss term, and a shape constraint loss term.
[0086] It should be noted that the feature response loss term calculates the matching error between the segmentation boundary and the image features, 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.
[0087] S4.6: Perform boundary segmentation on the fused feature map based on the dynamic behavior pattern map, the pose constraint rule, and the shape constraint condition.
[0088] The segmentation process includes: first, initializing the segmentation region based on the dynamic behavior pattern map, then adjusting the region boundary according to the pose constraint rule, and finally refining the segmentation result using the shape constraint condition. This hierarchical segmentation strategy can gradually improve the segmentation accuracy.
[0089] S4.7: Use a gradient weight adjustment algorithm to calculate the loss term weight based on the feature response intensity value and the temporal continuity coefficient, and update the shape template library parameters.
[0090] Specifically, a self-attention matrix is constructed for the feature response intensity value, the relative importance scores of the features of each region are extracted, and the feature response weight is 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 the coefficient; the feature response weight and the temporal consistency weight are input into a multi-layer perceptron to generate dynamic weight coefficients of the three-item combined loss function; based on the dynamic weight coefficients, the deformation optimization calculation is performed on the reference templates in the shape template library, and the template parameters are updated based on the deformation optimization results.
[0091] The deformation optimization calculation includes: selecting the corresponding reference template according to the pose constraint rule of the current frame; calculating the contour mapping relationship between the current segmentation region and the reference template; generating a deformation field based on the contour mapping relationship; performing regularization processing on the deformation field to generate optimal deformation parameters; updating the optimal deformation parameters to the shape template library.
[0092] Preferably, the application designs an adaptive weight adjustment mechanism based on feature response intensity and timing characteristics, establishes a dynamic weight calculation model through a self-attention mechanism and morphological analysis, realizes adaptive adjustment of the loss function weight and online update of the shape template, and improves the adaptability of the segmentation model to different scenes. Compared with the fixed weight or empirical setting method in the prior art, the dynamic weight mechanism of the application can better balance the influence of feature response, timing continuity and shape constraint, so that the segmentation result is more accurate and stable.
[0093] S4.8: Perform iterative optimization on the segmentation boundary, calculate the segmentation boundary difference value of adjacent iterations, when the segmentation boundary difference value is less than the quality threshold, take the current segmentation boundary as the segmentation mask, perform region filling processing based on the fused feature map, and generate an initial segmentation map.
[0094] The iterative process includes: calculating the feature response graph and the timing continuity graph of the current boundary; updating the shape template deformation parameters based on the feature response graph and the timing continuity graph; substituting the shape template deformation parameters into the three-item combined loss function; and correcting the segmentation boundary according to the calculation result of the three-item combined loss function. The iterative optimization process ensures the convergence and stability of the segmentation result, and significantly improves the accuracy of the boundary.
[0095] S5: Establish a group behavior model, take the group behavior model as an optimization criterion, correct the boundary of the initial segmentation map, and output the final segmentation result.
[0096] Specifically, the density clustering algorithm is used to perform region clustering on the initial segmentation map, the contour boundary point set of each black pig individual is extracted, and the spatial geometric feature descriptor based on the contour boundary point set is established; a space-time interaction feature network is constructed, the spatial geometric feature descriptor is input into the space-time interaction feature network, the relative position relationship and motion state parameters between individuals are extracted; the minimum spanning tree between individuals is calculated based on the relative position relationship, the topological connection relationship between tree nodes is extracted, and a dynamic interaction matrix is constructed in combination with the motion state parameters; feature decomposition is performed on the dynamic interaction matrix to obtain a feature value sequence and a feature vector group, and the feature vector group is projected to a spatial position domain to generate a group behavior potential field.
[0097] Further, the group behavior potential field is used to apply mechanical constraints to the segmentation boundary, wherein the constraint force is proportional to the potential field gradient, and the direction is perpendicular to the potential field equipotential line; deformation is performed on the segmentation boundary under the mechanical constraint, the displacement vector of the boundary point is calculated, and a local shape preserving term is introduced to constrain the displacement size to obtain the actual displacement value of the boundary point; the position of the segmentation boundary is updated according to the actual displacement value of the boundary point, the group behavior potential field is recalculated based on the updated boundary position, and when the actual displacement value of all boundary points is less than a preset convergence threshold, the final segmentation result is output.
[0098] Preferably, the boundary correction scheme based on the group behavior model converts the relative position relationship and motion state between individuals into a group behavior potential field, thereby providing stable constraint conditions for the segmentation boundary optimization. Especially in complex scenes 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. The use of a minimum spanning tree to describe the topological relationship between individuals, combined with a dynamic interaction matrix to capture the group motion pattern, makes the segmentation results not only conform to the morphological characteristics of individual black pigs, but also meet the statistical laws of group behavior, thereby significantly improving the accuracy and robustness of the segmentation.
[0099] Further, the embodiment also provides a black pig image segmentation system based on multi-feature fusion, comprising a gray scale enhancement processing module, used for acquiring a black pig image, calculating the gray scale distribution feature of the black pig image, performing contrast enhancement processing on the black pig image according to the gray scale distribution feature, and obtaining an enhanced image; a residual feature fusion module, used 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 double fitting strategy, fusing the local shape feature map with the depth feature map, and generating a black pig feature map; a priori correlation weighting module, used for establishing a spatial position prior probability map based on a black pig sample library, calculating the regional correlation of the black pig feature map and the prior probability map, performing regional adaptive weighting on the black pig feature map according to the regional correlation, and obtaining a fused feature map; a posture constraint segmentation module, used for performing boundary segmentation on the fused feature map based on a dynamic behavior pattern map and a posture constraint rule, and iteratively optimizing through a shape constraint condition to generate an initial segmentation map; and a group boundary correction module, used for establishing a group behavior model, taking the group behavior model as an optimization criterion to correct the boundary of the initial segmentation map, and outputting a final segmentation result.
[0100] To sum up, the application realizes differentiated enhancement of image preprocessing by constructing a segmented enhancement function based on bimodal characteristics and a local texture feature adaptive adjustment strategy; effectively fuses depth features and local shape features by using a residual convolutional neural network and a double 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 boundary positioning accuracy in the motion state by using a segmentation scheme based on time-space dual attention features and multi-level constraints; and solves the individual segmentation problem in dense scenes by introducing a group behavior model as an optimization criterion. The method significantly improves the accuracy, stability and robustness of black pig image segmentation, and provides effective technical support for intelligent breeding monitoring.
[0101] Embodiment 2, refer to Figures 1-4For the second embodiment of the application, the embodiment provides a black pig image segmentation method based on multi-feature fusion. In order to verify the beneficial effects of the application, economic benefit calculation and simulation experiments are used for scientific demonstration.
[0102] In order to verify the effectiveness of the application, a field test experiment was conducted in a pig farm in a certain city for 3 months. The test environment includes indoor pig house and outdoor activity site, and the test object is 200 adult black pigs. The collection equipment uses an industrial-grade high-definition camera with a resolution of 1920x1080 pixels, a frame rate of 30fps, an installation height of 3 meters, and a downward angle of 30 degrees. The image acquisition time spans 24 hours a day, including different light conditions and weather conditions.
[0103] In terms of hardware configuration, the black pig image segmentation system of the application recommends the following computer hardware configuration: the processor selects a server-level Intel Xeon gold processor, the graphics processing unit (GPU) is configured with an NVIDIA Tesla professional graphics card, the memory is matched with an enterprise-level ECC server memory, and the storage device selects a high-speed solid state drive (SSD). This configuration can meet the performance requirements of real-time image processing, deep learning model training and multi-feature fusion calculation, support processing 30 frames of 1920x1080 resolution black pig images per second, and realize stable and efficient image segmentation in complex breeding scenes.
[0104] In the image preprocessing stage, the collected original image is first converted to grayscale and divided into a grid, with a grid size of 32x32 pixels. By calculating the gray scale distribution feature, the image is enhanced using the multi-feature based contrast enhancement scheme proposed in the application. 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 at the same time maintains the skin texture details, and the gray scale difference between the background area and the target area is improved by 31.2%. Especially in the scene of insufficient light, the signal-to-noise ratio of the image is improved by 2.8dB, which lays a good foundation for subsequent feature extraction.
[0105] In the feature extraction and fusion stage, the residual convolutional neural network adopts a 5-layer convolutional structure. In the curvature threshold segmentation, the first preset threshold is obtained by dynamic calculation, with an average value of 0.085 and an adjustment factor of 0.65. Experimental data shows that the multi-feature fusion strategy proposed in the application improves the average response intensity of the feature map by 18.7% and the feature discrimination by 25.3%. When processing 1000 test images, the average detection accuracy of the head region reaches 94.8%, and the ellipse fitting accuracy of the torso region reaches 92.3%, which is better than existing single feature extraction methods.
[0106] Based on the established spatial position prior probability map and the region adaptive weighting mechanism, the black pig feature map is optimized. In the experiment, a sample library containing 10000 labeled images is constructed, a three-level hierarchical clustering structure is adopted, and the kernel function bandwidth parameter is set to 0.45. The spatiotemporal consistency features are extracted through the time series modeling network, the network depth is 4 layers, and the hidden layer node number is 256. The experimental results show that under the complex scene with a target occlusion rate of 40%, the segmentation accuracy can still be kept above 89.5%, and the temporal consistency error is reduced to 0.06, which is significantly better than the traditional method.
[0107] In the final segmentation optimization stage, the boundary correction is carried out in combination with the dynamic behavior pattern map and the group behavior model. In the experiment, behavior data containing 5 typical activity states are collected, and a template library containing 200 basic shape templates is established. Through iterative optimization, the average convergence number is 12, and the boundary point displacement threshold is set to 0.5 pixels. The final evaluation results on 2000 test images show that the average segmentation accuracy of the present scheme reaches 91.2%, the boundary positioning error is reduced to 1.8 pixels, and the segmentation accuracy in the group dense scene is improved by 15.6%. As shown in Table 1, the performance comparison results of the present application and the prior art method fully prove the superiority of the method.
[0108] Table 1 Performance comparison of the present application and the prior art
[0109]
[0110] As can be seen from the comparison data in Table 1, the method of the present application is significantly better than the prior art method in various key performance indicators. In the comparative experiment, the traditional segmentation method adopts the combination scheme of Otsu threshold method and watershed algorithm, and the deep learning method adopts the integrated model of U-Net and FCN network. The deep learning method based on multi-feature fusion of the present application not only improves the segmentation accuracy, but also reduces the calculation overhead. Especially in the processing of complex scenes, the present application shows stronger robustness and adaptability, which fully proves the innovation and practical value of the present application.
[0111] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and not to limit the present application. Although the present application has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that the technical solutions of the present application can be modified or replaced equivalently without departing from the spirit and scope of the technical solutions of the present application, which should be covered in the scope of the claims of the present application.
Claims
1. A black pig image segmentation method based on multi-feature fusion, characterized in that: include, A black pig image is acquired, the grayscale distribution characteristics of the black pig image are calculated, and the black pig image is subjected to contrast enhancement processing based on the grayscale distribution characteristics to obtain an enhanced image; The enhanced image is input into a residual convolutional neural network to generate a deep feature map. At the same time, a local shape feature map is extracted through curvature threshold segmentation and a dual fitting strategy. The local shape feature map is fused with the deep feature map to generate a black pig feature map. A spatial location prior probability map is established based on a black pig sample library. The regional correlation between the black pig feature map and the prior probability map is calculated. Based on the regional correlation, the black pig feature map is subjected to regional adaptive weighting to obtain a fused feature map. Boundary segmentation is performed on the fused feature map based on the dynamic behavior pattern map and pose constraint rules, and iterative optimization is performed through shape constraint conditions to generate an initial segmentation map. A group behavior model is established and used as an optimization criterion to correct the boundary of the initial segmentation map, and the final segmentation result is output.
2. The black pig image segmentation method based on multi-feature fusion as described in claim 1, characterized in that: The contrast enhancement process for the black pig image based on the grayscale distribution characteristics includes: Acquire original black pig images, and perform grayscale conversion on the original black pig images to obtain grayscale images; The grayscale image is divided into grids to generate regular sub-block image groups, and the grayscale distribution value of each sub-block image is calculated; The grayscale distribution values of the sub-block images are merged and smoothed sequentially to obtain a smooth histogram. The bimodal characteristics of the smooth histogram are detected to determine the location of the valley points. Centered on the valley point, the peak position of the background region is detected to the left, and the peak position of the fur region is detected to the right. The peak position of the background region, the valley point, and the peak position of the fur region are used as the three reference segmentation points of the nonlinear enhancement curve. Construct a piecewise enhancement function based on the three benchmark segmentation points; For each sub-block image in the regular sub-block image group, calculate local texture features, and calculate the adjustment coefficient of the piecewise enhancement function based on the local texture features; The grayscale image is enhanced using an adjusted piecewise enhancement function, and a smooth transition is applied at the boundaries of sub-blocks to obtain the enhanced image.
3. The black pig image segmentation method based on multi-feature fusion as described in claim 1, characterized in that: The extraction of local shape feature maps through curvature threshold segmentation and dual fitting strategy includes the following steps: Edge detection is performed on the enhanced image to extract the image contour point set, the curvature value of the image contour point set is calculated, and a curvature heatmap is generated. Contour points with curvature values greater than a first preset threshold are extracted from the curvature heatmap, a circular fitting candidate point set is constructed, the circular fitting candidate point set is fitted using the least squares method, and the circularity metric of the fitted circle is calculated. Based on the circularity metric, candidate head regions are selected, and the optimal head region is determined by combining the region area with the circularity metric. The boundary point sequence of the optimal head region is then extracted to construct the head contour features. Contour points with curvature values less than a first preset threshold are extracted from the curvature heatmap, an ellipse fitting candidate point set is constructed, the ellipse fitting candidate point set is fitted using a random consistency algorithm, and the elliptic metric value of the fitted ellipse is calculated. Based on the elliptic metric value, candidate regions of the torso are selected, and the optimal torso region is determined by combining the region area and the elliptic metric value. The boundary point sequence of the optimal torso region is extracted to construct the torso contour features. A position-aware encoder is used to perform spatial encoding transformation on the head contour features and the torso contour features, and outputs the head position feature vector and the torso position feature vector, respectively. The head position feature vector and the torso position feature vector are concatenated along the feature dimension, and the concatenated features are projected onto 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 as described in claim 1, characterized in that: The process of performing adaptive weighting of the black pig feature map based on the regional correlation includes the following steps: Hierarchical clustering was performed on the target distribution in the black pig sample library to construct a multi-level spatial location probability tree, and the spatial distribution probability of each level node was calculated using an adaptive kernel function. Perform a depth-first traversal of the hierarchical nodes of the probability tree to obtain the topological relationships between nodes, convert the topological relationships 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. The black pig feature map is input into the receptive field adjustment module, the receptive field scale parameter is calculated based on the feature local structure complexity, and a multi-scale feature response map is generated based on the receptive field scale parameter. A feedback path is constructed between the levels of the spatial location prior probability map, the mutual information value between the feature response map and the prior probability of each level is calculated, and a hierarchical correlation index is generated. The hierarchical correlation index is input into the temporal modeling network to extract the spatiotemporal consistency features of the black pig target and output the temporal enhancement feature response value. The temporal enhancement feature response value is input into the feature discriminator, and the region discrimination features are extracted by optimizing the contrastive loss function to generate a discrimination weight matrix; The black pig feature map is weighted using the discriminant weight matrix, and boundary-preserving filtering is performed on the weighted features to generate a fused feature map.
5. The black pig image segmentation method based on multi-feature fusion as described in claim 1, characterized in that: The boundary segmentation of the fused feature map based on the dynamic behavior pattern graph and pose constraint rules includes the following steps: The continuous frame image sequence from the black pig sample library is input into the temporal-spatial dual attention feature extraction network to calculate motion period features, posture change features and spatial displacement features. The motion cycle features are classified into activity states, and weighted fusion operations are performed on the posture change features and spatial displacement features according to different activity states to output a dynamic behavior pattern diagram. The black pig's body structure is divided into head, trunk, and limb regions. A position constraint tree between regions is constructed, and the relative position parameters and range of motion 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 pose parameters, and generate shape constraints through deformable convolution operations; Establish a three-term combined loss function that includes a feature response loss term, a temporal continuity loss term, and a shape constraint loss term; Boundary segmentation is performed on the fused feature map based on dynamic behavior pattern graphs, pose constraint rules, and shape constraint conditions; A gradient weight adjustment algorithm is used to calculate the weight of the loss term based on the feature response intensity value and the temporal continuity coefficient, and to update the parameters of the shape template library. Iterative optimization is performed on the segmentation boundary, and the difference between the segmentation boundaries of adjacent iterations is calculated. When the difference between the segmentation boundaries is less than the quality threshold, the current segmentation boundary is used as the segmentation mask, and region filling is performed based on the fused feature map to generate the initial segmentation map.
6. The black pig image segmentation method based on multi-feature fusion as described in claim 1, characterized in that: Using the group behavior model as an optimization criterion, the boundary of the initial segmentation map is corrected by the following steps: The initial segmentation map is clustered using a density clustering algorithm to extract the contour boundary point set of each black pig individual, and a spatial geometric feature descriptor based on the contour boundary point set is established. A spatiotemporal interaction feature network is constructed, and the spatial geometric feature descriptor is input into the spatiotemporal interaction feature network to extract the relative positional relationship and motion state parameters between individuals; The minimum spanning tree between individuals is calculated based on the relative positional relationship, the topological connection relationship between tree nodes is extracted, and a dynamic interaction matrix is constructed in combination with the motion state parameters; Eigenvalue decomposition is performed on the dynamic interaction matrix to obtain the eigenvalue sequence and eigenvector group. The eigenvector group is then projected onto the spatial location domain to generate a group behavior potential field. The group behavior potential field is used to apply mechanical constraints to the segmentation boundary; Under the mechanical constraints, deformation is applied to the segmented boundary, the displacement vector of the boundary point is calculated, and a local shape preservation term is introduced to constrain the displacement magnitude to obtain the actual displacement value of the boundary point. The segmentation boundary position is updated based on the actual displacement value of the boundary point. The group behavior potential field is recalculated based on the updated boundary position. When the actual displacement value of all boundary points is less than the preset convergence threshold, the final segmentation result is output.
7. The black pig image segmentation method based on multi-feature fusion as described in claim 3, characterized in that: The formula for calculating the ellipticity metric is as follows: in, Here, D is the weighting coefficient, and D is the average distance deviation. max The maximum permissible deviation is preset, O is the directional consistency metric, and M is the shape regularity metric.
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: It also includes, The grayscale enhancement processing module is used to 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 based on the grayscale distribution characteristics to obtain an enhanced image; The residual feature fusion module is used to input the enhanced image into a residual convolutional neural network to generate a deep feature map, extract local shape feature maps through curvature threshold segmentation and a dual fitting strategy, and fuse the local shape feature maps with the deep feature maps to generate a black pig feature map. The prior association weighting module is used to establish a spatial location prior probability map based on the 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. The pose constraint segmentation module is used to perform boundary segmentation on the fused feature map based on the dynamic behavior pattern map and pose constraint rules, and to perform iterative optimization through 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 to 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