The processing method and device of a kind of adapting to image brightness
Technical field
The present invention relates to the processing method and dress of technical field of image processing, more particularly to a kind of adapting to image brightness
Put.
Background technology
It is kept as a souvenir with mobile phone, camera seeing that scenery, personage are taken, is a kind of incomparable satisfied thing, can
It is due to that we can not compare with the photographer of specialty, the lightness taken often occurs not enough, whole poor effect,
The even dull face of picture can not all be differentiated.In brightness too strong place, image too bright, it is impossible to differentiate some thin
Section.At this moment we are accomplished by carrying out picture simple brightness enhancing processing, and traditional brightness enhancing processing can allow dark
Picture becomes to brighten, but original brighter image can become after treatment it is brighter, while some details can also lose.Instead
It, originally can also lose some details after bright image procossing excessively.
The content of the invention
The purpose of the embodiment of the present invention is to propose a kind of processing method of adapting to image brightness, it is intended to solve existing skill
The problem of art brightness enhancing processing can lose image detail.
The embodiment of the present invention is achieved in that a kind of processing method of adapting to image brightness, and methods described includes:
Image a is obtained, image a is normalized, image A is obtained;
Image A is converted into HSI spaces from rgb space and obtains image F;
Image F component I is handled by ad hoc fashion and obtains component I ';
By the component I ' and image F component S, component H merges into new image b;
Image b is obtained into image B from HSI spatial transformations for rgb space;
Output image B.
Further, described " handled by ad hoc fashion image F component I and obtain component I ' " is specially:
Statistics with histogram is carried out to component I, and is normalized and obtains histogram P;
Nogata distribution function p after normalized is divided into n gray scale interval by gray level, and calculates each gray area
Between gray level weight riWith the interval weight w for calculating each gray scale intervali;Wherein, i represents to carry out gray scale fraction to histogram P
Qu Hou, the sequence number for the gray scale interval being divided into, 1≤i≤n.
Pass through ri, wiNew gray scale interval is built, and draws each interval weight w ' of corresponding new gray scale intervali;
By wi, w 'iFunction sampling point is calculated, and constructs Nogata and returns fixedization function f, and meets function f for monotonically increasing function;
Fixedization function f is returned to calculate I ' by Nogata image F component I.
The another object of the embodiment of the present invention is to propose a kind of processing unit of adapting to image brightness, described device bag
Include:
Image collection module, for obtaining image a;
First normalized module, for image a to be normalized, obtains image A;
First space conversion module, image F is obtained for image A to be converted into HSI spaces from rgb space;
Component processing unit, is handled by ad hoc fashion for the component I to image F, obtains I ';
Component merging module, for by the component I ' and image F component S, component H to merge into new image b;
Second space modular converter, for image b to be obtained into image B for rgb space from HSI spatial transformations;
Output module, for output image B.
Further, the component processing unit also includes:
Statistics with histogram module, for carrying out statistics with histogram to component I;
Second normalized module, histogram is obtained for the component I after statistics with histogram to be normalized
P;
Division module, for the Nogata distribution function p after normalized to be carried out into subregion by gray level;
Interval gray level weight computation module, is used for and calculates the gray level weight r of each gray scale intervali;
Interval weight computing module, the interval weight w for calculating each gray scale intervali
Gray scale interval builds module, for passing through ri, wiBuild new gray scale interval;
Interval weight computing module, the interval weight w ' for calculating each new gray scale intervali;
Nogata returns determining function construction module, for by wi, w 'iFunction sampling point is calculated, and constructs Nogata and returns fixedization function f,
And function f is met for monotonically increasing function;
Component computing module, returns fixedization function f to calculate I ' for the component I to image F by Nogata.
Beneficial effects of the present invention
Much excessively dark, excessively bright image can't see details, the gray scale of usual this part of the image table in histogram
Show that gray scale span is narrow, gray value is excessively concentrated.Therefore in order that the image section of excessive details has bigger ash
Spend span, while in downscaled images unimportant part gray scale range.The inventive method is crossed from single channel histogram analysis, is adjusted
Whole component I value, the gray-level structure of appropriate adjustment source images, realizes the enhanced effect of image local.
Brief description of the drawings
Fig. 1 is a kind of process flow figure of adapting to image brightness of the preferred embodiment of the present invention;
Fig. 2 is the method detailed flow chart of step S103 in Fig. 1 flow charts;
Fig. 3 is that the histogram after gray level subregion is carried out to histogram P with threshold value partition method;
Fig. 4 is by wi, w 'iThe Nogata for calculating function sampling point construction returns fixedization linear function f;
Fig. 5 is by wi, w 'iThe Nogata for calculating function sampling point construction returns fixedization spline smooth function f;
Fig. 6 is the new histogram P ' returned to image F component I by Nogata after fixedization function f calculating;
Fig. 7 is a kind of processing unit structure chart of adapting to image brightness of the preferred embodiment of the present invention;
Fig. 8 is the detailed structure view of component processing unit in Fig. 7 structure charts.
Embodiment
In order to make the purpose , technical scheme and advantage of the present invention be clearer, it is right below in conjunction with drawings and examples
The present invention is further elaborated, for convenience of description, illustrate only the part related to the embodiment of the present invention.It should manage
Solution, the specific embodiment that this place is described is used only for explaining the present invention, is not intended to limit the invention.
Much excessively dark, excessively bright image can't see details, the gray scale of usual this part of the image table in histogram
Show that gray scale span is narrow, gray value is excessively concentrated.Therefore in order that the image section of excessive details has bigger ash
Spend span, while in downscaled images unimportant part gray scale range.The embodiment of the present invention from single channel histogram by dividing
Analysis, adjustment component I value, the gray-level structure of appropriate adjustment source images realizes the enhanced effect of image local.
Embodiment one
Fig. 1 is a kind of process flow figure of adapting to image brightness of the preferred embodiment of the present invention;Methods described includes
Following steps:
S101, obtains image a, image a is normalized, and obtains image A;
S102, is converted into HSI spaces from rgb space by image A and obtains image F;
S103, is handled image F component I by ad hoc fashion, obtains I ';
Specially:(Fig. 2 is the method detailed flow chart of step S103 in Fig. 1 flow charts)
S1031, carries out statistics with histogram, and be normalized and obtain histogram P to component I;
S1032, carries out subregion by gray level by the Nogata distribution function p after normalized, is divided into n gray scale interval,
And calculate the gray level weight r of each gray scale intervaliWith the interval weight w for calculating each gray scale intervali(i.e. interval length),
Wherein, i represents to carry out after gray level subregion histogram P, the sequence number for the gray scale interval being divided into;1≤i≤n;
Threshold value can be used to the methods for carrying out subregion of the Nogata distribution function p after normalized, the method such as cluster;Make
With threshold value, the method for cluster subregion is technology well-known in the art, the present invention only threshold value partition method is illustrated and
Citing.
Threshold value partition method is to set a threshold value ρ, the intersection point of threshold value ρ straight lines and grey value profile curve in histogram P
The abscissa at place is the critical point of gray scale interval;And threshold value ρ needs to meet:Work as p>During ρ, interval gray value is continuous, works as p<ρ
When interval gray value it is continuous.Wherein threshold value ρ is the threshold value of (0,1), and p represents Nogata distribution function.
It is illustrated in figure 3 and carries out the histogram after gray level subregion to histogram P with threshold value partition method, P points of histogram
Into 8 gray scale intervals;Wherein abscissa is normalized gray value, and ordinate is that the curve in gray value weight, figure is straight
Square distribution function p, k1、k2、k3、k4、k5、k6、k7For the critical point of gray scale interval.
Calculate the gray level weight r of each gray scale intervaliMethod be:
Wherein, riRepresent p all in i-th of gray scale interval integration, 1≤i≤n;1st gray scale interval is [k0,
k1), the 2nd gray scale interval is [k1,k2) ... ... n-th of gray scale interval is [kn-1,kn];
S1033, passes through ri, wiNew gray scale interval is built, and draws each interval weight w ' of corresponding new gray scale intervali;
w′i=(1- λ) ri+λ·wi, wherein λ is weight coefficient λ ∈ (0,1);
S1034, by wi, w 'iFunction sampling point is calculated, and constructs Nogata and returns fixedization function f, and meets function f for monotonic increase
Function.
The method for calculating function sampling point is as follows:
Wherein, N (xi,yi) represent f sampling point, xiRepresent the abscissa of sampling point, yiRepresent the ordinate of sampling point;wjRepresent former
The weight of j-th of gray scale interval of gray scale interval, w 'jRepresent the weight of new j-th of gray scale interval of gray scale interval, i is represented pair
Histogram P is carried out after gray level subregion, the sequence number for the gray scale interval being divided into;∑ represents summation.
Construction Nogata returns fixedization functional based method to be linear or spline smooth, Hermite interpolation etc..Such as
Fig. 4 is simple linear function, and Fig. 5 is spline smooth function;S1035, returns fixedization function f to count image F component I by Nogata
Calculate I ';
It is illustrated in figure 6 the new histogram P ' returned to image F component I by Nogata after fixedization function f calculating.Fig. 6
Middle abscissa represents gray level, and ordinate is distribution density.Origin, k ' on abscissa1、k′2、k′3、k′4、k′5、k′6、k′7
Represent the critical point of new gray scale interval.
S104, by the component I ' and image F component S, component H merges into new image b;
S105, image B is obtained by image b from HSI spatial transformations for rgb space;
S106, output image B.
Embodiment two
Fig. 7 is a kind of processing unit structure chart of adapting to image brightness of the preferred embodiment of the present invention, and described device includes:
Image collection module, for obtaining image a;
First normalized module, for image a to be normalized, obtains image A;
First space conversion module, image F is obtained for image A to be converted into HSI spaces from rgb space;
Component processing unit, is handled by ad hoc fashion for the component I to image F, obtains I ';
Component merging module, for by the component I ' and image F component S, component H to merge into new image b;
Second space modular converter, for image b to be obtained into image B for rgb space from HSI spatial transformations;
Output module, for output image B.
Further, the component processing unit is also including (Fig. 8 is the detailed knot of component processing module in Fig. 7 structure charts
Composition):
Statistics with histogram module, for carrying out statistics with histogram to component I;
Second normalized module, histogram is obtained for the component I after statistics with histogram to be normalized
P;
Division module, for the Nogata distribution function p after normalized to be carried out into subregion by gray level;
Interval gray level weight computation module, is used for and calculates the gray level weight r of each gray scale intervali;
Interval weight computing module, the interval weight w for calculating each gray scale intervali
Gray scale interval builds module, for passing through ri, wiBuild new gray scale interval;
Interval weight computing module, the interval weight w ' for calculating each new gray scale intervali;
Nogata returns determining function construction module, for by wi, w 'iFunction sampling point is calculated, and constructs Nogata and returns fixedization function f,
And function f is met for monotonically increasing function;
Component computing module, returns fixedization function f to calculate I ' for the component I to image F by Nogata;
Can it will be understood by those skilled in the art that realizing that all or part of step in above-described embodiment method is
With what is completed by programmed instruction related hardware, described program can be stored in a computer read/write memory medium,
Described storage medium can be ROM, RAM, disk, CD etc..
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the invention, all essences in the present invention
Any modifications, equivalent substitutions and improvements made within refreshing and principle etc., should be included in the scope of the protection.