Image defogging method based on histogram and neural networkTechnical Field
The invention relates to the technical field of image processing, in particular to an image defogging method based on a histogram and a neural network.
Background
With technological progress, new image technology is gradually popularized, and many cities are more often afflicted by haze weather. In haze days, the light transmission scattering of fine suspended matters such as mist, dust, water droplets and the like in the air greatly influences the human vision. Researchers in the defogging field put forward a lot of algorithms to realize defogging of a single image, one way is to process a frequency domain and a space domain, the basic methods are only aimed at image defogging under a specific scene, the defogging effect on a complex environment is not obvious, in recent years, an image enhancement technology based on deep learning is advanced, and the advanced image understanding tasks include: the image classification, target detection and other aspects achieve remarkable results. Therefore, the second method is generated, the image fog penetration technology based on the deep learning algorithm becomes a research hot spot, and the conventional method is to directly train the foggy image and the normal image of the image data training set to obtain the weight parameters, but the visual effect and the image quality are required to be improved after the defogging is completed. Therefore, new image fog penetration techniques of technical innovation are necessary.
Disclosure of Invention
In order to overcome the defects of the technology, the invention provides a method for learning potential transformation between the fog images and the histograms of the fog-free images and improving the identification degree of the images.
The technical scheme adopted for overcoming the technical problems is as follows:
an image defogging method based on a histogram and a neural network comprises the following steps:
a) Color channel conversion is carried out on a color picture input into a computer, an image is decomposed into an R channel image, a G channel image and a B channel image, gray images of the R channel image, the G channel image and the B channel image are respectively decomposed into a plurality of blocks, and gray histograms of the blocks are calculated statistically;
b) Representing the square gray level histogram as a matrix, and carrying out normalization processing on the matrix to obtain a normalized gray level histogram;
c) Inputting the matrix into an enhancement Net network, extracting relevant characteristic data, obtaining one layer by convolution operation each time to obtain L layers, and obtaining a characteristic mapping image with depth of 64 by convolution of ReLU and 3*3;
d) Introducing a DenseNet residual network into the enhancement Net network in the step b), connecting the L layers in the step c) together by using the DenseNet residual network, wherein the input of each layer consists of the feature mapping of all the previous layers;
e) Outputting and compressing the histogram of the feature mapping image processed in the step d) to obtain a histogram of the compressed feature mapping image;
f) Taking the histogram of the feature mapping image compressed in the step e) as an output histogram, taking the normalized gray level histogram in the step b) as an input histogram, carrying out data addition calculation on the output histogram and the input histogram once, and carrying out normalization processing after the addition calculation;
g) And f) splicing each square image subjected to normalization in the step f) into a whole image, and carrying out mean value filtering treatment on the spliced whole image to obtain a defogging image.
Further, in step a) the formula is passedCalculating a block gray level histogram p (r)k ) Wherein r isk N is the gray level of the blockk To have gray scale rk MN is the number of pixels in the block.
Further, in step b), the abscissa of the square gray level histogram is expressed as a three-channel matrix of 256×1×3 in units of 1 pixel.
Further, in step c), the enhanced net network performs convolution processing by using a convolution check matrix of 3*3 with a step size of 2.
Further, the histogram output of the feature map image in step e) is compressed to 64×1×3.
The beneficial effects of the invention are as follows: compared with the original network, the improved Enhance Net network structure is adopted to introduce a DenseNet residual network, all layers are directly connected together, in the information structure, the input of each layer consists of all previous feature maps, the output of each layer is transmitted to each subsequent layer, and the heat pattern maps are aggregated through deep cascade, so that the depth of a neural network is improved, and the calculation amount of image defogging is reduced.
Drawings
Fig. 1 is a functional block diagram of the present invention.
Detailed Description
The invention is further described with reference to fig. 1.
An image defogging method based on a histogram and a neural network comprises the following steps:
a) Color channel conversion is carried out on a color picture input into a computer, an image is decomposed into an R channel image, a G channel image and a B channel image, gray images of the R channel image, the G channel image and the B channel image are respectively decomposed into a plurality of blocks, and gray histograms of the blocks are calculated statistically;
b) Representing the square gray level histogram as a matrix, and carrying out normalization processing on the matrix to obtain a normalized gray level histogram;
c) Inputting the matrix into an enhancement Net network, extracting relevant characteristic data, obtaining one layer by convolution operation each time to obtain L layers, and obtaining a characteristic mapping image with depth of 64 by convolution of ReLU and 3*3;
d) Introducing a DenseNet residual network into the enhancement Net network in the step b), connecting the L layers in the step c) together by using the DenseNet residual network, wherein the input of each layer consists of the feature mapping of all the previous layers;
e) Outputting and compressing the histogram of the feature mapping image processed in the step d) to obtain a histogram of the compressed feature mapping image;
f) Taking the histogram of the feature mapping image compressed in the step e) as an output histogram, taking the normalized gray level histogram in the step b) as an input histogram, carrying out data addition calculation on the output histogram and the input histogram once, and carrying out normalization processing after the addition calculation;
g) And f) splicing each square image subjected to normalization in the step f) into a whole image, and carrying out mean value filtering treatment on the spliced whole image to obtain a defogging image.
Compared with the original network, the improved Enhance Net network structure is adopted to introduce a DenseNet residual network, all layers are directly connected together, in the information structure, the input of each layer consists of all previous feature maps, the output of each layer is transmitted to each subsequent layer, and the heat pattern maps are aggregated through deep cascade, so that the depth of a neural network is improved, and the calculation amount of image defogging is reduced.
Further, the gray histogram of an image is a function of gray level, describing the number of pixels in the image having that gray level: where the abscissa is the gray level and the ordinate is the frequency with which the gray level appears. However, the ordinate is typically normalized to [0,1 ]][0,1]Within a section, i.e. the frequency of occurrence of grey levels (number of pixels) divided by the total number of pixels in the image. Thus passing through the formula in step a)Calculating a block gray level histogram p (r)k ) Wherein r isk Is the gray scale of the squareStage, nk To have gray scale rk MN is the number of pixels in the block.
Preferably, in step b), the abscissa of the square gray level histogram is expressed as a three-channel matrix of 256×1×3 in units of 1 pixel.
Preferably, the enhanced net network in step c) performs convolution processing by using a convolution check matrix of 3*3 with a step size of 2.
Preferably, the histogram output of the feature map image in step e) is compressed to 64×1×3.
Finally, it should be noted that: the foregoing description is only a preferred embodiment of the present invention, and the present invention is not limited thereto, but it is to be understood that modifications and equivalents of some of the technical features described in the foregoing embodiments may be made by those skilled in the art, although the present invention has been described in detail with reference to the foregoing embodiments. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.