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.
Referring to fig. 1, a method for fusing super depth-of-field images includes the steps of:
s1, aligning an image sequence to be fused, wherein the focus point of each image in the image sequence is different;
s2, respectively carrying out Laplacian pyramid splitting on each image in the aligned image sequence, extracting high-frequency information and low-frequency information of each image, and obtaining a high-frequency information set and a low-frequency information set corresponding to the image sequence;
s3, obtaining synthesized high-frequency information according to the high-frequency information set, conducting guiding filtering processing on the low-frequency information set to obtain synthesized low-frequency information, and conducting Laplacian pyramid reconstruction according to the synthesized high-frequency information and the synthesized low-frequency information to obtain a super field depth image.
From the above description, the beneficial effects of the present invention are: the method comprises the steps of splitting an image to be fused through a Laplace pyramid to obtain a high-frequency information set and a low-frequency information set, conducting guided filtering on the low-frequency information set to obtain synthesized low-frequency information, and reconstructing the synthesized high-frequency information and the synthesized low-frequency information to obtain a super depth-of-field image.
Further, the step S1 includes:
extracting characteristic points of each image in the image sequence through a surf matching algorithm, and screening out a preset number of matching points;
calculating surf feature description of a preset dimension according to the preset number of matching points, and performing rough matching between images according to the surf feature description;
and calculating a transition matrix between the roughly matched images through a ransac algorithm, and aligning the corresponding images according to the transition matrix.
According to the description, the surf matching algorithm is adopted to extract the image feature points, calculate the feature description of the feature points, perform rough matching, and calculate the transition matrix between the images after rough matching through the ransac algorithm, so that the matching of the images to be fused is realized, the accurate matching between the images can be realized, and the accuracy of subsequent fusion is improved.
Further, the step S3 of obtaining the synthesized high-frequency information according to the high-frequency information set, and performing the guided filtering process on the low-frequency information set to obtain the synthesized low-frequency information includes:
selecting the high-frequency information with the maximum absolute value in the high-frequency information set as synthesized high-frequency information;
calculating the weight corresponding to each low-frequency information in the low-frequency information set by adopting a guided filtering method;
and weighting and summing each low-frequency information in the low-frequency information set and the corresponding weight thereof to obtain the synthesized low-frequency information.
According to the above description, the high-frequency information with the largest absolute value is selected as the synthesized high-frequency information, the weight corresponding to each low-frequency information in the low-frequency information set is calculated by adopting a guided filtering method, each low-frequency information is weighted based on the weight, and the synthesized low-frequency information is obtained, so that the small particle phenomenon in low-frequency synthesis can be prevented, the small particles in the fused image are avoided, the image synthesized by the super-depth of field is clear, fine and transparent, and more detailed information can be programmed.
Further, after the step S3 of performing the guided filtering process on the low frequency information set to obtain the synthesized low frequency information, the method further includes:
and performing region growth of a preset neighborhood on the synthesized low-frequency information, judging whether the region of each pixel point in the synthesized low-frequency information after growth is smaller than a preset value, and if so, removing the pixel point.
From the above description, it can be determined whether the synthesized low-frequency information has a "hole" by the region growing method, and if so, the "hole" is removed, so that an isolated small region can be removed, and the integrity of the fused image is ensured.
Further, the step S2 includes:
respectively carrying out Gaussian filtering on each image in the aligned image sequence according to a preset level, extracting high-frequency information of each layer of each image and low-frequency information of the highest layer of each image, and obtaining a high-frequency information set and a low-frequency information set corresponding to the image sequence;
in step S3, selecting the high frequency information with the largest absolute value in the high frequency information set as the synthesized high frequency information includes:
selecting the high-frequency information with the maximum absolute value in the high-frequency information of each layer in the high-frequency information set as the high-frequency information after the layer synthesis;
in the step S3, the performing laplacian pyramid reconstruction according to the synthesized high-frequency information and low-frequency information to obtain a super depth-of-field image includes:
and performing the following recursion on the synthesized low-frequency information from the highest layer to the bottom: and after the low-frequency information is up-sampled and subjected to Gaussian filtering, adding the high-frequency information of the corresponding level to serve as the low-frequency information of the next level.
As can be seen from the above description, by performing laplacian pyramid splitting and reconstruction of a preset level on an image sequence to be fused, features and details on different frequency bands of different decomposition layers can be extracted and displayed, features and details from different images can be fused together, and the fusion effect is good.
Referring to fig. 2, a super-depth-of-field image fusion terminal includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program to implement the following steps:
s1, aligning an image sequence to be fused, wherein the focus point of each image in the image sequence is different;
s2, respectively carrying out Laplacian pyramid splitting on each image in the aligned image sequence, extracting high-frequency information and low-frequency information of each image, and obtaining a high-frequency information set and a low-frequency information set corresponding to the image sequence;
s3, obtaining synthesized high-frequency information according to the high-frequency information set, conducting guiding filtering processing on the low-frequency information set to obtain synthesized low-frequency information, and conducting Laplacian pyramid reconstruction according to the synthesized high-frequency information and the synthesized low-frequency information to obtain a super field depth image.
From the above description, the beneficial effects of the present invention are: the method comprises the steps of splitting an image to be fused through a Laplace pyramid to obtain a high-frequency information set and a low-frequency information set, conducting guided filtering on the low-frequency information set to obtain synthesized low-frequency information, and reconstructing the synthesized high-frequency information and the synthesized low-frequency information to obtain a super depth-of-field image.
Further, the step S1 includes:
extracting characteristic points of each image in the image sequence through a surf matching algorithm, and screening out a preset number of matching points;
calculating surf feature description of a preset dimension according to the preset number of matching points, and performing rough matching between images according to the surf feature description;
and calculating a transition matrix between the roughly matched images through a ransac algorithm, and aligning the corresponding images according to the transition matrix.
According to the description, the surf matching algorithm is adopted to extract the image feature points, calculate the feature description of the feature points, perform rough matching, and calculate the transition matrix between the images after rough matching through the ransac algorithm, so that the matching of the images to be fused is realized, the accurate matching between the images can be realized, and the accuracy of subsequent fusion is improved.
Further, the step S3 of obtaining the synthesized high-frequency information according to the high-frequency information set, and performing the guided filtering process on the low-frequency information set to obtain the synthesized low-frequency information includes:
selecting the high-frequency information with the maximum absolute value in the high-frequency information set as synthesized high-frequency information;
calculating the weight corresponding to each low-frequency information in the low-frequency information set by adopting a guided filtering method;
and weighting and summing each low-frequency information in the low-frequency information set and the corresponding weight thereof to obtain the synthesized low-frequency information.
According to the above description, the high-frequency information with the largest absolute value is selected as the synthesized high-frequency information, the weight corresponding to each low-frequency information in the low-frequency information set is calculated by adopting a guided filtering method, each low-frequency information is weighted based on the weight, and the synthesized low-frequency information is obtained, so that the small particle phenomenon in low-frequency synthesis can be prevented, the small particles in the fused image are avoided, the image synthesized by the super-depth of field is clear, fine and transparent, and more detailed information can be programmed.
Further, after the step S3 of performing the guided filtering process on the low frequency information set to obtain the synthesized low frequency information, the method further includes:
and performing region growth of a preset neighborhood on the synthesized low-frequency information, judging whether the region of each pixel point in the synthesized low-frequency information after growth is smaller than a preset value, and if so, removing the pixel point.
From the above description, it can be determined whether the synthesized low-frequency information has a "hole" by the region growing method, and if so, the "hole" is removed, so that an isolated small region can be removed, and the integrity of the fused image is ensured.
Further, the step S2 includes:
respectively carrying out Gaussian filtering on each image in the aligned image sequence according to a preset level, extracting high-frequency information of each layer of each image and low-frequency information of the highest layer of each image, and obtaining a high-frequency information set and a low-frequency information set corresponding to the image sequence;
in step S3, selecting the high frequency information with the largest absolute value in the high frequency information set as the synthesized high frequency information includes:
selecting the high-frequency information with the maximum absolute value in the high-frequency information of each layer in the high-frequency information set as the high-frequency information after the layer synthesis;
in the step S3, the performing laplacian pyramid reconstruction according to the synthesized high-frequency information and low-frequency information to obtain a super depth-of-field image includes:
and performing the following recursion on the synthesized low-frequency information from the highest layer to the bottom: and after the low-frequency information is up-sampled and subjected to Gaussian filtering, adding the high-frequency information of the corresponding level to serve as the low-frequency information of the next level.
As can be seen from the above description, by performing laplacian pyramid splitting and reconstruction of a preset level on an image sequence to be fused, features and details on different frequency bands of different decomposition layers can be extracted and displayed, features and details from different images can be fused together, and the fusion effect is good.
Example one
Referring to fig. 1, a method for fusing super depth-of-field images includes the steps of:
s1, aligning an image sequence to be fused, wherein the focus point of each image in the image sequence is different;
specifically, feature points of each image in the image sequence are extracted through a surf matching algorithm, and a preset number of matching points are screened out;
calculating surf feature description of a preset dimension according to the preset number of matching points, and performing rough matching between images according to the surf feature description;
calculating a transition matrix between the images after rough matching through a ransac algorithm, and aligning the corresponding images according to the transition matrix;
preferably, all feature points of each image can be extracted through a surf matching algorithm, 500 matching points are screened out, and 64-dimensional surf feature description is calculated according to the 500 matching points;
performing coarse matching between images according to the surf feature description, wherein the coarse matching adopts nearest neighbor coarse matching;
finally, calculating a transition matrix between the roughly matched images through a ransac algorithm, and aligning the corresponding images through the transition matrix;
during image alignment, the above-mentioned alignment process may be performed between two images, so that all images in the image sequence are aligned;
s2, respectively carrying out Laplacian pyramid splitting on each image in the aligned image sequence, extracting high-frequency information and low-frequency information of each image, and obtaining a high-frequency information set and a low-frequency information set corresponding to the image sequence;
specifically, Gaussian filtering is respectively carried out on each image in the aligned image sequence according to a preset level, high-frequency information of each layer of each image and low-frequency information of the highest layer of each image are extracted, and a high-frequency information set and a low-frequency information set corresponding to the image sequence are obtained;
the specific implementation operation is as follows:
s2.1, assuming that the original image A is taken as the bottommost layer image LA0(layer 0 of the laplacian pyramid), convolved with a gaussian kernel W to obtain an image GA0;
S2.2, mixing LA0Subtract GA0Obtaining high-frequency information HA of layer 00;
S2.3, mixing GA0Downsampling (removing even rows and columns) to obtain the previous layer image LA1(layer 1 of the laplacian pyramid), repeating S2.1 and S2.2 to obtain high-frequency information HA of each layer0、HA1,……,HANAnd the low frequency information LA of the highest layerNWherein N is a preset hierarchy;
the decomposition of each image can be realized through the steps S2.1 to S2.3, and M pieces of high-frequency information HA corresponding to the M images can be obtained if M images exist0、HA1,……,HANAnd the low frequency information LA of the highest layerNForming a high frequency information set and a low frequency information set corresponding to the image sequence;
s3, obtaining synthesized high-frequency information according to the high-frequency information set, conducting guiding filtering processing on the low-frequency information set to obtain synthesized low-frequency information, and conducting Laplacian pyramid reconstruction according to the synthesized high-frequency information and the synthesized low-frequency information to obtain a super field depth image;
in step S3, the obtaining of the synthesized high-frequency information according to the high-frequency information set includes:
selecting the high-frequency information with the maximum absolute value in the high-frequency information set as synthesized high-frequency information;
specifically, the high-frequency information with the largest absolute value in the high-frequency information of each layer in the high-frequency information set is selected as the high-frequency information after the layer synthesis;
assuming that there are two images in total, the high frequency information set obtained is { HA0,HA1,……,HAN,HB0,HB1,……,HBNH, the synthesized high-frequency information is { H }0,H1,……,HnH, which includes N levels, each level having corresponding synthesized high-frequency information, Hi(m,n)=max(HAi(m,n),HBi(m, N)), i ═ 1,2, … …, N, (m, N) denotes the pixel point position;
preferably, 5-layer laplacian pyramid decomposition may be performed, and a gaussian filter with a window of 5 and σ of 1 is performed on the original image:
obtaining high-frequency information of a corresponding layer, subtracting the filtered image from the original image to be used as the high-frequency information of the corresponding layer, and extracting the filtered image in an interlaced and alternate manner to be used as an input image of the next layer;
performing Gaussian filtering with a window of 3 and sigma 1 on the high-frequency information of each layer, and then selecting the high-frequency information with the largest absolute value as the synthesized high-frequency information of each layer;
the step of performing guided filtering processing on the low-frequency information set to obtain synthesized low-frequency information comprises:
calculating the weight corresponding to each low-frequency information in the low-frequency information set by adopting a guided filtering method;
weighting and summing each low-frequency information in the low-frequency information set and the corresponding weight thereof to obtain synthesized low-frequency information;
specifically, assuming that there are two pictures in total, the low-frequency information LA of the highest layer of each picture is obtained by pyramid decompositionNAnd LBN;
Calculating LA by adopting guide filtering modeNAnd LBNThe synthesized weight W1And W2Then the synthesized low frequency information LN=W1*LAN+W2*LBN;
The calculation process of the guided filtering mode is as follows:
will LANConsidering as an input image P, the weight W is calculated with G as a guide map1And W2Wherein G (m, n) ═ max (LA)N(m,n),LBN(m, n)), (m, n) denoting the pixel location;
setting a guide image G, inputting an image P and outputting an image Q; the goal of guided filtering is: making the input P and output Q as identical as possible, while the texture part is similar to the guide map G;
to meet the first objective, to make the input P and output Q as similar as possible, it is desirable to minimize the squared difference min (Q-P)2;
To satisfy the second object, it is required that the texture of the output image Q is similar to that of the guide map G
Integrating to obtain Q ═ alpha G + b;
consider a small window WkIn WkThe internal assumption is that alpha, b remains unchanged and is set as alphak,bk;
WkInner pixel satisfy
qi=αkgi+bk,i∈Wk (1)
Substituting (1) into the first target, so that the pixels in the window satisfy the above two conditions simultaneously:
where ε is a penalized large αkPreferably, epsilon is 0.01, and the guide window is 3;
to minimize (2), satisfy
Where | W | is the window WkThe total number of pixels. Get it solved
Let p
kIs to input a picture P in a window W
kAverage value of (d), μ
kAnd
is to guide the drawing G in the window W
kMean and variance of, then
Wherein the content of the first and second substances,
is the guide graph G and the input graph P at W
kAn inner covariance;
calculating alphak,bkThen, the window W can be calculated according to (1)kThe output pixel of (1);
for a pixel i, the output value qiAnd all windows W covering the pixels ikRelated, therefore when WkDifferent from qiAre also different, a simple strategy is to average all possible qiA value;
all windows W covering i are calculatedkAlpha of (A)k,bkAll windows W covering the pixel ikIs | W |, then
Specifically, when the guide map G is the same as the input image P, the guide filter edge occurrence maintains a smooth characteristic, which is analyzed as follows:
when G ═ P, it is clear
Obtained from the formulae (5) and (6)
b
k=μ
k(1-α
k);
When ε is equal to 0, αk=1,bk0, i.e. the output is the same as the input image; if epsilon>0, consider two cases:
first, high variance: if the image P is in the window W
kIn a number of variations, then
Having a
k≈1,b
k≈0;
Second, flat block: then
Having a
k≈0,b
k≈μ
k(ii) a If the whole input image is like window W
kIs likely to be very flat when a
k,b
kIs averaged to obtain alpha
k≈0,b
k≈μ
k,q
i≈μ
k。
Thus, when a pixel is in a window of high variance, its output value is constant, in the flat region, its output value becomes the average of the surrounding window pixels, specifically, the criteria of high variance and flat are controlled by a parameter ε, if the window variance is much smaller than this parameter then it is smoothed then the variance is much larger and the window size determines how large the surrounding range of pixels is referenced to calculate the variance and mean;
in this case, the output image Q can be calculated by calculating the parameters of the guided filtering according to equations (5) to (8);
the filtering result of the oriented filtering at the pixel point i can be expressed as a weighted average
qi=∑jWij(G)pj (9)
Wherein i, j are both pixel indices;
filter weight WijIs a function of the pilot graph G and is independent of P;
the filter weights are calculated by substituting (6) into (8) and eliminating b to obtain:
calculating a partial derivative:
wherein the content of the first and second substances,
when j is not in the window W
kWhen the temperature of the water is higher than the set temperature,
is 0;
bringing (12) and (13) into (11) to obtain
I.e. the weight of the output image
So that the image Q is outputij=Wij×Pij;
Wherein, WijIs the weight corresponding to the pixel point (i, j) in the low frequency information (i.e., the input image); e.g. with low frequency information LANAnd LBNAs the input image, the input image LA is calculated by the above-mentioned guiding filtering methodNAnd LBNCorresponding weight WA of each pixel point inijAnd WBijThen weighted and summed to obtain input image LANAnd LBNIs QA to WAij*LANij,QB=WBij*LBNijFinally synthesized low frequency information LNQA + QB; the performing laplacian pyramid reconstruction according to the synthesized high-frequency information and low-frequency information to obtain a super-depth-of-field image includes:
and performing the following recursion on the synthesized low-frequency information from the highest layer to the bottom: performing up-sampling and Gaussian filtering on the low-frequency information, and adding the high-frequency information of the corresponding level as the low-frequency information of the next level;
specifically, the synthesized low-frequency information is up-sampled, with a 2-fold window of 5 and a 1-sigma gaussian filter, and then the synthesized top-most high-frequency H is addedNTo obtain the input G of the next layerN-1;
Then to GN-1Upsampling is performed, a 2-time window is 5, sigma is 1 Gaussian filtering, and then the high frequency H of the synthesized N-1 layer is addedN-1To obtain the input G of the next layerN-2And the upper layer of the pyramid is recurred to the lower layer of the pyramid, and finally the fused super-depth-of-field image which is as large as the input image is obtained.
Example two
The difference between the present embodiment and the first embodiment is:
in step S3, after the performing the guided filtering process on the low frequency information set to obtain the synthesized low frequency information, the method further includes:
performing region growth of a preset neighborhood on the synthesized low-frequency information, judging whether a region of each pixel point in the synthesized low-frequency information after growth is smaller than a preset value, and if so, removing the pixel point;
preferably, the synthesized low-frequency information is subjected to region growth of 4 neighborhoods, and if the region of each point after growth is less than 10000 pixel points, the point is judged to be a cavity, and the cavity is removed.
Specifically, after calculating the guiding filter of the low-frequency information, the weights W1 and W2 of the two pieces of low-frequency information are calculated respectively, and the W1 and W2 of each pixel point (i, j) are compared to obtain a matrix C, wherein the matrix C is obtained
Four-neighborhood region growing for each point of matrix C with value 1, e.g. CijComparing whether four points of upper (A), lower (B), left (C) and right (D) are 1, judging whether the points of 1 are the points of 1, counting the number N of the points of 1 until reaching the boundary of the matrix C, and if N is less than 10000, counting the number N of the points of 1ijIs a void, and is removed.
EXAMPLE III
Referring to fig. 2, a super-depth-of-field image fusion terminal 1 includes a memory 2, a processor 3, and a computer program stored in the memory 1 and executable on the processor 3, where the processor 3 implements the steps in the first embodiment when executing the computer program.
Example four
Referring to fig. 2, a super-depth-of-field image fusion terminal 1 includes a memory 2, a processor 3, and a computer program stored in the memory 1 and executable on the processor 3, where the processor 3 implements the steps in the second embodiment when executing the computer program.
In summary, according to the fusion method and the terminal for the super depth-of-field image provided by the invention, the image to be fused is split through the laplacian pyramid to obtain the high-frequency information set and the low-frequency information set, the high-frequency information set is synthesized by adopting the method of obtaining the maximum absolute value, the low-frequency information set is subjected to the guided filtering processing to obtain the weight of the low-frequency information, the low-frequency information is weighted and synthesized, the synthesized low-frequency information is subjected to the region growing method to remove the isolated small region, the synthesized high-frequency information and low-frequency information are reconstructed to obtain the super depth-of-field image, the problems that a large amount of particles and water stains appear in the depth-of-field synthesized image in the existing depth-of-field fusion method are solved, the small particle blocks in the fusion image are thoroughly eliminated, the obtained super depth-of-field image is closer to the original image, and the fused super depth-of-field image is clear, Fine and transparent, and can present more detailed information.
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.