Image processing method and related equipment
By filling zeros around the image and cutting image blocks, combined with deep convolutional neural network model processing, the problem of low statistical efficiency of crop distribution and inaccurate edge prediction is solved, achieving higher image processing accuracy and efficiency.
Patent Information
- Application Number
- CN202011600406.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-29
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-12-29
AI Technical Summary
The existing crop distribution statistical scheme is inefficient, and the edge prediction of the neural network due to zero padding in image processing is inaccurate, resulting in low crop distribution accuracy.
By filling K/2 circles of zeros around the image, and using the sliding window window and step size to cut the image, a deep convolutional neural network model is used to process the image blocks, extract features and perform convolution and pooling operations, combined with sub- The processing results of image blocks are combined to ultimately improve image processing accuracy.
It improves the accuracy and efficiency of image processing, avoids the problem of inaccurate prediction of image edges by neural networks, and can quickly obtain the target object distribution map, which is more efficient than manual statistics.
Smart Images

Figure CN112669323B
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to an image processing method and related equipment. Background Art
[0002] In the current crop distribution statistics scheme, it is necessary to manually measure the distribution data of crops in a certain area, such as the types of crops, the distribution locations and distribution areas of different crops, and then make a statistical map based on the distribution data of crops in a certain area obtained by manual measurement to obtain a distribution map of crops. Therefore, the statistical efficiency of the existing crop distribution statistics scheme is low and time-consuming and labor-intensive. In addition, a neural network can be used to predict the crop distribution of remote sensing images of the area to be counted, but when the neural network is used to calculate the image, a large amount of zero padding is performed in order to maintain the resolution, resulting in inaccurate prediction of the edge of the image by the neural network, which will result in low accuracy of the crop distribution predicted by the neural network. Summary of the invention
[0003] The embodiments of the present application disclose an image processing method and related equipment, which are beneficial to improving the accuracy of image processing.
[0004] The first aspect of an embodiment of the present application discloses an image processing method, comprising: filling K / 2 circles of zeros around a first image to obtain a second image, wherein the size of the first image is an integer multiple of the size of a sliding window, and K is the sliding window step; performing image cutting on the second image according to the sliding window and the sliding window step to obtain a plurality of image blocks; using a first neural network model to process the plurality of image blocks to obtain a processing result of each sub-image block in a plurality of sub-image blocks, wherein the plurality of image blocks correspond one-to-one to the plurality of sub-image blocks, and the sub-image block is a regional image in the image block with a center of the image block as the center and a size of K×K; obtaining the processing result of the first image according to the processing results of all or part of the sub-image blocks in the plurality of sub-image blocks.
[0005] In an embodiment of the present application, K / 2 circles of zeros are filled around the first image to obtain a second image, and the size of the first image is an integer multiple of the size of the sliding window; then the second image is cut according to the sliding window and the sliding window step size of K to obtain a plurality of image blocks, and the size of each image block in the plurality of image blocks is the same as the size of the sliding window; then the first neural network model is used to process the plurality of image blocks to obtain a processing result of each sub-image block in a plurality of sub-image blocks, and the plurality of image blocks correspond one-to-one to the plurality of sub-image blocks, and the sub-image block is a regional image of the image block with a size of K×K centered on the center of the image block, that is, the sub-image block is the central area of the corresponding image block, and the first image can be obtained by combining all or part of the plurality of sub-image blocks, so the processing result of the first image can be obtained by combining all or part of the processing results of the plurality of sub-image blocks. In the embodiment of the present application, the input of the first neural network model is an image block, and its output is the processing result of the sub-image block, and the sub-image block is the central area of the corresponding image block, so the processing result of the sub-image block is the calculation result of the central area of each image block, thereby avoiding the accuracy problem caused by the inaccurate prediction of the image edge by the neural network model, which is conducive to improving the accuracy of image processing. It should be understood that the processing result of the sub-image block can be the target object distribution map corresponding to the sub-image block predicted by the first neural network model, and the processing result of the first image is the target object distribution map corresponding to the first image; since the first image can be obtained by shooting the area where the target object needs to be counted, the embodiment of the present application can quickly obtain the target object distribution map of the area, which is more efficient than manual statistics.
[0006] In a possible implementation, filling K / 2 circles of zeros around the first image to obtain the second image includes: if the size of the first image is not an integer multiple of the size of the sliding window, padding the first image to obtain a padded first image, wherein the size of the padded first image is an integer multiple of the size of the sliding window; and filling K / 2 circles of zeros around the padded first image to obtain the second image.
[0007] In one possible implementation, the using of the first neural network model to process the multiple image blocks to obtain a processing result for each of the multiple sub-image blocks includes: using the first neural network model to process the multiple image blocks to obtain a processing result for each of the multiple image blocks; and performing image interception on the processing result of each of the multiple image blocks to obtain a processing result for each of the multiple sub-image blocks.
[0008] In the embodiment of the present application, the first neural network model outputs the processing result of the image block, and the image is intercepted for the processing result of the image block to obtain the processing result of the sub-image block corresponding to the image block, thereby eliminating the problem of image processing accuracy being affected by the inaccurate edge prediction of the image block by the first neural network model. It should be understood that the processing result of the sub-image block is the target object distribution map corresponding to the sub-image block, and when the processing result of the first image is the target object distribution map corresponding to the first image, the processing result of the image block is the target object distribution map corresponding to the image block.
[0009] In a possible implementation, the image interception of the processing result of each image block in the multiple image blocks to obtain the processing result of each sub-image block in the multiple sub-image blocks includes: for the processing result of each image block in the multiple image blocks, performing the following steps to obtain the processing result of each sub-image block in the multiple sub-image blocks: taking the center of the processing result of the target image block as the center, image interception of a regional image with a size of K×K in the processing result of the target image block to obtain a target sub-image block, wherein the target image block is any one of the multiple image blocks, and the target sub-image block is a sub-image block corresponding to the target image block.
[0010] In a possible implementation, the using a first neural network model to process the multiple image blocks to obtain a processing result of each of the multiple image blocks includes: for each of the multiple image blocks, performing the following steps to obtain a processing result of each of the multiple image blocks: using a deep convolutional neural network model to extract features of a target image block to obtain a first feature map of the target image block, wherein the target image block is any one of the multiple image blocks; performing a convolution operation according to the first feature map and a first convolution kernel to obtain a first target feature map, wherein, The size of the first convolution kernel is 1×1; an expansion convolution operation is performed according to the first feature map and the second convolution kernel to obtain a second target feature map, wherein the size of the second convolution kernel is n×n, the expansion rate of the second convolution kernel is a first preset value, and n is an integer greater than 1; an expansion convolution operation is performed according to the first feature map and the third convolution kernel to obtain a third target feature map, wherein the size of the third convolution kernel is n×n, and the expansion rate of the third convolution kernel is a second preset value; an expansion convolution operation is performed according to the first feature map and the fourth convolution kernel to obtain a fourth target feature map, wherein the fourth convolution kernel is The size is n×n, and the expansion rate of the fourth convolution kernel is a third preset value; a pooling operation is performed on the first feature map to obtain a fifth target feature map; wherein the first target feature map, the second target feature map, the third target feature map, the fourth target feature map and the fifth target feature map have the same size; the first target feature map, the second target feature map, the third target feature map, the fourth target feature map and the fifth target feature map are fused to obtain a second feature map; a convolution operation is performed according to the second feature map and the fifth convolution kernel to obtain a third feature map, wherein the fifth convolution kernel The size of the first feature map is 1×1; the third feature map is upsampled to obtain a fourth feature map; a convolution operation is performed according to the first feature map and the sixth convolution kernel to obtain a fifth feature map, wherein the size of the sixth convolution kernel is 1×1, and the fourth feature map and the fifth feature map have the same size; the fourth feature map and the fifth feature map are fused to obtain a sixth feature map; a convolution operation is performed according to the sixth feature map and the seventh convolution kernel to obtain a seventh feature map, wherein the size of the seventh convolution kernel is n×n; the seventh feature map is upsampled to obtain a processing result of the target image block.
[0011] In an embodiment of the present application, convolution layers with different expansion rates are used to perform convolution calculations on the first feature map, so that features can be extracted under different receptive fields without increasing the amount of calculation; and the first feature map is directly pooled, the main purpose of which is to denoise and reduce the amount of calculation, thereby preventing overfitting to a certain extent; and the first target feature map, the second target feature map, the third target feature map, the fourth target feature map and the fifth target feature map are then fused to improve the recognition accuracy.
[0012] In a possible implementation, the processing result of the sub-image block is a target object distribution map corresponding to the sub-image block, and the processing result of the first image is a target object distribution map corresponding to the first image; the processing result of the first image is obtained according to the processing results of all or part of the sub-image blocks in the multiple sub-image blocks, including: processing the target object distribution map corresponding to each sub-image block in the multiple sub-image blocks to obtain the target object distribution map corresponding to all or part of the sub-image blocks in the multiple sub-image blocks after processing, wherein the processing includes hole filling and small connected domain removal, the hole refers to the target object-free area surrounded by the distribution area of the same target object in the sub-image block, and the small connected domain refers to the scattered distribution area of the target object in the sub-image block; the target object distribution map corresponding to the first image is obtained according to the target object distribution map corresponding to all or part of the sub-image blocks in the multiple sub-image blocks after processing.
[0013] In an embodiment of the present application, the target object distribution map corresponding to the sub-image block is post-processed such as hole filling and small connected domain removal, and then the target object distribution map corresponding to the processed sub-image block is combined to obtain the target object distribution map corresponding to the first image, which is beneficial to improve the accuracy of target object distribution prediction.
[0014] In a possible implementation, the first neural network model is obtained by the following steps: using the first training set to train the preset neural network to obtain the second neural network model, wherein the sample image blocks in the first training set have labels; using the second neural network model to predict the second training set to obtain a third training set, wherein the sample image blocks in the second training set have no labels, and the sample image blocks in the third training set have pseudo labels; merging the first training set and the third training set to obtain a fourth training set; using the fourth training set to train the preset neural network to obtain the first neural network model.
[0015] In an embodiment of the present application, a preset neural network is first trained using labeled sample image blocks to obtain a second neural network model; then the second neural network model is used to predict sample image blocks without labels to generate pseudo labels; then the sample image blocks with pseudo labels are added to a training set, and the preset neural network is retrained using the training set containing the sample image blocks with pseudo labels to obtain a first neural network model, thereby improving the prediction accuracy of the first neural network model, which is beneficial to improving the accuracy of image processing.
[0016] In a possible implementation, the sample image block is obtained by the following strategy: the sample image is cut with the sliding window size of 1024×1024 and the sliding window step of 900, and when the background area in the sliding window accounts for more than 7 / 8 of the sliding window, the image block currently framed by the sliding window is not cut; when the background area in the sliding window accounts for less than 1 / 3 of the sliding window, the sliding window step is reduced to 512 to increase the sampling rate; or the sample image is cut with the sliding window size of 1024×1024 and the sliding window step of 512, and when the background area in the sliding window accounts for more than 1 / 3 of the sliding window, the image block currently framed by the sliding window is not cut.
[0017] In the embodiment of the present application, when obtaining the sample image block for training, the sample image can be cut with a sliding window size of 1024×1024 and a sliding window step of 900 or 512; if the sliding window step is 900, when the background class area in the sliding window accounts for more than 7 / 8 of the sliding window, it means that the image block currently framed by the sliding window has less data available for training, and the image block currently framed by the sliding window is not cut; when the background class area in the sliding window accounts for less than 1 / 3 of the sliding window, it means that the image block currently framed by the sliding window has more data available for training, and the sliding window step can be reduced, for example, to 512, to increase the sampling rate; if the sliding window step is 512, when the background class area in the sliding window accounts for more than 1 / 3 of the sliding window, it means that the image block currently framed by the sliding window has less data available for training, and the image block currently framed by the sliding window is not cut. In this way, the effective data in the obtained sample image block can be as much as possible, which is conducive to training to obtain the first neural network model with high-precision prediction ability.
[0018] In a possible implementation, the label of the sample image block is obtained by the following steps: setting a transition zone at the edge of the sample image block and the boundary between classes, wherein the boundary between classes refers to the boundary between distribution areas of different classes in the sample image block; setting the label probability of the non-transition zone area in the sample image block to 1, and setting the label probability of the transition zone area in the sample image block to between 0 and 1.
[0019] In an embodiment of the present application, a transition zone is set at the edge of the sample image block and the boundary between classes, the label probability of the non-transition zone area in the sample image block is set to 1, and the label probability of the transition zone area in the sample image block is set between 0 and 1. Since it is difficult for the neural network model to correctly classify the data at the edge of the image and the boundary between classes, compared to setting the label probability of the transition zone area to 0 or 1, setting the label probability of the transition zone area in the sample image block between 0 and 1 is beneficial to improving the accuracy of the neural network model in predicting the category of the transition zone area.
[0020] The second aspect of an embodiment of the present application discloses an image processing device, comprising: a filling unit, used to fill K / 2 circles of zeros around a first image to obtain a second image, wherein the size of the first image is an integer multiple of the size of a sliding window, and K is the sliding window step; a cutting unit, used to perform image cutting on the second image according to the sliding window and the sliding window step to obtain a plurality of image blocks; a processing unit, used to process the plurality of image blocks using a first neural network model to obtain a processing result of each sub-image block in a plurality of sub-image blocks, wherein the plurality of image blocks correspond one-to-one to the plurality of sub-image blocks, and the sub-image block is a regional image in the image block with the center of the image block as the center and a size of K×K; and obtaining the processing result of the first image according to the processing result of each sub-image block in the plurality of sub-image blocks.
[0021] In a possible implementation, in terms of filling K / 2 circles of zeros around the first image to obtain the second image, the filling unit is specifically used to: if the size of the first image is not an integer multiple of the size of the sliding window, fill the first image to obtain a filled first image, wherein the size of the filled first image is an integer multiple of the size of the sliding window; and fill K / 2 circles of zeros around the filled first image to obtain the second image.
[0022] In one possible implementation, in terms of using the first neural network model to process the multiple image blocks to obtain a processing result for each of the multiple sub-image blocks, the processing unit is specifically used to: use the first neural network model to process the multiple image blocks to obtain a processing result for each of the multiple image blocks; and perform image capture on the processing result of each of the multiple image blocks to obtain a processing result for each of the multiple sub-image blocks.
[0023] In a possible implementation, in terms of performing image interception on the processing result of each image block in the multiple image blocks to obtain the processing result of each sub-image block in the multiple sub-image blocks, the processing unit is specifically used to: perform the following steps for the processing result of each image block in the multiple image blocks to obtain the processing result of each sub-image block in the multiple sub-image blocks: taking the center of the processing result of the target image block as the center, performing image interception of a regional image with a size of K×K in the processing result of the target image block to obtain a target sub-image block, wherein the target image block is any one of the multiple image blocks, and the target sub-image block is a sub-image block corresponding to the target image block.
[0024] In a possible implementation, in the aspect of using the first neural network model to process the multiple image blocks to obtain the processing result of each image block in the multiple image blocks, the processing unit is specifically used to: for each image block in the multiple image blocks, perform the following steps to obtain the processing result of each image block in the multiple image blocks: use a deep convolutional neural network model to extract features of a target image block to obtain a first feature map of the target image block, wherein the target image block is any one of the multiple image blocks; perform a convolution operation according to the first feature map and a first convolution kernel to obtain a first A target feature map, wherein the size of the first convolution kernel is 1×1; performing an expansion convolution operation on the first feature map and the second convolution kernel to obtain a second target feature map, wherein the size of the second convolution kernel is n×n, the expansion rate of the second convolution kernel is a first preset value, and n is an integer greater than 1; performing an expansion convolution operation on the first feature map and the third convolution kernel to obtain a third target feature map, wherein the size of the third convolution kernel is n×n, and the expansion rate of the third convolution kernel is a second preset value; performing an expansion convolution operation on the first feature map and the fourth convolution kernel to obtain a fourth target feature map, wherein The size of the fourth convolution kernel is n×n, and the expansion rate of the fourth convolution kernel is a third preset value; a pooling operation is performed on the first feature map to obtain a fifth target feature map; wherein the first target feature map, the second target feature map, the third target feature map, the fourth target feature map and the fifth target feature map have the same size; the first target feature map, the second target feature map, the third target feature map, the fourth target feature map and the fifth target feature map are fused to obtain a second feature map; a convolution operation is performed according to the second feature map and the fifth convolution kernel to obtain a third feature map, wherein the fifth The size of the convolution kernel is 1×1; the third feature map is upsampled to obtain a fourth feature map; a convolution operation is performed based on the first feature map and the sixth convolution kernel to obtain a fifth feature map, wherein the size of the sixth convolution kernel is 1×1, and the fourth feature map and the fifth feature map have the same size; the fourth feature map and the fifth feature map are fused to obtain a sixth feature map; a convolution operation is performed based on the sixth feature map and the seventh convolution kernel to obtain a seventh feature map, wherein the size of the seventh convolution kernel is n×n; the seventh feature map is upsampled to obtain a processing result of the target image block.
[0025] In a possible implementation, the processing result of the sub-image block is a target object distribution map corresponding to the sub-image block, and the processing result of the first image is a target object distribution map corresponding to the first image; in terms of obtaining the processing result of the first image based on the processing results of all or part of the sub-image blocks in the multiple sub-image blocks, the processing unit is specifically used to: process the target object distribution map corresponding to each sub-image block in the multiple sub-image blocks to obtain the target object distribution map corresponding to all or part of the sub-image blocks in the multiple sub-image blocks after processing, wherein the processing includes hole filling and small connected domain removal, the hole refers to a target object-free area surrounded by a distribution area of the same target object in the sub-image block, and the small connected domain refers to a scattered distribution area of the target object in the sub-image block; the target object distribution map corresponding to the first image is obtained based on the target object distribution map corresponding to all or part of the sub-image blocks in the multiple sub-image blocks after processing.
[0026] In a possible implementation, the first neural network model is obtained by the following steps: using the first training set to train the preset neural network to obtain the second neural network model, wherein the sample image blocks in the first training set have labels; using the second neural network model to predict the second training set to obtain a third training set, wherein the sample image blocks in the second training set have no labels, and the sample image blocks in the third training set have pseudo labels; merging the first training set and the third training set to obtain a fourth training set; using the fourth training set to train the preset neural network to obtain the first neural network model.
[0027] In a possible implementation, the sample image block is obtained by the following strategy: the sample image is cut with the sliding window size of 1024×1024 and the sliding window step of 900, and when the background area in the sliding window accounts for more than 7 / 8 of the sliding window, the image block currently framed by the sliding window is not cut; when the background area in the sliding window accounts for less than 1 / 3 of the sliding window, the sliding window step is reduced to 512 to increase the sampling rate; or the sample image is cut with the sliding window size of 1024×1024 and the sliding window step of 512, and when the background area in the sliding window accounts for more than 1 / 3 of the sliding window, the image block currently framed by the sliding window is not cut.
[0028] In a possible implementation, the label of the sample image block is obtained by the following steps: setting a transition zone at the edge of the sample image block and the boundary between classes, wherein the boundary between classes refers to the boundary between distribution areas of different classes in the sample image block; setting the label probability of the non-transition zone area in the sample image block to 1, and setting the label probability of the transition zone area in the sample image block to between 0 and 1.
[0029] A third aspect of an embodiment of the present application discloses an electronic device, comprising a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the steps in the method as described in any one of the first aspect of the embodiment of the present application.
[0030] A fourth aspect of an embodiment of the present application discloses a chip, characterized in that it includes: a processor for calling and running a computer program from a memory, so that a device equipped with the chip executes a method as described in any one of the first aspects of the embodiment of the present application.
[0031] A fifth aspect of an embodiment of the present application discloses a computer-readable storage medium, characterized in that it stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute a method as described in any one of the first aspects of the embodiments of the present application.
[0032] A sixth aspect of the embodiments of the present application discloses a computer program product, which enables a computer to execute a method as described in any one of the first aspects of the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present application, 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. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0034] Figure 1 It is a flowchart of an image processing method provided in an embodiment of the present application.
[0035] Figure 2 It is a schematic diagram of an image processing process provided in an embodiment of the present application.
[0036] Figure 3 It is a schematic diagram of a data processing flow chart of a neural network model provided in an embodiment of the present application.
[0037] Figure 4It is a schematic diagram of a grid effect provided in an embodiment of the present application.
[0038] Figure 5 It is a post-processing schematic diagram of a target object distribution map provided in an embodiment of the present application.
[0039] Figure 6 It is a flowchart of a neural network model training provided in an embodiment of the present application.
[0040] Figure 7 This is a schematic diagram of a remote sensing image and label provided in an embodiment of the present application.
[0041] Figure 8 It is a schematic diagram of a hard label and a soft label provided in an embodiment of the present application.
[0042] Fig. 9 It is a schematic diagram of a transition zone in an image provided in an embodiment of the present application.
[0043] Fig.10 It is a schematic diagram of a sample image visualization provided in an embodiment of the present application.
[0044] Fig.11 It is a structural schematic diagram of an image processing device provided in an embodiment of the present application.
[0045] Fig.12 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0046] The embodiments of the present application are described below in conjunction with the drawings in the embodiments of the present application.
[0047] See also Figure 1 , Figure 1 1 is a flow chart of an image processing method provided in an embodiment of the present application. The image processing method can be applied to electronic devices. The image processing method includes but is not limited to the following steps.
[0048] Step 101: Fill K / 2 circles of zeros around a first image to obtain a second image, wherein the size of the first image is an integer multiple of the size of a sliding window, and K is the sliding window step size.
[0049] Wherein, padding K / 2 circles of zeros around the first image to obtain the second image includes: if the size of the first image is not an integer multiple of the size of the sliding window, padding the first image to obtain a padded first image, wherein the size of the padded first image is an integer multiple of the size of the sliding window; padding K / 2 circles of zeros around the padded first image to obtain the second image. It should be understood that padding is also padding with zeros, that is, the padded pixel value is zero.
[0050] For example, see Figure 2 , Figure 2 is a schematic diagram of an image processing process provided by an embodiment of the present application, such as Figure 2 As shown, if the size of the first image is 2304×2304 and the size of the sliding window is 1024×1024, the size of the first image is not an integer multiple of the size of the sliding window; the first image is padded in rows and columns to obtain a padded first image, and the size of the padded first image is 2560×2560, which is an integer multiple of the size of the sliding window; then K / 2 circles of zeros are padded around the padded first image to obtain a second image, for example, if the sliding window step K is equal to 512, 256 circles of zeros are padded around the padded first image, and the size of the obtained second image is 3072×3072.
[0051] Step 102: perform image segmentation on the second image according to the sliding window and the sliding window step size to obtain a plurality of image blocks.
[0052] It should be understood that the size of the multiple image blocks obtained by image segmentation according to the sliding window is the size of the sliding window; if the size of the sliding window is M×M, the size of the image block is also M×M, where M is a positive integer greater than or equal to K.
[0053] For example, see Figure 2 , the size of the sliding window is 1024×1024, then the size of the image block obtained by image segmentation using the sliding window is also 1024×1024.
[0054] Step 103: Use the first neural network model to process the multiple image blocks to obtain a processing result of each sub-image block in the multiple sub-image blocks, wherein the multiple image blocks correspond to the multiple sub-image blocks one by one, and the sub-image block is a regional image in the image block with a size of K×K centered on the center of the image block.
[0055] It should be understood that the sub-image block is the image of the central area of the image block; each image block has a corresponding sub-image block, so multiple image blocks correspond to multiple sub-image blocks; the size of the sub-image block is K×K, and the size of the processing result of the sub-image block is also K×K.
[0056] Among them, the efficiency of image processing is related to the sliding window step size. If it is necessary to improve the efficiency of image cutting or using the first neural network model to process the multiple image blocks, the sliding window step size during image cutting can be adjusted to obtain a larger sliding window step size, or a larger central area can be retained (that is, a larger sub-image block size is obtained), thereby improving processing efficiency.
[0057] In one possible implementation, the using of the first neural network model to process the multiple image blocks to obtain a processing result for each of the multiple sub-image blocks includes: using the first neural network model to process the multiple image blocks to obtain a processing result for each of the multiple image blocks; and performing image interception on the processing result of each of the multiple image blocks to obtain a processing result for each of the multiple sub-image blocks.
[0058] Exemplarily, performing image cropping on the processing result of each image block in the multiple image blocks to obtain the processing result of each sub-image block in the multiple sub-image blocks includes: performing the following steps for the processing result of each image block in the multiple image blocks to obtain the processing result of each sub-image block in the multiple sub-image blocks: taking the center of the processing result of the target image block as the center, performing image cropping of a regional image with a size of K×K in the processing result of the target image block to obtain a target sub-image block, wherein the target image block is any one of the multiple image blocks, and the target sub-image block is a sub-image block corresponding to the target image block.
[0059] For example, see Figure 2 , the size of the image block is 1024×1024, the sliding window step is equal to 512, and the size of the sub-image block is 512×512; specifically, any image block is input into the first neural network model, and the first neural network model outputs the processing result of the image block, and the size of the processing result of the image block is 1024×1024. The processing result of the image block is intercepted according to the size of the sub-image block corresponding to the image block, so that the size of the processing result of each sub-image block is 512×512.
[0060] In an embodiment of the present application, the first neural network model outputs the processing result of the image block, and image capture is performed on the processing result of the image block to obtain the processing result of the sub-image block corresponding to the image block, thereby eliminating the problem of image processing accuracy being affected by inaccurate edge prediction of the image block by the first neural network model.
[0061] See also Figure 3 , Figure 3 is a data processing flow chart of a neural network model provided in an embodiment of the present application. The neural network model may be a first neural network model. Figure 3 The processing flow shown processes the multiple image blocks to obtain a processing result for each of the multiple image blocks.
[0062] In a possible implementation, the using a first neural network model to process the multiple image blocks to obtain a processing result of each of the multiple image blocks includes: for each of the multiple image blocks, performing the following steps to obtain a processing result of each of the multiple image blocks: using a deep convolutional neural network model to extract features of a target image block to obtain a first feature map of the target image block, wherein the target image block is any one of the multiple image blocks; performing a convolution operation according to the first feature map and a first convolution kernel to obtain a first target feature map, wherein, The size of the first convolution kernel is 1×1; an expansion convolution operation is performed according to the first feature map and the second convolution kernel to obtain a second target feature map, wherein the size of the second convolution kernel is n×n, the expansion rate of the second convolution kernel is a first preset value, and n is an integer greater than 1; an expansion convolution operation is performed according to the first feature map and the third convolution kernel to obtain a third target feature map, wherein the size of the third convolution kernel is n×n, and the expansion rate of the third convolution kernel is a second preset value; an expansion convolution operation is performed according to the first feature map and the fourth convolution kernel to obtain a fourth target feature map, wherein the fourth convolution kernel is The size is n×n, and the expansion rate of the fourth convolution kernel is a third preset value; a pooling operation is performed on the first feature map to obtain a fifth target feature map; wherein the first target feature map, the second target feature map, the third target feature map, the fourth target feature map and the fifth target feature map have the same size; the first target feature map, the second target feature map, the third target feature map, the fourth target feature map and the fifth target feature map are fused to obtain a second feature map; a convolution operation is performed according to the second feature map and the fifth convolution kernel to obtain a third feature map, wherein the fifth convolution kernel The size of the first feature map is 1×1; the third feature map is upsampled to obtain a fourth feature map; a convolution operation is performed according to the first feature map and the sixth convolution kernel to obtain a fifth feature map, wherein the size of the sixth convolution kernel is 1×1, and the fourth feature map and the fifth feature map have the same size; the fourth feature map and the fifth feature map are fused to obtain a sixth feature map; a convolution operation is performed according to the sixth feature map and the seventh convolution kernel to obtain a seventh feature map, wherein the size of the seventh convolution kernel is n×n; the seventh feature map is upsampled to obtain a processing result of the target image block.
[0063] Specifically, Figure 3The deep convolutional neural network model (DCNN) in the neural network model shown can be DeeplabV3plus, Xception-65, ResNet-101 and DenseNet-121; when processing the image block, these multiple models can be used for processing (i.e. voting), and then the processing results of each model are averaged, and the average value is used as the processing result of the image block; wherein each model used for voting is trained with different data, so that the model difference can be increased. wherein n can be 3, 5, 7, 9, etc.; the first expansion rate, i.e. the expansion rate of the second convolution kernel, is a first preset value, for example, the first expansion rate can be 6; the second expansion rate, i.e. the expansion rate of the third convolution kernel, is a second preset value, for example, the second expansion rate can be 12; the third expansion rate, i.e. the expansion rate of the fourth convolution kernel, is a third preset value, for example, the third expansion rate can be 18; the upsampling step size is 4.
[0064] In an embodiment of the present application, convolution layers with different expansion rates are used to perform convolution calculations on the first feature map, so that features can be extracted under different receptive fields without increasing the amount of calculation; and the first feature map is directly pooled, the main purpose of which is to denoise and reduce the amount of calculation, thereby preventing overfitting to a certain extent; and the first target feature map, the second target feature map, the third target feature map, the fourth target feature map and the fifth target feature map are then fused to improve the recognition accuracy.
[0065] Among them, when obtaining the processing result of the image block, the image block can be first flipped horizontally, vertically, and horizontally and vertically, and then input into the first neural network model for processing to obtain the processing result, that is, to obtain the predicted result of the processing result of the image block, so that the processing result of the image block under different input methods can be obtained, and then the processing results of the same image block under different input methods are averaged, and the average value is used as the final processing result, which can improve the accuracy of image processing.
[0066] Step 104: Obtain a processing result of the first image according to processing results of all or part of the sub-image blocks in the plurality of sub-image blocks.
[0067] Among them, when the neural network model predicts, only the central area of the prediction result is retained, and the edges with inaccurate predictions are discarded, which is called dilation prediction. Because a large amount of zero padding is performed in order to maintain resolution during convolution calculation, the neural network model makes inaccurate edge predictions; if the prediction results of the neural network are directly spliced with non-overlapping sliding window predictions, the prediction results will have obvious splicing traces, that is, a grid effect is produced, such as Figure 4 By expanding the prediction, the grid effect can be eliminated.
[0068] In a possible implementation, the processing result of the sub-image block is a target object distribution map corresponding to the sub-image block, and the processing result of the first image is a target object distribution map corresponding to the first image; the processing result of the first image is obtained according to the processing results of all or part of the sub-image blocks in the multiple sub-image blocks, including: processing the target object distribution map corresponding to each sub-image block in the multiple sub-image blocks to obtain the target object distribution map corresponding to all or part of the sub-image blocks in the multiple sub-image blocks after processing, wherein the processing includes hole filling and small connected domain removal, the hole refers to the target object-free area surrounded by the distribution area of the same target object in the sub-image block, and the small connected domain refers to the scattered distribution area of the target object in the sub-image block; the target object distribution map corresponding to the first image is obtained according to the target object distribution map corresponding to all or part of the sub-image blocks in the multiple sub-image blocks after processing.
[0069] It should be understood that the embodiments of the present application can be applied to predict the distribution map of target objects in an image; in this case, the processing result of the sub-image block is the distribution map of target objects corresponding to the sub-image block, the processing result of the first image is the distribution map of target objects corresponding to the first image, and the processing result of the image block is the distribution map of target objects corresponding to the image block. For example, it is used to predict the distribution of crops in a certain area, and the target objects may include various crops, etc.
[0070] Specifically, Figure 5 As shown, the target object distribution map corresponding to each sub-image block is post-processed, wherein the post-processing is mainly to fill holes and remove small connected domains. It should be understood that in the embodiment of the present application, the target object distribution map corresponding to the image block can be post-processed first to obtain the target object distribution map corresponding to the processed image block, and then the target object distribution map corresponding to the processed image block can be carefully cut to obtain the target object distribution map corresponding to the processed sub-image block; or the target object distribution map corresponding to the image block can be carefully cut to obtain the target object distribution map corresponding to the sub-image block, and then the target object distribution map corresponding to the sub-image block can be post-processed to obtain the target object distribution map corresponding to the processed sub-image block; the present application does not make specific limitations on this.
[0071] In an embodiment of the present application, the target object distribution map corresponding to the sub-image block is post-processed such as hole filling and small connected domain removal, and then the target object distribution map corresponding to the processed sub-image block is combined to obtain the target object distribution map corresponding to the first image, which is beneficial to improve the accuracy of target object distribution prediction.
[0072] It should be noted that the embodiments of the present application can be used to statistically analyze the distribution of crops in a certain area. For example, the area is first photographed by aerial means to obtain a remote sensing image of the area, and then the remote sensing image of the area is used as the first image. The image processing method provided by the present application is used to statistically analyze the distribution of crops in the area.
[0073] exist Figure 1 In the described image processing method, K / 2 circles of zeros are filled around the first image to obtain a second image, and the size of the first image is an integer multiple of the size of the sliding window; then the second image is cut according to the sliding window and the sliding window step size of K to obtain multiple image blocks, and the size of each image block in the multiple image blocks is the same as the size of the sliding window; then the first neural network model is used to process the multiple image blocks to obtain the processing results of each sub-image block in the multiple sub-image blocks, and the multiple image blocks correspond one-to-one to the multiple sub-image blocks, the sub-image block is a regional image with a size of K×K centered on the center of the image block in the image block, that is, the sub-image block is the central area of the corresponding image block, and the first image can be obtained by combining all or part of the multiple sub-image blocks, so the processing results of all or part of the sub-image blocks in the multiple sub-image blocks can be combined to obtain the processing result of the first image. In the embodiment of the present application, the input of the first neural network model is an image block, and its output is the processing result of the sub-image block, and the sub-image block is the central area of the corresponding image block, so the processing result of the sub-image block is the calculation result of the central area of each image block, thereby avoiding the accuracy problem caused by the inaccurate prediction of the image edge by the neural network model, which is conducive to improving the accuracy of image processing. It should be understood that the processing result of the sub-image block can be the target object distribution map corresponding to the sub-image block predicted by the first neural network model, and the processing result of the first image is the target object distribution map corresponding to the first image; since the first image can be obtained by shooting the area where the target object needs to be counted, the embodiment of the present application can quickly obtain the target object distribution map of the area, which is more efficient than manual statistics.
[0074] In a possible implementation, the first neural network model is obtained by the following steps: using the first training set to train the preset neural network to obtain the second neural network model, wherein the sample image blocks in the first training set have labels; using the second neural network model to predict the second training set to obtain a third training set, wherein the sample image blocks in the second training set have no labels, and the sample image blocks in the third training set have pseudo labels; merging the first training set and the third training set to obtain a fourth training set; using the fourth training set to train the preset neural network to obtain the first neural network model.
[0075] Specifically, a semi-supervised learning method is used to train the first neural network model, the unlabeled test set is predicted to generate pseudo labels, and then the training set is added to retrain the preset neural network. The retrained model is the first neural network model. The first neural network model trained in this way has a significant improvement in prediction accuracy.
[0076] Among them, snapshot ensemble can be introduced during model training. Snapshot ensemble is a simple and universal technique for improving scores. It uses the learning rate adjustment strategy of cosine periodic annealing to save multiple models that converge to the local minimum, and improves the model effect through model self-fusion. Another function of snapshot ensemble is to verify new solutions. The results of deep learning training have a certain degree of randomness. When verifying new improvement solutions, it is sometimes difficult to determine whether the small increase in online scores comes from randomness or the effect of the improvement solution. Snapshot ensemble is a stable method for verifying new solutions.
[0077] In an embodiment of the present application, a preset neural network is first trained using labeled sample image blocks to obtain a second neural network model; then the second neural network model is used to predict sample image blocks without labels to generate pseudo labels; then the sample image blocks with pseudo labels are added to a training set, and the preset neural network is retrained using the training set containing the sample image blocks with pseudo labels to obtain a first neural network model, thereby improving the prediction accuracy of the first neural network model, which is beneficial to improving the accuracy of image processing.
[0078] In a possible implementation, the sample image block is obtained by the following strategies: Strategy 1, cutting the sample image with the size of the sliding window being 1024×1024 and the sliding window step being 900. When the background area in the sliding window accounts for more than 7 / 8 of the sliding window, the image block currently framed by the sliding window is not cut; when the background area in the sliding window accounts for less than 1 / 3 of the sliding window, the sliding window step is reduced to 512 to increase the sampling rate; Strategy 2, cutting the sample image with the size of the sliding window being 1024×1024 and the sliding window step being 512. When the background area in the sliding window accounts for more than 1 / 3 of the sliding window, the image block currently framed by the sliding window is not cut.
[0079] Among them, the following three aspects are mainly considered when performing image cutting:
[0080] (1) Speed: GDAL (Geospatial Data Abstraction Library) is used for image segmentation, and multi-process acceleration is used during reading. When the image block size is 1024, a single image can be segmented in 5 to 6 minutes.
[0081] (2) Image block size: There are two cutting methods: 1024 and 512.
[0082] (3) Category balance: Filter out areas where the background area accounts for more than 7 / 8; when the background area accounts for less than 1 / 3, reduce the sliding window step size and increase the sampling rate.
[0083] In the embodiment of the present application, when obtaining the sample image block for training, the sample image can be cut with a sliding window size of 1024×1024 and a sliding window step of 900 or 512; if the sliding window step is 900, when the background class area in the sliding window accounts for more than 7 / 8 of the sliding window, it means that the image block currently framed by the sliding window has less data available for training, and the image block currently framed by the sliding window is not cut; when the background class area in the sliding window accounts for less than 1 / 3 of the sliding window, it means that the image block currently framed by the sliding window has more data available for training, and the sliding window step can be reduced, for example, to 512, to increase the sampling rate; if the sliding window step is 512, when the background class area in the sliding window accounts for more than 1 / 3 of the sliding window, it means that the image block currently framed by the sliding window has less data available for training, and the image block currently framed by the sliding window is not cut. In this way, the effective data in the obtained sample image block can be as much as possible, which is conducive to training to obtain the first neural network model with high-precision prediction ability.
[0084] Among them, sample image blocks can be obtained by cutting in two ways: 1024 and 512, which are used to train different models respectively to improve the difference of the models, which is beneficial to model voting.
[0085] Take the distribution map of target objects corresponding to the predicted image blocks as an example, see Figure 6 , Figure 6 Schematic diagram of a neural network model training process provided by the embodiment of the present application. Figure 6As shown in the figure, the first neural network model is obtained by training in three ways: (1) Strategy 1 is used for image segmentation to obtain sample image blocks with a size of 1024×1024, and these sample image blocks are used to train the Xception-65+atrous spatial pyramid pooling (ASPP) network architecture to obtain the target object distribution map prediction result 1; (2) Strategy 2 is used for image segmentation to obtain sample image blocks with a size of 1024×1024, and these sample image blocks are used to train the Xception-65+ASPP network architecture to obtain the target object distribution map prediction result 2; (3) Strategy 2+random segmentation is used for image segmentation to obtain sample image blocks with a size of 512×512, and these sample image blocks are used to train the ResNet-101+ASPP network architecture to obtain the target object distribution map prediction result 3; Based on the results of the above three methods, one-hot encoding and argmax function are used to determine the best way to train the first neural network model, that is, the best target object distribution map prediction result is obtained.
[0086] In a possible implementation, the label of the sample image block is obtained by the following steps: setting a transition zone at the edge of the sample image block and the boundary between classes, wherein the boundary between classes refers to the boundary between distribution areas of different classes in the sample image block; setting the label probability of the non-transition zone area in the sample image block to 1, and setting the label probability of the transition zone area in the sample image block to between 0 and 1.
[0087] Taking the distribution map of the target object corresponding to the predicted image block as an example, the sample image in the embodiment of the present application may be a remote sensing image, such as Figure 7 As shown in the figure, the remote sensing image is an aerial image of the same area; the upper part is the original image, and the lower part is a single-channel image composed of corresponding different labels, where the provided label is a single-channel image with a 1:1 size of the original image, and the size of the pixel corresponds to different annotation categories; the pixel value of "flue-cured tobacco" is 1, the pixel value of "corn" is 2, the pixel value of "job's tears rice" is 3, the pixel value of "artificial building" is 4, and the pixel value of the background class is 0; in this way, the training set data can be visualized.
[0088] Among them, in the image, the labels of the pixels at the edge of the image and the boundary of the category (that is, the boundary between different categories) are hard labels (hard samples), while the labels of the pixels in the same category distribution area are soft labels (easy samples), such as Figure 8 shown.
[0089] Specifically, in the image segmentation task, the classification result of each pixel depends largely on the surrounding pixels. Based on this, in order to discover the hard labels in some samples, the following two types of data are mainly considered:
[0090] (1) Data at the edge of the image: During the convolution operation, too much zero padding is applied to the edge of the image, resulting in a lack of information, making it difficult to correctly classify the image, and producing a checkerboard effect.
[0091] (2) Data at the boundary between different classes: The boundary between classes is difficult to define and there are many labeling errors. The gradient is unstable during training. The points at the boundary between classes often differ by only a few pixels. For the network, the input information is highly similar, but the labels are different during training, which is also an unstable factor in the training process.
[0092] See also Fig. 9 , Fig. 9 is a schematic diagram of a sample image visualization provided in an embodiment of the present application, Fig. 9 From top to bottom in the figure, the original image, the prediction result of the model without expansion prediction, and the model prediction confidence visualization for each pixel (the confidence p<0.8 is visualized as black, and p>=0.8 is visualized as white). It can be clearly seen that for the edge data of the image, the information-missing network is difficult to make a correct classification. For the boundary between classes, due to the unstable gradient of the training process, the network has a low grasp of the classification of this part of the data.
[0093] It should be understood that the model trained after label smoothing is more stable and has stronger generalization ability. Therefore, in the process of training the first neural network model, the sample image blocks can be label smoothed. In knowledge distillation, the student model trained with the soft target output by the teacher model has stronger generalization ability than the model trained directly with hard labels. Soft labels more reasonably reflect the true distribution of samples. Hard labels only have full probability and 0 probability, which are too absolute. During knowledge distillation, the teacher model realizes the "sorting" (label smoothing) of soft labels and hard labels, outputs lower confidence for hard labels, and outputs higher confidence for soft labels, so that the student model learns richer information.
[0094] Specifically, label smoothing is done by setting a transition zone between the image edge and the boundary between classes, such as Fig.10 As shown in the figure, the labels of the pixels in the transition zone are regarded as hard labels and need to be smoothed. The degree of smoothing depends on the proportion of hard label pixels in each image block to the total input pixels during training. The size of the transition zone w (width) is a hyperparameter, w = 11 pixels.
[0095] When training the model, the cross entropy loss function is calculated in different ways for soft labels and hard labels. The cross entropy loss function corresponding to the soft label is shown in formula (1), and the cross entropy loss function corresponding to the hard label is shown in formulas (2) and (3).
[0096]
[0097]
[0098]
[0099] Among them, K represents the classification category; p k It is expressed as the result after softmax, that is, the confidence level; the parameter α is used to control the degree of label smoothing, and its value is the proportion of hard label pixels in the input data each time; y k Represents manually annotated labels; Indicates a soft tag; Indicates the probability value of the model output when the soft label is used as input; Indicates a hard tag; Indicates the probability value of the model output when the hard label is used as input;
[0100] In an embodiment of the present application, a transition zone is set at the edge of the sample image block and the boundary between classes, the label probability of the non-transition zone area in the sample image block is set to 1, and the label probability of the transition zone area in the sample image block is set between 0 and 1. Since it is difficult for the neural network model to correctly classify the data at the edge of the image and the boundary between classes, compared to setting the label probability of the transition zone area to 0 or 1, setting the label probability of the transition zone area in the sample image block between 0 and 1 is beneficial to improving the accuracy of the neural network model in predicting the category of the transition zone area.
[0101] The method of the embodiment of the present application is described in detail above, and the device of the embodiment of the present application is provided below.
[0102] See also Fig.11 , Fig.11 1 is a schematic diagram of the structure of an image processing device 1100 provided in an embodiment of the present application. The image processing device is applied to an electronic device. The image processing device 1100 may include a filling unit 1101, a cutting unit 1102 and a processing unit 1103, wherein each unit is described in detail as follows:
[0103] A filling unit 1101 is used to fill K / 2 circles of zeros around the first image to obtain a second image, wherein the size of the first image is an integer multiple of the size of the sliding window, and K is the sliding window step size;
[0104] A cutting unit 1102, configured to perform image cutting on the second image according to the sliding window and the sliding window step size to obtain a plurality of image blocks;
[0105] The processing unit 1103 is used to process the multiple image blocks using a first neural network model to obtain a processing result of each sub-image block in a plurality of sub-image blocks, wherein the multiple image blocks correspond to the multiple sub-image blocks one by one, and the sub-image block is a regional image of the image block with a size of K×K centered on the center of the image block; and obtain a processing result of the first image according to the processing result of each sub-image block in the plurality of sub-image blocks.
[0106] In a possible implementation, in terms of filling K / 2 circles of zeros around the first image to obtain the second image, the filling unit 1101 is specifically used to: if the size of the first image is not an integer multiple of the size of the sliding window, fill the first image to obtain a filled first image, wherein the size of the filled first image is an integer multiple of the size of the sliding window; fill K / 2 circles of zeros around the filled first image to obtain the second image.
[0107] In a possible implementation, in terms of using the first neural network model to process the multiple image blocks to obtain a processing result for each of the multiple sub-image blocks, the processing unit 1103 is specifically used to: use the first neural network model to process the multiple image blocks to obtain a processing result for each of the multiple image blocks; and perform image capture on the processing result of each of the multiple image blocks to obtain a processing result for each of the multiple sub-image blocks.
[0108] In a possible implementation, in terms of performing image interception on the processing result of each image block in the multiple image blocks to obtain the processing result of each sub-image block in the multiple sub-image blocks, the processing unit 1103 is specifically used to: perform the following steps for the processing result of each image block in the multiple image blocks to obtain the processing result of each sub-image block in the multiple sub-image blocks: taking the center of the processing result of the target image block as the center, performing image interception of a regional image with a size of K×K in the processing result of the target image block to obtain a target sub-image block, wherein the target image block is any one of the multiple image blocks, and the target sub-image block is a sub-image block corresponding to the target image block.
[0109] In a possible implementation, in the aspect of using the first neural network model to process the multiple image blocks to obtain the processing result of each image block in the multiple image blocks, the processing unit 1103 is specifically used to: for each image block in the multiple image blocks, perform the following steps to obtain the processing result of each image block in the multiple image blocks: use a deep convolutional neural network model to extract features of a target image block to obtain a first feature map of the target image block, wherein the target image block is any one of the multiple image blocks; perform a convolution operation according to the first feature map and a first convolution kernel to obtain to a first target feature map, wherein the size of the first convolution kernel is 1×1; performing an expansion convolution operation according to the first feature map and the second convolution kernel to obtain a second target feature map, wherein the size of the second convolution kernel is n×n, the expansion rate of the second convolution kernel is a first preset value, and n is an integer greater than 1; performing an expansion convolution operation according to the first feature map and the third convolution kernel to obtain a third target feature map, wherein the size of the third convolution kernel is n×n, and the expansion rate of the third convolution kernel is a second preset value; performing an expansion convolution operation according to the first feature map and the fourth convolution kernel to obtain a fourth target feature map, wherein, The size of the fourth convolution kernel is n×n, and the expansion rate of the fourth convolution kernel is a third preset value; a pooling operation is performed on the first feature map to obtain a fifth target feature map; wherein the first target feature map, the second target feature map, the third target feature map, the fourth target feature map and the fifth target feature map have the same size; the first target feature map, the second target feature map, the third target feature map, the fourth target feature map and the fifth target feature map are fused to obtain a second feature map; a convolution operation is performed according to the second feature map and the fifth convolution kernel to obtain a third feature map, wherein the first The size of the fifth convolution kernel is 1×1; the third feature map is upsampled to obtain a fourth feature map; a convolution operation is performed according to the first feature map and the sixth convolution kernel to obtain a fifth feature map, wherein the size of the sixth convolution kernel is 1×1, and the fourth feature map and the fifth feature map have the same size; the fourth feature map and the fifth feature map are fused to obtain a sixth feature map; a convolution operation is performed according to the sixth feature map and the seventh convolution kernel to obtain a seventh feature map, wherein the size of the seventh convolution kernel is n×n; the seventh feature map is upsampled to obtain a processing result of the target image block.
[0110] In a possible implementation, the processing result of the sub-image block is a target object distribution map corresponding to the sub-image block, and the processing result of the first image is a target object distribution map corresponding to the first image; in terms of obtaining the processing result of the first image based on the processing results of all or part of the sub-image blocks in the multiple sub-image blocks, the processing unit 1103 is specifically used to: process the target object distribution map corresponding to each sub-image block in the multiple sub-image blocks to obtain the target object distribution map corresponding to all or part of the sub-image blocks in the multiple sub-image blocks after processing, wherein the processing includes hole filling and small connected domain removal, the hole refers to a target object-free area surrounded by a distribution area of the same target object in the sub-image block, and the small connected domain refers to a scattered distribution area of the target object in the sub-image block; the target object distribution map corresponding to the first image is obtained based on the target object distribution map corresponding to all or part of the sub-image blocks in the multiple sub-image blocks after processing.
[0111] In a possible implementation, the first neural network model is obtained by the following steps: using the first training set to train the preset neural network to obtain the second neural network model, wherein the sample image blocks in the first training set have labels; using the second neural network model to predict the second training set to obtain a third training set, wherein the sample image blocks in the second training set have no labels, and the sample image blocks in the third training set have pseudo labels; merging the first training set and the third training set to obtain a fourth training set; using the fourth training set to train the preset neural network to obtain the first neural network model.
[0112] In a possible implementation, the sample image block is obtained by the following strategy: the sample image is cut with the sliding window size of 1024×1024 and the sliding window step of 900, and when the background area in the sliding window accounts for more than 7 / 8 of the sliding window, the image block currently framed by the sliding window is not cut; when the background area in the sliding window accounts for less than 1 / 3 of the sliding window, the sliding window step is reduced to 512 to increase the sampling rate; or the sample image is cut with the sliding window size of 1024×1024 and the sliding window step of 512, and when the background area in the sliding window accounts for more than 1 / 3 of the sliding window, the image block currently framed by the sliding window is not cut.
[0113] In a possible implementation, the label of the sample image block is obtained by the following steps: setting a transition zone at the edge of the sample image block and the boundary between classes, wherein the boundary between classes refers to the boundary between distribution areas of different classes in the sample image block; setting the label probability of the non-transition zone area in the sample image block to 1, and setting the label probability of the transition zone area in the sample image block to between 0 and 1.
[0114] It should be noted that the implementation of each unit can also refer to Figure 1 Of course, the image processing device 1100 provided in the embodiment of the present application includes but is not limited to the above-mentioned unit modules, for example: the image processing device 1100 may also include a storage unit 1104, and the storage unit 1104 may be used to store the program code and data of the image processing device 1100.
[0115] exist Fig.11 In the described image processing device 1100, K / 2 circles of zeros are filled around the first image to obtain a second image, and the size of the first image is an integer multiple of the size of the sliding window; then the second image is cut according to the sliding window and the sliding window step size of K to obtain multiple image blocks, and the size of each image block in the multiple image blocks is the same as the size of the sliding window; then the first neural network model is used to process the multiple image blocks to obtain the processing results of each sub-image block in the multiple sub-image blocks, and the multiple image blocks correspond to the multiple sub-image blocks one by one, and the sub-image block is a regional image with a size of K×K centered on the center of the image block in the image block, that is, the sub-image block is the central area of the corresponding image block, and the first image can be obtained by combining all or part of the multiple sub-image blocks, so the processing results of all or part of the sub-image blocks in the multiple sub-image blocks can be combined to obtain the processing result of the first image. In the embodiment of the present application, the input of the first neural network model is an image block, and its output is the processing result of the sub-image block, and the sub-image block is the central area of the corresponding image block, so the processing result of the sub-image block is the calculation result of the central area of each image block, thereby avoiding the accuracy problem caused by the inaccurate prediction of the image edge by the neural network model, which is conducive to improving the accuracy of image processing. It should be understood that the processing result of the sub-image block can be the target object distribution map corresponding to the sub-image block predicted by the first neural network model, and the processing result of the first image is the target object distribution map corresponding to the first image; since the first image can be obtained by shooting the area where the target object needs to be counted, the embodiment of the present application can quickly obtain the target object distribution map of the area, which is more efficient than manual statistics.
[0116] See also Fig.12 , Fig.12It is a structural diagram of an electronic device 1210 provided in an embodiment of the present application. The electronic device 1210 includes a processor 1211, a memory 1212 and a communication interface 1213. The processor 1211, the memory 1212 and the communication interface 1213 are interconnected via a bus 1214.
[0117] The memory 1212 includes, but is not limited to, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), or a portable read-only memory (CD-ROM), and the memory 1212 is used for related computer programs and data. The communication interface 1213 is used to receive and send data.
[0118] The processor 1211 may be one or more central processing units (CPUs). When the processor 1211 is a CPU, the CPU may be a single-core CPU or a multi-core CPU.
[0119] The processor 1211 in the electronic device 1210 is used to read the computer program code stored in the above-mentioned memory 1212, and perform the following steps: fill K / 2 circles of zeros around the first image to obtain a second image, wherein the size of the first image is an integer multiple of the size of the sliding window, and K is the sliding window step; perform image segmentation on the second image according to the sliding window and the sliding window step to obtain a plurality of image blocks; use a first neural network model to process the plurality of image blocks to obtain a processing result of each sub-image block in a plurality of sub-image blocks, wherein the plurality of image blocks correspond one-to-one to the plurality of sub-image blocks, and the sub-image block is a regional image in the image block with the center of the image block as the center and a size of K×K; obtain the processing result of the first image according to the processing results of all or part of the sub-image blocks in the plurality of sub-image blocks.
[0120] It should be noted that the implementation of each operation can also refer to Figure 1 The corresponding description of the illustrated embodiment will not be repeated here.
[0121] exist Fig.12In the described electronic device 1210, K / 2 circles of zeros are filled around the first image to obtain a second image, and the size of the first image is an integer multiple of the size of the sliding window; then the second image is cut according to the sliding window and the sliding window step size of K to obtain multiple image blocks, and the size of each image block in the multiple image blocks is the same as the size of the sliding window; then the first neural network model is used to process the multiple image blocks to obtain the processing results of each sub-image block in the multiple sub-image blocks, and the multiple image blocks correspond to the multiple sub-image blocks one by one, and the sub-image block is a regional image with a size of K×K centered on the center of the image block in the image block, that is, the sub-image block is the central area of the corresponding image block, and the first image can be obtained by combining all or part of the multiple sub-image blocks, so the processing results of all or part of the sub-image blocks in the multiple sub-image blocks can be combined to obtain the processing results of the first image. In the embodiment of the present application, the input of the first neural network model is an image block, and its output is the processing result of the sub-image block, and the sub-image block is the central area of the corresponding image block, so the processing result of the sub-image block is the calculation result of the central area of each image block, thereby avoiding the accuracy problem caused by the inaccurate prediction of the image edge by the neural network model, which is conducive to improving the accuracy of image processing. It should be understood that the processing result of the sub-image block can be the target object distribution map corresponding to the sub-image block predicted by the first neural network model, and the processing result of the first image is the target object distribution map corresponding to the first image; since the first image can be obtained by shooting the area where the target object needs to be counted, the embodiment of the present application can quickly obtain the target object distribution map of the area, which is more efficient than manual statistics.
[0122] The embodiment of the present application further provides a chip, the chip comprising at least one processor, a memory and an interface circuit, the memory, the transceiver and the at least one processor are interconnected through a line, the at least one memory stores a computer program; when the computer program is executed by the processor, Figure 1 The method flow shown is realized.
[0123] The present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, which, when executed on a computer, Figure 1 The method flow shown is realized.
[0124] The present application also provides a computer program product. When the computer program product is run on a computer, Figure 1 The method flow shown is realized.
[0125] It should be understood that the processor mentioned in the embodiments of the present application may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
[0126] It should also be understood that the memory mentioned in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus random access memory (Direct Rambus RAM, DR RAM).
[0127] It should be noted that when the processor is a general-purpose processor, DSP, ASIC, FPGA or other programmable logic device, discrete gate or transistor logic device, discrete hardware component, the memory (storage module) is integrated in the processor.
[0128] It should be noted that the memory described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0129] It should also be understood that the first, second, third, fourth and various numerical numbers involved in this document are only distinctions made for the convenience of description and are not intended to limit the scope of the present application.
[0130] It should be understood that the term "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0131] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be obtained based on its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0132] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0133] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0134] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0135] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0136] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0137] If the above functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method shown in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0138] The steps in the method of the embodiment of the present application can be adjusted in order, combined and deleted according to actual needs.
[0139] The modules in the device of the embodiment of the present application can be merged, divided and deleted according to actual needs.
[0140] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.
Claims
1. An image processing method, characterized in that: include: Fill K / 2 circles of zeros around the first image to obtain a second image, wherein the size of the first image is an integer multiple of the size of the sliding window, and K is the sliding window step size; Performing image segmentation on the second image according to the sliding window and the sliding window step size to obtain a plurality of image blocks; The first neural network model is used to process the multiple image blocks to obtain the processing result of each sub-image block in the multiple sub-image blocks, including: for each image block in the multiple image blocks, the following steps are performed to obtain the processing result of each image block in the multiple image blocks: a deep convolutional neural network model is used to extract features of the target image block to obtain a first feature map of the target image block, wherein the target image block is any one of the multiple image blocks; a convolution operation is performed according to the first feature map and a first convolution kernel to obtain a first target feature map, wherein the size of the first convolution kernel is 1×1; an expansion convolution operation is performed according to the first feature map and the second convolution kernel, To obtain a second target feature map, wherein the size of the second convolution kernel is n×n, the expansion rate of the second convolution kernel is a first preset value, and n is an integer greater than 1; performing an expansion convolution operation according to the first feature map and the third convolution kernel to obtain a third target feature map, wherein the size of the third convolution kernel is n×n, and the expansion rate of the third convolution kernel is a second preset value; performing an expansion convolution operation according to the first feature map and the fourth convolution kernel to obtain a fourth target feature map, wherein the size of the fourth convolution kernel is n×n, and the expansion rate of the fourth convolution kernel is a third preset value; performing a pooling operation on the first feature map to obtain a fifth target feature map; wherein the first target feature map , the second target feature map, the third target feature map, the fourth target feature map and the fifth target feature map have the same size; the first target feature map, the second target feature map, the third target feature map, the fourth target feature map and the fifth target feature map are merged to obtain a second feature map; a convolution operation is performed according to the second feature map and the fifth convolution kernel to obtain a third feature map, wherein the size of the fifth convolution kernel is 1×1; the third feature map is up-sampled to obtain a fourth feature map; a convolution operation is performed according to the first feature map and the sixth convolution kernel to obtain a fifth feature map, wherein the size of the sixth convolution kernel is 1×1, and the fourth feature map is The fourth feature map and the fifth feature map have the same size; the fourth feature map and the fifth feature map are merged to obtain a sixth feature map; a convolution operation is performed according to the sixth feature map and a seventh convolution kernel to obtain a seventh feature map, wherein the size of the seventh convolution kernel is n×n; the seventh feature map is upsampled to obtain a processing result of the target image block; an image is intercepted on the processing result of each image block in the multiple image blocks to obtain a processing result of each sub-image block in the multiple sub-image blocks; wherein the multiple image blocks correspond to the multiple sub-image blocks one by one, and the sub-image block is a regional image of the image block with a center of the image block as the center and a size of K×K; The processing result of the first image is obtained according to the processing results of all or part of the sub-image blocks in the multiple sub-image blocks.
2. The method according to claim 1, characterized in that The processing result of the sub-image block is a target object distribution map corresponding to the sub-image block, and the processing result of the first image is a target object distribution map corresponding to the first image; The obtaining the processing result of the first image according to the processing results of all or part of the sub-image blocks in the plurality of sub-image blocks comprises: Processing the target object distribution map corresponding to each sub-image block in the multiple sub-image blocks to obtain the target object distribution map corresponding to all or part of the sub-image blocks in the multiple sub-image blocks after processing, wherein the processing includes hole filling and small connected domain removal, the hole refers to a target object-free area surrounded by a distribution area of the same target object in the sub-image block, and the small connected domain refers to a scattered distribution area of the target object in the sub-image block; The target object distribution map corresponding to the first image is obtained according to the target object distribution maps corresponding to all or part of the sub-image blocks in the multiple sub-image blocks after processing.
3. The method according to claim 1 or 2, characterized in that: The first neural network model is obtained by the following steps: Using a first training set to train a preset neural network to obtain a second neural network model, wherein the sample image blocks in the first training set have labels; Using the second neural network model to predict the second training set to obtain a third training set, wherein the sample image blocks in the second training set have no labels, and the sample image blocks in the third training set have pseudo labels; Merging the first training set and the third training set to obtain a fourth training set; The preset neural network is trained using the fourth training set to obtain the first neural network model.
4. The method according to claim 3, characterized in that The sample image block is obtained by the following strategy: The sample image is cut with the size of the sliding window being 1024×1024 and the sliding window step being 900. When the proportion of the background area in the sliding window to the sliding window is greater than 7 / 8, the image block currently framed by the sliding window is not cut; when the proportion of the background area in the sliding window to the sliding window is less than 1 / 3, the sliding window step is reduced to 512 to increase the sampling rate; Alternatively, the sample image is cut with the sliding window size of 1024×1024 and the sliding window step of 512. When the background area in the sliding window accounts for more than 1 / 3 of the sliding window, the image block currently framed by the sliding window is not cut.
5. The method according to claim 3, characterized in that: The label of the sample image block is obtained by the following steps: Setting a transition zone at the edge of the sample image block and at the boundary between classes, wherein the boundary between classes refers to the boundary between distribution areas of different classes in the sample image block; The label probability of the non-transition zone area in the sample image block is set to 1, and the label probability of the transition zone area in the sample image block is set between 0 and 1.
6. An image processing device, characterized in that: include: A filling unit, used to fill K / 2 circles of zeros around the first image to obtain a second image, wherein the size of the first image is an integer multiple of the size of the sliding window, and K is the sliding window step size; a cutting unit, configured to perform image cutting on the second image according to the sliding window and the sliding window step size to obtain a plurality of image blocks; A processing unit, configured to process the plurality of image blocks using a first neural network model to obtain a processing result of each sub-image block in the plurality of sub-image blocks, comprising: for each image block in the plurality of image blocks, performing the following steps to obtain a processing result of each image block in the plurality of image blocks: extracting features of a target image block using a deep convolutional neural network model to obtain a first feature map of the target image block, wherein the target image block is any one of the plurality of image blocks; performing a convolution operation according to the first feature map and a first convolution kernel to obtain a first target feature map, wherein the size of the first convolution kernel is 1×1; performing an expansion convolution operation according to the first feature map and a second convolution kernel to obtain a first feature map; The method comprises the steps of: generating a first target feature map, a second target feature map, a second convolution kernel, a size of n×n, a dilation rate of the second convolution kernel, and a first preset value; performing a dilated convolution operation on the first feature map and the third convolution kernel to obtain a third target feature map, wherein the size of the third convolution kernel is n×n, and the dilation rate of the third convolution kernel is a second preset value; performing a dilated convolution operation on the first feature map and the fourth convolution kernel to obtain a fourth target feature map, wherein the size of the fourth convolution kernel is n×n, and the dilation rate of the fourth convolution kernel is a third preset value; performing a pooling operation on the first feature map to obtain a fifth target feature map; wherein the first target feature map, the second target feature map, and the third target feature map are The first target feature map, the fourth target feature map and the fifth target feature map have the same size; the first target feature map, the second target feature map, the third target feature map, the fourth target feature map and the fifth target feature map are fused to obtain a second feature map; a convolution operation is performed according to the second feature map and the fifth convolution kernel to obtain a third feature map, wherein the size of the fifth convolution kernel is 1×1; the third feature map is up-sampled to obtain a fourth feature map; a convolution operation is performed according to the first feature map and the sixth convolution kernel to obtain a fifth feature map, wherein the size of the sixth convolution kernel is 1×1, and the fourth feature map and the fifth feature map have the same size; the fourth feature map and the The fifth feature map is fused to obtain a sixth feature map; a convolution operation is performed according to the sixth feature map and the seventh convolution kernel to obtain a seventh feature map, wherein the size of the seventh convolution kernel is n×n; the seventh feature map is up-sampled to obtain a processing result of the target image block; an image is cropped for the processing result of each image block in the multiple image blocks to obtain a processing result of each sub-image block in the multiple sub-image blocks; wherein the multiple image blocks correspond to the multiple sub-image blocks one by one, and the sub-image block is a regional image in the image block with the center of the image block as the center and a size of K×K; and the processing result of the first image is obtained according to the processing result of each sub-image block in the multiple sub-image blocks.
7. An electronic device, characterized in that: The method comprises a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for executing the steps in the method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: It stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method for extracting image region of interest based on eye movement data and bottom-layer features
CN102521595A
Image generation method and device based on deep neural network model
CN111260655A
YOLO-based image target recognition method and apparatus, electronic device, and storage medium
WO2020164282A1
