Detailed Description
In order to explain technical contents, achieved objects, and effects of the present invention in detail, the following description is made with reference to the accompanying drawings in combination with the embodiments.
The most key concept of the invention is as follows: firstly correcting color cast, then converting the image into an LAB space, only performing subsequent image effect enhancement processing on the component L, and finally combining the components and converting the components back into an RGB space, thereby having real-time processing and good image effect.
The technical terms related to the invention are explained as follows:
referring to fig. 1, the present invention provides a method for processing a muddy water image in real time, comprising:
s1: correcting color cast of the input muddy water image;
s2: converting the corrected muddy water image from an RGB space to an LAB space, and acquiring a corresponding brightness component L, a color component A and a color component B;
s3: carrying out automatic contrast adjustment and sharpening on the brightness component L in sequence to obtain a processed brightness component L;
s4: the processed luminance component L, the color component a and the color component B are combined and converted back to the RGB space.
Further, the S1 specifically includes: and (4) processing the color cast of the input muddy water image according to the color correction of a statistical method.
Further, the S1 specifically includes:
s11: calculating respective mean values and root-mean-square errors of RGB three-color channels corresponding to the input muddy water image;
s12: calculating to obtain an upper limit value and a lower limit value in the corrected color cast mapping according to the respective mean value and the root mean square error;
s13: mapping the upper limit value and the lower limit value to obtain new gray level graphs of the RGB three-color channels corresponding to the muddy water image;
s14: and obtaining a muddy water image after correcting color cast according to the new gray level image.
As can be seen from the above description, in a specific embodiment, the color correction is performed by counting the shift degree of the gray level of the pixel point of each channel, so as to significantly improve the color shift phenomenon of the image.
Further, the automatic contrast adjustment specifically includes:
s31: performing histogram statistics on the luminance component L;
s32: solving an upper limit value and a lower limit value of a gray value corresponding to a certain pixel number in a histogram of the brightness component L;
s33: and carrying out image gray mapping transformation according to the upper limit value and the lower limit value of the gray value.
As can be seen from the above description, in a specific embodiment, an automatic contrast adjustment can be implemented by using a gray histogram mapping manner, so as to effectively enhance the contrast of an image and enrich the detailed information of the image.
Further, the certain number of pixels is 0.5% -2% of the total number of pixels of the histogram.
As can be seen from the above description, setting the number of pixels corresponding to the upper and lower limit values of the gray scale value to 0.5% -2% of the total number of pixels can make the processing effect more general.
Further, the sharpening process specifically includes:
s34: carrying out mean value filtering on the brightness component L after automatic contrast adjustment to obtain a low-frequency component S of the brightness component Ll;
S35: subtracting the low frequency component S from the automatically contrast adjusted luminance component LlObtaining a high frequency component S of the luminance component Lh;
S36: using the formula
Solving sharpened brightness component L image S'
L(ii) a Wherein, the Amont is an adjusting coefficient; said S
LThe luminance component L image after the automatic contrast adjustment.
As can be seen from the above description, in a specific embodiment, the local detail blur of the image can be removed by the above specific sharpening process, and the contrast of the image can be further enhanced, so as to obtain an excellent image processing effect.
Further, the numerical range of the adjustment coefficient Amont is 0.5 to 5.
As can be seen from the above description, in one embodiment, the adjustment coefficient Amont is set to 0.5-5, which can achieve better adjustment effect.
The invention provides another technical scheme as follows:
a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs all the steps included in the method for processing a muddy water image in real time according to any one of the above embodiments or a combination of the above embodiments.
From the above description, the beneficial effects of the present invention are: it should be understood by those skilled in the art that all or part of the processes in the above technical solutions may be implemented by instructing the related hardware through a computer program, where the program may be stored in a computer-readable storage medium, and when executed, the program may include the processes of the above methods.
The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
Example one
Referring to fig. 1 to 7, the present embodiment provides a method for processing a muddy water image in real time, which can significantly improve the color cast of the image, enhance the detail and contrast, and improve the recognition capability of the underwater object, so that the image is more suitable for human eyes to watch, i.e., a good image processing effect can be obtained; meanwhile, the processing efficiency of the image can be obviously improved, so that the image processing method has real-time processing capability.
Referring to the flow chart of fig. 1, the method may specifically include the following steps:
the method comprises the following steps: adopting color correction based on a statistical method to the input muddy water image to process the color cast of the image;
specifically, the implementation process of this step may include:
the mean value and the root mean square error of the RGB three-color channels of the input image are calculated firstly, the upper limit value and the lower limit value in the color cast correction mapping are calculated accordingly, then the new gray level images of the three channels are obtained by utilizing the mapping of the upper limit value and the lower limit value, namely the gray level images of the three channels are obtained by mapping transformation. The specific formula is as follows:
wherein S' is the mapped gray value; s is a gray value before mapping; sminThe image gray scale lower limit value; smaxThe image gray scale upper limit value;
namely, color correction is carried out by counting the deviation degree of the gray value of the pixel point of each channel. By linearly stretching the different coefficients set by each channel, the color cast condition of the picture can be corrected better.
Step two: changing the color space of the image after color correction from an RGB space to an LAB space;
specifically, a color-displayed muddy water image is converted into a gray-scale-displayed muddy water image, and a brightness component L, a color component a and a color component B corresponding to the color-corrected muddy water image are obtained respectively.
The color space is converted into the LAB space through the step, and only the brightness component L is analyzed and processed, so that the data amount required to be processed can be obviously reduced, the color information of the image can be ensured not to be changed, and the real-time processing is further realized.
Step three: performing histogram statistics on the brightness component L;
step four: solving an upper limit value and a lower limit value of a gray value corresponding to a certain pixel number in the L component histogram;
preferably, the certain number of pixels is 0.5% -2% of the total number of pixels, so that the processing effect is more universal.
Step five: performing image gray mapping according to the upper limit value and the lower limit value of the gray value obtained in the previous step;
through the gray level histogram mapping from the third step to the fifth step, the contrast of the image can be effectively enhanced, and the detail information of the image is enriched.
Step six: sharpening the brightness component L after mapping transformation in the last step;
specifically, the implementation process of this step may include:
firstly, mean filtering is carried out on the brightness component L after mapping transformation to obtain a low-frequency component S of the L componentl(ii) a Then the L component is used for subtracting the low frequency component diagram to obtain a high frequency component S in the L componenth(ii) a The sharpened image is further solved by the following formula:
wherein, the SLThe luminance component L image is subjected to automatic contrast adjustment; amont is an adjustment coefficient, and preferably, the value thereof is set in the range of 0.5 to 5 to obtain a preferable effect.
And sixthly, sharpening the image subjected to the previous processing, so that local detail blurring of the image can be removed, and the contrast of the image can be further enhanced.
Step seven: and combining the brightness component L processed in the previous step and the A component and the B component which are not processed in the second step to restore a color image, and finally converting the color image back to an RGB color space for display.
Step eight: and outputting the image processed in the step seven.
The comparison between the image effect obtained by the image processing method of the present embodiment and the effect before processing is specifically shown in fig. 2 to 7. It should be particularly noted that, because the drawings in the specification of the application document specified in the patent law cannot be colored "color drawings", the images originally having colors can only be converted into "gray scale" for display to meet the requirements, and the conversion will certainly affect the more significant contrast effect before and after processing, and is expected to be known; however, even if the processing based on the gray scale display is compared in sequence, the obvious difference in image effect before and after the processing can be obviously seen.
Example two
This embodiment corresponds to the first embodiment, and provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps included in the method for processing a muddy water image in real time according to the first embodiment. The details of the steps will not be repeated, and the details will be described in the first embodiment.
In conclusion, the method and the computer storage mechanism for processing the muddy water image in real time provided by the invention can not only obtain the image quality effects of clear image details, high contrast and true color; the processing process is quick and efficient, and real-time processing and good image effect can be achieved; furthermore, the method also has the advantage of more universal processing effect, and the picture is more suitable for most of human eye watching requirements.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all equivalent changes made by using the contents of the present specification and the drawings, or applied directly or indirectly to the related technical fields, are included in the scope of the present invention.