A dynamic programming optimal splicing line detection method based on the shortest matrix path
The shortest-path matrix-based dynamic programming approach for seam detection in high-resolution remote sensing images addresses the speed-accuracy tradeoff by constructing a cost matrix from intensity and gradient differences, ensuring optimal seam detection and minimizing visible seams.
Patent Information
- Application Number
- CN202211427912.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2042-11-15
AI Technical Summary
The prior art is difficult to detect the optimal splicing lines quickly and with high accuracy in high-space resolution remote sensing image stitching, especially when avoiding buildings and other places, resulting in misalignment or obvious traces in the splicing results.
Using a dynamic programming method based on the shortest matrix path, by constructing an intra-joining matrix in the overlap area, combining the cost functions of intensity difference, gradient difference and geometric structure difference, the dynamic programming algorithm is used to calculate the minimum average path cost and reverse the optimal splicing line.
It realizes the rapid and high-precision detection of the optimal splicing lines in high-spatial resolution remote sensing image stitching, avoiding obvious objects, and ensuring the naturalness and accuracy of splicing results.
Smart Images

Figure CN115861053B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of remote sensing image processing, and relates to a dynamic programming optimal seam line detection method based on the shortest matrix path. Background Art
[0002] Due to the limitations of the physical factors of the sensor itself, a single remote sensing image often cannot completely cover the research area of interest. Therefore, it is necessary to expand the coverage of the image for further processing and research. With the continuous development of high-spatial-resolution remote sensing technology, high-spatial-resolution remote sensing images have gradually become the main data source for quickly obtaining geographical information data. However, for remote sensing images of the same size, the higher the spatial resolution, the smaller the coverage of a single image. In order to obtain the same research area of interest, more high-spatial-resolution remote sensing images need to be stitched together into one image. Image stitching is to stitch two or even multiple (with overlapping areas) images together to form a natural image without obvious stitching marks.
[0003] Optimal seam line detection is one of the key steps in image stitching, and the quality of the seam line determines the quality of the stitching result. Especially in high-spatial-resolution remote sensing images, if the seam line passes through obvious ground objects such as buildings, for non-orthoimages, obvious misalignment phenomena will occur in the stitched image; even for orthoimages, stitching marks are likely to appear. Currently, the research on optimal seam line detection mainly uses information such as the gray level, gradient, and texture of adjacent images to describe the pixel difference in the overlapping area, and then uses algorithms such as the Dijkstra algorithm, traditional dynamic programming algorithm, and graph cut to perform seam line detection. However, most methods fail to solve the contradiction between fast speed and high accuracy in the detection of the best seam line. For example, the Dijkstra and graph cut algorithms can find the global optimal seam line, but their detection efficiency is low for high-spatial-resolution remote sensing images with a large width; the traditional dynamic programming method has the significant advantage of fast detection, but the seam line it selects is usually not globally optimal. Therefore, how to design a suitable seam line detection algorithm that can quickly detect the optimal seam line and effectively avoid buildings is still a difficult point in the stitching of high-spatial-resolution remote sensing images. Summary of the Invention
[0004] Aiming at the deficiencies of the existing technology, the present invention aims to provide a dynamic programming optimal seam line detection method based on the shortest matrix path.
[0005] To achieve the above object, the present invention adopts the following technical solutions:
[0006] A dynamic programming optimal seam line detection method based on the shortest matrix path, comprising the following steps:
[0007] Step 1: According to the geographic coordinate information of adjacent high-spatial-resolution remote sensing images to be spliced, obtain the overlapping relationship and the overlapping area range of the adjacent images. According to the overlapping relationship of the adjacent images, determine the starting pixel coordinates and the ending pixel coordinates of the optimal splicing line. Then, calculate the four-corner coordinates of the inscribed matrix in the overlapping area through the diagonal pixel coordinates, and determine the detection directions of the pixels in the inscribed matrix in the overlapping area;
[0008] Step 2: Jointly establish a cost function for describing the pixel difference magnitude in the inscribed matrix from three aspects: intensity difference, gradient difference, and geometric structure difference. Calculate the cost magnitudes of all pixels in the inscribed matrix in the overlapping area according to the cost function, and establish an inscribed pixel cost matrix for the overlapping area of the adjacent images;
[0009] Step 3: Based on the pixel cost matrix, use the dynamic programming method to sequentially solve the minimum average path cost from each pixel in the inscribed matrix to the starting pixel, and construct an inscribed minimum average path cost matrix for the overlapping area;
[0010] Step 4: According to the minimum average path cost matrix, inversely deduce the "shortest path" from each pixel to the starting pixel. The "shortest path" from the ending pixel to the starting pixel is the optimal splicing line between the adjacent images.
[0011] Further, in the above Step 1, the specific method for determining the starting pixel coordinates and the ending pixel coordinates of the optimal splicing line, as well as the detection directions of the pixels in the inscribed matrix in the overlapping area, is as follows:
[0012] Step 1.1: Judge the overlapping relationship of the images according to the positional relationship of the four-corner coordinates of the adjacent images, which is divided into two types: upper left - lower right and lower left - upper right;
[0013] Step 1.2: If the adjacent images overlap in the upper left - lower right manner, the starting pixel is the upper right corner pixel of the overlapping area, and the ending pixel is the lower left corner pixel; if the adjacent images overlap in the lower left - upper right manner, the starting pixel is the upper left corner pixel of the overlapping area, and the ending pixel is the lower right corner pixel;
[0014] Step 1.3: If the adjacent images overlap in the upper left - lower right manner, the pixels in the last row of the inscribed matrix can only be detected in one direction to the left, the pixels in the first column can be detected in two directions: downward and lower right, the pixels in the last column can be detected in three directions: left, lower left, and downward, and the remaining pixels can be detected in four directions: left, lower left, downward, and lower right; if the adjacent images overlap in the lower left - upper right manner, the pixels in the last row of the inscribed matrix can only be detected in one direction to the right, the pixels in the last column can be detected in two directions: downward and lower left, the pixels in the first column can be detected in three directions: right, lower right, and downward, and the remaining pixels can be detected in four directions: right, lower right, downward, and lower left.
[0015] Further, in the above Step 2, the specific method for constructing the cost function is as follows:
[0016] Step 2.1: First, construct the intensity difference function. In the HSI color space, construct the intensity difference function, calculate the sum of the absolute values of the intensity differences within the 3×3 neighborhood of each pixel in the inscribed matrix of the overlapping area, and then take the average value as the intensity difference magnitude of the pixel. The specific formula is as follows:
[0017]
[0018] where C d (x, y) represents the intensity difference magnitude of pixel (x, y), respectively represent the intensity components of the pixels with coordinates (x, y) in images f and g in the HSI color space, and i and j represent the 3×3 neighborhood range;
[0019] Step 2.2: Construct the gradient difference function. In the RGB color space, calculate the minimum value of the first-order difference gradient between the current pixel and the pixel in the next detection direction in the inscribed matrix of the overlapping area of the image as the gradient difference magnitude of the pixel. The specific formula is as follows:
[0020]
[0021] where C e (x, y) represents the gradient difference magnitude of pixel (x, y), grad f (x m , y m ) and grad g (x m , y m ) represent the first-order difference gradients between the pixels with coordinates (x, y) in images f and g and the pixel in the m-th search direction;
[0022] Step 2.3: Construct the geometric structure difference function. In the RGB color space, use the eight-direction Sobel operator to calculate the Sobel gradient value of the pixel in the inscribed matrix of the overlapping area, and obtain the geometric structure difference magnitude of the pixel by summation. The specific formula is as follows:
[0023]
[0024]
[0025] where C k (x, y) represents the geometric structure difference magnitude of pixel (x, y), G t (x, y) represents the Sobel gradient in the t-th direction, S t represents the Sobel operator in the t-th direction, t takes values from 1 to 8, indicating 8 directions, f n (x, y), g n(x, y) are the pixel values of the nth band of the pixels at coordinates (x, y) in the RGB color space of image f and image g respectively;
[0026] In step 2.4, after obtaining the three sub-functions of the pixel cost function, different weights are assigned to the intensity difference function, gradient difference function, and geometric structure difference function respectively to form the final pixel cost function. The specific formula is as follows:
[0027] C(x, y) = C d (x, y) + αC e (x, y) + βC k (x, y)
[0028] Among them, α and β are empirical values used to balance the weights of the three parts of the cost function.
[0029] Furthermore, the 8 directions are 0°, 45°, 90°, 135°, 180°, 225°, 270°, and 315°.
[0030] Furthermore, in step 3, the specific steps for constructing the minimum average path cost matrix inscribed in the overlapping area are as follows:
[0031] Set the overlapping relationship of adjacent images as upper left - lower right overlap. The starting pixel is the upper right pixel of the inscribed matrix, and the ending pixel is the lower left pixel of the inscribed matrix. Using the idea of dynamic programming, sequentially solve the minimum average path cost from each pixel in the inscribed matrix of the overlapping area to the starting pixel;
[0032] In step 3.1, calculate the minimum average path cost of the pixels in the first row of the inscribed matrix in the overlapping area. Due to the limitation of the search direction, the previous pixel of the pixels in the first row can only be the pixel to its right. Then the calculation formula for the minimum average path cost of the pixels in the first row is:
[0033]
[0034] In step 3.2, calculate the minimum average path cost of the pixels in the last column of the inscribed matrix in the overlapping area. The previous pixel of the pixels in the last column can be the pixel above it or the pixel in the upper left. Then the calculation formula for the minimum average path cost of the pixels in the last column is:
[0035]
[0036] In step 3.3, calculate the minimum average path cost of the pixels in the first column of the inscribed matrix in the overlapping area. The previous pixel of the pixels in the first column can only be the pixel above it, the pixel in the upper right, or the pixel to its right. Then the calculation formula for the minimum average path cost of the pixels in the first column is:
[0037]
[0038] Step 3.4: Calculate the minimum average path cost of the pixels in the middle area of the inscribed matrix in the overlapping area. The previous pixel of the pixel in the middle area can be its upper left, upper, upper right, or right pixel. The calculation formula for the minimum average path cost of the pixel in the middle area is as follows:
[0039]
[0040] PC in the above formula (x,y) represents the minimum average path cost from the pixel point (x, y) to the starting pixel, and L (x,y) represents the optimal path length from the pixel point (x, y) to the starting pixel. The Min function takes the smallest value among them.
[0041] Furthermore, in the above Step 3, the specific steps for constructing the minimum average path cost matrix inscribed in the overlapping area are as follows:
[0042] Set the adjacent image overlapping relationship as lower left - upper right overlap, the starting pixel as the upper left pixel of the inscribed matrix, and the ending pixel as the lower right pixel of the inscribed matrix. Using the idea of dynamic programming, sequentially solve the minimum average path cost from each pixel in the inscribed matrix in the overlapping area to the starting pixel;
[0043] Step 3.1: Calculate the minimum average path cost of the pixels in the first row of the inscribed matrix in the overlapping area. Due to the limitation of the search direction, the previous pixel of the pixel in the first row can only be its left pixel. The calculation formula for the minimum average path cost of the pixel in the first row is as follows:
[0044]
[0045] Step 3.2: Calculate the minimum average path cost of the pixels in the first column of the inscribed matrix in the overlapping area. The previous pixel of the pixel in the last column can be its upper or upper right pixel. The calculation formula for the minimum average path cost of the pixel in the first column is as follows:
[0046]
[0047] Step 3.3: Calculate the minimum average path cost of the pixels in the last column of the inscribed matrix in the overlapping area. The previous pixel of the pixel in the last column can only be its upper, upper left, or left pixel. The calculation formula for the minimum average path cost of the pixel in the first column is as follows:
[0048]
[0049] Step 3.4: Calculate the minimum average path cost of the pixels in the middle area of the inscribed matrix in the overlapping area. The previous pixel of the pixel in the middle area can be its upper left, upper, upper right, or left pixel. The calculation formula for the minimum average path cost of the pixel in the middle area is as follows:
[0050]
[0051] PC in the above formula (x,y) represents the minimum average path cost from the pixel point (x, y) to the starting pixel, and L (x,y) represents the optimal path length from the pixel point (x, y) to the starting pixel. The Min function takes the smallest value among them.
[0052] Furthermore, in step 4, the specific steps for solving the optimal path from the termination pixel to the starting pixel are as follows:
[0053] Starting from the termination pixel, according to the minimum average path cost value of the termination pixel and the minimum average path cost calculation formula in step 3, deduce the previous pixel of the termination pixel, record the coordinates of this pixel, and then use this pixel as the "termination pixel", and deduce the previous pixel through the minimum average path cost value of this pixel and the formula in step 3, record the pixel coordinates, and iterate in turn to deduce the coordinates of the previous pixel until reaching the starting pixel. Connect the coordinates of these pixels deduced backwards to obtain the optimal path between the starting pixel and the termination pixel, which is the optimal stitching line between adjacent images.
[0054] The beneficial effects produced by the present invention are:
[0055] 1. Inspired by the shortest path problem in the matrix, the present invention transforms the optimal stitching line detection problem into the optimal path problem between a vertex and the corresponding corner point in the inscribed matrix of the overlapping area of adjacent images. The detected optimal path is globally optimal in the inscribed matrix of the overlapping area.
[0056] 2. The dynamic programming optimal stitching line detection method based on the shortest matrix path not only calculates the intensity difference, gradient difference and geometric structure difference of the pixels in the image to ensure that the optimal stitching line can bypass obvious ground objects as much as possible, but also inherits the advantage of fast detection of the dynamic programming method. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 is the overall flowchart of the method of the present invention. DETAILED DESCRIPTION OF THE INVENTION
[0058] In order to facilitate the understanding and implementation of the present invention by those of ordinary skill in the art, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0059] As Figure 1 shown, a dynamic programming optimal stitching line detection method based on the shortest matrix path is as follows:
[0060] Step 1: Obtain the overlapping relationship and the range of the overlapping area of adjacent images according to the geographic coordinate information of adjacent high-spatial-resolution remote sensing images to be spliced. According to the overlapping relationship of adjacent images, determine the starting pixel coordinates and ending pixel coordinates of the optimal splicing line, and then calculate the four corner coordinates of the inscribed matrix in the overlapping area through the diagonal pixel coordinates to determine the detection directions of the pixels in the inscribed matrix in the overlapping area. The specific method is as follows:
[0061] Step 1.1: Judge the overlapping relationship of the images according to the positional relationship of the four corner coordinates of adjacent images, which is divided into two types: upper left - lower right and lower left - upper right;
[0062] Step 1.2: If the adjacent images overlap in the upper left - lower right manner, the starting pixel is the upper right corner pixel of the overlapping area, and the ending pixel is the lower left corner pixel; if the adjacent images overlap in the lower left - upper right manner, the starting pixel is the upper left corner pixel of the overlapping area, and the ending pixel is the lower right corner pixel;
[0063] Step 1.3: If the adjacent images overlap in the upper left - lower right manner, the pixels in the last row of the inscribed matrix can only be detected in one direction to the left, the pixels in the first column can be detected in two directions: down and lower right, the pixels in the last column can be detected in three directions: left, lower left, and down, and the remaining pixels can be detected in four directions: left, lower left, down, and lower right; if the adjacent images overlap in the lower left - upper right manner, the pixels in the last row of the inscribed matrix can only be detected in one direction to the right, the pixels in the last column can be detected in two directions: down and lower left, the pixels in the first column can be detected in three directions: right, lower right, and down, and the remaining pixels can be detected in four directions: right, lower right, down, and lower left;
[0064] Step 2: Jointly establish a cost function for describing the pixel difference size in the inscribed matrix from three aspects: intensity difference, gradient difference, and geometric structure difference. Calculate the cost sizes of all pixels in the inscribed matrix in the overlapping area according to the cost function, and establish an inscribed pixel cost matrix for the overlapping area of adjacent images. The specific method is as follows:
[0065] Step 2.1: First, construct an intensity difference function. Compared with the RGB model, the HSI model separates the chromaticity and intensity of the image and can only process the intensity component. According to this feature, construct an intensity difference function in the HSI color space, calculate the sum of the absolute values of the intensity differences within the 3×3 neighborhood of each pixel in the inscribed matrix in the overlapping area, and then take the average value as the intensity difference size of the pixel. The specific formula is as follows:
[0066]
[0067] Among them, C d (x, y) represents the intensity difference size of the pixel (x, y), respectively represent the intensity components of the pixels with coordinates (x, y) in the HSI color space in images f and g, where i and j represent the 3×3 neighborhood range;
[0068] Step 2.2: Construct the gradient difference function. In the RGB color space, calculate the minimum value of the first-order difference gradient between the current pixel and the pixel in the next detection direction in the inscribed matrix of the image overlap area as the gradient difference magnitude of the pixel. The specific formula is as follows:
[0069]
[0070] Among them, C e (x, y) represents the gradient difference magnitude of the pixel (x, y), and grad f (x m , y m ) and grad g (x m , y m ) represent the first-order difference gradients between the pixels with coordinates (x, y) in images f and g and the pixels in the m-th search direction. The search direction is determined according to the specific pixel and overlap situation. If the adjacent images overlap in the upper left - lower right direction, it is divided into four directions: left, lower left, down, and lower right; if the adjacent images overlap in the lower left - upper right direction, it is divided into four directions: right, lower right, down, and lower left;
[0071] Step 2.3: Construct the geometric structure difference function. In the RGB color space, use the eight-direction Sobel operator to calculate the Sobel gradient value of the pixels in the inscribed matrix of the overlap area, and obtain the geometric structure difference magnitude of the pixel by summation. The specific formula is as follows:
[0072]
[0073]
[0074] Among them, C k (x, y) represents the geometric structure difference magnitude of the pixel (x, y), G t (x, y) represents the Sobel gradient in the t-th direction, S t represents the Sobel operator in the t-th direction, where t takes values from 1 to 8, representing the eight directions as 0°, 45°, 90°, 135°, 180°, 225°, 270°, and 315°. f n (x, y), g n (x, y) are respectively the pixel values of the n-th band of the pixels with coordinates (x, y) in images f and g in the RGB color space, where n takes values from 1 to 3, representing the three RGB bands;
[0075] Step 2.4: After obtaining the three sub - parts of the pixel cost function, different weights are assigned to the intensity difference function, gradient difference function, and geometric structure difference function to form the final pixel cost function. The specific formula is as follows:
[0076] C(x,y) = C d (x,y)+αC e (x,y)+βC k (x,y)
[0077] where α and β are empirical values used to balance the weights of the three - part cost function.
[0078] Step 3: Based on the pixel cost matrix, use the dynamic programming method to sequentially solve the minimum average path cost from each pixel in the inscribed matrix to the starting pixel, and construct the minimum average path cost matrix in the overlapping area. The specific steps are as follows:
[0079] If the adjacent image overlapping relationship is upper - left to lower - right overlap, the starting pixel is the upper - right corner pixel of the inscribed matrix, and the ending pixel is the lower - left corner pixel of the inscribed matrix.
[0080] Step 3.1: Calculate the minimum average path cost of the pixels in the first row of the overlapping area inscribed matrix. Due to the limitation of the search direction, the previous pixel of the pixels in the first row can only be the pixel to its right. Then the formula for calculating the minimum average path cost of the pixels in the first row is:
[0081]
[0082] Step 3.2: Calculate the minimum average path cost of the pixels in the last column of the overlapping area inscribed matrix. The previous pixel of the pixels in the last column can be the pixel above it or the pixel above - left of it. Then the formula for calculating the minimum average path cost of the pixels in the last column is:
[0083]
[0084] Step 3.3: Calculate the minimum average path cost of the pixels in the first column of the overlapping area inscribed matrix. The previous pixel of the pixels in the first column can only be the pixel above it, the pixel above - right of it, or the pixel to its right. Then the formula for calculating the minimum average path cost of the pixels in the first column is:
[0085]
[0086] Step 3.4: Calculate the minimum average path cost of the pixels in the middle area of the overlapping area inscribed matrix. The previous pixel of the pixels in the middle area can be the pixel above - left of it, the pixel above it, the pixel above - right of it, or the pixel to its right. Then the formula for calculating the minimum average path cost of the pixels in the middle area is:
[0087]
[0088] If the overlapping relationship of adjacent images is lower - left to upper - right overlap, the starting pixel is the upper - left pixel of the inscribed matrix, and the ending pixel is the lower - right pixel of the inscribed matrix.
[0089] Step 3.1: Calculate the minimum average path cost of the pixels in the first row of the inscribed matrix within the overlapping area. Due to the limitation of the search direction, the previous pixel of the pixels in the first row can only be the pixel to its left. Then the calculation formula for the minimum average path cost of the pixels in the first row is:
[0090]
[0091] Step 3.2: Calculate the minimum average path cost of the pixels in the first column of the inscribed matrix within the overlapping area. The previous pixel of the pixels in the last column can be the pixel above it or the pixel above - right of it. Then the calculation formula for the minimum average path cost of the pixels in the first column is:
[0092]
[0093] Step 3.3: Calculate the minimum average path cost of the pixels in the last column of the inscribed matrix within the overlapping area. The previous pixel of the pixels in the last column can only be the pixel above it, the pixel above - left of it, or the pixel to its left. Then the calculation formula for the minimum average path cost of the pixels in the first column is:
[0094]
[0095] Step 3.4: Calculate the minimum average path cost of the pixels in the middle area of the inscribed matrix within the overlapping area. The previous pixel of the pixels in the middle area can be the pixel above - left of it, the pixel above it, the pixel above - right of it, or the pixel to its left. Then the calculation formula for the minimum average path cost of the pixels in the middle area is:
[0096]
[0097] PC in the above formula (x,y) represents the minimum average path cost from the pixel point (x, y) to the starting pixel, and L (x,y) represents the optimal path length from the pixel point (x, y) to the starting pixel. The Min function takes the smallest one of them.
[0098] Step 4: According to the minimum average path cost matrix, inversely deduce the "shortest path" from each pixel to the starting pixel. The "shortest path" from the ending pixel to the starting pixel is the optimal stitching line between adjacent images. The specific steps are as follows:
[0099] Starting from the terminating pixel, according to the minimum average path cost value of the terminating pixel and the minimum average path cost calculation formula in step 3, the previous pixel of the terminating pixel is deduced, the coordinates of this pixel are recorded, and then this pixel is used as the "terminating pixel". The previous pixel is deduced backward through the minimum average path cost value of this pixel and the formula in step 3, and the pixel coordinates are recorded. The coordinates of the previous pixel are deduced iteratively in sequence until the starting pixel is reached. The coordinates of these pixels deduced backward are connected to obtain the optimal path between the starting pixel and the terminating pixel, which is the optimal stitching line between adjacent images.
[0100] The present invention draws on the solution idea of the shortest path problem in a matrix, constructs a pixel cost matrix in the overlapping area of adjacent images to describe the pixel gray level difference, gradient difference, and geometric structure difference, and then determines the search direction of the pixels in the inscribed matrix in the overlapping area according to the overlapping relationship of adjacent images, and calculates the minimum average path cost from each pixel in the inscribed matrix in the overlapping area to the starting pixel in sequence to construct the minimum average path cost matrix. Finally, according to the minimum average path cost function, starting from the terminating pixel, the previous pixel is deduced backward in sequence until the starting pixel is reached, and the optimal path between these two pixels is obtained as the optimal stitching line between adjacent images.
[0101] It should be understood that the parts not elaborated in detail in this specification all belong to the prior art.
[0102] It should be understood that the above description of the preferred embodiment is relatively detailed and should not be considered as a limitation on the protection scope of the invention patent of the present invention. Under the inspiration of the present invention, without departing from the protection scope defined by the claims of the present invention, those of ordinary skill in the art can also make substitutions or modifications, which all fall within the protection scope of the present invention. The scope of protection claimed by the present invention shall be subject to the appended claims.
Claims
1. A dynamic programming optimal stitching line detection method based on the shortest matrix path, characterized in that It includes the following steps: Step 1: According to the geographic coordinate information of adjacent high-spatial-resolution remote sensing images to be spliced, obtain the overlapping relationship and the range of the overlapping area of adjacent images. According to the overlapping relationship of adjacent images, determine the starting pixel coordinates and ending pixel coordinates of the optimal splicing line. Then, calculate the four-corner coordinates of the inscribed matrix in the overlapping area through the diagonal pixel coordinates, and determine the detection direction of the pixels in the inscribed matrix in the overlapping area; Step 2: Jointly establish a cost function for describing the pixel difference magnitude in the inscribed matrix from three aspects: intensity difference, gradient difference, and geometric structure difference. Calculate the cost magnitudes of all pixels in the inscribed matrix in the overlapping area according to the cost function, and establish an inscribed pixel cost matrix for the overlapping area of adjacent images; In the above Step 2, the specific method for constructing the cost function is as follows: Step 2.1: First, construct an intensity difference function; construct an intensity difference function in the HSI color space, calculate the sum of the absolute values of the intensity differences within the 3×3 neighborhood of each pixel in the inscribed matrix in the overlapping area, and then take the average value as the intensity difference magnitude of the pixel. The specific formula is as follows: Among them, C d (x, y) represents the intensity difference magnitude of the pixel (x, y), respectively represent the intensity components of the pixels with coordinates (x, y) in the HSI color space in the images f and g, and i and j represent the 3×3 neighborhood range; Step 2.2: Construct a gradient difference function. Under the RGB color space, calculate the minimum value of the first-order differential gradient between the current pixel and the pixel in the next detection direction in the inscribed matrix of the overlapping area of the image as the gradient difference magnitude of the pixel. The specific formula is as follows: Among them, C e (x, y) represents the gradient difference magnitude of the pixel (x, y), and grad f (x m , y m ), grad g (x m , y m ) represents the first-order differential gradient between the pixels with coordinates (x, y) in the images f and g and the pixels in the m-th search direction; Step 2.3: Construct a geometric structure difference function. Under the RGB color space, use the eight-direction Sobel operator to calculate the Sobel gradient value of the pixels in the inscribed matrix in the overlapping area, and obtain the geometric structure difference magnitude of the pixel by summation. The specific formula is as follows: Among them, C k (x, y) represents the geometric structure difference magnitude of the pixel (x, y), and G t (x, y) represents the Sobel gradient in the t-th direction, and S t represents the Sobel operator in the t-th direction. t takes values from 1 to 8, indicating 8 directions, and f n (x, y), and g n (x, y) are respectively the pixel values of the n-th band of the pixel with coordinates (x, y) in the RGB color space of the image f and the image g; Step 2.4: After obtaining the three sub-functions of the pixel cost function, assign different weights to the intensity difference function, the gradient difference function, and the geometric structure difference function respectively to form the final pixel cost function. The specific formula is as follows: C(x,y) = C d (x,y) + αC e (x,y) + βC k (x,y) where α and β are empirical values used to balance the weights of the three parts of the cost function; Step 3: Based on the pixel cost matrix, use the dynamic programming method to sequentially solve the minimum average path cost from each pixel in the inscribed matrix to the starting pixel, and construct an inscribed minimum average path cost matrix for the overlapping area; Step 4: According to the minimum average path cost matrix, reverse-deduce the "shortest path" from each pixel to the starting pixel. The "shortest path" from the ending pixel to the starting pixel is the optimal splicing line between adjacent images.
2. The dynamic programming optimal splicing line detection method based on the shortest matrix path according to claim 1, wherein: In the above Step 1, the specific method for determining the starting pixel coordinates and ending pixel coordinates of the optimal splicing line, and the detection direction of the pixels in the inscribed matrix in the overlapping area is as follows: Step 1.1: Judge the overlapping relationship of the images according to the positional relationship of the four-corner coordinates of adjacent images, which is divided into two types: upper left - lower right and lower left - upper right; Step 1.2: If the adjacent images overlap in the upper left - lower right manner, the starting pixel is the upper right corner pixel of the overlapping area, and the ending pixel is the lower left corner pixel; if the adjacent images overlap in the lower left - upper right manner, the starting pixel is the upper left corner pixel of the overlapping area, and the ending pixel is the lower right corner pixel. Step 1.3, if the adjacent images are overlapped in the upper-left to lower-right direction, the pixels in the last row of the inscribed matrix can only be detected in the left direction, the pixels in the first column can be detected in the downward and lower-right directions, the pixels in the last column can be detected in the left, lower-left, and downward directions, and the remaining pixels can be detected in the left, lower-left, downward, and lower-right directions; if the adjacent images are overlapped in the lower-left to upper-right direction, the pixels in the last row of the inscribed matrix can only be detected in the right direction, the pixels in the last column can be detected in the downward and lower-left directions, the pixels in the first column can be detected in the right, lower-right, and downward directions, and the remaining pixels can be detected in the right, lower-right, downward, and lower-left directions.
3. The dynamic programming optimal splicing line detection method based on the shortest matrix path according to claim 2, characterized in that: The 8 directions are 0°, 45°, 90°, 135°, 180°, 225°, 270°, and 315°.
4. A dynamic programming optimal splicing line detection method based on the shortest matrix path according to claim 1, characterized in that: In the said Step 3, the specific steps for constructing the inscribed minimum average path cost matrix in the overlapping area are as follows: Set the overlapping relationship of adjacent images as upper-left to lower-right overlap, the starting pixel as the pixel in the upper-right corner of the inscribed matrix, and the ending pixel as the pixel in the lower-left corner of the inscribed matrix. Using the idea of dynamic programming, successively solve the minimum average path cost from each pixel in the inscribed matrix in the overlapping area to the starting pixel. Step 3.1, calculate the minimum average path cost of the pixels in the first row of the inscribed matrix in the overlapping area. Due to the limitation of the search direction, the previous pixel of the pixels in the first row can only be the pixel to its right. Then the calculation formula for the minimum average path cost of the pixels in the first row is: Step 3.2, calculate the minimum average path cost of the pixels in the last column of the inscribed matrix in the overlapping area. The previous pixel of the pixels in the last column can be the pixel above it or the pixel above and to its left. Then the calculation formula for the minimum average path cost of the pixels in the last column is: Step 3.3, calculate the minimum average path cost of the pixels in the first column of the inscribed matrix in the overlapping area. The previous pixel of the pixels in the first column can only be the pixel above it, the pixel above and to its right, or the pixel to its right. Then the calculation formula for the minimum average path cost of the pixels in the first column is: Step 3.4, calculate the minimum average path cost of the pixels in the middle area of the inscribed matrix in the overlapping area. The previous pixel of the pixels in the middle area can be the pixel above and to its left, the pixel above it, the pixel above and to its right, or the pixel to its right. Then the calculation formula for the minimum average path cost of the pixels in the middle area is: PC in the above formula (x,y) represents the minimum average path cost from the pixel point (x, y) to the starting pixel, and L (x,y) represents the optimal path length from the pixel point (x, y) to the starting pixel, and the Min function takes the smallest one of them.
5. The dynamic programming optimal splicing line detection method based on the shortest matrix path according to claim 1, characterized in that: In the said Step 3, the specific steps for constructing the inscribed minimum average path cost matrix in the overlapping area are as follows: Set the overlapping relationship of adjacent images as lower-left to upper-right overlap, the starting pixel as the pixel in the upper-left corner of the inscribed matrix, and the ending pixel as the pixel in the lower-right corner of the inscribed matrix. Using the idea of dynamic programming, successively solve the minimum average path cost from each pixel in the inscribed matrix in the overlapping area to the starting pixel. Step 3.1, calculate the minimum average path cost of the pixels in the first row of the inscribed matrix in the overlapping area. Due to the limitation of the search direction, the previous pixel of the pixels in the first row can only be the pixel to its left. Then the calculation formula for the minimum average path cost of the pixels in the first row is: Step 3.2, calculate the minimum average path cost of the pixels in the first column of the inscribed matrix in the overlapping area. The previous pixel of the pixels in the last column can be the pixel above it or the pixel above and to its right. Then the calculation formula for the minimum average path cost of the pixels in the first column is: Step 3.3: Calculate the minimum average path cost of the pixels in the last column of the inscribed matrix in the overlapping area. The previous pixel of the pixels in the last column can only be the pixel above it, the pixel in the upper left, or the pixel to its left. The formula for calculating the minimum average path cost of the pixels in the first column is as follows: Step 3.4: Calculate the minimum average path cost of the pixels in the middle area of the inscribed matrix in the overlapping area. The previous pixel of the pixels in the middle area can be the pixel in the upper left, above it, the pixel in the upper right, or the pixel to its left. The formula for calculating the minimum average path cost of the pixels in the middle area is as follows: PC in the above formula (x,y) represents the minimum average path cost from pixel point (x, y) to the starting pixel, and L (x,y) represents the optimal path length from pixel point (x, y) to the starting pixel, and the Min function takes the smallest one of them.
6. The dynamic programming optimal splicing line detection method based on the shortest matrix path according to claim 1, wherein: In the said Step 4, the specific steps for solving the optimal path from the termination pixel to the start pixel are as follows: Starting from the termination pixel, according to the minimum average path cost value of the termination pixel and the formula for calculating the minimum average path cost in Step 3, deduce the previous pixel of the termination pixel, record the coordinates of this pixel, and then use this pixel as the "termination pixel", and deduce the previous pixel through the minimum average path cost value of this pixel and the formula in Step 3, record the pixel coordinates, and successively iterate to deduce the coordinates of the previous pixel until reaching the start pixel. Connect the coordinates of these pixels deduced backwards to obtain the optimal path between the start pixel and the termination pixel, which is the optimal stitching line between adjacent images.
Citation Information
Patent Citations
Method and system for searching optimal splicing lines among orthographic images based on gradient domain
CN106709897A
Rapid suture line optimization method for panoramic image stitching
CN113506216A