Spanning tree-based microscopic image scanning and parallel efficient splicing method
Through spanning tree algorithm and multi-threading technology, the splicing failure problem caused by no obvious feature areas in microscopic image stitching is solved, and high-precision and efficient image stitching are achieved.
Patent Information
- Application Number
- CN202510424666.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-07
- Publication Date
- 2025-07-11
AI Technical Summary
The existing microscopic image stitching technology is prone to failure when there are no obvious feature areas, and the calculation is complex or misaligned, so it is impossible to efficiently splice multiple small-field images into large-field images.
A microscopic image scanning method based on spanning tree is used to estimate adjacent image overlapping regions as template matching algorithms, and global stitching points are calculated in combination with the spanning tree algorithm, and high-speed stitching is used to perform high-speed stitching.
High-precision and high-efficiency splicing of microscopic images are achieved, single-direction splicing errors are eliminated, and multi-threading is used to complete splicing tasks.
Smart Images

Figure CN120298213A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of microscope imaging, and in particular to a microscopic image scanning and parallel efficient stitching method based on a spanning tree. Background Art
[0002] Manual microscopy has problems such as small observation fields of view, high time and labor costs in the field of observation. At the same time, due to the easy oxidation of the sections by air, the sections deteriorate, and there are difficulties in reexamination. Using digital section technology for digital storage and preservation, and then observation can effectively solve the above difficulties. The primary problem faced by digital section technology is how to stitch multiple small-field images into a large-field image. Currently, existing image stitching technologies can be divided into two categories: one is the microscopic image stitching technology based on feature points; this technology first extracts the corner features of adjacent images, and then performs feature matching based on the corners. The stitching technology based on feature point matching has the advantage of good adaptability, but its disadvantages are complex calculations and the need for sufficient features. Especially when there are no obvious features in the overlapping area between adjacent images, not enough feature points can be extracted, resulting in image stitching failure; the other is the microscopic image stitching technology based on template matching. This technology uses a known small image and then searches for the most similar position in the large image. The disadvantage of this method is that the overlapping area range needs to be delimited in advance, and a sliding window method is used for searching within the overlapping area range. It has the advantage of fast calculation speed compared with feature point matching, but it also faces the problem of misalignment matching when there are no obvious feature areas between adjacent images. Summary of the Invention
[0003] The purpose of the present invention is to overcome the deficiencies of the prior art and provide a microscopic image scanning and parallel efficient stitching method based on a spanning tree, which realizes adjacent image matching, high-precision matching of global stitching points based on a spanning tree, and multi-threaded high-speed image stitching technology.
[0004] To achieve the above purpose, the technical solution provided by the present invention is: a microscopic image scanning and parallel efficient stitching method based on a spanning tree, including the following steps:
[0005] 1) Obtain multiple cell images within a rectangular scanning area M×N to form a set {P 1,1 , P 1,2 ,..., P m,n}, where M represents the number of scanning rows of the platform, N represents the number of scanning columns, and P m,n represents the scanning image of the m-th row and the n-th column;
[0006] 2) Estimate the overlapping area of adjacent images as the matching template of the template matching algorithm according to the scanning parameters, and calculate the matching results of any two adjacent images;
[0007] 3) Calculate the spanning tree based on the matching results and calculate the global stitching points;
[0008] 4) Perform multi-threaded parallel stitching of images based on the global stitching points.
[0009] Furthermore, step 1) includes the following steps:
[0010] 101) Set parameters: Set the number of scanning rows M of the platform, the number of scanning columns N, and the distance X that the platform moves once along the X-axis direction distance , and the distance Y that the platform moves once along the Y-axis direction distance ;
[0011] 102) According to the above set parameters, continuously collect multiple cell images within the M×N area to form a set {P 1,1 , P 1,2 ,..., P m,n}.
[0012] Furthermore, step 2) includes the following steps:
[0013] 201) According to the platform parameter settings, calculate the coordinates and size of the estimated overlapping area. If images P1 and P2 are adjacent on the left and right, the coordinates and size of the estimated overlapping area with the upper left corner of image P1 as the origin are:
[0014]
[0015] In the formula, X overlap represents the X-axis coordinate of the estimated overlapping area, Y overlap represents the Y-axis coordinate of the estimated overlapping area, W overlap represents the width of the estimated overlapping area in pixels, Y overlap represents the height of the estimated overlapping area in pixels, X distance represents the physical distance that the platform moves once along the X-axis, W view represents the physical width of the image shooting area, W p1 represents the width of the image in pixels, H p1 represents the height of the image in pixels;
[0016] If images P1 and P2 are adjacent above and below, the coordinates and size of the estimated overlapping area on P1 are:
[0017]
[0018] In the formula, Y distance represents the physical distance that the platform moves once along the Y-axis, H view represents the physical height of the image shooting area;
[0019] 202) The preset range in the center of the estimated overlapping area is intercepted as a template, and the estimated overlapping area is traversed by a sliding window method, and the similarity R(x, y) between the template and the estimated overlapping area when the template is offset by a length x, y along the X and Y axis directions is calculated, wherein the similarity calculation formula is as follows:
[0020]
[0021] Where x and y represent the window offset values along the X and Y axis directions, that is, the coordinate offset value of the image window of the template corresponding to the image window of the estimated overlapping area; where i′=x+i, j′=y+j; h and w represent the image height and width of the template, respectively; T i,j Represents the pixel value of the i-th row and j-th column of the template image; Represents the average value of all pixels in the template image; I i′,j′ The pixel value of the i′th row and j′th column of the image window representing the estimated overlapping area; Represents the average value of all pixels in the image window of the estimated overlapping area; the numerator minus the mean is to centralize the template and the estimated overlapping area image to eliminate the influence of the overall brightness on the matching result. The variance of the image reflects the overall deviation. The denominator uses the variance to ensure that the image and template have the same scale when matching, so that the similarity is limited to [-1,1];
[0022] 203) calculating the similarity matching results of all windows, taking the maximum value as the final matching result, and obtaining the image offset value information; wherein the value range of the similarity calculation result is [-1, 1], when the two images are completely the same, the maximum value 1 is obtained, and when the two images are completely inverted, the minimum value -1 is obtained;
[0023] 204) Calculate the similarity matching results between any other image and its right and bottom images. x,y , the matching results are as follows:
[0024]
[0025] In the formula, X r Represents the right image P x+1,y Relative to P x,y X-axis offset value, Y r Represents the right image P x+1,y Relative to P x,y The Y-axis offset value, R r Represents the credibility of the matching result, X d Represents the lower image P x,y+1 Relative to P x,y X-axis offset value, Y d Represents the lower image P x,y+1Relative to P x,y The Y-axis offset value, R d represents the confidence level of the matching result.
[0026] Furthermore, step 3) includes the following steps:
[0027] 301) Starting from the starting image P at the upper left corner using the Prim spanning tree algorithm 1,1 calculate the spanning tree with the P 1,1 image as the root image, and calculate the global stitching points of all sub-images according to the parent-child image relationship within the spanning tree. First, mark its global stitching points as (0, 0) and record and mark them as visited;
[0028] 302) From the set of visited images, find a new image with the highest confidence level among all matching results, add it to the spanning tree, and mark it as visited. Then, calculate the full-set stitching points of this new image according to the global stitching points (X p , Y p ) of its parent image and the matching result:
[0029]
[0030] In the formula, X p represents the X-axis coordinate value of the global stitching points of its parent image, Y p represents the Y-axis coordinate value of the global stitching points of its parent image, X s represents the X-axis relative offset value of the matching result in step 2), and Y s represents the Y-axis relative offset value of the matching result in step 2);
[0031] 303) Repeat step 302) until all images are marked as visited and added to the spanning tree, finally forming a spanning tree with the P 1,1 image as the root image, and the global stitching points of all images have been calculated.
[0032] Furthermore, step 4) includes the following steps:
[0033] 401) Divide all images into 4 categories according to their position numbers: odd rows and odd columns, odd rows and even columns, even rows and even columns, even rows and odd columns;
[0034] 402) Start min(M * N / 4, S limit ) threads, where M and N respectively represent the number of rows and columns set in step 1), and S limit represents the upper limit of the number of threads that the CPU can actually run simultaneously, and min represents taking the minimum of the two;
[0035] 403) Each thread selects an unstitched image from the set of images belonging to the odd rows and odd columns, copies the image to the stitched image Pano according to the globally calculated stitching points in step 3), and marks it as stitched;
[0036] 404) Each thread selects an unstitched image from the set of images belonging to the odd rows and even columns, stitches the image onto the stitched image Pano according to the globally calculated stitching points in step 3). At this time, both the left and right sides are stitched images, and there is an overlapping area. For the non-overlapping area, the direct copy method is used, and for the overlapping area, a fusion algorithm is used for smoothing. The pixel value I(x′,y′) after fusion of the overlapping area is calculated by the following formula:
[0037]
[0038] In the formula, x′ and y′ respectively represent the X-axis coordinate and Y-axis coordinate with the upper left corner of the stitched image Pano as the origin; X1 and Y1 respectively represent the globally calculated stitching points of the left image; I1 is the area occupied by the left cell image in the stitched image Pano; I1(x′ - X1, y′ - Y1) is the pixel value of the x′ - X1 row and y′ - Y1 column of the left image; X2 and Y2 respectively represent the globally calculated stitching points of the right image; I2 is the area occupied by the right cell image in the stitched image Pano; I2(x′ - X2, y′ - Y2) is the pixel value of the x′ - X2 row and y′ - Y2 column of the right image; ω1 and ω2 are weight coefficients, 0 < ω1, ω2 < 1 and ω1 + ω2 = 1; among them, the calculation formula for the stitching weight coefficient in the X-axis direction is as follows:
[0039]
[0040] ω1 = 1 - ω2
[0041] In the formula, W′ overlap is the width of the overlapping area;
[0042] 405) Each thread selects an unstitched image from the set of images belonging to the even rows and odd columns, stitches the image onto the stitched image Pano according to the globally calculated stitching points in step 3). At this time, both the upper and lower sides are stitched images, and the same formula as in step 404) is used for fusion. The calculation formula for the stitching weight coefficient in the Y-axis direction is as follows:
[0043]
[0044] ω1 = 1 - ω2
[0045] In the formula, H′ overlap is the height of the overlapping area;
[0046] 406) Each thread selects an unstitched image from the set of images belonging to the even rows and even columns of the image, and stitches the image onto the stitched image Pano according to the global stitching points calculated in step 3). At this time, the four sides are all stitched images, and fusion is performed using the same formula as in step 404). The formula in step 404) is used for the weight in the X-axis direction, and the formula in step 405) is used for the weight in the Y-axis direction.
[0047] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0048] The present invention fully considers the characteristics of no distortion in the microscope scanning perspective and the invariance of the correspondence between the physical scale and pixel scale of the microscope platform, and based on the advantages of the template-based image matching algorithm, automatically divides the overlapping area range for the template matching algorithm, and fully considers the credibility of the matching results of the surrounding adjacent edge images. The global stitching points are calculated using the spanning tree algorithm to eliminate the errors caused by the lack of obvious features in the stitching in a single direction, and can make full use of multiple threads to complete high-speed stitching. The microscopic image scanning and parallel efficient stitching method provided by the present invention is a multi-thread stitching method based on template matching and the spanning tree algorithm, realizing high-precision and high-efficiency stitching of microscopic images, which is worthy of popularization. Description of the Drawings
[0049] Figure 1 is the flowchart of the method provided by the embodiment of the present invention.
[0050] Figure 2 is the schematic diagram of template matching provided by the embodiment of the present invention.
[0051] Figure 3 is the schematic diagram of spanning tree calculation provided by the embodiment of the present invention.
[0052] Figure 4 is the schematic diagram of multi-thread stitching provided by the embodiment of the present invention.
[0053] Figure 5 is the schematic diagram of adjacent image stitching provided by the embodiment of the present invention. Detailed Embodiments
[0054] The present invention will be further described in detail below with reference to the embodiments and the drawings, but the embodiments of the present invention are not limited thereto.
[0055] Refer to Figures 1 to 5 As shown, this embodiment discloses a microscopic image scanning and parallel efficient stitching method based on a spanning tree, and the specific situation is as follows:
[0056] 1) Obtain multiple cell images within the rectangular scanning area M×N to form a set {P 1,1 , P 1,2 ,..., Pm,n}, where M represents the number of rows scanned by the platform, N represents the number of columns scanned, and P m,n represents the scanned image of the m-th row and the n-th column, including the following steps:
[0057] 101) Set parameters: Set the number of rows M scanned by the platform, the number of columns N scanned, and the single movement distance X of the platform in the X-axis direction distance and the single movement distance Y in the Y-axis direction distance ;
[0058] 102) According to the above-set parameters, continuously collect multiple cell images in the M×N area to form a set {P 1,1 , P 1,2 ,..., P m,n}.
[0059] 2) Estimate the overlapping area of adjacent images as the matching template for the template matching algorithm, and calculate the matching results of any two adjacent images, including the following steps:
[0060] 201) According to the platform parameter settings, calculate the coordinates and size of the estimated overlapping area. If images P1 and P2 are adjacent on the left and right, the coordinates and size of the estimated overlapping area with the upper left corner of image P1 as the origin are:
[0061]
[0062] In the formula, X overlap represents the X-axis coordinate of the estimated overlapping area, Y overlap represents the Y-axis coordinate of the estimated overlapping area, W overlap represents the width of the estimated overlapping area in pixels, Y overlap represents the height of the estimated overlapping area in pixels, X distance represents the physical distance of the platform moving once in the X-axis direction, W view represents the physical width of the image shooting area, W p1 represents the width of the image in pixels, H p1 represents the height of the image in pixels;
[0063] If images P1 and P2 are adjacent above and below, the coordinates and size of the estimated overlapping area on P1 are:
[0064]
[0065] In the formula, Y distance represents the physical distance of the platform moving once in the Y-axis direction, H view represents the physical height of the image shooting area;
[0066] 202) The preset range in the center of the estimated overlapping area is intercepted as a template, and the estimated overlapping area is traversed by a sliding window method, and the similarity R(x, y) between the template and the estimated overlapping area when the template is offset by a length x, y along the X and Y axis directions is calculated, wherein the similarity calculation formula is as follows:
[0067]
[0068] Where x and y represent the window offset values along the X and Y axis directions, that is, the coordinate offset value of the image window of the template corresponding to the image window of the estimated overlapping area; where i′=x+i, j′=y+j; h and w represent the image height and width of the template, respectively; T i,j Represents the pixel value of the i-th row and j-th column of the template image; Represents the average value of all pixels in the template image; I i′,j′ The pixel value of the i′th row and j′th column of the image window representing the estimated overlapping area; Represents the average value of all pixels in the image window of the estimated overlapping area; the numerator minus the mean is to centralize the template and the estimated overlapping area image to eliminate the influence of the overall brightness on the matching result. The variance of the image reflects the overall deviation. The denominator uses the variance to ensure that the image and template have the same scale when matching, so that the similarity is limited to [-1,1];
[0069] 203) calculating the similarity matching results of all windows, taking the maximum value as the final matching result, and obtaining the image offset value information; wherein the value range of the similarity calculation result is [-1, 1], when the two images are completely the same, the maximum value 1 is obtained, and when the two images are completely inverted, the minimum value -1 is obtained;
[0070] 204) Calculate the similarity matching results between any other image and its right and bottom images. x,y , the matching results are as follows:
[0071]
[0072] Where, X r Represents the right image P x+1,y Relative to P x,y X-axis offset value, Y r Represents the right image P x+1,y Relative to P x,y The Y-axis offset value, R r Represents the credibility of the matching result, X d Represents the lower image P x,y+1 Relative to P x,y X-axis offset value, Y d Represents the lower image P x,y+1Relative to P x,y The Y-axis offset value, R d represents the confidence level of the matching result.
[0073] 3) Calculate the spanning tree based on the matching results and calculate the global stitching points, including the following steps:
[0074] 301) Starting from the top-left starting image P 1,1 calculate the spanning tree with the P 1,1 image as the root image, and calculate the global stitching points of all sub-images according to the parent-child image relationship within the spanning tree. First, mark its global stitching points as (0, 0) and record and mark it as visited;
[0075] 302) From the set of visited images, find a new image with the maximum confidence level among all matching results, add it to the spanning tree, and mark it as visited. Then, calculate the global stitching points of this new image according to the global stitching points (X p , Y p ) of its parent image and the matching results:
[0076]
[0077] where X p represents the X-axis coordinate value of the global stitching points of its parent image, Y p represents the Y-axis coordinate value of the global stitching points of its parent image, X s represents the X-axis relative offset value of the matching result in step 2), and Y s represents the Y-axis relative offset value of the matching result in step 2);
[0078] 303) Repeat step 302) until all images are marked as visited and added to the spanning tree, finally forming a spanning tree with the P 1,1 image as the root image, and the global stitching points of all images have been calculated.
[0079] 4) Perform multi-threaded parallel stitching of images according to the global stitching points, including the following steps:
[0080] 401) Divide all images into 4 categories according to their position numbers: odd rows and odd columns, odd rows and even columns, even rows and even columns, even rows and odd columns;
[0081] 402) Start min(M * N / 4, S limit ) threads, where M and N respectively represent the number of rows and columns set in step 1), and S limit represents the upper limit of the number of threads that the CPU can actually run simultaneously, and min represents taking the minimum of the two;
[0082] 403) Each thread selects an unstitched image from the set of images belonging to the odd rows and odd columns, copies the image to the stitched image Pano according to the global stitching points calculated in step 3), and marks it as stitched;
[0083] 404) Each thread selects an unstitched image from the set of images belonging to the odd rows and even columns, stitches the image onto the stitched image Pano according to the global stitching points calculated in step 3). At this time, both the left and right sides are stitched images, and there is an overlapping area. For the non-overlapping area, the direct copy method is used, and for the overlapping area, a fusion algorithm is used for smooth processing. The pixel value I(x′,y′) after fusion of the overlapping area is calculated by the following formula:
[0084]
[0085] In the formula, x′ and y′ respectively represent the X-axis coordinate and Y-axis coordinate with the upper left corner of the stitched image Pano as the origin; X1 and Y1 respectively represent the global stitching points of the left image; I1 is the area occupied by the left cell image in the stitched image Pano; I1(x′ - X1, y′ - Y1) is the pixel value of the x′ - X1 row and y′ - Y1 column of the left image; X2 and Y2 respectively represent the global stitching points of the right image; I2 is the area occupied by the right cell image in the stitched image Pano; I2(x′ - X2, y′ - Y2) is the pixel value of the x′ - X2 row and y′ - Y2 column of the right image; ω1 and ω2 are weight coefficients, 0 < ω1, ω2 < 1 and ω1 + ω2 = 1; among them, the calculation formula for the stitching weight coefficient in the X-axis direction is as follows:
[0086]
[0087] ω1 = 1 - ω2
[0088] In the formula, W′ overlap is the width of the overlapping area;
[0089] 405) Each thread selects an unstitched image from the set of images belonging to the even rows and odd columns, stitches the image onto the stitched image Pano according to the global stitching points calculated in step 3). At this time, both the upper and lower sides are stitched images, and the same formula as in step 404) is used for fusion. Among them, the calculation formula for the stitching weight coefficient in the Y-axis direction is as follows:
[0090]
[0091] ω1 = 1 - ω2
[0092] In the formula, H′ overlap is the height of the overlapping area;
[0093] 406) Each thread selects an unstitched image from the set of images belonging to the even rows and even columns, and stitches the image onto the stitched image Pano according to the global stitching points calculated in step 3). At this time, the four sides are all stitched images, and the same formula in step 404) is used for fusion. The formula in step 404) is used for the X-axis direction weight, and the formula in step 405) is used for the Y-axis direction weight.
[0094] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications made without departing from the spirit and principle of the present invention shall be equivalent replacement methods and are all included in the protection scope of the present invention.
Claims
1. A microscopic image scanning and parallel efficient stitching method based on a spanning tree, characterized in that The following steps are involved: 1) Obtain multiple cell images within the rectangular scanning area of M×N to form a set {P 1,1 , P 1,2 ,..., P m,n}, where M represents the number of scanning rows of the platform, N represents the number of scanning columns, and P m,n represents the scanning image of the m-th row and the n-th column; 2) Estimate the overlapping area of adjacent images based on the scanning parameters as the matching template of the template matching algorithm, and calculate the matching results of any two adjacent images; 3) Calculate the spanning tree based on the matching results and calculate the global splicing points; 4) Perform multi-threaded parallel stitching of images based on global stitching points.
2. The method for microscopic image scanning and parallel efficient stitching based on a spanning tree according to claim 1, wherein, The step 1) comprises the following steps: 101) Set parameters: Set the number of scanning rows M of the platform, the number of scanning columns N, and the single moving distance X of the platform in the X-axis direction distance , and the single moving distance Y in the Y-axis direction distance ; 102) According to the above set parameters, continuously collect multiple cell images within the M×N region to form a set {P 1,1 , P 1,2 ,..., P m,n}.
3. The method for microscopic image scanning and parallel efficient stitching based on a spanning tree according to claim 2, wherein The step 2) comprises the following steps: 201) According to the platform parameter settings, the coordinates and size of the estimated overlapping area are calculated. If the images P1 and P2 are adjacent to each other, the coordinates and size of the estimated overlapping area with the upper left corner of the image P1 as the origin are: Wherein, X overlap represents the X-axis coordinate of the estimated overlapping area, Y overlap represents the Y-axis coordinate of the estimated overlapping area, W overlap represents the width of the estimated overlapping area in pixels, Y overlap represents the height of the estimated overlapping area in pixels, X distance represents the physical distance of one movement of the platform along the X-axis, W view represents the physical width of the image capture area, W p1 represents the width of the image in pixels, H p1 represents the height of the image in pixels; If images P1 and P2 are adjacent to each other, the estimated coordinates and size of the overlapping area on P1 are: where Y distance represents the physical distance of one movement of the platform along the Y-axis, and H view represents the physical height of the image capture area; 202) The preset range in the center of the estimated overlapping area is intercepted as a template, and the estimated overlapping area is traversed by a sliding window method, and the similarity R(x, y) between the template and the estimated overlapping area when the template is offset by a length x, y along the X and Y axis directions is calculated, wherein the similarity calculation formula is as follows: In the formula, x and y respectively represent the window offset values along the X and Y axes, that is, the coordinate offset values of the image window of the template corresponding to the image window of the estimated overlapping region; where i' = x + i, j' = y + j; h and w respectively represent the height and width of the image of the template; T i,j represents the pixel value of the i-th row and j-th column of the image of the template; represents the average value of all pixels within the image of the template; I i′,j′ represents the pixel value of the i'-th row and j'-th column of the image window of the estimated overlapping region; represents the average value of all pixels of the image window of the estimated overlapping region; where subtracting the mean value in the numerator part is to centralize the template and the image of the estimated overlapping region to eliminate the influence of the overall brightness on the matching result, and the variance of the image reflects the overall deviation degree. Using the variance in the denominator part is to ensure that the image and the template have the same scale during matching, so that the similarity is restricted between [-1, 1]; 203) calculating the similarity matching results of all windows, taking the maximum value as the final matching result, and obtaining the image offset value information; wherein the value range of the similarity calculation result is [-1, 1], when the two images are completely the same, the maximum value 1 is obtained, and when the two images are completely inverted, the minimum value -1 is obtained; 204) Calculate the similarity matching results between any other arbitrary image and the images on its right and below. For any image P x,y , there are the following matching results: In the formula, X r represents the X-axis offset value of the right image P x+1,y relative to P x,y ; Y r represents the Y-axis offset value of the right image P x+1,y relative to P x,y ; R r represents the confidence level of the matching result; X d represents the X-axis offset value of the lower image P x,y+1 relative to P x,y ; Y d represents the Y-axis offset value of the lower image P x,y+1 relative to P x,y ; R d represents the confidence level of the matching result.
4. A method for microscopic image scanning and parallel efficient stitching based on a spanning tree according to claim 3, characterized in that, The step 3) comprises the following steps: (301) Starting from the top-left starting image P, use the Prim's spanning tree algorithm to calculate the spanning tree with the P image as the root image, and calculate the global stitching points of all sub-images according to the parent-child image relationship within the spanning tree. First, mark its global stitching points as (0, 0) and record and mark them as visited; 1,1 Start from 1,1 the P image, calculate the spanning tree with the P image as the root image, and calculate the global stitching points of all sub-images according to the parent-child image relationship within the spanning tree. First, mark its global stitching points as (0, 0) and record and mark them as visited; (302) From the set of accessed images, find a new image with the highest confidence among all the matching results, add it to the spanning tree, mark it as accessed, and then calculate the full-set stitching points of this new image based on the global stitching points (X p , Y p ) of its parent image and the matching results: where X p represents the X-axis coordinate value of the global stitching point of its parent image, and Y p represents the Y-axis coordinate value of the global stitching point of its parent image, X s represents the relative X-axis offset value of the matching result in step 2), and Y s represents the relative Y-axis offset value of the matching result in step 2); 303) Repeat step 302) until all images are marked as visited and added to the spanning tree, finally forming a spanning tree with the P 1,1 image as the root image, and all global stitching points of the images have been calculated.
5. A microscopic image scanning and parallel efficient stitching method based on a spanning tree according to claim 4, characterized in that, The step 4) comprises the following steps: 401) Divide all images into 4 categories according to their position numbers: odd rows and odd columns, odd rows and even columns, even rows and even columns, and even rows and odd columns; 402) Start min(M*N / 4, S limit ) threads, where M and N respectively represent the number of rows and columns set in step 1), and S limit represents the upper limit of the number of threads that the CPU can actually run simultaneously, and min represents taking the minimum of the two; 403) Each thread selects an unjoined image from the image set belonging to the odd-numbered rows and odd-numbered columns, copies the image to the stitching map Pano according to the global stitching point calculated in step 3), and marks it as stitched; 404) Each thread selects an unjoined image from the image set belonging to the odd-numbered rows and even-numbered columns, and stitches the image onto the stitching map Pano according to the global stitching point calculated in step 3). At this time, both the left and right sides are stitched images, and there is an overlapping area. The non-overlapping area is directly copied, and the overlapping area is smoothed by a fusion algorithm. The pixel value I (x′, y′) after the overlapping area is fused is calculated by the following formula: Wherein, x′, y′ represent the X-axis coordinate and Y-axis coordinate with the upper left corner of the mosaic image Pano as the origin; X1, Y1 represent the global stitching point of the left image; I1 is the area occupied by the left cell image in the mosaic image Pano; I1(x′-X1, y′-Y1) is the pixel value of the x′-X1th row and y′-Y1th column of the left image; X2, Y2 represent the global stitching point of the left image; I2 is the area occupied by the right cell image in the mosaic image Pano; I2(x′-X2, y′-Y2) is the pixel value of the x′-X2th row and y′-Y2th column of the right image; ω1, ω2 are weight coefficients, 0<ω1, ω2<1 and ω1+ω2=1; wherein, the calculation formula of the stitching weight coefficient in the X-axis direction is as follows: ω1=1-ω2 where W′ overlap is the width of the overlapping region; 405) Each thread selects an unstitched image from the set of images belonging to the odd columns of the even rows, and stitches the image onto the stitched image Pano according to the global stitching points calculated in step 3). At this time, both the upper and lower sides are stitched images, and the same formula as in step 404) is used for fusion. The calculation formula for the stitching weight coefficient in the Y-axis direction is as follows: ω1 = 1 - ω2 where H′ overlap is the height of the overlapping region; 406) Each thread selects an unstitched image from the set of images belonging to the even columns of the even rows, and stitches the image onto the stitched image Pano according to the global stitching points calculated in step 3). At this time, all four sides are stitched images, and the same formula as in step 404) is used for fusion. The formula in step 404) is used for the weight in the X-axis direction, and the formula in step 405) is used for the weight in the Y-axis direction.
Citation Information
Cited By
Image splicing method and device, computer equipment and storage medium
CN120997045A
Image stitching method and device, computer device and storage medium
CN120997045B
