Foreground and background fused similarity task processing method and device, equipment and medium
By optimizing the generation of refined segmentation maps through segmentation networks and conditional random fields, and combining standard convolution and dynamic grouping strategies, the accuracy problem of blurred image boundary regions is solved, and stable representation and similarity calculation of foreground and background features are achieved, thus improving the accuracy of image analysis in the fields of fintech and healthcare.
Patent Information
- Application Number
- CN202610046596.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-14
- Publication Date
- 2026-05-01
AI Technical Summary
Existing image segmentation methods lack accuracy when dealing with regions with blurred boundaries, leading to foreground region leakage or background misclassification, which affects the accuracy of subsequent feature extraction, especially reducing the reliability of business recognition processes in the fields of fintech and healthcare.
An initial mask matrix is generated using a segmentation network model, and a refined segmentation map is generated by combining it with a conditional random field. Foreground and background feature representations are generated by standard convolutional kernels and dynamic grouping strategies, respectively. Finally, a unified feature representation is generated by fusing dual attention and gating to determine the image background similarity.
It improves the accuracy of image background similarity calculation, provides a more stable feature base, and enhances the reliability and consistency of subsequent task processing.
Smart Images

Figure CN121962658A_ABST
Abstract
Description
Methods, apparatus, equipment and media for foreground-background fusion similarity task processing Technical Field
[0001] This invention relates to the field of image detection technology, and in particular to a method, apparatus, device, and medium for foreground-background fusion similarity task processing. Background Technology
[0002] In the fintech sector, image data processing increasingly relies on the precise separation of foreground and background regions. For example, in multimodal customer behavior recognition, remote identity verification, or external scene monitoring, core analysis of the foreground region of the target image is required, while simultaneously assessing the changing trends of the background content. However, existing image segmentation methods are unstable when dealing with regions with blurred boundaries. When the textures of the background and foreground are similar, lighting conditions are complex, or edge structures are unclear, foreground region leakage or misclassification of the background can easily occur. These errors directly affect the accuracy of subsequent feature extraction, making it difficult for image analysis models to maintain stable output when data quality varies, thus reducing the reliability of the business recognition process.
[0003] In the healthcare field, the boundaries between organs and tissues in medical images are often inherently ambiguous. Factors such as transitional regions between soft tissues, diffuse boundaries around lesions, or unclear structures caused by imaging noise all make traditional segmentation methods prone to bias in boundary determination. Especially when further analysis based on anatomical structures or lesion regions is required, boundary errors can lead to inaccurate representation of regional features. Furthermore, many existing methods use structured convolution or static grouping to process different regional features, but this fixed grouping method cannot effectively cope with the diversity of background textures in medical images, resulting in unstable background feature representation and further affecting the representation quality of foreground regions. Summary of the Invention
[0004] The main objective of this invention is to provide a method, apparatus, device, and storage medium for foreground-background fusion similarity task processing, aiming to solve the technical problem that existing image segmentation and feature representation methods are not accurate enough in handling foreground-background boundary blurring, background texture changes, and foreground-background semantic association modeling, resulting in unstable unified feature representation.
[0005] To achieve the above objectives, this invention provides a method for processing foreground-background fusion similarity tasks, comprising: acquiring a target image to be processed; inputting the target image into a preset segmentation network model to perform feature extraction and pixel-level classification operations to generate an initial foreground-background binary mask matrix; constructing an energy function containing color potential terms and position potential terms; inputting the initial foreground-background binary mask matrix as an initial state into a conditional random field model; and using the conditional random field model to iteratively optimize the mask boundaries of the initial foreground-background binary mask matrix by minimizing the energy function to generate a refined foreground-background segmentation map; and using the refined foreground-background segmentation map to perform region division on the target image. The process involves obtaining foreground and background image regions; performing convolutional encoding on the foreground image region using standard convolutional kernels to generate a foreground feature representation; performing structured convolutional processing on the background image region using a dynamic grouping strategy and gating mechanism to generate a background feature representation; inputting the foreground and background feature representations into a dual attention module and a gating fusion unit, and generating a unified feature representation through weighted processing of spatial attention and channel attention, as well as gating fusion processing; determining the feature distance metric between the unified feature representation and a reference background feature; determining the image background similarity based on the feature distance metric; and performing the target task based on the image background similarity to obtain the target task result.
[0006] Furthermore, to achieve the above objectives, the present invention provides a foreground-background fusion similarity task processing device, comprising: a segmentation network module, used to acquire a target image to be processed, input the target image into a preset segmentation network model to perform feature extraction and pixel-level classification operations, and generate an initial foreground-background binary mask matrix; a boundary optimization module, used to construct an energy function containing color potential terms and position potential terms, input the initial foreground-background binary mask matrix as an initial state into a conditional random field model, and use the conditional random field model to iteratively optimize the mask boundary of the initial foreground-background binary mask matrix by minimizing the energy function, thereby generating a refined foreground-background segmentation map; and a region division module, used to perform region division processing on the target image using the refined foreground-background segmentation map to obtain a foreground-background fusion similarity task processing device, comprising: a segmentation network module, used to acquire a target image to be processed into a target image, input the target image into a conditional random field model, and use the conditional random field model to iteratively optimize the mask boundary of the initial foreground-background binary mask matrix by minimizing the energy function, thereby generating a refined foreground-background segmentation map; and a region division module, used to perform region division processing on the target image using the refined foreground-background segmentation map, thereby obtaining a foreground-background fusion similarity task processing device, comprising: a segmentation network module, used to acquire a target image to be processed into a target image, input the target image into a target image, and generate a target image to be processed into a target image; a region division module, used to perform region division processing on the target image using the refined foreground-background segmentation map, thereby obtaining a target image to be processed into a target image; a region division module, used to perform region division processing on the target image using the refined foreground-background segmentation map; and a region division module, used to perform region division processing on the target image using the foreground-background fusion similarity task processing device, and generate a target image to be processed into a target image to be The system comprises a foreground image region and a background image region; a foreground encoding module, used to perform convolutional encoding on the foreground image region using a standard convolutional kernel to generate a foreground feature representation; a background structured convolution module, used to perform structured convolutional processing on the background image region using a dynamic grouping strategy and a gating mechanism to generate a background feature representation; a feature fusion module, used to input the foreground feature representation and the background feature representation into a dual attention module and a gating fusion unit, and generate a unified feature representation through weighted processing of spatial attention and channel attention and gating fusion processing; and a background similarity determination module, used to determine the feature distance metric between the unified feature representation and the reference background features, determine the image background similarity based on the feature distance metric, and perform the target task based on the image background similarity to obtain the target task result.
[0007] Furthermore, to achieve the above objectives, the present invention also provides a computer device, the computer device including a memory, a processor, and a foreground-background fusion similarity task processing program stored in the memory and executable on the processor, wherein when the foreground-background fusion similarity task processing program is executed by the processor, it implements the steps of the foreground-background fusion similarity task processing method as described above.
[0008] Furthermore, to achieve the above objectives, the present invention also provides a computer-readable storage medium storing a foreground-background fusion similarity task processing program, wherein when the foreground-background fusion similarity task processing program is executed by a processor, it implements the steps of the foreground-background fusion similarity task processing method described above.
[0009] Beneficial Effects: This invention relates to the field of image detection technology and can be applied to business scenarios such as fintech and healthcare. It discloses a method, apparatus, device, and medium for foreground-background fusion similarity task processing, comprising: inputting a target image into a segmentation network to generate an initial mask matrix, and optimizing it using a conditional random field to obtain a refined segmentation map; dividing the foreground and background regions based on the refined segmentation map, generating foreground feature representations and background feature representations respectively, and obtaining a unified feature representation through dual attention and gating fusion; determining the image background similarity based on the feature distance metric between the unified feature representation and the reference background features, and thus completing the target task processing to obtain the target task result. This invention achieves accurate characterization of the semantic relationship between foreground and background through refined boundary modeling, structured background feature construction, and attention fusion mechanism, making the unified feature representation more discriminative, thereby improving the accuracy of image background similarity calculation and providing a more stable feature foundation for subsequent task processing. Attached Figure Description
[0010] The present invention will be further described below with reference to the accompanying drawings and embodiments. In the drawings: Figure 1 is a schematic diagram of an application environment of the foreground-background fusion similarity task processing method in an embodiment of the present invention; Figure 2 is a schematic flowchart of an embodiment of the foreground-background fusion similarity task processing method in the present invention; Figure 3 is a schematic diagram of the functional modules of a preferred embodiment of the foreground-background fusion similarity task processing device in the present invention; Figure 4 is a schematic diagram of the structure of a computer device in an embodiment of the present invention; Figure 5 is another schematic diagram of the structure of a computer device in an embodiment of the present invention. Detailed Implementation
[0011] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0012] The foreground-background fusion similarity task processing method provided in this invention can be applied in the application environment shown in Figure 1, where the client communicates with the server via a network. The server can input the target image into a segmentation network via the client to generate an initial mask matrix, and then optimize it using a conditional random field to obtain a refined segmentation map. Based on the refined segmentation map, foreground and background regions are divided, generating foreground and background feature representations respectively, and then fusing them using dual attention and gating to obtain a unified feature representation. The image background similarity is determined based on the feature distance metric between the unified feature representation and the reference background features, and the target task processing is completed accordingly to obtain the target task result. This invention achieves accurate characterization of the semantic relationship between foreground and background through refined boundary modeling, structured background feature construction, and attention fusion mechanisms, making the unified feature representation more discriminative, thereby improving the accuracy of image background similarity calculation and providing a more stable feature foundation for subsequent task processing. The client can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster consisting of multiple servers. The invention will be described in detail below through specific embodiments.
[0013] Please refer to Figure 2, which is a flowchart illustrating an embodiment of the foreground-background fusion similarity task processing method provided by the present invention. It should be noted that although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here.
[0014] As shown in Figure 2, the foreground-background fusion similarity task processing method proposed in this invention includes the following steps: S10, acquiring the target image to be processed, inputting the target image into a preset segmentation network model to perform feature extraction and pixel-level classification operations, and generating an initial foreground-background binary mask matrix; in this embodiment, acquiring the target image to be processed corresponds to inputting a complete pixel matrix from a data interface, acquisition terminal, or task system, so that it can be used as an image input in a unified format. Inputting the target image into the preset segmentation network model means loading a pre-trained segmentation structure for extracting semantic expressions. The encoding part of the model performs spatial convolution and channel convolution separation processing on the image through depthwise separable convolution, capturing local details such as edges and textures on the one hand, and integrating high-level semantics on the other hand, so that multi-scale encoded features are formed after layer-by-layer downsampling. Low-level detail features come from shallow convolution units and contain richer texture cues. The decoding part restores the spatial size through upsampling operations and performs channel concatenation with low-level detail features, making the structural contour clearer after fusion. The classification layer performs pixel-by-pixel classification on the fused features, mapping each pixel to a category probability value, forming a pixel prediction probability map. The thresholding operation converts the probabilities into binary labels, thereby forming an initial foreground-background binary mask matrix, which provides a structural basis for subsequent data processing.
[0015] The coding structure can select different depths of convolutional layers according to the task scale to achieve a balance between performance and computational cost. Upsampling restoration can be achieved through deconvolution or interpolation, with the specific choice depending on the texture density and boundary fineness requirements of the target image. Channel adjustment units can be added to the fusion stage to make the ratio of high-level semantics to detailed structure more stable. The threshold can be set statically or automatically inferred from historical data statistics to enhance adaptability.
[0016] In one implementation, the segmentation network model is built upon an improved MobileNetV3 architecture. MobileNetV3 is a lightweight convolutional neural network architecture that uses a combination of depthwise separable convolutions, asymmetric convolutions, channel attention units, and nonlinear activation functions to compress and represent image features. To adapt to pixel-level segmentation tasks of foreground and background, the backbone of the network uses the improved MobileNetV3 as its encoding backbone. Multiple layers of convolutional units extract feature maps at different receptive field scales, improving the responsiveness to fine-grained contour and texture changes while maintaining manageable computational cost. Near the output, the global pooling and fully connected structures of the original classification network are removed, and upsampling units and one or more 1x1 convolutions are introduced to map the channel dimensions to mask channels for foreground and background categories, outputting foreground and background probabilities at each spatial location. By normalizing and thresholding these two channels in the pixel dimension, the category label of each pixel is encoded as a zero or one value, thus forming a two-dimensional or three-dimensional binary mask matrix. Each element in the matrix corresponds one-to-one with a pixel position in the target image. Discrete labels are used to distinguish the foreground and background regions, providing the input data basis for subsequent mask boundary optimization and region segmentation.
[0017] This embodiment transforms the target image into a binary mask matrix after feature extraction, upsampling restoration, and pixel-level classification. This results in clearer structural boundaries and more stable region separation, thereby reducing the interference of background noise on subsequent image analysis and improving the basic separation quality of the foreground and background.
[0018] S20: Construct an energy function containing color potential and position potential terms. Use the initial foreground / background binary mask matrix as the initial state input to the conditional random field model (CRF). Utilize the CRF model to iteratively optimize the mask boundaries of the initial foreground / background binary mask matrix by minimizing the energy function, generating a refined foreground / background segmentation map. In this embodiment, the energy function construction process is based on the pixel differences between the foreground and background, establishing a pixel association structure through color and position potential terms. The color potential term originates from the difference between adjacent pixels in the color space, often expressed as RGB, Lab, or HSV, and is used to measure the color similarity within a local region; a smaller value indicates greater consistency in appearance between the two pixels. The position potential term originates from the spatial distance between pixels and is used to limit the smoothness of pixel labels in the processed region. Weights are formed through spatial distance mapping, making the energy minimization operation tend to preserve local coherence. The initial foreground / background binary mask matrix is used as the initial state input to the CRF model, undertaking the initial assignment of pixel labels. Driven by an energy function, the Conditional Random Field (CRF) model iteratively updates pixel classification labels, incorporating both color consistency and spatial coherence into the optimization process. The energy minimization algorithm evaluates the impact of pixel label changes on the overall energy in each update, gradually approaching a stable solution and redistributing blurred boundary regions. When the energy decreases to a stable level, a label matrix can be output, forming a more refined foreground-background segmentation map that better conforms to the structural contours.
[0019] The color potential term can be constructed using different color space difference metrics, such as prioritizing the Lab color space in scenes with weak textures to enhance robustness to illumination changes. The location potential term can have its Gaussian kernel width set according to image resolution, allowing the spatial neighborhood to adapt to different scales of texture complexity. Energy minimization can employ mean field updates, graph optimization, or iterative belief propagation, chosen based on computational resources and real-time requirements. The mask initialization stage can synchronously load the predicted probability map, making it easier to adjust the initial labels to stable boundary regions. The model can adjust the number of iterations based on the image noise level to avoid over-smoothing leading to detail loss.
[0020] This embodiment incorporates the color and spatial distribution relationships of pixels into the energy function and utilizes the iterative optimization mechanism of conditional random fields to significantly reduce the offset of the initial mask boundary caused by noise, weak texture, or occlusion. This makes the boundary between the foreground and background more coherent, the details more accurate, and improves the basic quality of subsequent image analysis tasks.
[0021] S30, the target image is divided into foreground and background image regions using the refined foreground / background segmentation map. In this embodiment, the region division using the refined foreground / background segmentation map is based on pixel classification results. A binary label matrix is used to divide the target image into foreground and background parts. Foreground labels are used to indicate regions with main structures or target objects, while background labels are used to identify environments, textures, or irrelevant regions. In the foreground label matrix, pixels with foreground markings are typically represented as 1, while background markings are represented as 0. Using this binary structure, a point-by-point mapping operation can be performed on the target image at the pixel level, filtering the foreground labels against the original pixels to zero out non-foreground pixel values. Similarly, a background label matrix can be constructed by logically inverting the foreground labels, filtering background pixel regions in the same way. The original color values and texture information of the pixels are preserved during the point-by-point mapping process, ensuring that both the segmented foreground and background image regions retain their true visual attributes in the target image. Region culling is used to remove holes or zero blocks that still exist after mapping, so that the final region output has a continuous structure, which is convenient for subsequent processing modules to use.
[0022] During region segmentation, morphological smoothing can be applied to the refined foreground and background segmentation maps to reduce the impact of isolated pixels on region integrity. Point-by-point mapping between the foreground label matrix and the original image can be performed using a channel-based approach to maintain consistency in RGB or multi-channel features. For high-resolution images, a region compression strategy can be introduced, performing connected component analysis on the label matrix before removing zero-value regions to preserve structurally continuous and significantly large foreground regions. Threshold filtering conditions can be set during background region extraction to prevent isolated background blocks caused by noise from interfering with subsequent processing.
[0023] This embodiment directly applies the refined segmentation results to image pixels, generating clearly structured foreground and background image regions without destroying the original information. This improves the accuracy and stability of region segmentation, enabling subsequent computational tasks to be processed based on the independent representations of the target object and the background environment.
[0024] S40, the foreground image region is convolutionally encoded using a standard convolutional kernel to generate a foreground feature representation. In this embodiment, the convolutional encoding process on the foreground image region relies on a standard convolutional kernel to extract features. A standard convolutional kernel typically refers to a weight matrix that slides at a fixed size in space and performs element-wise operations with local pixel regions. Its function is to compress local spatial information and generate feature maps that can be used for subsequent calculations. When processing the foreground image region, the convolutional kernel performs a dot product operation with the input multi-channel pixel matrix position by position to extract texture gradients, edge shapes, and local structural patterns. The convolutional feature map retains visually significant details while reducing the interference of residual background noise on the foreground region. Batch normalization is used to standardize the convolution output in the channel dimension, ensuring a stable distribution of features during forward propagation and reducing the impact of pixel brightness fluctuations. Nonlinear activation transformation enhances the expressive range of features through function mapping, enabling the convolution result to distinguish different semantic regions. Continuously executing convolution, normalization, and activation operations allows the foreground image region to be converted into multi-scale feature maps layer by layer, ultimately forming a foreground feature representation.
[0025] The kernel size can be adjusted according to the density of the foreground structure. For example, a smaller kernel is used when the foreground texture is fine to enhance fine-grained capture; a larger kernel is configured when the foreground edge width is large to obtain a more stable boundary response. The foreground image region can be linearly scaled or channel normalized before being input to the convolutional layer to reduce computational fluctuations caused by resolution differences. The scaling factor and bias parameter in batch normalization can be automatically learned during the training phase to adapt to different foreground distributions. When applied to foreground regions with multi-layered textures, multiple convolutional coding units can be stacked and skip connections can be introduced at different depths to preserve shallow details.
[0026] This embodiment uses convolutional coding to extract highly discriminative local features without changing the overall structure of the foreground region, making the output foreground feature representation more stable and more expressive, and providing higher quality input for subsequent feature fusion or similarity calculation.
[0027] S50, the background image region is subjected to structured convolution processing using a dynamic grouping strategy and a gating mechanism to generate a background feature representation. In this embodiment, when performing structured convolution processing on the background image region, a dynamic grouping strategy is introduced to divide features along the channel dimension, causing the input channels to be adaptively split into several independent groups. The sources of the dynamic grouping strategy may include channel importance estimation based on channel statistics, pattern clustering results based on texture changes, or segmentation rules based on spatial response distribution. The purpose is to make features within different groups more correlated and reduce cross-group redundancy. Each group is configured with an independent convolution kernel, so that the convolution operation is structured according to the texture differences of the background region. The initial grouped features obtained after convolution often do not have consistent numerical distributions, so a gating mechanism is used to perform filtering. The gating mechanism generates control weights through learnable parameters and maps them to interval weight values to adjust the passability of grouped features, so that groups with strong texture saliency receive higher responses, while groups with mixed textures or high noise are suppressed. Element-wise multiplication operations make the gating weights and grouped features precisely matched at each channel position and complete the filtering function. Finally, all weighted grouped features are spliced together in the channel direction to form a background feature representation.
[0028] The dynamic grouping strategy can be adjusted based on the complexity of the background texture. When the background texture is relatively uniform, the number of groups is reduced to improve the capture efficiency of continuous spatial structures; when the background texture exhibits a multi-modal structure, the number of groups is increased to improve the feature representation bandwidth. The parameters in the gating mechanism can be learned during the training phase or automatically generated by statistically analyzing the local distribution of the background region to adapt to different image types. Depthwise extended convolutions can be added to the convolutional structure to enhance the receptive range, or multi-scale convolutional kernels can be configured to adapt to large-scale changes in the background region. In background regions with large offsets, the weight change rate of the gating mechanism can be adapted to make the gating response smoother.
[0029] This embodiment reduces feature aliasing within the background region by combining structured convolution with dynamic grouping and gating mechanisms, enabling the background feature representation to have clearer texture differentiation and more stable channel response, which is beneficial for subsequent differential analysis of foreground and background features.
[0030] S60, the foreground feature representation and the background feature representation are input to the dual attention module and the gated fusion unit. A unified feature representation is generated through weighted processing of spatial attention and channel attention, followed by gated fusion processing. In this embodiment, after being input into the dual attention module, the foreground and background feature representations undergo weighted processing in both spatial and channel dimensions. Spatial attention is introduced to enhance the discriminative ability of features at different spatial locations. By extracting statistics from the feature map in the height and width directions to construct a spatial response distribution, the spatial attention weights can capture the importance of local regions and suppress irrelevant regions. Channel attention is added to measure the contribution of each channel to the discriminative ability. By extracting the overall statistical values in the channel direction and generating a channel weight vector through nonlinear transformation, the foreground and background features obtain different response amplitudes in the channel dimension. In the dual attention module, spatial attention and channel attention act on the foreground and background features in parallel, strengthening each type of feature in different dimensions.
[0031] After processing by the dual attention module, spatially enhanced foreground features, spatially enhanced background features, channel-enhanced foreground features, and channel-enhanced background features are generated. A feature fusion process then combines the results of spatial and channel enhancements, giving the foreground features a doubly enhanced representation, and similarly generating doubly enhanced background features. These are then input into a gated fusion unit, where joint features are constructed by concatenating the two types of doubly enhanced features. A fusion balance coefficient is generated based on a learnable mapping, which determines the contribution ratio of foreground and background features during the fusion process. Finally, the two types of features are weighted using the fusion balance coefficient to obtain a unified feature representation. This representation simultaneously includes spatial differences, channel differences, and complementary information between foreground and background, making the representation more focused and more discriminative.
[0032] Spatial attention can be implemented using average or maximum statistics along the height and width directions to form different spatial response patterns; learnable projections can also be introduced to make spatial attention weights more adaptable to complex structures. Channel attention can use a compression-expansion structure to adjust the representation range of channel vectors to adapt to different model scales. Foreground and background features can have their spatial dimensions and channel order adjusted before fusion to adapt to different feature flow organization methods. Multiple nonlinear transformations can be configured in the gated fusion unit to enhance the expressive power of the fusion balance coefficients, or the fusion balance coefficients can be divided into multiple scales to adapt to different levels of feature fusion. Before inputting dual-enhanced features, the normalization method can also be adjusted to keep features from different sources within a more stable numerical range.
[0033] This embodiment uses a combination of spatial attention and channel attention to weight foreground and background features in different dimensions, and then uses the fusion balance coefficient generated by the gating fusion unit to complete the weighted integration, making the unified feature representation more discriminative and consistent, and improving the stability of subsequent processing.
[0034] S70, determine the feature distance metric between the unified feature representation and the reference background features, determine the image background similarity based on the feature distance metric, and perform the target task based on the image background similarity to obtain the target task result.
[0035] In this embodiment, after fusing foreground and background information, the unified feature representation needs to be numerically compared with a reference background feature to construct a feature distance metric that characterizes the degree of difference between the two. The unified feature representation is used to describe the comprehensive background expression of the current image, while the reference background feature comes from a pre-established set of background features and is used to provide statistical feature vectors of the background in similar scenes. To ensure the comparability of the two types of features, vector normalization or interval mapping is performed on the unified feature representation to make it consistent in numerical range, dimensional structure, and scale.
[0036] Feature distance metrics are obtained by calculating the vector difference between a uniform feature representation and a reference background feature. This difference can be generated by vector offset, vector direction angle, or a combination of both, and reflects the degree of deviation from the image background. A smaller distance value indicates a closer proximity to the reference background, while a larger distance value indicates a greater degree of deviation. To make the distance values applicable to comparisons across different background categories, the original distance needs to be further mapped to image background similarity. This can be achieved by constructing a monotonic mapping function or generating a similarity distribution based on empirical statistics, ensuring that the background similarity stably reflects the range of distance variations.
[0037] After obtaining the image background similarity, the task input conditions are formed by comparing it with a task threshold. Different thresholds correspond to different task triggering logic. When the background similarity meets the predetermined conditions, the system executes the corresponding target task, including marking the current image state, triggering anomaly handling procedures, or generating task output related to the degree of background matching. Finally, the target task result is obtained according to the task execution process, providing usable decision data for the overall processing.
[0038] Feature distance metrics can be implemented using the sum of squared vector differences, vector direction cosines, or multidimensional feature kernel functions. Multiple difference calculation methods can also be combined to enhance the representation of complex backgrounds. When mapping background similarity, piecewise linear functions can be used to make distance changes exhibit more significant similarity differences within specific intervals, or exponential decay functions can be used to make small distance changes correspond to higher background similarity. When performing the target task, different threshold values can be adapted to different types of images; for example, a more lenient threshold can be used in high-noise environments, while a stricter threshold can be used in environments with clear structures. Alternatively, a multi-level threshold structure can be used to divide background similarity into multiple levels, each corresponding to a different task processing flow, thereby improving the flexibility and applicability of task execution.
[0039] The execution of the target task is driven by image background similarity. The feature distance metric between the previously obtained unified feature representation and the reference background features is transformed into executable task control instructions. Image background similarity typically exists as a scalar or low-dimensional vector, reflecting the proximity between the current target image background and the reference background scene. During task execution, task status markers, such as compliant, available, requiring review, and abnormal, are generated based on similarity. These markers are then matched against a pre-defined set of task rules to determine the type of task to be executed. Task types can include data receiving tasks, quality screening tasks, alarm tasks, recording tasks, or tasks triggered by subsequent processing links. During task execution, the target image itself, the unified feature representation, and the image background similarity are encapsulated as task context data. The task execution engine loads the corresponding processing flow based on this context data, marking, filtering, routing, or distributing the image, ultimately generating the task execution result. This result can be presented as a label field, decision tag, processing instruction, or business output data, forming the target task result.
[0040] When executing a target task, task decision units and task execution units can be deployed in the computing nodes. The task decision unit receives image background similarity and associated identifier information of the target image. Based on the relationship between similarity and a threshold table, it outputs a task level code. This task level code corresponds one-to-one with a task rule table, used to determine the subsequent task flow to be invoked. The task execution unit can select different processing flows according to the task level code, such as invoking a quality verification flow, a manual review flow, an automatic pass flow, or an isolation observation flow. During execution, the task execution unit can generate a task execution record including a timestamp, image identifier, background similarity, and decision result, and write the record to the task result storage area for easy subsequent statistics and tracking. A task queue can also be introduced into the task execution unit, assigning low priority to objects with low image background similarity and high priority to objects with similarity near the threshold. This dynamically schedules computing resources, allowing a balance between latency and accuracy in achieving the target task results.
[0041] Example: In the healthcare field, a reference background feature library can be built for remote follow-up images. When performing a target task, the similarity of the image background can be used to determine whether the patient's uploaded image meets the prescribed collection environment. If the similarity is high, it will automatically enter the subsequent analysis process. If the similarity is low, the task result will be generated to prompt the user to re-collect the image or transfer it to manual review.
[0042] In the financial sector, reference background features of branch office backgrounds or standard collection environments can be maintained for identity verification scenarios. Image background similarity can be mapped to task result labels such as pass, review, and rejection through the target task execution process. When the similarity reaches the threshold, image archiving and business flow are automatically completed. When the similarity deviates from the threshold, an anomaly mark is output and pushed to the risk control link, thereby providing quantifiable decision-making basis for image background consistency control.
[0043] This embodiment quantifies the difference between the unified feature representation and the reference background features, maps the distance value to the background similarity, and performs the target task based on the similarity. This enables the processing flow to reflect the degree of deviation of the background information in a more accurate way, achieves stable judgment of image background changes, and improves the consistency and reliability of task execution.
[0044] In one embodiment, step S10 includes: S101, acquiring the target image to be processed, performing feature extraction on the target image using a depthwise separable convolutional encoder constructed in a preset segmentation network model, generating an encoded feature map containing multi-scale information and low-level detail features that retain texture information through layer-by-layer downsampling processing; S102, performing a layer-by-layer upsampling recovery operation on the encoded feature map using a decoder corresponding to the encoder in the segmentation network model, generating an upsampled feature map; S103, acquiring the low-level detail features through a skip connection mechanism, and concatenating and fusing the low-level detail features with the upsampled feature map of the corresponding spatial resolution in the channel dimension to generate a multi-scale fused feature map; S104, inputting the multi-scale fused feature map into a classification layer to perform pixel-level classification, outputting the probability value of the category to which each pixel belongs, forming a pixel prediction probability map, and binarizing the probability values according to a preset threshold to generate an initial foreground and background binary mask matrix.
[0045] In this embodiment, when acquiring the target image to be processed, one or more frames of static image data can be received from the image acquisition terminal, the business system storage, or the dataset loading interface. This image typically exists in the form of a two-dimensional pixel matrix, with each pixel containing brightness or multi-channel color information, such as three-channel RGB encoding or four-channel RGBA encoding. To ensure the consistency of subsequent network inputs, the image typically undergoes preprocessing operations such as size resampling, channel order adjustment, normalization, and mean reduction before entering the segmentation network model. This ensures that the pixel values fall within a preset numerical range and are consistent with the data distribution used during the pre-training of the segmentation network model.
[0046] The pre-designed segmentation network model structurally comprises an encoding path and a decoding path. The encoding path utilizes a depthwise separable convolutional encoder. This depthwise separable convolution decomposes standard convolution into channel-wise spatial convolution and linear combinations of channel operations. On one hand, in the spatial dimension, it uses small-scale convolution kernels to perform convolution operations on local image regions, capturing low-order patterns such as texture edges and local shapes. On the other hand, in the channel dimension, it uses point convolution to achieve cross-channel information recombination, thus significantly reducing the number of parameters and computational cost while maintaining a similar receptive field configuration. Layer-wise downsampling can be achieved through convolution with a stride greater than one, pooling operations, or a combination of both. After each downsampling, the width and height of the feature map are reduced by a fixed ratio, while the number of channels gradually increases according to the design, forming a set of encoded feature maps containing different spatial resolutions and different levels of semantic abstraction. The encoded feature maps closer to the input retain more local texture and detail information, while those closer to the end of the encoding path highlight higher-order semantic patterns such as object categories and background structures. To ensure that local boundary information is available in subsequent stages, the encoding path explicitly preserves low-level detail features in several layers near the input. These features still maintain high spatial resolution and contain rich edge, corner, and texture orientation information.
[0047] The decoding path restores spatial resolution through decoders that correspond to each level of the encoding path. The decoder performs progressive upsampling on the encoded feature map, using deconvolution, interpolation with convolution, or other learnable upsampling units to gradually restore low-resolution features to a spatial size close to the original image. Each upsampled feature map is spatially close to or identical to the corresponding level of the encoded feature map, facilitating the construction of a multi-scale information fusion pathway. While restoring spatial information, the decoding path also refines higher-order semantic features, ensuring clear representation of the boundary between objects and background at a near-pixel scale.
[0048] The skip connection mechanism establishes a direct information pathway between the encoding and decoding paths. By recording low-level detail features generated during forward propagation, these features are concatenated and fused with the current upsampled feature map at the corresponding spatial resolution level along the channel dimension. Channel-dimensional concatenation directly stacks the two types of information together, preserving the semantic contours contained in the upsampled features while introducing fine boundary information from the low-level detail features. The concatenated result is further integrated by convolutional units, enabling the network to simultaneously utilize texture, edge, and category-related features at the same spatial location to form a multi-scale fused feature map. The multi-scale fused feature map closely approximates the original image in spatial resolution and encodes multi-level structural information along the channels, providing sufficient discriminative basis for subsequent pixel segmentation.
[0049] During the classification phase, multi-scale fused feature maps are fed into the classification layer for pixel-level classification. The classification layer typically employs a one-dimensional or two-dimensional convolutional output structure with the number of channels equal to the number of classes. It calculates the response value for each class at each spatial location and then transforms the response value into a probability distribution using an activation function. The activation function is usually a Softmax form for multi-class tasks or a sigmoid form for foreground / background binary classification. During training, the network learns, through label supervision, to map foreground regions to a probability output close to one and background regions to a probability output close to zero. In the inference phase, the classification layer outputs the probability value of each pixel's class. These probability values are spatially arranged to form a pixel prediction probability map, which reflects the confidence level of classifying each pixel location as foreground or background.
[0050] To obtain the binary partitioning result, the probabilities in the pixel prediction probability map need to be thresholded according to a preset threshold. The preset threshold can be derived from cross-validation, empirical statistics, or the business requirement for balancing foreground recall and background accuracy. The specific value can be set as a fixed scalar, or different thresholds can be set for different categories or scenarios. When the probability corresponding to a pixel location is greater than or equal to the threshold, that location is marked as foreground; when the probability is less than the threshold, that location is marked as background. By performing thresholding operation point by point on the entire pixel prediction probability map, an initial foreground-background binary mask matrix composed of foreground and background labels can be formed. Numerically, this matrix typically uses zeros and ones to represent the two types of labels, and spatially it directly corresponds to the pixel grid of the target image, serving as the basic input for subsequent boundary optimization and region partitioning processes.
[0051] For example, the definition of a binary mask matrix:
[0052] Where M represents the initial foreground / background binary mask matrix. H represents the height of the target image. W represents the width of the target image. =1 indicates that the i-th and j-th pixels are divided into the foreground region. =0 indicates that the i-th and j-th pixels are classified as background regions.
[0053] For example, the pixel-level segmentation loss expression:
[0054] in, This represents the segmentation loss for the entire image. This represents the true class label for the i-th and j-th pixels, with 1 for the foreground and 0 for the background. This represents the network's prediction probability that the i-th and j-th pixels belong to the foreground. This represents the weighting coefficient for the foreground category. This represents the weighting coefficient for the background category.
[0055] This embodiment introduces a depthwise separable convolutional encoder and a layer-by-layer downsampling structure to fully extract multi-level features during the encoding stage while controlling computational complexity. It also explicitly preserves low-level detail features to provide high-precision boundary information for subsequent spatial reconstruction. Through the decoder's layer-by-layer upsampling and skip connection mechanism, high-order semantic features and low-level detail features are fused along the channel dimension to construct a multi-scale fusion feature map with high spatial resolution and multi-scale semantic expression capabilities, improving the separability of foreground and background at the pixel level. The classification layer outputs a pixel prediction probability map and combines it with a preset threshold to generate an initial foreground-background binary mask matrix, transforming the continuous probability space into a clear binary label space. This provides a structurally well-defined initial draft for foreground-background segmentation in subsequent energy optimization and region partitioning processes, thereby improving the overall accuracy of foreground extraction and the stability of background segmentation.
[0056] In one embodiment, step S20 includes: S201, constructing a univariate potential term representing the classification confidence of a single pixel based on the predicted probability value of each pixel in the pixel prediction probability map corresponding to the initial foreground-background binary mask matrix; S202, determining the color space difference value and Euclidean space distance value between adjacent pixel pairs in the target image; S203, generating a color potential term based on the color space difference value using a Gaussian kernel function mapping; S204, generating a position potential term based on the Euclidean space distance value using a Gaussian kernel function mapping; S205 S206. The unary potential energy term, color potential energy term, and position potential energy term are linearly combined according to preset weight coefficients to construct a complete energy function; S207. The initial foreground and background binary mask matrix is used as the initial label and input into the conditional random field model; S208. In the conditional random field model, the energy function is iteratively minimized starting from the initial label, and the pixel label is updated in each iteration to enhance the label consistency between adjacent pixels; S209. When the energy function converges to a stable state, the final optimized pixel label is output as a refined foreground and background segmentation map.
[0057] In this embodiment, after generating the initial foreground and background binary mask matrix, a conditional random field model is introduced to refine the boundary between the foreground and background. To do this, the foreground or background probability value corresponding to each pixel position needs to be extracted from the pixel prediction probability map, and this probability value is converted into a univariate potential energy term. The univariate potential energy term is used here to measure the cost of a single pixel being labeled as a certain category; the closer the probability is to one, the lower the cost, and the closer the probability is to zero, the higher the cost. Specifically, a monotonic transformation can be performed on the probability value at each position in the pixel prediction probability map. For example, by taking the negative logarithm of the probability or other decreasing mappings, the probability, originally between zero and one, can be mapped to a non-negative energy value. Two univariate potential energy values corresponding to the foreground label and background label are recorded in memory for each pixel, forming a pixel-level distribution of the univariate potential energy term.
[0058] To characterize the adjacency relationships between pixels, an adjacency set needs to be constructed on the pixel grid of the target image. A four-adjacency or eight-adjacency structure can be used, pairing each pixel with adjacent pixels in the horizontal, vertical, or diagonal directions to form a set of adjacent pixel pairs. For each pair of adjacent pixels, the color space difference value is first calculated in the color space. The color space can use RGB encoding or Lab encoding, which is closer to human visual perception. The three color channel values of each pixel are treated as a three-dimensional vector, and the color space difference value is obtained through the norm of the vector difference, thus providing a numerical value reflecting whether adjacent pixels are similar in color. Simultaneously, the Euclidean distance value is calculated based on the row and column coordinates of the two pixels in the image plane. The spatial distance is obtained by taking the square root of the square of the coordinate difference, which measures the geometric proximity of the two pixels.
[0059] The color potential and position potential terms are obtained by mapping the aforementioned difference and distance values using a Gaussian kernel function. For color space difference values, a color scale parameter can be selected. The difference value is squared, divided by the square of this parameter, and a negative sign is added as an exponent input. The exponential function maps the color difference to a weight coefficient between zero and one. The smaller the difference, the closer the mapping result is to one; the larger the difference, the closer the mapping result is to zero. This mapping result acts as the color potential term in the energy representation, used to enhance the consistency of pixels with similar colors on the label. For Euclidean space distance values, a spatial scale parameter can be selected, and a Gaussian kernel function is constructed in a similar manner. Closer pixel pairs are assigned higher weights, and farther pixel pairs are assigned lower weights. This mapping result serves as the position potential term, used to suppress strong constraints across large spatial intervals and emphasize the smoothness requirements within the local neighborhood.
[0060] The complete energy function is constructed through a linear combination of unary potential energy terms, color potential energy terms, and location potential energy terms. At the pixel level, the total energy of each pixel under a given label consists of two parts: the unary potential energy of the pixel itself and the binary potential energy from its neighboring pixels. The binary potential energy is obtained by summing the color and location potential energy terms by preset weighting coefficients, ensuring that pixels with similar colors and close spatial distances incur a higher energy cost when labels are inconsistent. These preset weighting coefficients can be determined through offline training, empirical tuning, or validation set search, balancing the influence between pixel confidence and spatial smoothness. For the entire image, the energy function corresponds to the sum of the unary potential energy of all pixels and the sum of the binary potential energy of all neighboring pixel pairs. Given a set of foreground and background label distributions, the energy function can calculate the overall cost of that label configuration.
[0061] The initial foreground-background binary mask matrix is used as the initial label configuration in the Conditional Random Field (CRF) model. In its implementation, the CRF model treats each pixel as a node, adjacent pixel pairs as edges, and limits the label set to foreground and background. The previously constructed energy function assigns a corresponding energy cost to the nodes and edges. The initial foreground-background binary mask matrix provides the initial label for each node, and the probability values in the pixel prediction probability map provide the numerical basis for the univariate potential energy. The CRF model then initiates an iterative optimization process based on this initial configuration, reducing the global energy through multiple rounds of label updates.
[0062] Iterative optimization algorithms can employ approximate inference frameworks, such as iterative updates based on mean-field approximation, or multiple label expansion mechanisms based on graph cuts. In the mean-field framework, each iteration re-estimates the label distribution for each pixel based on the current label distribution and energy function. It weights and integrates the pixel confidence from univariate potential energy with the influence of bivariate potential energy from neighboring pixels, thereby adjusting the probability allocation between foreground and background. In the graph cut framework, new candidate label configurations can be proposed in each iteration. The energy of the current configuration is compared with that of the candidate configurations, and a lower-energy label partition is found using a graph cut algorithm, replacing the current configuration with the lower-energy label configuration. Regardless of the implementation path, each iteration checks the overall value of the energy function. If the energy decreases significantly after the update, the next round of label updates continues. If the energy change is below a preset threshold or the number of iterations reaches the upper limit, the energy function is considered to have converged to a relatively stable state.
[0063] After the energy function converges, the final label configuration for each pixel is read from the conditional random field model. The foreground and background labels are rearranged into a two-dimensional matrix of the same size as the target image, forming a refined foreground-background segmentation map. Compared with the initial foreground-background binary mask matrix, the refined foreground-background segmentation map better matches the contours of real objects in boundary regions, reduces isolated false detections in noisy regions, and avoids overexpansion in regions with similar textures but different semantics, thus providing higher quality foreground-background segmentation results.
[0064] For example, the energy function expression for a conditional random field:
[0065] in, This represents the overall energy value for the pixel label matrix M. The unary potential energy of the i-th and j-th pixels is derived from the classification confidence at the corresponding position in the pixel prediction probability map. Represents pixel pairs and The pairwise potential energy is used to characterize the compatibility between adjacent pixel labels. λ represents the balance coefficient that controls the weights of the pairwise potential energy terms. This represents the set of pixel neighborhoods, containing the indices of pixel pairs that participate in the smoothing constraint.
[0066] For example, the expression for the paired potential function of an indoor scene:
[0067] in, This represents the pairwise potential energy value of pixel pairs (i,j) and (k,l), used to constrain the relationship between the two labels. This indicates the weight of the appearance item, controlling the intensity of the effect of color difference on potential energy. This indicates the weight of the position term, which controls the intensity of the influence of spatial distance on potential energy. This represents the color value or color vector of the image at pixels (i,j) and (k,l). This represents the square of the color difference, used to measure the difference between two pixels in the color space. (i,j) and (k,l) represent the spatial coordinates of the two pixels. It represents the square of the coordinate difference, used to measure the distance between two pixels on the image plane. The scale parameter represents the appearance difference and controls the decay rate of color difference. The scale parameter representing the location difference term controls the rate at which spatial distance decays.
[0068] This embodiment constructs color and position potential terms based on color space difference values and Euclidean distance values, and linearly combines them in the energy function with preset weight coefficients. This allows the conditional random field model to simultaneously consider the confidence level of a pixel and the correlation between neighboring pixels in color and spatial position, enhancing local label consistency while maintaining clear structural boundaries. By using the initial foreground-background binary mask matrix as the initial label, iterative optimization is performed in the conditional random field model, and a refined foreground-background segmentation map is output after the energy function converges. This automatically suppresses boundary noise and local mislabeling based on the initial segmentation results, significantly improving the accuracy and robustness of foreground-background segmentation, and providing more reliable input for subsequent region-level feature extraction and background similarity calculation.
[0069] In one embodiment, step S30 includes: S301, setting the pixel values identifying the foreground region in the refined foreground-background segmentation image to a first value to generate a foreground mask matrix; S302, performing a logical NOT operation on the foreground mask matrix to generate a background mask matrix; S303, performing a dot product operation between the foreground mask matrix and the target image to generate a foreground region image; S304, performing a dot product operation between the background mask matrix and the target image to generate a background region image; S305, removing all regions with zero pixel values from the foreground region image to generate a foreground image region; S306, removing all regions with zero pixel values from the background region image to generate a background image region.
[0070] In this embodiment, the refined foreground / background segmentation map is a two-dimensional matrix with pixel-level foreground and background categories, where each position corresponds one-to-one with a pixel at the same coordinate in the target image. In this segmentation map, a single numerical value is typically used to represent the foreground category, for example, a set of Boolean values or a single-channel grayscale value to represent the difference between the foreground and background positions. To perform subsequent region cropping using matrix operations, the pixels identifying the foreground region in the segmentation map are first uniformly mapped to a first numerical value, such as one or the maximum grayscale value, while non-foreground positions are kept at zero or another fixed value. Through this numerical remapping, the segmentation result, which was originally just category labels, is transformed into a foreground mask matrix that can directly participate in numerical calculations. The non-zero positions in the matrix will be multiplied with the corresponding pixels in the target image to preserve foreground information.
[0071] After the foreground mask matrix is constructed, a logical NOT operation can be performed on it at the same size to obtain the background mask matrix. The logical NOT operation targets the binary or quasi-binary structure in the foreground mask matrix. In implementation, one at the foreground position can be replaced with zero, and zero with one. Alternatively, in a more general numerical range, the first value can be mapped to zero, and zero to the first value, thus obtaining a background mask complementary to the foreground mask. This method eliminates the need to re-parse the refined foreground-background segmentation map; a single element-wise NOT operation on the existing foreground mask matrix is sufficient to construct the background mask matrix, ensuring that the foreground and background do not intersect at the mask level and have no blank areas.
[0072] After obtaining the foreground and background mask matrices, the masks need to be multiplied by the target image to generate foreground and background region images. The target image can be a three-channel color image or a multi-channel image. To perform pixel-by-pixel multiplication with the single-channel mask matrix, the mask matrix can be extended in the channel dimension, so that each channel reuses the same mask value. Then, at each pixel position, the channel values of the target image are multiplied by the corresponding values of the mask matrix. For the foreground mask matrix, the mask value at the foreground position is one or the first value, and the mask value at the background position is zero. After multiplication, the foreground position retains the original color or intensity value of the target image, while the background position becomes zero, resulting in the foreground region image. For the background mask matrix, the background position retains the value of the target image, while the foreground position becomes zero, resulting in the background region image. Through this pixel-by-pixel multiplication operation, the spatial structure is perfectly aligned, and the image content is numerically divided into regions without changing the relative positions of the original pixels.
[0073] The foreground and background images, in matrix form, still cover the entire image plane, but non-target regions are set to zero. To facilitate subsequent feature extraction from the effective regions, these zero-value regions need to be removed. This can be done by scanning the foreground image, identifying regions where all pixel values are zero, determining the outer boundaries of non-zero pixels along the row and column directions, and cropping a sub-image within these boundaries as the foreground image region. Alternatively, connectivity analysis can be performed on non-zero pixels, identifying connected non-zero regions as valid blocks, retaining only these valid blocks, and removing pure zero blocks from storage and computation, thus limiting the foreground image region to locations that truly contain foreground information. The background image can be processed in the same way: by locating the effective range or effective connected blocks of non-zero background pixels, all-zero regions are removed to generate the background image region. This removal process cleans up the zero-value padding caused by the mask, providing compact and content-concentrated foreground and background image regions for subsequent computations.
[0074] This embodiment constructs a foreground mask matrix on a refined foreground-background segmentation map and generates a background mask matrix through a logical NOT operation. This ensures pixel-by-pixel alignment with the target image while converting category labels into mask representations that can directly participate in numerical calculations, providing a unified matrix framework for the construction of subsequent region images. By performing dot product operations on the foreground and background mask matrices with the target image, pixel-level separation of foreground and background content can be achieved in a single matrix operation, avoiding the efficiency issues associated with iterative point-by-point cropping while preserving the geometric structure of the original image. By removing all regions with zero pixel values from both the foreground and background region images, invalid regions that only serve a filling function are removed from the data, making the foreground and background image regions more spatially compact. This reduces meaningless computation in subsequent feature extraction, convolutional coding, or statistical analysis and reduces the interference of residual noise near the boundaries on subsequent processing results, thereby improving overall processing efficiency and stability while maintaining region segmentation accuracy.
[0075] In one embodiment, step S40 includes: S401, constructing a foreground encoding branch comprising a convolutional layer, a batch normalization layer, and a nonlinear activation layer connected in sequence, wherein the convolutional layer is configured with a standard convolutional kernel; S402, inputting the foreground image region into the convolutional layer of the foreground encoding branch, wherein the standard convolutional kernel is used to perform convolution processing on the foreground image region in the convolutional layer to generate a convolutional feature map; S403, inputting the convolutional feature map into the batch normalization layer for batch normalization processing to generate a normalized feature map; S404, inputting the normalized feature map into the nonlinear activation layer for nonlinear activation transformation to generate an activation feature map, wherein the activation feature map is used as a foreground feature representation.
[0076] In this embodiment, the foreground image region is a compact image block containing only valid foreground pixels, obtained after region segmentation. Its channel structure remains consistent with the original image, and it serves as the direct input for convolutional coding. To extract structured features from this local region, a foreground coding branch needs to be constructed. This branch consists of convolutional layers, batch normalization layers, and nonlinear activation layers in sequence, forming a fixed forward data flow path in the computation graph. The convolutional layers use a standard convolutional kernel configuration, with kernel size, stride, and padding determined according to preset rules. They are used to perform local neighborhood weighted accumulation operations on the input image region to capture the spatial texture pattern, local structural distribution, and contour changes of the foreground region.
[0077] When the foreground image region enters the convolutional layer, the convolutional kernel slides point-by-point along the spatial dimension. By calculating the weighted sum of the convolutional kernel and the corresponding local receptive field pixel by pixel, the input image is mapped into a convolutional feature map in multiple channel directions. This convolutional feature map contains the response values of the local spatial structure of the foreground region at the scale of the convolutional kernel, representing a channelized spatial feature representation. After convolution, the output enters the batch normalization layer. The batch normalization layer performs mean and variance normalization on the response of each channel, adjusting the feature distribution to a stable numerical range. This reduces the impact of dynamic range changes in the input data on gradient propagation in subsequent computation paths and ensures statistically consistent distribution across different foreground regions.
[0078] The normalized features are input into a nonlinear activation layer. This layer, based on the mapping rules of the activation function, transforms the linear transformation result into a nonlinear feature response, thereby expanding the expressive power of the foreground encoding branch and enabling convolutional coding to characterize more high-order structural features. The activation function performs nonlinear compression or amplification on the responses of different intensity segments, making the shape boundaries, local details, and texture gradients of the foreground region more discriminative in the feature space.
[0079] After forward computation involving standard convolution, batch normalization, and nonlinear activation, the activation feature map serves as the foreground feature representation. This representation maintains a consistent topological relationship with the effective foreground region in the spatial dimension and defines the multi-scale response of the foreground content in the channel dimension, serving as the basic input for subsequent feature fusion and similarity calculation.
[0080] This embodiment uses a foreground encoding branch containing a standard convolutional kernel to generate a stable foreground feature representation that can express local texture differences without destroying the spatial structure of the foreground region. Batch normalization ensures that the statistical characteristics of the convolutional response remain consistent, thereby reducing the distribution instability caused by foreground texture changes. Nonlinear activation enhances the discriminative power of the feature space, enabling a clearer representation of the foreground local structure in subsequent processing stages.
[0081] In one embodiment, step S50 includes: S501, dividing the background image region into multiple independent feature groups along the channel dimension according to a dynamic grouping strategy; S502, configuring a corresponding independent convolution kernel and performing convolution processing for each feature group to generate preliminary grouped features; S503, based on the gating mechanism, using learnable gating parameters and processing through a Sigmoid activation function to generate gating weight coefficients for the current feature group; S504, performing element-wise multiplication of the preliminary grouped features with the gating weight coefficients to adaptively filter or suppress the preliminary grouped features through the gating weight coefficients to obtain weighted grouped features; S505, concatenating and aggregating all weighted grouped features along the channel dimension to complete structured convolution processing and generate a background feature representation.
[0082] In this embodiment, the background image region is obtained from the preceding region segmentation process, retaining only background pixels while removing the foreground subject. The corresponding tensor maintains its original coordinate layout in the spatial dimension and includes color channels and intermediate feature channels that may be generated by the previous network in the channel dimension. To reduce unnecessary computation while preserving diverse texture information in the background, a dynamic grouping strategy is applied to the background image region in the channel direction, dividing the complete channel set into several non-overlapping feature groups. Channel segmentation can be based on a fixed number of channels equally, or it can be based on offline statistical results to cluster according to texture category, frequency band response, or semantic relevance, grouping channels with similar response patterns into the same group. Each group is subsequently treated as a relatively independent convolutional processing sub-path.
[0083] After obtaining multiple feature groups, a dedicated set of convolutional kernels is configured for each group. These kernels only establish connections with channels within the current group and do not share weights across groups. The kernel size, stride, and padding can be set according to the scale and detail requirements of the background texture. For example, when a group contains large-scale color block responses, a larger kernel can be used to cover a wider receptive field. During the convolution operation, each feature group slides its corresponding kernel separately in the spatial dimension, weighting and accumulating the channels within the group to obtain preliminary grouped features. The preliminary grouped features retain the layout of the background region in the spatial dimension, and only reflect the local patterns focused by the current group in the channel dimension. For example, one group may emphasize edge textures, while another group may emphasize color gradients or repeating texture structures.
[0084] To avoid treating all groups equally and retaining the same computational results, a gating mechanism is introduced to adaptively adjust the importance of different groups. Internally, the gating mechanism maintains a set of learnable gating parameters. These parameters can be set as scalar weights according to the group dimension, or as vectors or matrices related to the number of channels or spatial location of the group. During forward inference, the gating parameters are first mapped to a continuous value range between zero and one using the sigmoid activation function, resulting in gating weight coefficients. The closer the coefficient is to one, the more the current group's features should be retained; the closer it is to zero, the more the current group's features should be suppressed. Subsequently, the initial group features are multiplied element-wise with the corresponding gating weight coefficients. If the gating weight is a scalar, the entire group is scaled uniformly; if it is a vector or matrix, differentiated scaling is performed on the channels or spatial locations, thus achieving fine-grained reduction of redundant background information and emphasis on key background patterns. The result after gating is considered a weighted group feature, equivalent to adding a data-driven selection mechanism on top of the original convolutional output.
[0085] After all feature groups have undergone convolution and gating processing, the weighted features of each group are concatenated and aggregated along the channel dimension to restore a single overall background feature tensor with a higher number of channels. The channel concatenation operation maintains the relative order of each group in the channel index, allowing for the reservation of fixed channel ranges for different groups during the design phase. This enables subsequent modules to re-split or apply specific operations based on the channel range as needed. The resulting background feature representation still covers the entire background region in the spatial dimension and integrates the gated responses of each feature group in the channel dimension. It represents a unified representation of the background content after structured convolution processing, providing the background-side input basis for subsequent comparison or fusion with foreground features.
[0086] This embodiment introduces a dynamic grouping strategy and gating mechanism on the background image region. Instead of performing uniform and fixed calculations on all channels, the convolutional processing first divides the image into multiple functional groups along the channel dimension, then configures independent convolutional kernels for different groups and combines them with learnable gating weights for adaptive filtering and suppression. This effectively reduces the response intensity to irrelevant background details and lowers redundant computational load while maintaining the ability to express diverse background textures. The resulting background feature representation is more numerically focused on the background structure and texture patterns relevant to subsequent tasks, improving the discriminativeness and compactness of the background representation. This provides cleaner and more efficient background feature input for subsequent operations based on the difference between foreground and background.
[0087] In one embodiment, step S60 includes: S601, using a dual attention module to perform spatial attention weighting and channel attention weighting on the foreground feature representation and the background feature representation respectively, to obtain spatially enhanced foreground features and spatially enhanced background features, as well as channel-enhanced foreground features and channel-enhanced background features respectively; S602, fusing the spatially enhanced foreground features and channel-enhanced foreground features to generate dual-enhanced foreground features, and fusing the spatially enhanced background features and channel-enhanced background features to generate dual-enhanced background features; S603, performing feature concatenation on the dual-enhanced foreground features and dual-enhanced background features through a gating fusion unit, and determining a fusion balance coefficient based on the concatenated features; S604, performing weighted fusion on the dual-enhanced foreground features and dual-enhanced background features based on the fusion balance coefficient to generate a unified feature representation.
[0088] In this embodiment, the foreground feature representation is a high-dimensional feature tensor obtained by convolutional encoding of the foreground image region. It preserves the spatial distribution of human contours, pose structures, and other spatial features, and encodes texture, edge, and semantic attributes in the channel dimension. The background feature representation originates from the structured convolutional processing of the background image region. It covers areas such as interior walls, furniture, and floors in the spatial dimension, and contains texture, lighting, and structural information at different scales in the channel dimension. Feeding both types of feature representations into the dual attention module and the gating fusion unit simultaneously models the differences and relationships between the foreground and background in a unified feature space, rather than making judgments based on a single branch.
[0089] The dual-attention module comprises a spatial attention branch and a channel attention branch, processing foreground and background feature representations in parallel. Spatial attention weighting estimates the relative importance of each location within the overall feature map. This is achieved by performing global convergence operations on the height and width dimensions to obtain a low-dimensional spatial description, followed by several linear transformations and nonlinear activations to generate a two-dimensional spatial attention weight map. The spatial attention weight map is identical in size to the spatial dimensions of the original features, assigning a weight between zero and one at each location. Multiplying the spatial attention weight map point-by-point with the foreground feature representation enhances the response of locations such as the figure's outline and key limb areas, while suppressing foreground regions that are not involved in subsequent discrimination. Similarly, multiplying the spatial attention weight map point-by-point with the background feature representation emphasizes locations in the background with significant texture changes, severe occlusion, or those easily confused with the foreground. This process yields spatially enhanced foreground and background features, which have undergone a reweighting based on location importance in the spatial dimension.
[0090] Channel attention weighting processing is channel-oriented, estimating the contribution of each channel to the overall semantic representation. Global average convergence and global maximum convergence are performed on the foreground feature representation in the spatial dimension, resulting in two one-dimensional channel description vectors. These are then used to generate channel attention weight vectors through shared or independent fully connected transformations and nonlinear activations, with the weight vector length matching the number of channels. This weight vector is then multiplied channel-by-channel by the foreground feature representation. High-weight channels, corresponding to edge patterns, human contour patterns, or key texture patterns, are amplified, while low-weight channels, corresponding to noise patterns or redundant channels, are suppressed, thus forming channel-enhanced foreground features. The same process is performed on the background feature representation in the channel attention branch. The channel attention weight vector tends to boost channels sensitive to texture differences, lighting changes, or background layout, thus forming channel-enhanced background features. Through parallel spatial and channel attention processing, the foreground and background are reshaped in two different dimensions.
[0091] Spatial enhanced foreground features and channel enhanced foreground features numerically reflect positional weights and channel weights, respectively. They operate on the same tensor but focus on different dimensions. To obtain a representation that incorporates both weighting information, the spatial enhanced foreground features and channel enhanced foreground features are fused according to element-wise correspondences. This can be achieved through additive fusion, summing the two feature tensors element-wise, or by concatenating and then performing a linear transformation to generate new channel combinations. The resulting fusion operation yields a dual-enhanced foreground feature, which spatially highlights the main human body region and enhances channels strongly correlated with the semantics of the person. The background processing is completely symmetrical; the spatial enhanced background features and channel enhanced background features are synthesized into a dual-enhanced background feature through the same fusion operation. This makes the background representation spatially highlight locations that easily interfere with foreground judgment and channelally emphasize texture and structure-sensitive channels, while weakening uniform regions that are not beneficial for subsequent judgments.
[0092] The gated fusion unit receives dual-enhanced foreground and background features to establish their contrast and complementarity in a unified feature space. First, the dual-enhanced foreground and background features are concatenated along the channel dimension or a newly introduced fusion dimension, arranging the two types of features in a fixed order within the same tensor, introducing a joint representation encompassing both foreground and background perspectives. The concatenated feature tensor then extracts fusion context information through a series of linear mappings and nonlinear activation operations, from which fusion balance coefficients are learned. These fusion balance coefficients can be scalars, controlling the ratio of overall foreground to overall background weights, or channel vectors or spatial weight maps, used to set different foreground-to-background weight ratios in different channels or locations. The learning process of the fusion balance coefficients utilizes the differences in foreground and background response intensities contained in the concatenated features to automatically adjust whether to rely more on background or foreground information under different image conditions.
[0093] After obtaining the fusion balance coefficient, the gated fusion unit performs a weighted fusion operation on the dual-enhanced foreground features and dual-enhanced background features. For scalar coefficients, the dual-enhanced foreground features are multiplied by the coefficient, and the dual-enhanced background features are multiplied by one minus the coefficient, then the two are summed element-wise to obtain a unified feature representation. For fusion balance coefficients in vector or matrix form, the foreground and background components are proportionally allocated position-wise or channel-wise in the corresponding dimension. The unified feature representation inherits the positional structure of the foreground and background in the spatial dimension and fuses the semantic features of both in the channel dimension. At the same time, the fusion balance coefficient suppresses conflicting information and noise components, allowing this representation to serve as a single input to carry foreground-background relationship information in subsequent calculations without requiring further branching.
[0094] This embodiment introduces parallel spatial attention weighting and channel attention weighting processing for foreground and background feature representations. The foreground branch can automatically focus on the main human body region at the location level and highlight textures and semantic patterns related to the person at the channel level. The background branch can emphasize background areas that are prone to interference with judgment at the location level and highlight texture and structural differences at the channel level, thereby obtaining spatially enhanced foreground features, spatially enhanced background features, channel-enhanced foreground features, and channel-enhanced background features, respectively. These features are then fused within the branches to form dual-enhanced foreground features and dual-enhanced background features. Furthermore, feature splicing and fusion balance coefficient learning are performed through a gated fusion unit to adaptively determine the contribution ratio of the foreground and background under different foreground-background combinations. The dual-enhanced foreground features and dual-enhanced background features are weighted and fused to obtain a unified feature representation. This ensures that the input for subsequent processing has already completed joint foreground-background modeling in both spatial and channel dimensions, reducing the discrimination burden of subsequent modules and improving the robustness of background similarity judgment to foreground leakage and complex background textures.
[0095] In one embodiment, a foreground-background fusion similarity task processing device is provided, which corresponds one-to-one with the foreground-background fusion similarity task processing method in the above embodiments. Referring to Figure 3, Figure 3 is a functional block diagram of a preferred embodiment of the foreground-background fusion similarity task processing device of the present invention. The device includes a segmentation network module 10, a boundary optimization module 20, a region partitioning module 30, a foreground encoding module 40, a background structured convolution module 50, a feature fusion module 60, and a background similarity determination module 70. The functional modules are described in detail below: The segmentation network module 10 acquires the target image to be processed, inputs the target image into a preset segmentation network model to perform feature extraction and pixel-level classification operations, and generates an initial foreground / background binary mask matrix; the boundary optimization module 20 constructs an energy function containing color and position potential terms, inputs the initial foreground / background binary mask matrix as the initial state into a conditional random field model, and uses the conditional random field model to iteratively optimize the mask boundary of the initial foreground / background binary mask matrix by minimizing the energy function, generating a refined foreground / background segmentation map; the region division module 30 uses the refined foreground / background segmentation map to perform region division processing on the target image, obtaining foreground image regions and background image regions; foreground... The encoding module 40 is used to perform convolutional encoding on the foreground image region using a standard convolutional kernel to generate a foreground feature representation; the background structured convolution module 50 is used to perform structured convolutional processing on the background image region using a dynamic grouping strategy and a gating mechanism to generate a background feature representation; the feature fusion module 60 is used to input the foreground feature representation and the background feature representation into a dual attention module and a gating fusion unit, and generate a unified feature representation through weighted processing of spatial attention and channel attention and gating fusion processing; the background similarity determination module 70 is used to determine the feature distance metric between the unified feature representation and the reference background features, determine the image background similarity based on the feature distance metric, and perform the target task based on the image background similarity to obtain the target task result.
[0096] Specific limitations regarding the foreground-background fusion similarity task processing device can be found in the aforementioned limitations regarding the foreground-background fusion similarity task processing method, and will not be repeated here. Each module in the aforementioned foreground-background fusion similarity task processing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0097] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram is shown in Figure 4. The computer device includes a processor, memory, a network interface, and a database connected via a system bus. The processor of the computer device provides determination and control capabilities. The memory of the computer device includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the computer device is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements the functions or steps of a foreground-background fusion similarity task processing method on the server side.
[0098] In one embodiment, a computer device is provided, which can be a client, and its internal structure diagram is shown in Figure 5. The computer device includes a processor, memory, network interface, display screen, and input device connected via a system bus. The processor of the computer device provides determination and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements the functions or steps of a foreground-background fusion similarity task processing method on the client side.
[0099] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it performs the following steps: acquiring a target image to be processed; inputting the target image into a preset segmentation network model to perform feature extraction and pixel-level classification operations to generate an initial foreground-background binary mask matrix; constructing an energy function containing color potential terms and position potential terms; inputting the initial foreground-background binary mask matrix as an initial state into a conditional random field model; and using the conditional random field model to iteratively optimize the mask boundaries of the initial foreground-background binary mask matrix by minimizing the energy function to generate a refined foreground-background segmentation map; and using the refined foreground-background... The segmentation map divides the target image into foreground and background image regions. The foreground image region is then convolutionally encoded using a standard convolution kernel to generate a foreground feature representation. The background image region is then structured through a dynamic grouping strategy and gating mechanism to generate a background feature representation. The foreground and background feature representations are input into a dual-attention module and a gating fusion unit. Through weighted processing of spatial and channel attention and gating fusion, a unified feature representation is generated. A feature distance metric between the unified feature representation and a reference background feature is determined. Based on this feature distance metric, the image background similarity is determined, and the target task is performed based on the image background similarity to obtain the target task result.
[0100] In one embodiment, a computer-readable storage medium is provided, which may be non-volatile or volatile, storing a computer program thereon. When the computer program is executed by a processor, it performs the following steps: acquiring a target image to be processed; inputting the target image into a preset segmentation network model to perform feature extraction and pixel-level classification operations to generate an initial foreground-background binary mask matrix; constructing an energy function containing color potential terms and position potential terms; inputting the initial foreground-background binary mask matrix as an initial state into a conditional random field model, and using the conditional random field model to iteratively optimize the mask boundary of the initial foreground-background binary mask matrix by minimizing the energy function to generate a refined foreground-background segmentation map; and using the refined... The target image is divided into foreground and background image regions using a foreground-background segmentation map. The foreground image region is then convolutionally encoded using a standard convolution kernel to generate a foreground feature representation. The background image region is then structured through a dynamic grouping strategy and a gating mechanism to generate a background feature representation. These foreground and background feature representations are input into a dual-attention module and a gating fusion unit. Through weighted processing of spatial and channel attention and gating fusion, a unified feature representation is generated. A feature distance metric between the unified feature representation and a reference background feature is determined. Based on this feature distance metric, the image background similarity is determined, and the target task is performed based on the image background similarity to obtain the target task result.
[0101] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0102] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0103] It should be noted that if any software tools or components not belonging to this company appear in the embodiments of this application, they are merely illustrative examples and do not represent actual use. The embodiments described above are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
[0104] The user personal information involved in this application embodiment is all authorized (knowing and consenting) by the relevant parties or fully authorized by all parties, and the executing entity can obtain it through various open, legal and compliant means. The collection, storage, use, processing, transmission, provision and disclosure of the information, data and signals involved all comply with the relevant laws and regulations of the relevant countries and regions, and do not violate public order and good morals.
Claims
1. A method for processing similarity tasks involving foreground-background fusion, characterized in that, The process includes the following steps: acquiring the target image to be processed; inputting the target image into a preset segmentation network model to perform feature extraction and pixel-level classification operations to generate an initial foreground-background binary mask matrix; constructing an energy function containing color potential and position potential terms; inputting the initial foreground-background binary mask matrix as the initial state into a conditional random field model; and using the conditional random field model to iteratively optimize the mask boundary of the initial foreground-background binary mask matrix by minimizing the energy function to generate a refined foreground-background segmentation map; and using the refined foreground-background segmentation map to perform region division processing on the target image to obtain foreground image regions and background image regions. The foreground image region is convolutionally encoded using a standard convolution kernel to generate a foreground feature representation. The background image region is subjected to structured convolution processing using a dynamic grouping strategy and a gating mechanism to generate a background feature representation. The foreground feature representation and the background feature representation are input into a dual attention module and a gating fusion unit. Through weighted processing of spatial attention and channel attention and gating fusion processing, a unified feature representation is generated. The feature distance metric between the unified feature representation and the reference background features is determined. Based on the feature distance metric, the image background similarity is determined. The target task is then performed based on the image background similarity to obtain the target task result.
2. The foreground-background fusion similarity task processing method as described in claim 1, characterized in that, The process involves: acquiring the target image to be processed; inputting the target image into a preset segmentation network model to perform feature extraction and pixel-level classification operations to generate an initial foreground-background binary mask matrix; acquiring the target image; performing feature extraction on the target image using a depthwise separable convolutional encoder constructed in the preset segmentation network model; generating an encoded feature map containing multi-scale information and low-level detail features that retain texture information through layer-by-layer downsampling processing; performing a layer-by-layer upsampling recovery operation on the encoded feature map using a decoder corresponding to the encoder in the segmentation network model to generate an upsampled feature map; acquiring the low-level detail features through a skip connection mechanism and concatenating and fusing the low-level detail features with the upsampled feature map of the corresponding spatial resolution in the channel dimension to generate a multi-scale fused feature map; inputting the multi-scale fused feature map into a classification layer to perform pixel-level classification operations, outputting the probability value of the category to which each pixel belongs to form a pixel prediction probability map, and binarizing the probability values according to a preset threshold to generate an initial foreground-background binary mask matrix.
3. The foreground-background fusion similarity task processing method as described in claim 1, characterized in that, An energy function containing color and position potential terms is constructed. The initial foreground-background binary mask matrix is used as the initial state input to a conditional random field model. The conditional random field model is then used to iteratively optimize the mask boundary of the initial foreground-background binary mask matrix by minimizing the energy function, generating a refined foreground-background segmentation map. This includes: constructing a univariate potential term representing the classification confidence of a single pixel based on the prediction probability value of each pixel in the pixel prediction probability map corresponding to the initial foreground-background binary mask matrix; determining the color space difference value and Euclidean space distance value between adjacent pixel pairs in the target image; and based on the color space difference value... A color potential term is generated through Gaussian kernel mapping; a position potential term is generated based on the Euclidean space distance value through Gaussian kernel mapping; the univariate potential term, color potential term, and position potential term are linearly combined according to preset weight coefficients to construct a complete energy function; the initial foreground-background binary mask matrix is used as an initial label input to the conditional random field model; in the conditional random field model, the energy function is iteratively minimized starting from the initial label, and the pixel label is updated in each iteration to enhance the label consistency between adjacent pixels; when the energy function converges to a stable state, the final optimized pixel label is output as a refined foreground-background segmentation map.
4. The foreground-background fusion similarity task processing method as described in claim 1, characterized in that, The target image is divided into foreground and background image regions using the refined foreground / background segmentation map. This process includes: setting the pixel values identifying the foreground region in the refined foreground / background segmentation map to a first value to generate a foreground mask matrix; performing a logical NOT operation on the foreground mask matrix to generate a background mask matrix; performing a dot product between the foreground mask matrix and the target image to generate a foreground region image; performing a dot product between the background mask matrix and the target image to generate a background region image; removing all regions with zero pixel values from the foreground region image to generate the foreground image region; and removing all regions with zero pixel values from the background region image to generate the background image region.
5. The foreground-background fusion similarity task processing method as described in claim 1, characterized in that, The foreground image region is convolutionally encoded using a standard convolutional kernel to generate a foreground feature representation. This process includes: constructing a foreground encoding branch comprising a convolutional layer, a batch normalization layer, and a nonlinear activation layer connected sequentially, wherein the convolutional layer is configured with a standard convolutional kernel; inputting the foreground image region into the convolutional layer of the foreground encoding branch, where the standard convolutional kernel is used to perform convolution processing on the foreground image region to generate a convolutional feature map; inputting the convolutional feature map into the batch normalization layer for batch normalization processing to generate a normalized feature map; inputting the normalized feature map into the nonlinear activation layer for nonlinear activation transformation to generate an activation feature map, and using the activation feature map as the foreground feature representation.
6. The foreground-background fusion similarity task processing method as described in claim 1, characterized in that, The background image region is subjected to structured convolution processing using a dynamic grouping strategy and a gating mechanism to generate a background feature representation. This includes: dividing the background image region into multiple independent feature groups along the channel dimension according to the dynamic grouping strategy; configuring a corresponding independent convolution kernel for each feature group and performing convolution processing to generate preliminary grouped features; based on the gating mechanism, using learnable gating parameters processed through a Sigmoid activation function to generate gating weight coefficients for the current feature group; performing element-wise multiplication of the preliminary grouped features with the gating weight coefficients to adaptively filter or suppress the preliminary grouped features through the gating weight coefficients, obtaining weighted grouped features; and concatenating and aggregating all weighted grouped features along the channel dimension to complete the structured convolution processing and generate a background feature representation.
7. The foreground-background fusion similarity task processing method as described in claim 1, characterized in that, The foreground feature representation and the background feature representation are input into a dual-attention module and a gated fusion unit. A unified feature representation is generated through weighted processing of spatial attention and channel attention, followed by gated fusion processing. This includes: using the dual-attention module to perform parallel spatial attention weighted processing and channel attention weighted processing on the foreground feature representation and the background feature representation, respectively, to obtain spatially enhanced foreground features and spatially enhanced background features, as well as channel-enhanced foreground features and channel-enhanced background features; fusing the spatially enhanced foreground features and channel-enhanced foreground features to generate dual-enhanced foreground features, and fusing the spatially enhanced background features and channel-enhanced background features to generate dual-enhanced background features; performing feature concatenation on the dual-enhanced foreground features and dual-enhanced background features through the gated fusion unit, and determining a fusion balance coefficient based on the concatenated features; and performing weighted fusion on the dual-enhanced foreground features and dual-enhanced background features based on the fusion balance coefficient to generate a unified feature representation.
8. A foreground-background fusion similarity task processing device, characterized in that, The foreground-background fusion similarity task processing device includes: a segmentation network module, used to acquire the target image to be processed, input the target image into a preset segmentation network model to perform feature extraction and pixel-level classification operations, and generate an initial foreground-background binary mask matrix; a boundary optimization module, used to construct an energy function containing color potential and position potential terms, input the initial foreground-background binary mask matrix as the initial state into a conditional random field model, and use the conditional random field model to iteratively optimize the mask boundary of the initial foreground-background binary mask matrix by minimizing the energy function, generating a refined foreground-background segmentation map; and a region division module, used to perform region division processing on the target image using the refined foreground-background segmentation map to obtain foreground image regions and background images. The system comprises the following modules: a foreground encoding module, which performs convolutional encoding on the foreground image region using standard convolutional kernels to generate a foreground feature representation; a background structured convolution module, which performs structured convolutional processing on the background image region using dynamic grouping strategies and gating mechanisms to generate a background feature representation; a feature fusion module, which inputs the foreground feature representation and the background feature representation into a dual attention module and a gating fusion unit, and generates a unified feature representation through weighted processing of spatial attention and channel attention and gating fusion processing; and a background similarity determination module, which determines the feature distance metric between the unified feature representation and the reference background features, determines the image background similarity based on the feature distance metric, and performs the target task based on the image background similarity to obtain the target task result.
9. A computer device, characterized in that, The computer device includes a memory, a processor, and a foreground-background fusion similarity task processing program stored in the memory and executable on the processor. When executed by the processor, the foreground-background fusion similarity task processing program implements the steps of the foreground-background fusion similarity task processing method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The storage medium stores a foreground-background fusion similarity task processing program, which, when executed by a processor, implements the steps of the foreground-background fusion similarity task processing method as described in any one of claims 1-7.
