Mask pattern generation method and device
By extracting and fusing the feature images of the target image, and using the attention enhancement mechanism to eliminate the gaps, the box mask map that removes the impact of the gaps is solved, and the positioning accuracy is improved.
Patent Information
- Application Number
- CN202410903354.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2044-07-05
AI Technical Summary
During the box detection process, detection errors occur due to gaps on the box surface, which affects positioning accuracy.
By acquiring the target image, feature images of multiple sizes are extracted and fused, the first and second fusion feature images are generated, and the second fusion feature image is used to remove the second fusion feature image by using the attention enhancement mechanism to generate a box mask to remove the effect of the gap. Film diagram.
The positioning accuracy of the box containing the gap is improved and detection errors caused by the gap are reduced.
Smart Images

Figure CN118887667A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information technology, and in particular to a method and device for generating a mask image. Background Art
[0002] At present, box detection has been widely used in the target recognition process. In the process of box recognition, a box mask can also be generated. However, in actual use, there are often gaps on the surface of the box. For example, a box with two cabinet doors may cause detection errors during the box detection process due to the gap between the two cabinet doors, and one cabinet may be detected as two cabinets. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a mask image generation method and device to solve the problem of box detection errors caused by gaps. The specific technical solution is as follows:
[0004] According to a first aspect of an embodiment of the present application, a method for generating a mask image is provided, the method comprising:
[0005] Acquire a target image, wherein the target image includes a box, and a surface of at least one box includes a gap;
[0006] Extracting a feature image from the target image to obtain feature images of multiple sizes;
[0007] Fusing the feature images of the multiple sizes to obtain a first fused feature image and a second fused feature image, wherein the size of the first fused feature image is larger than that of the second fused feature image;
[0008] Gap elimination is performed according to the first fused feature image and the second fused feature image to generate a box mask image of the target image with gap influence removed.
[0009] In a possible implementation, extracting a feature image from the target image to obtain feature images of multiple sizes includes:
[0010] Performing background filtering on the target image to obtain a foreground image;
[0011] Resizing the foreground image to obtain a foreground image of a preset size;
[0012] A feature image is extracted from the foreground image of the preset size to obtain feature images of the multiple sizes.
[0013] In a possible implementation, performing gap elimination according to the first fused feature image and the second fused feature image to generate a box mask image of the target image with the gap effect removed includes:
[0014] According to the first fused feature image, performing gap elimination on the second fused feature image by attention enhancement to obtain the elimination result;
[0015] Performing box identification on the rejection result to obtain first box information;
[0016] A mask image of the box is generated according to the first box information.
[0017] In a possible implementation, performing gap elimination on the second fused feature image by attention enhancement according to the first fused feature image to obtain the elimination result includes:
[0018] Downsampling the first fused feature image to obtain a third fused feature image having a size corresponding to the second fused feature image;
[0019] The third fused feature image and the second fused feature image are subjected to feature fusion to eliminate gap features in the second fused feature image, thereby obtaining the elimination result.
[0020] In a possible implementation, generating a mask image of the box according to the first box information includes:
[0021] Extracting coding features and top-level features according to the first fused feature image and the second fused feature image;
[0022] A mask image is predicted according to the first box information, the encoding features and the top-level features to obtain a mask image of the box.
[0023] In a possible implementation, performing gap elimination according to the first fused feature image and the second fused feature image to generate a box mask image of the target image with the gap effect removed includes:
[0024] Identify the box according to the second fused feature image to obtain second box information;
[0025] A box mask image of the target image for removing the effect of gaps is generated according to the first fused feature image and the second box information.
[0026] In a possible implementation, after fusing the feature images of the multiple sizes to obtain a first fused feature image and a second fused feature image, the method further includes:
[0027] Perform binary classification semantic segmentation on the first fused feature image to obtain a gap mask image.
[0028] In a possible implementation, after performing binary classification semantic segmentation on the first fused feature image to obtain a slit mask image, the method further includes:
[0029] Identifying gap position information according to the gap mask image;
[0030] For any target gap, based on the gap position information, identifying two sub-boxes that satisfy a preset relative position relationship with the target gap;
[0031] The two identified sub-boxes are merged to obtain a merged corrected mask image.
[0032] In a possible implementation manner, merging the two identified sub-boxes to obtain a merged corrected mask image includes:
[0033] When the target gap and the two sub-boxes have an intersection, the two sub-boxes are merged to obtain the corrected mask image;
[0034] The method of identifying, for any target gap, two sub-boxes that satisfy a preset relative position relationship with the target gap based on the gap position information, comprises:
[0035] For any target gap, based on the gap position information, two boxes where the target gap is located in the middle are identified to obtain the two sub-boxes.
[0036] According to a second aspect of an embodiment of the present application, a mask image generating device is provided, the device comprising:
[0037] An image acquisition module, used for acquiring a target image, wherein the target image includes a box, and a surface of at least one box includes a gap;
[0038] A feature extraction module is used to extract feature images from the target image to obtain feature images of multiple sizes;
[0039] An image fusion module, used for fusing the feature images of the multiple sizes to obtain a first fused feature image and a second fused feature image, wherein the size of the first fused feature image is larger than that of the second fused feature image;
[0040] The seam elimination module is used to eliminate seams according to the first fused feature image and the second fused feature image, and generate a box mask image of the target image that removes the seam influence.
[0041] In a possible implementation, the feature extraction module is specifically used to perform background filtering on the target image to obtain a foreground image; resize the foreground image to obtain a foreground image of a preset size; and extract a feature image from the foreground image of the preset size to obtain feature images of the multiple sizes.
[0042] In a possible implementation manner, the gap removal module includes:
[0043] A result generation submodule is used to perform gap elimination on the second fused feature image through attention enhancement according to the first fused feature image to obtain the elimination result;
[0044] A box identification submodule, used to identify the box of the rejection result to obtain first box information;
[0045] The mask image generating submodule is used to generate a mask image of the box according to the first box information.
[0046] In a possible implementation, the result generation submodule is specifically used to downsample the first fused feature image to obtain a third fused feature image of a size corresponding to the second fused feature image; perform feature fusion on the third fused feature image and the second fused feature image to eliminate gap features in the second fused feature image to obtain the elimination result.
[0047] In a possible implementation, the mask image generation submodule is specifically used to extract coding features and top-level features based on the first fused feature image and the second fused feature image; and perform mask image prediction based on the first box information, the coding features and the top-level features to obtain the mask image of the box.
[0048] In a possible implementation, the gap removal module is specifically used to identify the box according to the second fused feature image to obtain second box information; and generate a box mask image of the target image that removes the influence of gaps according to the first fused feature image and the second box information.
[0049] In a possible implementation, the device further includes:
[0050] The binary classification module is used to perform binary classification semantic segmentation on the first fused feature image to obtain a gap mask image.
[0051] In a possible implementation, the device further includes:
[0052] A position identification module, used for identifying the slot position information according to the slot mask image;
[0053] A sub-box identification module, for identifying, for any target gap, two sub-boxes that satisfy a preset relative position relationship with the target gap based on the gap position information;
[0054] The box merging module is used to merge the two identified sub-boxes to obtain a merged corrected mask image.
[0055] In a possible implementation manner, the box merging module is specifically configured to merge the two sub-boxes to obtain the corrected mask image when the target gap and the two sub-boxes have an intersection;
[0056] The sub-box identification module is specifically used to identify, for any target gap, two boxes located in the middle of the target gap based on the gap position information, to obtain the two sub-boxes.
[0057] Another aspect of the present application provides an electronic device, including:
[0058] Memory, used to store computer programs;
[0059] The processor is used to implement any of the above-mentioned mask image generation methods when executing the program stored in the memory.
[0060] In another aspect of an embodiment of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any of the above-mentioned mask image generation methods is implemented.
[0061] The embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute any of the above-mentioned mask image generating methods.
[0062] Beneficial effects of the embodiments of the present application:
[0063] The embodiment of the present application provides a method and device for generating a mask image, wherein the mask image generating method comprises: obtaining a target image, wherein the target image includes a box, and the surface of at least one box includes a gap; extracting a feature image from the target image to obtain feature images of multiple sizes; fusing the feature images of multiple sizes to obtain a first fused feature image and a second fused feature image, wherein the size of the first fused feature image is larger than the second fused feature image; removing gaps according to the first fused feature image and the second fused feature image to generate a box mask image of the target image with the gap effect removed. The scheme of the present application can extract feature images after obtaining a target image including a box, and obtain a first fused feature image and a second fused feature image by fusing the extracted feature images, thereby removing gaps and generating a mask image by removing gaps from the first fused feature image and the second fused feature image, thereby reducing the box detection error caused by gaps and improving the positioning accuracy of the network for the box including gaps.
[0064] Of course, implementing any product or method of the present application does not necessarily require achieving all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other embodiments can also be obtained based on these drawings.
[0066] Figure 1 A schematic diagram of a process flow of a mask image generation method provided in an embodiment of the present application;
[0067] Figure 2 A schematic diagram of a flow chart of a feature image extraction method provided in an embodiment of the present application;
[0068] Figure 3 A schematic diagram of a process for generating a box mask image provided in an embodiment of the present application;
[0069] Figure 4 An example flow chart of a mask image generation method provided in an embodiment of the present application;
[0070] Figure 5 Another schematic diagram of the process of generating a mask image provided by an embodiment of the present application;
[0071] Figure 6 A schematic diagram of another process of the mask image generation method provided in the embodiment of the present application;
[0072] Figure 7 A schematic diagram of another process of the mask image generation method provided in the embodiment of the present application;
[0073] Figure 8 A structural diagram of the attention module provided in the embodiment of the present application
[0074] Fig. 9 A schematic diagram of a process flow of a box mask correction method provided in an embodiment of the present application;
[0075] Fig.10 Another schematic diagram of the process of the box mask correction method provided in the embodiment of the present application;
[0076] Fig.11 A schematic structural diagram of a mask image generating device provided in an embodiment of the present application;
[0077] Fig.12 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0078] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field based on the present application belong to the scope of protection of the present application.
[0079] In order to solve the problem of box detection errors caused by the presence of gaps on the box surface, the embodiment of the present application provides a mask image generation method and device.
[0080] In a first aspect of the embodiments of the present application, a method for generating a mask image is provided. Figure 1 , Figure 1 A schematic diagram of a process of generating a mask image provided in an embodiment of the present application, the method comprising:
[0081] Step S11, acquiring a target image;
[0082] Step S12, extracting a feature image from the target image to obtain feature images of multiple sizes;
[0083] Step S13, fusing feature images of multiple sizes to obtain a first fused feature image and a second fused feature image, wherein the size of the first fused feature image is larger than that of the second fused feature image;
[0084] Step S14, performing seam elimination according to the first fused feature image and the second fused feature image to generate a box mask image of the target image with the seam effect removed.
[0085] Corresponding to the above step S11, the target image referred to in the embodiment of the present application includes a box, and the surface of at least one box includes a gap. Specifically, the box may refer to a cabinet, a box, etc. The gap included in the surface of the box may refer to the gap between two doors of the cabinet, cracks on the surface of the box, etc.
[0086] Corresponding to the above step S12, feature images are extracted from the target image to obtain feature images of multiple sizes, and the feature images can be extracted by a pre-created network module. In one example, the pre-created network module can be a Backbone module (backbone network). By inputting the target image into the Backbone module for feature image extraction, feature maps of different scales can be obtained. Among them, the Backbone module is mainly responsible for receiving input data, and performing data preprocessing and feature extraction to obtain feature maps (feature images) corresponding to the input image, and passing it to the next layer. In an embodiment of the present application, when the Backbone module is used to extract feature images, multiple feature images can be extracted, such as the first feature image, the second feature image, the third feature image, and the fourth feature image, which can be respectively expressed as: res2, res3, res4, res5. Specifically, the Backbone module can be Resnet50 (a network structure). res2, res3, res4, and res5 can be extracted from different network layers, specifically, the feature maps can be extracted from the network layers: the first layer (network layer), the second layer, the third layer, and the fourth layer.
[0087] Corresponding to the above step S13, when the feature images of multiple sizes are fused to obtain the first fused feature image and the second fused feature image, since the size of the first fused feature image is larger than the second fused feature image, the first fused feature image may include more detail features. Since the size of the first fused feature image is larger than the second fused feature image, the first fused feature image may include more gap features, while the second fused feature image may include fewer gap features or does not include these gap features. Specifically, when the feature images of multiple sizes are fused, the feature images at each scale may be input into the FPN (feature graph pyramid network) for fusion to obtain the first fused feature image and the second fused feature image. In an embodiment of the present application, when the target image includes gaps, the first fused feature graph may be targeted at the task of gap detection and has the ability to identify gap features. The second feature graph is responsible for the detection and segmentation of the box, and the second feature image is easily affected by the gap and causes false detection. Therefore, for the solution of the embodiment of the present application, when the surface of the box in the target image contains gaps, the first fused feature image and the second fused feature map can be feature fused through the attention mechanism, so that the second feature map has the ability to eliminate gaps while detecting the box, thereby improving the accuracy of detection.
[0088] Corresponding to the above step S14, as described above, the size of the first fused feature image is larger than that of the second fused feature image, and the first fused feature image includes more gap features. Therefore, gap removal can be performed based on the first fused feature image and the second fused feature image. Specifically, in one case, the second fused feature image can be directly used to identify the box with reference to the first fused feature image. Specifically, the first feature map responsible for locating the box gap is fused to the second feature map responsible for locating the box. Through the attention mechanism learning, the weight of the non-gap feature is increased, so that the network has the functions of gap perception and gap elimination while locating the box surface, and the box mask map of the target image with the gap effect removed is obtained. In another case, after the second fused feature image is used to identify the box, the box instance segmentation result is sent to the post-processing module. In the post-processing module, the box surface gap predicted by the first fused feature map is used to post-process the instance segmentation result, eliminate the influence of the gap, and obtain the corrected result, thereby finally improving the network's positioning accuracy for the box containing the gap.
[0089] It can be seen that through the mask image generation method of the present application, after obtaining the target image containing the box, the feature image can be extracted, and the first fused feature image and the second fused feature image can be obtained by fusing the extracted feature images, so as to remove gaps and generate a mask image through the first fused feature image and the second fused feature image, so as to obtain a box mask image with the influence of the gaps removed, thereby improving the network's positioning accuracy for the box containing the gap.
[0090] In one possible implementation, see Figure 2 , Figure 2 A flow chart of a feature image extraction method provided in an embodiment of the present application, step S12 extracts a feature image from a target image to obtain feature images of multiple sizes, including:
[0091] Step S121, performing background filtering on the target image to obtain a foreground image;
[0092] Step S122, resizing the foreground image to obtain a foreground image of a preset size;
[0093] Step S123, extracting a feature image from the foreground image of a preset size to obtain feature images of multiple sizes.
[0094] Among them, the target image in the embodiment of the present application can be an image captured by a camera or other capture device. When the target image is subjected to background filtering, background interference such as stacking boards can be filtered out, and only the foreground image is retained. When the foreground image is resized, the size can be adjusted by pre-processing operations such as resize (changing the size) to obtain a foreground image of a preset size. Specifically, the preset size can be set according to actual conditions. In an example, the preset size can be 640*640, 320*320, etc. The foreground image of the preset size is extracted with feature images, and feature images can be extracted by a pre-created network module such as a Backbone module. The Backbone module used in the embodiment of the present application can extract feature images to obtain res2, res3, res4, and res5. Among them, res2, res3, res4, and res5 can be feature images corresponding to different sizes, which can be specifically extracted by different layers, with different sizes and different receptive fields, so that different levels of information can be fully covered.
[0095] In one possible implementation, see Figure 3 , Figure 3 A schematic diagram of a process for generating a box mask image provided by an embodiment of the present application, step S14 performs seam elimination according to the first fused feature image and the second fused feature image to generate a box mask image of the target image with the seam removed, including:
[0096] Step S141, based on the first fused feature image, performing gap elimination on the second fused feature image by attention enhancement to obtain a elimination result;
[0097] Step S142, identifying the box body of the rejection result to obtain first box body information;
[0098] Step S143: generating a mask image of the box according to the first box information.
[0099] In a possible implementation, based on the first fused feature image, the second fused feature image is subjected to gap elimination through attention enhancement to obtain a elimination result, including: downsampling the first fused feature image to obtain a third fused feature image of a size corresponding to the second fused feature image; fusing the third fused feature image with the second fused feature image to eliminate gap features in the second fused feature image to obtain a elimination result. Specifically, the first fused feature image can be downsampled, passed through a softmax layer (normalization layer), and the score_map (detection result) obtained is then weighted and multiplied by the features of the second fused feature image to achieve feature fusion. See Figure 4 After the target image is processed by the backbone network, the first feature image, the second feature image, the third feature image and the fourth feature image are obtained; then the four feature images are fused to obtain the first fused feature image and the second fused feature image; the first fused feature image is classified into two categories to obtain a gap mask image; the first fused feature image can also be normalized by downsampling to obtain the detection result, and the detection result can be obtained by using The second fused feature image is calculated, and then processed by the detection head module and the feature extraction module respectively; the box information and attention features can be obtained through the detection head module, and after being encoded by the feature extraction module, they are input into the segmentation module together to obtain the box mask image. This figure is a schematic diagram of the architecture of the entire network, in which the dotted box is the box gap attention module. Through the attention mechanism of the attention module, the second fused feature image can have the gap perception function, so that the gaps on the box surface can be eliminated according to the perceived gap features, so that in the subsequent target detection tasks, the positioning information of the complete box can be correctly learned, and it is not easily affected by the gaps on the box surface and produces false detection frames. Among them, the Backbone module can extract the feature images: res2, res3, res4, res5. The extracted feature images are fused by FPN (feature map pyramid network) to obtain p2 and p3, where p2 can correspond to the first fused feature image in the embodiment of the present application, and p3 can correspond to the second fused feature image in the embodiment of the present application. The fused image can obtain the box information and attention features by downsampling. See Figure 5After the input image is preprocessed, it is fused through the backbone network to obtain the first fused feature image and the second fused feature image; the first fused feature image outputs the gap segmentation result through the semantic segmentation module; the second fused feature image and the first fused feature image are input into the attention module together, and then through the target detection module, the target detection result is output, and the output of the target detection module can also pass through the feature extraction module, and then through the instance segmentation module to output the instance segmentation result. After being processed by the attention module, it can be further processed by the target detection module and the instance segmentation module, and finally the instance segmentation result is output. During the processing of the instance segmentation module, feature extraction can be performed through the tower module (feature extraction module) to obtain the encoding feature. After the target detection module performs target detection, the target detection result can also be output to generate a mask map. Figure 4 In the figure, after processing by the attention module corresponding to the dotted box part, the encoding features and box features such as Boxes, Classes, and Attns can be obtained. In instance segmentation, ins-seg (instance segmentation module) can be used for segmentation to finally generate a box mask.
[0100] In a possible implementation, gap elimination is performed based on the first fused feature image and the second fused feature image to generate a box mask image of the target image with the gap effect removed, including: identifying the box based on the second fused feature image to obtain second box information; generating a box mask image of the target image with the gap effect removed based on the first fused feature image and the second box information. When the box is identified based on the second fused feature image to obtain the second box information, the second fused feature image can be input into the target detection module to obtain the box detection frame and corresponding confidence information. Figure 6, after the input image is preprocessed, it is input into the backbone network and then fused to obtain the first fused feature image and the second fused feature image. The first fused feature image outputs the gap segmentation result through the semantic segmentation module and then inputs the post-processing module; the second fused feature image is input into the instance segmentation module after passing through the feature extraction module, and the second fused feature image is also input into the instance segmentation module after the target detection module; the input result of the instance segmentation module is passed through the post-processing module to output the instance segmentation result. After the feature images are fused through the FPN module, the first fused feature image (p2) and the second fused feature image (p3) are obtained; for the first fused feature image, semantic segmentation can be performed through the semantic segmentation module to obtain and output the gap segmentation result. For the second fused feature image, it can be processed through the target detection module and the instance segmentation module to obtain the second box information. Finally, post-processing is performed based on the second box information and the gap stitching result to generate a box mask image of the target image with the gap effect removed. In the embodiment of the present invention, the gap elimination process can be as follows Figure 6 and Figure 7 There are two process methods. Figure 7 In the process, the input image is input into the backbone network after image preprocessing, and then fused to obtain the first fused feature image, and then the gap segmentation result is output through the semantic segmentation module; the input image is input into the backbone network after image preprocessing, and then fused to obtain the second fused feature image; after being processed by the feature extraction module, it is input into the instance segmentation module, and after being processed by the target detection module, it is input into the instance segmentation module, and the instance segmentation result is output through the post-processing module. The box gap segmentation result is obtained by a separate network. Figure 6 The process is Figure 7 Based on the process, there is no need for a separate network training to learn the box surface gap perception process, which can be achieved by sharing a network feature extractor. The network feature extractor outputs the gap segmentation result and the box positioning result, and the final correct instance segmentation result is obtained and output through the post-processing module. Figure 8, the semantic segmentation module can be composed of multiple blocks (network modules), specifically, it can include: network module 1, network module 2, network module 3, network module 4, network module 5. The input features are obtained after passing through the five network modules, and the calculation results of the five network modules can also be output as convolution layer, normalization layer, and activation function layer. Among them, the block can be composed of three layers: conv layer (convolution layer), bn layer (normalization layer), and relu layer (activation function layer). In an example, when performing the segmentation of the surface gap of the box, the input first fusion feature image scale can be [batch, 192, 160, 160], and the feature dimension output after passing through the semantic segmentation module can be [batch, num_class (number of types), 160, 160], where num_class can be 2. During the segmentation process, the surface gap of the box can be set as the foreground, and the rest as the background. Specifically, a binary classification semantic segmentation task can be performed based on the cross_entropy loss function.
[0101] In a possible implementation, after fusing the feature images of multiple sizes to obtain a first fused feature image and a second fused feature image, the method further includes: performing binary semantic segmentation on the first fused feature image to obtain a gap mask image. In an example, see Figure 4 ,After generating the first fused feature image (p2), a binary classification can be performed through seg-head (a semantic segmentation network) to obtain the gap mask image.
[0102] In a possible implementation, a mask map of a box is generated according to the first box information, including: extracting coding features and top-level features according to the first fused feature image and the second fused feature image; predicting the mask map according to the first box information, the coding features and the top-level features to obtain the mask map of the box. Specifically, the first box information, the coding features and the top-level features can be input into the instance segmentation module to obtain the corresponding feature map, and then the feature map is scaled to a uniform size, and the mask map is predicted to obtain the mask map of the box. In an example, the input of the instance segmentation module can be the underlying coding features, the top-level attentions (interest features) and the box (box) information. Specifically, the corresponding feature map can be obtained on the coding features of the fused attentions through the roi area (region of interest) provided by the box, and finally the feature map is scaled to a uniform size to predict the instance segmentation mask.
[0103] In a possible implementation, after performing binary semantic segmentation on the first fused feature image to obtain a gap mask image, see Fig. 9 , the above method further comprises:
[0104] Step S91, identifying the slot position information according to the slot mask image;
[0105] Step S92, for any target gap, based on the gap position information, identifying two sub-boxes that satisfy a preset relative position relationship with the target gap;
[0106] Step S93: merge the two identified sub-boxes to obtain a merged corrected mask image.
[0107] In a possible implementation, the two identified sub-boxes are merged to obtain a merged corrected mask image, including: when a target gap and two sub-boxes have an intersection, the two sub-boxes are merged to obtain a corrected mask image; for any target gap, based on the gap position information, two sub-boxes that satisfy a preset relative position relationship with the target gap are identified, including: for any target gap, based on the gap position information, two boxes where the target gap is located in the middle position are identified to obtain two sub-boxes.
[0108] For a specific example, see Fig.10 , the step of generating a modified mask image may include:
[0109] The first step is to obtain a binary mask of the gaps on the box surface, and obtain a single gap by traversing the connected components;
[0110] The second step is to find the center point (cx, cy) of the gap area according to the mask image of a single gap, where cx and cy represent the horizontal and vertical coordinates of the center point respectively;
[0111] The third step is to find the two boxes closest to the gap based on the obtained gap center point. The box is the instance segmentation result of the box, and the minimum enclosing rectangle of each instance mask is obtained. First, determine whether the gap is in the middle of a single box. If so, it means that the instance is predicted correctly and no post-processing is required. Continue to obtain the next gap for processing; if the gap is not in the middle of a single box, go to step 4 to continue processing;
[0112] Step 4: Determine whether the gap is between the two boxes. If not, the instance mask merging condition is not met and no post-processing is required. Continue to obtain the next gap for processing. If the gap is between the two boxes, go to step 5 to continue processing.
[0113] The fifth step is to determine whether there is an intersection between the gap and the masks of the two boxes; if not, the instance mask merging condition is not met, no post-processing is required, and the next gap is obtained for processing; if so, there is an intersection and the merging condition is met, the three masks are merged, the prediction result is updated, the gap mask and the two instance segmentation masks are mask-merged, and the merged mask is updated to the instance segmentation prediction result, thereby removing the false detection box caused by the gap on the box surface.
[0114] The solution of the present application can build a network for locating gaps on the surface of the box while performing target detection and instance segmentation tasks on the box, so that the network can synchronously segment the gaps on the surface of the box, and then take the corresponding features as the scoremap and merge them with the features for target detection. Through this attention mechanism learning, the network has the functions of gap perception and gap elimination while locating the surface of the box, ultimately improving the network's positioning accuracy for boxes containing gaps.
[0115] In a second aspect of the embodiments of the present application, a mask image generating device is provided. Fig.11 , Fig.11 A schematic diagram of a structure of a mask image generating device provided in an embodiment of the present application, the device comprising:
[0116] An image acquisition module 1101 is used to acquire a target image, wherein the target image includes a box, and a surface of at least one box includes a gap;
[0117] The feature extraction module 1102 is used to extract feature images from the target image to obtain feature images of multiple sizes;
[0118] An image fusion module 1103 is used to fuse feature images of multiple sizes to obtain a first fused feature image and a second fused feature image, wherein the size of the first fused feature image is larger than that of the second fused feature image;
[0119] The gap elimination module 1104 is used to eliminate gaps according to the first fused feature image and the second fused feature image, and generate a box mask image of the target image with the gap effect removed.
[0120] In a possible implementation, the feature extraction module is specifically used to perform background filtering on the target image to obtain a foreground image; resize the foreground image to obtain a foreground image of a preset size; and extract feature images from the foreground image of the preset size to obtain feature images of multiple sizes.
[0121] In a possible implementation, the gap removal module includes:
[0122] A result generation submodule is used to perform gap elimination on the second fused feature image through attention enhancement according to the first fused feature image to obtain a elimination result;
[0123] The box identification submodule is used to identify the box of the rejection result and obtain the first box information;
[0124] The mask image generating submodule is used to generate a mask image of the box according to the first box information.
[0125] In a possible implementation, the result generation submodule is specifically used to downsample the first fused feature image to obtain a third fused feature image of a size corresponding to the second fused feature image; perform feature fusion on the third fused feature image and the second fused feature image to eliminate gap features in the second fused feature image to obtain an elimination result.
[0126] In a possible implementation, the mask image generation submodule is specifically used to extract coding features and top-level features based on the first fused feature image and the second fused feature image; and perform mask image prediction based on the first box information, coding features and top-level features to obtain a mask image of the box.
[0127] In a possible implementation, the gap removal module is specifically configured to identify a box according to the second fused feature image to obtain second box information; and to generate a box mask image of the target image for removing the effect of gaps according to the first fused feature image and the second box information.
[0128] In a possible implementation, the device further includes:
[0129] The binary classification module is used to perform binary classification semantic segmentation on the first fused feature image to obtain a gap mask image.
[0130] In a possible implementation, the device further includes:
[0131] A position identification module, used to identify the gap position information according to the gap mask image;
[0132] A sub-box identification module is used to identify, for any target gap, two sub-boxes that meet a preset relative position relationship with the target gap based on the gap position information;
[0133] The box merging module is used to merge the two identified sub-boxes to obtain a merged corrected mask image.
[0134] In a possible implementation, the box merging module is specifically used to merge the two sub-boxes to obtain a corrected mask image when the target gap and the two sub-boxes have an intersection;
[0135] The sub-box identification module is specifically used to identify, for any target gap, two boxes with the target gap located in the middle based on the gap position information, and obtain two sub-boxes.
[0136] It can be seen that, through the mask image generating device of the present application, after obtaining the target image containing the box, the feature image can be extracted, and the first fused feature image and the second fused feature image can be obtained by fusing the extracted feature images, so as to eliminate the gaps and generate the mask image through the first fused feature image and the second fused feature image, and obtain the box mask image with the gap effect removed.
[0137] The present application also provides an electronic device, such as Fig.12 As shown, including:
[0138] Memory 1201, used for storing computer programs;
[0139] The processor 1202 is used to implement the following steps when executing the program stored in the memory 1201:
[0140] Acquire a target image, wherein the target image includes a box, and a surface of at least one box includes a gap;
[0141] Extracting feature images of the target image to obtain feature images of multiple sizes;
[0142] Fusing feature images of multiple sizes to obtain a first fused feature image and a second fused feature image, wherein the size of the first fused feature image is larger than that of the second fused feature image;
[0143] The gaps are eliminated according to the first fused feature image and the second fused feature image to generate a box mask image of the target image which removes the gaps.
[0144] Furthermore, the electronic device may further include a communication bus and / or a communication interface, and the processor 1202, the communication interface, and the memory 1201 communicate with each other via the communication bus.
[0145] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0146] The communication interface is used for communication between the above electronic device and other devices.
[0147] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0148] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0149] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned mask image generation methods are implemented.
[0150] In another embodiment provided by the present application, a computer program product including instructions is also provided, and when the computer is run on the computer, the computer executes any mask image generating method in the above embodiments.
[0151] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a solid-state hard disk (SSD), etc.
[0152] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0153] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device, storage medium and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0154] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
Claims
1. A mask image generation method, characterized in that: The method comprises: Acquire a target image, wherein the target image includes a box, and a surface of at least one box includes a gap; Extracting a feature image from the target image to obtain feature images of multiple sizes; Fusing the feature images of the multiple sizes to obtain a first fused feature image and a second fused feature image, wherein the size of the first fused feature image is larger than that of the second fused feature image; Gap elimination is performed according to the first fused feature image and the second fused feature image to generate a box mask image of the target image with gap influence removed.
2. The method according to claim 1, characterized in that The step of extracting a feature image from the target image to obtain feature images of multiple sizes includes: Performing background filtering on the target image to obtain a foreground image; Resizing the foreground image to obtain a foreground image of a preset size; A feature image is extracted from the foreground image of the preset size to obtain feature images of the multiple sizes.
3. The method according to claim 1, characterized in that The performing gap elimination according to the first fused feature image and the second fused feature image to generate a box mask image of the target image with the gap effect removed includes: According to the first fused feature image, performing gap elimination on the second fused feature image by attention enhancement to obtain the elimination result; Performing box identification on the rejection result to obtain first box information; A mask image of the box is generated according to the first box information.
4. The method according to claim 3, characterized in that The step of performing gap elimination on the second fused feature image by attention enhancement according to the first fused feature image to obtain the elimination result includes: Downsampling the first fused feature image to obtain a third fused feature image having a size corresponding to the second fused feature image; The third fused feature image and the second fused feature image are subjected to feature fusion to eliminate gap features in the second fused feature image, thereby obtaining the elimination result.
5. The method according to claim 3, characterized in that: The step of generating a mask image of a box according to the first box information includes: Extracting coding features and top-level features according to the first fused feature image and the second fused feature image; A mask image is predicted according to the first box information, the encoding features and the top-level features to obtain a mask image of the box.
6. The method according to claim 1, characterized in that The performing gap elimination according to the first fused feature image and the second fused feature image to generate a box mask image of the target image with the gap effect removed includes: Identify the box according to the second fused feature image to obtain second box information; A box mask image of the target image for removing the effect of gaps is generated according to the first fused feature image and the second box information.
7. The method according to claim 1, characterized in that After fusing the feature images of the multiple sizes to obtain a first fused feature image and a second fused feature image, the method further includes: Perform binary classification semantic segmentation on the first fused feature image to obtain a gap mask image.
8. The method according to claim 7, characterized in that After performing binary classification semantic segmentation on the first fused feature image to obtain a slit mask image, the method further includes: Identifying gap position information according to the gap mask image; For any target gap, based on the gap position information, identifying two sub-boxes that satisfy a preset relative position relationship with the target gap; The two identified sub-boxes are merged to obtain a merged corrected mask image.
9. The method according to claim 8, characterized in that The method of identifying, for any target gap, two sub-boxes that satisfy a preset relative position relationship with the target gap based on the gap position information, comprises: For any target gap, based on the gap position information, two boxes where the target gap is located in the middle are identified to obtain the two sub-boxes; And / or, merging the two identified sub-boxes to obtain a merged corrected mask image includes: When the target gap and the two sub-boxes have an intersection, the two sub-boxes are merged to obtain the corrected mask image.
10. A mask image generating device, characterized in that: The device comprises: An image acquisition module, used for acquiring a target image, wherein the target image includes a box, and a surface of at least one box includes a gap; A feature extraction module is used to extract feature images from the target image to obtain feature images of multiple sizes; An image fusion module, used for fusing the feature images of the multiple sizes to obtain a first fused feature image and a second fused feature image, wherein the size of the first fused feature image is larger than that of the second fused feature image; The seam elimination module is used to eliminate seams according to the first fused feature image and the second fused feature image, and generate a box mask image of the target image with the seam effect removed.
Citation Information
Patent Citations
Visual detection method for slots on the surface of a bridge pier
CN109523479A
Scene image detection method and device
CN113361521A
Image generation method based on heterogeneous feature fusion and readable storage medium
CN115965845A
Feature embedding-based image fusion method, defect detection method and system
CN116310685A
Chromatic aberration correction method and system for multi-video panoramic stitching, and electronic equipment
CN116630174A
