Summary of the invention
Technical matters to be solved by this invention provides a kind of based on the monocular infrared image depth estimation method of optimizing the BP neural network model, and this method can be estimated the depth information of infrared image comparatively exactly.
The technical solution adopted for the present invention to solve the technical problems is: provide a kind of based on the monocular infrared image depth estimation method of optimizing the BP neural network model, may further comprise the steps:
(1) (x y) reaches and the pairing depth map of said monocular infrared image I (x, y) to obtain any monocular infrared image I;
(2) be said monocular infrared image I (x; Y) each pixel in is set the characteristic area at least three different scales; Three ascending being respectively of different scale: first yardstick, second yardstick and the 3rd yardstick; Wherein, the characteristic area of each yardstick comprises that at least the image block that is positioned at the center reaches and the adjacent image block in said image block upper and lower, left and right, and the image block that be positioned at center of i pixel on first yardstick is i pixel itself; I pixel comprises all images piece on first yardstick at the image block that is positioned at the center on second yardstick; I pixel comprises all images piece on second yardstick at the image block that is positioned at the center on the 3rd yardstick; By that analogy;
(3) calculate monocular infrared image I (x; Y) proper vector of the pairing characteristic area of each pixel in; The characteristic component of the proper vector of i pixel comprises at least: the gray-scale value of all images piece of i pixel on first yardstick; The texture energy of each image block of i pixel on other yardsticks except that first yardstick; The gradient energy of the different directions of each image block of i pixel on other yardsticks except that first yardstick and the average and the variance of all gradient energy, and the sharpness of each image block of i pixel on other yardsticks except that first yardstick;
(4) utilize the method for progressively linear regression analysis and independent component analysis to screen successively to all proper vectors of obtaining, obtain meeting the proper vector of infrared image depth information;
(5) utilize the middle screening of step (4) to obtain proper vector and said monocular infrared image I (x; Y) pairing depth map makes up the set of degree of depth training sample; The proper vector in the set of degree of depth training sample and the depth value of depth map are carried out nonlinear fitting with the BP neural network; And be optimized, and then make up depth model through the initial weight and the threshold value of genetic algorithm to the BP neural network;
The new monocular infrared image that (6) will collect obtains the estimation of Depth value through the depth model analysis that structure obtains.
Texture energy in the said step (3) calculates through the Louth mask, and concrete steps are: adopt N basic two-dimentional Louth mask, be designated as M
1..., M
N, with said monocular infrared image I (x y) does convolution with each two-dimentional Louth mask, then monocular infrared image I (x, y) with k two-dimentional Louth mask convolution after value be: T
k(x, y)=I (x, y) * M
k, k=1 ..., N, then i m the image block N of pixel on the j yardstick
i(m) monocular infrared image I (x, y) with k two-dimentional Louth mask convolution after the texture energy that obtains do
The gradient energy of the different directions of each image block of i pixel on second yardstick and the 3rd yardstick and the average and the variance of all gradient energy calculate through following steps in the said step (3); Concrete steps are: (x y) tries to achieve x axial gradient figure I respectively on x direction of principal axis and y direction of principal axis to monocular infrared image I
Gradx(x is y) with y axial gradient figure I
Grady(x, y), then (x is y) at angle θ for monocular infrared image I
lGrad G on the direction
l(x, y)=I
Gradx(x, y) * cos (θ
l)+I
Grady(x, y) * sin (θ
l), wherein,
L=0 ..., 7, calculate the gradient energy of the different directions of each image block of each pixel on other yardsticks except that first yardstick subsequently, wherein, i m the image block N of pixel on the j yardstick
i(m) at angle θ
lGradient energy on the direction does
I m the image block N of pixel on the j yardstick then
i(m) at angle θ
lThe average of the gradient energy on the direction
I m the image block N of pixel on the j yardstick
i(m) at angle θ
lGradient energy variance on the direction
Wherein, size is image block N
iThe number of the pixel that (m) is comprised,
The sharpness of each image block of i pixel on second yardstick and the 3rd yardstick calculates through following steps in the said step (3), and concrete steps are: i m the image block N of pixel on the j yardstick
i(m) sharpness
Wherein, (x y) is image block N to I
i(m) contain the gray scale of pixel,
Be image block N
i(m) average of the gray scale of contained pixel,
Size is image block N
iThe number of the pixel that (m) is comprised.
In the said step (4) progressively linear regression analysis comprise following substep:
(411) related coefficient of each characteristic component and depth value in the calculated characteristics vector is according to the descending ordering that obtains each characteristic component to the effect of depth degree of the absolute value of related coefficient;
(412) the absolute value biggest characteristic component from related coefficient begins progressively to introduce regression equation; And do regression equation significance test; If do not think significantly that selected whole characteristic component all is not the principal element that influences depth value, if significantly again from depth value is influenced the descending regression equation of introducing one by one successively;
(413) new characteristic component of every introducing all need carry out significance test to each contained in regression equation characteristic component; With that in new regression equation significantly and to the minimum characteristic component rejection of depth value influence, repeat this step each characteristic component in regression equation all significantly till;
(414) introduce a characteristic component that in the characteristic component of not introducing depth value is had the greatest impact again, repeating step (413) and step (414) up to rejecting selected characteristic component, also can't be introduced till the new characteristic component.
What independent component analysis was used in the said step (4) is quick ICA algorithm, to analyzing through the proper vector of progressively linear regression analysis, makes between each component independently as much as possible through quick ICA algorithm, comprises following substep:
(421) specifying the proper vector through M pixel after the linear regression analysis progressively is observation data X, and observation data X is carried out centralization, and making it average is 0;
(422), be about to become the albefaction vector Z, Z=W after observation data X projects to new subspace with the observation data X albefaction of centralization
0X, wherein, W
0Be albefaction matrix, W
0=Λ
-1/2U
T, Λ is the eigenvalue matrix of the covariance matrix of observation data X, U is the eigenvectors matrix of the covariance matrix of observation data X;
(423) upgrade W
*Make W
*=E{Zg (W
TZ) }-E{g ' (W
TZ}W, wherein g () is a nonlinear function, and then to W
*Standardization: W=W
*/ || W
*||, if do not restrain and then do not repeat this step, wherein, selecting a mould is 1 the initial random weight vector initial value as W.
Initial weight and the threshold value of utilizing genetic algorithm to be optimized the BP neural network in the said step (5) also comprise following substep:
(511) make up initial BP neural network according to training sample, and confirm the number of input layer, hidden layer and the output layer of this network;
(512) carry out the initialization of genetic algorithm population; Wherein each individuality of population all is to be made up of the threshold value of the weights between the weights between input layer and the hidden layer, hidden layer and the output layer, hidden layer and threshold value four parts of output layer, and all weights and threshold value are listed as into a real number vector;
(513) maximum iteration time is set as stopping criterion for iteration, iterative process each time comprises selection, intersection and mutation operation, when reaching stopping criterion for iteration, output the last reign of a dynasty population optimum individual be the approximate optimal solution of initial weight and threshold value.
Beneficial effect
Owing to adopted above-mentioned technical scheme; The present invention compared with prior art; Have following advantage and good effect: the present invention utilizes infrared image " spatial context " and " multiple dimensioned " information extraction depth characteristic vector; Through the method for progressively linear regression analysis and independent component analysis the characteristic of extracting is screened successively, help finding the depth characteristic that is fit to infrared image more, and make up degree of depth training set with this; Adopt the back propagation learning theory that nonlinear fitting is carried out in the training set, and be optimized, improved the training speed of experiment and the accuracy rate of match through genetic algorithm.
Embodiment
Below in conjunction with specific embodiment, further set forth the present invention.Should be understood that these embodiment only to be used to the present invention is described and be not used in the restriction scope of the present invention.Should be understood that in addition those skilled in the art can do various changes or modification to the present invention after the content of having read the present invention's instruction, these equivalent form of values fall within the application's appended claims institute restricted portion equally.
As shown in Figure 1, present embodiment discloses a kind of monocular infrared image depth estimation method of the BP neural network model based on genetic algorithm optimization, the steps include:
Step 1, obtain any monocular infrared image I (x, y) and with this monocular infrared image I (x, y) pairing depth map;
Step 2, be monocular infrared image I (x; Y) each pixel in is set the characteristic area on three different scales; Three ascending being respectively of different scale: first yardstick, second yardstick and the 3rd yardstick; Wherein, The characteristic area of each yardstick comprises image block and the image block adjacent with these image block upper and lower, left and right that is positioned at the center; The image block that be positioned at center of i pixel on first yardstick is i pixel itself, and this i pixel comprises all images piece on first yardstick at the image block that is positioned at the center on second yardstick, and this i pixel comprises all images piece on second yardstick at the image block that is positioned at the center on the 3rd yardstick;
Step 3, calculating monocular infrared image I (x; Y) proper vector of the pairing characteristic area of each pixel in; The characteristic component of the proper vector of i pixel comprises at least: the gray-scale value of all images piece of i pixel on first yardstick; The texture energy of each image block of i pixel on second yardstick and the 3rd yardstick; I pixel gradient energy and the average and variance of all gradient energy on 8 directions of each image block on second yardstick and the 3rd yardstick, and the sharpness of each image block of i pixel on second yardstick and the 3rd yardstick;
The texture energy of each image block of i pixel on second yardstick and the 3rd yardstick calculates through following steps:
Adopt 9 basic two-dimentional Louth masks, be designated as M
1..., M
9, with monocular infrared image I (x y) does convolution with each two-dimentional Louth mask, then monocular infrared image I (x, y) with k two-dimentional Louth mask convolution after value be: T
k(x, y)=I (x, y) * M
k, k=1 ..., 9, i m the image block N of pixel on the j yardstick then
i(m) monocular infrared image I (x, y) with k two-dimentional Louth mask convolution after the texture energy that obtains do
The gradient energy of the different directions of each image block of i pixel on second yardstick and the 3rd yardstick and the average and the variance of all gradient energy calculate through following steps:
(x y) tries to achieve x axial gradient figure I respectively on x direction of principal axis and y direction of principal axis to monocular infrared image I
Gradx(x is y) with y axial gradient figure I
Grady(x, y), then (x is y) at angle θ for monocular infrared image I
lGrad G on the direction
l(x, y)=I
Gradx(x, y) * cos (θ
l)+I
Grady(x, y) * sin (θ
l), wherein,
L=0 ..., 7, calculate the gradient energy of the different directions of each image block of each pixel on other yardsticks except that first yardstick subsequently, wherein, i m the image block N of pixel on the j yardstick
i(m) at angle θ
lGradient energy on the direction does
I m the image block N of pixel on the j yardstick then
i(m) at angle θ
lThe average of the gradient energy on the direction
I m the image block N of pixel on the j yardstick
i(m) at angle θ
lGradient energy variance on the direction
Wherein, size is image block N
iThe number of the pixel that (m) is comprised,
The sharpness of each image block of i pixel on second yardstick and the 3rd yardstick calculates through following steps:
I m the image block N of pixel on the j yardstick
i(m) sharpness
Wherein, (x y) is image block N to I
i(m) contain the gray scale of pixel,
Be image block N
i(m) average of the gray scale of contained pixel,
Step 4, utilize the method for progressively linear regression analysis and independent component analysis to screen successively, comparatively met the proper vector of infrared image depth information all proper vectors of having obtained in the step 3.
In the step 4 progressively the concrete steps of linear regression analysis be:
The related coefficient of each characteristic component and depth value in step 4.1.1, the calculated characteristics vector is according to the descending ordering that obtains each characteristic component to the effect of depth degree of the absolute value of related coefficient;
Step 4.1.2, begin progressively to introduce regression equation from the absolute value biggest characteristic component of related coefficient; And do regression equation significance test; If can not think significantly that selected whole characteristic component all is not the principal element that influences depth value, if significantly again from depth value is influenced the descending regression equation of introducing one by one successively;
Step 4.1.3, new characteristic component of every introducing all need carry out significance test to each contained in regression equation characteristic component; With that in new regression equation significantly and to the minimum characteristic component rejection of depth value influence, repeat this step each characteristic component in regression equation all significantly till;
Step 4.1.4, introduce a characteristic component that in the characteristic component of not introducing depth value is had the greatest impact again, repeating step 4.1.3 and step 4.1.4 up to rejecting selected characteristic component, also can't introduce till the new characteristic component.
What independent component analysis was used in the step 4 is quick ICA algorithm, to analyzing through the proper vector of progressively linear regression analysis, makes between each component independent as much as possible through quick ICA algorithm.In the present embodiment, the ICA algorithm is maximum as searching direction with negentropy fast, and its concrete steps are following:
Step 4.2.1, to specify the proper vector through M pixel after the linear regression analysis progressively be observation data X, and observation data X is carried out centralization, and making it average is 0;
Step 4.2.2, with the observation data X albefaction of centralization, be about to become the albefaction vector Z, Z=W after observation data X will project to new subspace
0X, wherein, W
0Be albefaction matrix, W
0=Λ
-1/2U
T, Λ is the eigenvalue matrix of the covariance matrix of observation data X, U is the eigenvectors matrix of the covariance matrix of observation data X;
Step 4.2.3, renewal W
*Be to find the solution the separation matrix that draws, the separation matrix W that finally draws
*And observation data X multiplies each other and can obtain between each component as far as possible independently source data and make W
*=E{Zg (W
TZ) }-E{g ' (W
TZ) } W, wherein E () is the expectation computing, wherein g () is a nonlinear function, and then to W
*Standardization: W=W
*/ || W
*||, if do not restrain and then do not repeat this step, wherein, selecting a mould is 1 the initial random weight vector initial value as W.
The depth map of step 5, the proper vector of utilizing the infrared image that is drawn by step 4 and infrared image makes up degree of depth training sample set { f
i, depth
i, wherein, f
iBe the proper vector of i pixel, i=1 ..., l, f
i∈ χ, depth
iBe i the pairing depth value of pixel.Utilize back propagation learning The Theory Construction depth model then, and be optimized, and then new infrared image is carried out estimation of Depth through genetic algorithm.
The concrete steps of BP neural metwork training are following in the step 5:
Step 5.1.1, according to proper vector f
iWith depth value depth
iConfirm the input layer of BP neural network and the node number of output layer.Then through counting scope with reference to the roughly definite hidden layer node of formula
; Wherein n is the input layer number; M is an output layer node number; A is the constant between 0 ~ 10, and l is the hidden layer node number.Confirm the hidden layer node number that square error is minimum through trial method again;
The weights and the threshold value of step 5.1.2, initialization BP neural network, and given maximum iteration time, learning rate parameter η and neuron excitation function
wherein a be constant;
The output H of step 5.1.3, calculating hidden layer:
Wherein l is the hidden layer node number, ω
IjFor connecting the weights between input layer and the hidden layer, x
iBe the proper vector f that mentions among the step 5.1.1
i, a
jBe the threshold value of each hidden layer node, the neuron excitation function of f (.) for mentioning among the step 5.1.2;
Step 5.1.4, calculating prediction output O:
Wherein m is an output layer node number, ω
JkFor connecting the weights between hidden layer and the output layer, b
kThreshold value for each output layer node;
Step 5.1.5, according to prediction output and desired output error of calculation e, and upgrade the weights and the threshold value of network according to error e:
e
k=Y
k-O
k,k=1,...,m
ω
jk=ω
jk+ηH
je
k,j=1,...,l;k=1,...,m
b
k=b
k+e
k,k=1,...,m
Wherein n is the input layer number, Y
kBe desired output, i.e. depth value in the training set;
Step 5.1.6, circulation step 5.1.3 finish after reaching maximum iteration time to step 5.1.5;
Step 5.1.7, to obtaining the proper vector of each pixel after feature extraction and the screening of new infrared image through step 1 and step 2; Each component of proper vector is corresponded to the input layer of the BP neural network of having trained respectively; Draw corresponding depth value through prediction, just accomplished estimation new infrared image depth value.
BP neural network initial weight and threshold value are following through the concrete steps that genetic algorithm is optimized in the step 5:
Step 5.2.1, carry out the initialization of genetic algorithm population, wherein each individuality of population all is to be made up of the threshold value of the weights between the weights between input layer and the hidden layer, hidden layer and the output layer, hidden layer and threshold value four parts of output layer.All weights and threshold value are listed as into a real number vector;
Step 5.2.2, carry out the selection operation of genetic algorithm, at first individuality acted on the BP neural network, with the Error Absolute Value between prediction output that draws and the desired output as this individual fitness value F.Select according to each individual adaptive value, then the selection Probability p of each individual i
iFor:
f
i=k/F
i
F wherein
iBe the fitness value of individuality, the coefficient of k for being provided with is a constant; N is the individual number of population, because of F
iWhat reflect is the error between desired output and the prediction output, and the bright individuality of novel is excellent more more for error, and selecteed probability is just big more, so with F
iGet inverse and become f
iSo that with select the big or small proportional of probability; f
jMeaning and f
iIdentical, wherein subscript j represents the population individual amount;
Step 5.2.3, carry out the interlace operation of genetic algorithm, need chromosome that intersects and the position that needs to intersect to select at random.Suppose k chromosome a
kWith l chromosome a
lIntersect j position, then method of operating is following:
Wherein b is the random number between [0,1];
Step 5.2.4, carry out the mutation operation of genetic algorithm, need the chromosome of variation and the position of variation to select at random.Suppose the gene a of j position of i individuals
IjNeed make a variation, then method of operating is following:
A wherein
MaxBe gene a
IjThe upper bound, a
MinBe gene a
IjLower bound;
R and r
2All be the random number between [0,1], g is the current iteration number of times, G
MsxIt is maximum iteration time.
Step 5.2.5, circulation step 5.2.2 are provided with the circulation maximum times to step 5.2.4, when circulation reaches maximum times, stop, and take out initial weight and the threshold value of the minimum individuality of fitness value F as neural metwork training.