Disclosure of Invention
The invention provides an improved feature extraction method and an image splicing method based on the method, aiming at solving the problem of improving the splicing speed of aerial images under the condition of not reducing the splicing precision:
an improved region-based feature extraction method, comprising the steps of:
s1, image I to be spliced is processed by using FAST-9 algorithmAAnd IBExtracting features, obtaining coordinates of feature points, sequencing the obtained feature points from good to bad by using Harris corner detection, and screening to obtain the feature points with better performance of corner records;
s2, determining the direction of each feature point descriptor through the intensity centroid;
s3, obtaining a binary characteristic string through the improved BRISK algorithm, namely the extracted characteristic information.
2. Further defining, in S1, the image I to be stitched is processed by using FAST-9 algorithmAAnd IBIn the process of feature extraction, the value range of feature extraction is as follows:
image I to be stitchedAAnd IBThe overlapping rate is gamma, gamma belongs to (0,1), a threshold value delta, delta belongs to (0, gamma) for feature extraction is set, and an image I to be spliced isAAnd IBThe width of the image to be spliced is w, the height of the image to be spliced is h, the overlapping areas of the images to be spliced are positioned at the upper, lower, left or right sides of the images to be spliced, and the areas which respectively correspond to the areas needing to extract the characteristics are marked as omegat、Ωb、Ωl、ΩrThe specific value range is shown in the following formula:
further defined, the method for determining the direction of each feature descriptor through the intensity centroid as described in S2 is as follows:
determining the direction of the feature point descriptor by the intensity centroid: setting the position of the feature point in the image to be spliced as O, and defining the moment of the neighborhood where the feature point is located as follows:
wherein p, q belongs to (0,1), and the brightness center of the neighborhood where the characteristic point is defined by the moment is as follows:
obtaining a vector pointing to a brightness center C from a position O of the feature point
The directions defining the characteristic region are thus:
θ=atan2(m01,m10),
wherein atan2 is a quadrant version of arctan, i.e. the output is a vector
And the positive direction of the X axis.
Further defined, the modified BRISK algorithm described in S3 is as follows:
defining a corresponding binary test at the smoothed pixel block p as:
wherein P (x) is the luminance of the pixel block P at point x, and finally an n-dimensional binary vector describing the features is obtained:
another aspect of the invention: the image splicing method based on the feature extraction method comprises the following steps:
(1) image preprocessing: inputting an image I to be splicedAAnd IBCarrying out image rotation, image enhancement and smoothing pretreatment;
(2) ORB feature extraction: the feature extraction method of claim 1 obtaining a binary feature string;
(3) and (3) eliminating mismatching: the characteristic point pairs are obtained through a k nearest neighbor algorithm,then screening I by a random consistency sampling algorithmAAnd IBEliminating a large amount of mismatching by using the characteristic points to be matched; selecting the feature points with better matching effect by setting a threshold t by taking the Euclidean distance between the feature descriptors as the main reference basis of feature registration, searching the potential matching points which are closest and next closest to the feature descriptors in the image to be matched for each feature point in the image to be spliced, and when the closest distance d is reached1And a second near distance d2Satisfies the inequality d1/d2If t is less than t, the point with the closest distance is considered as a correct feature matching point;
(4) image registration: after at least 4 groups of pairable point pairs are obtained, solving a transformation model between the images to be registered through the following formula, and applying matrix parameters obtained through the solution to the image I to be splicedBObtaining a converted image I'B:
Wherein, (x, y,1)THomogeneous coordinates representing characteristic points of the image to be stitched, (x ', y', 1)TRepresenting homogeneous coordinates of feature points registered therewith;
(5) image fusion: converting the post-image I'BAnd an image I to be stitchedAAs input, image I 'is respectively'BAnd IAThe above pixel points are calculated according to the formula (1) to obtain the transformation distance d1、d2Then, α used for Alpha fusion is obtained and substituted into expression (2), and a fused image, that is, a final image is obtained according to an Alpha fusion algorithm, and expressions (1) and (2) are as follows:
(x,y)∈{(x,y)|I(x,y)≠0},
Ii(x,y)=α(x,y)Ii1(x,y)+[1-α(x,y)]Ii2(x,y) (2)。
the invention also provides a computer device comprising a memory in which a computer program is stored and a processor which, when running the computer program stored by the memory, executes the improved region-based feature extraction method according to any one of claims 1 to 4.
The invention also provides a computer device comprising a memory in which a computer program is stored and a processor which, when running the computer program stored by the memory, executes the image stitching method according to claim 5.
The invention has the beneficial effects that:
on the premise of ensuring the splicing precision, the invention improves the splicing speed of aerial images, and has the following specific effects:
the improved region-based feature extraction method is provided by improving the feature extraction mode, is applied to the image stitching method based on the feature extraction, and effectively proves the good performance of the algorithm in aerial image stitching through a specific comparison experiment.
The improved image splicing method is applied to an SIFT-based image splicing algorithm, an SURF-based image splicing algorithm and an ORB-based image splicing algorithm, simulation experiments are carried out, and the results show that: the improved region-based feature extraction algorithm can effectively reduce the number of feature extraction, is suitable for various image splicing algorithms, and can effectively reduce the time required by splicing while ensuring the image splicing precision. Especially for the image splicing algorithm based on SIFT (scale invariant feature transform) features with relatively complex feature descriptors, in twenty sets of simulation experiments, the minimum splicing speed of the improved algorithm is 2 times that of the original algorithm, when a large number of pictures are spliced, the significance of the splicing speed of the algorithm is particularly obvious, and the total time consumption of the improved splicing is less than 1/4 of the time consumption of the original algorithm. The improved algorithm also shows very good performance in SURF-based image splicing simulation, the total splicing speed is 1/2 of the original algorithm, in addition, the average PSNR value is consistent with the original algorithm, and the splicing precision is not reduced while the splicing speed is improved. In the improved simulation based on the ORB algorithm, even if the ORB feature extraction operator has the characteristics of low computational complexity and high feature extraction speed, the splicing speed of the original ORB-based image is greatly improved compared with the splicing speed of the two previous algorithms, the improved region-based feature extraction algorithm provided by the text still improves the splicing speed of the algorithm on the original basis, saves about 20% of time compared with the original algorithm in the time consumption of 20 pairs of image splicing, and does not change the average PSNR value too much, namely, the speed is accelerated and the precision is not influenced too much when the image splicing is finished.
The method can be widely applied to the splicing processing of aerial images. The global image of the aerial photographing area can be rapidly and accurately obtained.
Detailed Description
Example 1: improved region-based feature extraction method
There are many methods for implementing image stitching, and the specific details of different algorithm implementations are different to some extent, but the implementation steps included in the methods are approximately the same. Generally, image stitching is mainly performed according to the flow shown in fig. 1.
The general steps of image stitching are as follows:
(1) feature extraction
By analyzing the image, the position coordinates of the feature points in the image are obtained by finding solutions satisfying the corresponding extreme value conditions, and meanwhile, in order to describe the feature points, corresponding feature descriptors are constructed as description vectors of the feature points. For the subsequent related task, the extracted features should remain unchanged under the conditions of uneven illumination, image translation, rotation and scaling. At present, the feature detection algorithm which meets the above conditions and has good performance mainly comprises a SIFT operator, a SURF operator and an ORB feature detection operator which introduces a scale space.
(2) Image registration
The image registration refers to that two images to be registered are mapped to another image by constructing a space transformation model, and finally coordinate points of the two images at the same position in space are mutually overlapped, so that the matching of image pixels is further realized. The characteristic-based image registration firstly needs to determine characteristic points and characteristic vectors of images to be spliced, selects characteristic point pairs meeting conditions through a corresponding algorithm, and finally solves to obtain a corresponding transformation model.
Let I1(x,y),I2(u, v) respectively represent the image I1,I2The gray values of the pixel points (x, y), (u, v) and the spatial coordinate transformation between the registration images are shown as the following formula:
I2(u,v)=I1(f(x,y))
some spatial transformation models commonly used at present include rigid transformation, similarity transformation, affine transformation, perspective transformation, and the like. The perspective transformation model is the most general transformation model, and the specific transformation effect of each transformation model is shown in fig. 2.
According to the imaging principle of the camera, when the camera moves under a certain condition, the transformation relation between the coordinates of different images in the same scene collected by the camera is a 3 x 3 matrix called homography matrix. The transformation between images generally belongs to a perspective transformation, and a homography matrix of a perspective transformation model is given below.
When the image is subjected to perspective transformation, parallel straight lines in the image may not be parallel any more, and when the originally parallel lines are compared with an infinite point, the original image is transformed into perspective transformation, and the transformed result is shown in an e diagram in fig. 2. The corresponding normalized homography matrix is shown as the following formula:
the number of degrees of freedom of the transformation is 8, and for the perspective transformation containing 8 degrees of freedom, at least 4 groups of non-collinear feature matching pairs exist, so that all parameters of the matrix can be calculated.
(3) Image fusion
Due to the influence of different shooting angles, illumination and shooting environments, if images are directly spliced, obvious splicing seams often appear, and blurring and distortion may appear in an overlapping area. In order to achieve a good stitching effect, a proper image fusion method needs to be selected.
In consideration of the characteristics of the images shot by the text, the text realizes image fusion by using an Alpha fusion method in the process of image splicing simulation. Alpha fusion involves an important concept, Alpha channels. In the case of a picture taken normally having only three channels of RGB, the channel used to represent the transparency of each pixel is called the Alpha channel, in addition to the three primary color channels used to describe the digital image. Indications of Alpha channel concept: a pixel can be represented by (r, g, b, α) four channels, where α (x, y) e [0,1], represents the contribution of each color of the image to the pixel value of the point, where α (x, y) e [0,1], represents the transparency classified into 256 levels at the pixel point (x, y), pure white is opaque (α ═ 1, corresponding to 255 levels), and pure black is completely transparent (α ═ 0, corresponding to 0 levels).
In order to perform image fusion, two images to be fused are respectively regarded as a foreground and a background, and then the foreground image is extracted from a single background color to obtain a foreground image with a channel, which is called Mask. On the Mask, α (x, y) is 1 at each pixel inside the image, and α (x, y) is 0 outside the image. To solve the jaggy phenomenon at the edge of an image, the Alpha value at the edge pixel of Mask satisfies α (x, y) ∈ (0, 1).
After the Alpha value of each pixel is determined, the calculation of the formula is carried out on the image to be fused according to the pixel values of the three channels of RGB, and finally the components of the three channels are synthesized into one pixel for output.
Ii(x,y)=α(x,y)Ii1(x,y)+[1-α(x,y)]Ii2(x,y)
Where α (x, y) ∈ [0,1], i ═ 1,2,3 denotes three pixel channels.
Under the condition of the same environmental configuration and parameter setting, the aerial image with the resolution of 7952 x 5304 is subjected to a preliminary image stitching simulation experiment according to an image stitching process based on SIFT characteristics, SURF characteristics and ORB characteristics. The experiment is used for comparing the performance of three different algorithms in aerial photography image splicing, the specific splicing effect is shown in figure 3, and the simulation experiment result is shown in table 1.
TABLE 1 comparison of results of aerial image stitching simulation experiments with three different algorithms
From the image splicing effect shown in fig. 3, the three splicing effects are not very different visually, and the splicing seam is not obvious after image fusion, so that the splicing effect is ideal.
The performance of the image stitching algorithm is judged by taking the peak signal-to-noise ratio (PSNR) of the stitched image as a main basis, and the specific definition of the PSNR is shown in the following formula:
wherein M, N refer to the width and length of the image; n is generally 8, and the bit number corresponding to each pixel is shown in a table; i isoThe original image is shown, the spliced and fused image is shown, and the higher the PSNR value is, the better the image splicing and fusing effect is.
The evaluation of the effect of the simulation experiment is to cut 20 pictures with overlap respectively, then splice the cut images according to different splicing algorithms, compare the spliced images with the original images respectively to obtain corresponding PSRNR values, and finally average the PSRNR values to be used as PSNR for evaluation. The invention respectively records the index value related to time and the index value for measuring the splicing effect in the simulation experiment process, and the specific value taking situation is shown in table 1.
As can be seen from the data in table 1, in the application scenario, the ORB-based image mosaic algorithm has great advantages in speed, and is not much different from the SIFT-feature-based image mosaic algorithm in precision, so that the invention is improved on the basis of the ORB-based image mosaic algorithm.
From the results in table 1, the calculation amount of image registration is mainly caused by image registration, so the improvement of the image registration algorithm will have a direct influence on the image registration speed. The image registration only needs to extract 4 pairs of sufficiently matched feature points, and the existing registration mode is to directly extract the features of two registration images, so that a large number of feature point pairs are obtained. The feature extraction and description is a process requiring complex calculations such as convolution and the like, and great time complexity is brought to the algorithm. The data in table 1 show that it is verified that the time-consuming feature extraction of the image stitching algorithm takes approximately 3/4 hours.
In combination with the real application scene requirement, when shooting in real time, the unmanned aerial vehicle shoots and stores shooting data according to the shooting path shown in fig. 4. The presentation diagram and the return picture style effect diagram of the data acquisition process of unmanned aerial vehicle shooting are shown in fig. 5.
According to the distribution characteristics of the overlapped area of the images to be spliced, the characteristic points which are overlapped parts are really useful in characteristic matching. Therefore, before feature extraction, the image to be spliced is firstly subjected to block matching, and then ORB features are extracted for each block, so that the calculation amount is fundamentally reduced, and the purpose of improving the timeliness of the algorithm is achieved. The feature extraction area is schematically shown in fig. 6.
Setting the overlapping rate of images to be spliced as gamma, gamma belongs to (0,1), setting a threshold delta used for feature extraction, delta belongs to (0, gamma), setting the width of the images as w and the height as h, positioning the overlapping areas of the images to be spliced at the upper, lower, left or right sides of the images, and respectively marking the corresponding areas needing feature extraction as omegat、Ωb、Ωl、ΩrThe specific value range is shown in the following formula:
an improved region-based feature extraction method is provided by combining the characteristics of aerial images returned by an unmanned aerial vehicle and based on an ORB image stitching algorithm, and comprises the following specific steps:
s1, image I to be spliced is processed by using FAST-9 algorithmAAnd IBAnd extracting features, obtaining coordinates of the feature points, sequencing the obtained feature points from good to bad by using Harris corner detection, and screening to obtain the feature points with better performance of the corner records.
S1, using FAST-9 algorithm to treat image I to be splicedAAnd IBIn the process of feature extraction, the value range of feature extraction is as follows:
image I to be stitchedAAnd IBThe overlapping rate is gamma, gamma belongs to (0,1), a threshold value delta, delta belongs to (0, gamma) for feature extraction is set, and an image I to be spliced isAAnd IBThe width of the image to be spliced is w, the height of the image to be spliced is h, and the overlapping areas of the images to be spliced are positioned on the upper, lower, left or right sides of the images to be spliced and respectively correspond to the image to be splicedThe region needing to extract features is recorded as omegat、Ωb、Ωl、ΩrThe specific value range is shown in the following formula:
s2, determining the direction of each feature point descriptor through the intensity centroid:
determining the direction of the feature point descriptor by the intensity centroid: setting the position of the feature point in the image to be spliced as O, and defining the moment of the neighborhood where the feature point is located as follows:
wherein p, q belongs to (0,1), and the brightness center of the neighborhood where the characteristic point is defined by the moment is as follows:
obtaining a vector pointing to a brightness center C from a position O of the feature point
The directions defining the characteristic region are thus:
θ=atan2(m01,m10),
wherein atan2 is a quadrant version of arctan, i.e. the output is a vector
And the positive direction of the X axis.
S3, obtaining a binary characteristic string through the improved BRISK algorithm, namely the extracted characteristic information.
The modified BRISK algorithm is as follows:
defining a corresponding binary test at the smoothed pixel block p as:
wherein P (x) is the luminance of the pixel block P at point x, and finally an n-dimensional binary vector describing the features is obtained:
example 2: image stitching method based on feature extraction method described in embodiment 1
(1) Image pre-processing
Inputting an image I to be splicedA、IBAre respectively to IA、IBAnd performing image rotation, image enhancement and smoothing preprocessing.
(2) ORB feature extraction
The binary feature string is obtained according to the feature extraction method described in embodiment 1.
(3) Eliminating mismatch
Obtaining feature point pairs by a k nearest neighbor algorithm, and screening I by a random consensus sampling algorithm (RANSAC)AAnd IBEliminating a large amount of mismatching by using the characteristic points to be matched; meanwhile, the Euclidean distance between the feature descriptors is used as a main reference basis for feature registration, the feature points with better matching effect are selected by setting a threshold value t, for each feature point in the images to be spliced, the potential matching point closest to and next closest to the feature point is searched in the images to be matched, and when the closest distance d is reached1And a second near distance d2Satisfies the inequality d1/d2If t is less than t, the point with the closest distance is considered as the correct feature matching point.
(4) Image registration
After at least 4 groups of pairable point pairs are obtained, a transformation model between the images to be registered is solved through the following formula. Wherein, (x, y,1)THomogeneous coordinates representing characteristic points of the image to be stitched, (x ', y', 1)TRepresenting the homogeneous coordinates of the feature points with which it happens to be registered.
Applying the matrix parameters obtained by solving to the image I to be splicedBObtaining a converted image I'B。
(5) Image fusion
Converting the post-image I'BAnd an image I to be stitchedAAs input, image I 'is respectively'BAnd IAThe above pixel points are calculated according to the formula (1) to obtain the transformation distance d1、d2Then, α used for Alpha fusion is obtained and substituted into expression (2), and a fused image, that is, a final image is obtained according to an Alpha fusion algorithm, and expressions (1) and (2) are as follows:
(x,y)∈{(x,y)|I(x,y)≠0},
Ii(x,y)=α(x,y)Ii1(x,y)+[1-α(x,y)]Ii2(x,y) (2)。
(6) quality evaluation-Peak Signal-to-noise ratio (PSNR)
The peak signal-to-noise ratio is one of indexes for performing objective evaluation of image quality. The method can reflect the approximation degree between the processed image and the standard image, but the method cannot introduce visual influence factors of human eyes when carrying out error sensitivity analysis, so that the subjective visual perception of people needs to be considered when carrying out comparison of experimental results so as to comprehensively and objectively evaluate the image quality. PSNR is defined as follows:
wherein M, N refer to the width and length of the image; generally, 8 is taken, and the bit number corresponding to each pixel is shown; i isoThe image splicing and fusion method comprises the steps of representing an original image, representing an image after splicing and fusion by I, and representing the effect of image splicing and fusion by the PSNR value to be better when the PSNR value is larger.
Algorithm simulation and performance comparison:
in order to ensure that the experimental result can verify the general rule to a certain extent and avoid the contingency of the result, the invention respectively carries out image splicing simulation and performance evaluation on 20 groups of images. The relevant environment and parameter configuration of this simulation experiment are shown in table 2.
Table 2 environmental and parametric formulations
The 20 aerial images with the resolution of 7952 × 5304 are cut into 20 images to be stitched according to the overlapping rate of 75%, and the original images are used as reference images to measure the performance of the image stitching algorithm. Under the environment and parameter configuration of table 2, the improved region-based feature extraction algorithm is applied to an SIFT-based image mosaic algorithm, a SURF-based image mosaic algorithm, and an ORB-based image mosaic algorithm, respectively, and simulation experiments are performed. To verify the performance of the improved region-based feature extraction algorithm. The algorithm operating effect is shown in table 3.
TABLE 3 data presentation of improved feature extraction algorithm simulation results based on three algorithms
According to the results in the table 3, the designed algorithm for eliminating mismatching can effectively reduce the matching number of the feature points, reduce the mismatching and improve the speed and the precision of image splicing to a certain extent. The improved region-based feature extraction algorithm can effectively reduce the number of feature extraction, is suitable for various image splicing algorithms, and can effectively reduce the time required by splicing while ensuring the image splicing precision. Especially for the image splicing algorithm based on SIFT (scale invariant feature transform) features with relatively complex feature descriptors, in twenty sets of simulation experiments, the minimum splicing speed of the improved algorithm is 2 times that of the original algorithm, when a large number of pictures are spliced, the significance of the splicing speed of the algorithm is particularly obvious, and the total time consumption of the improved splicing is less than 1/4 of the time consumption of the original algorithm. The improved algorithm also shows very good performance in SURF-based image splicing simulation, the total splicing speed is 1/2 of the original algorithm, in addition, the average PSNR value is consistent with the original algorithm, and the splicing precision is not reduced while the splicing speed is improved. In the improved simulation based on the ORB algorithm, even if the ORB feature extraction operator has the characteristics of low computational complexity and high feature extraction speed, the splicing speed of the original ORB-based image is greatly improved compared with the splicing speed of the two previous algorithms, the improved region-based feature extraction algorithm provided by the text still improves the splicing speed of the algorithm on the original basis, saves about 20% of time compared with the original algorithm in the time consumption of 20 pairs of image splicing, and does not change the average PSNR value too much, namely, the speed is accelerated and the precision is not influenced too much when the image splicing is finished.
The invention splices 12 aerial images with the resolution of 5964 x 5304 through an improved image splicing method based on ORB, and the obtained panoramic image is shown in figure 7. The improved algorithm only takes 15.25 seconds to obtain a high-resolution panoramic image which is free of splicing seams and has the resolution of 10120 multiplied by 7951, and the improved method has better performance in aerial image splicing and gives consideration to speed and precision.
The improved algorithm of the invention has slight loss in precision, but the loss is not obvious in vision. Meanwhile, the algorithm effectively improves the splicing speed, so the algorithm is very suitable for rapidly acquiring the post-disaster panoramic image and is superior to the existing algorithm.