A mask-guided image inlaid line generation method and device, computer equipment and storage medium
The mask-guided image mosaic line generation method uses a graph cut algorithm to automatically generate image mosaic lines, solving the problems of low efficiency in manual editing and unstable automatic segmentation in existing technologies, and achieving efficient and accurate image mosaic line generation.
Patent Information
- Application Number
- CN202210865265.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-21
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2042-07-21
AI Technical Summary
Existing technologies for generating image mosaic lines suffer from problems such as high manual editing workload, low efficiency, and unstable results of automatic segmentation methods, making it difficult to meet the demand for rapid image output.
The mask-guided method automatically generates image mosaic lines through steps such as generating mask image files, initial mosaic line raster files, marked image files, image segmentation, and pixel value assignment. The mosaic lines are then calculated using a graph cut algorithm and vectorized.
It improves the accuracy and efficiency of image mosaic line generation, reduces the need for manual editing, and achieves efficient automatic generation of image mosaic lines.
Smart Images

Figure CN115170685B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of remote sensing data processing, in particular to a method and device for generating image mosaic lines. BACKGROUND
[0002] With the development of remote sensing technology, satellite remote sensing images have gradually become one of the most important sources of spatial data. In the process of splicing two or more orthographic images together to form a larger orthographic mosaic image, the most critical step is the generation of image mosaic lines. At present, part of the image mosaic lines is drawn by manual editing in GIS editing software such as ArcGIS, or the image mosaic lines are generated by using an image automatic segmentation method to calculate the splicing lines between two images, and then combined into the image mosaic lines in the region. The defect of manual editing is that the workload is large and the efficiency is low, which is difficult to meet the requirements of application scenarios requiring rapid mapping. The defect of the method of generating mosaic lines by segmentation is that it can only avoid part of the artificial features with obvious features, and the effect is very unstable, and still needs a lot of manual editing. SUMMARY
[0003] The purpose of the present application is to provide a mask-guided image mosaic line generation method and device to realize the automatic generation of image mosaic lines and improve the efficiency and accuracy of image mosaic line generation.
[0004] To achieve the above purpose, the present application provides a mask-guided image mosaic line generation method, comprising:
[0005] generating a mask image file according to the interpretation data;
[0006] generating an initial mosaic line raster file according to the to-be-mosaicked images;
[0007] calculating the position of the image range of the to-be-mosaicked images in the mask image file, and generating a mark image file for each to-be-mosaicked image;
[0008] segmenting the images and updating the mosaic line raster file according to the mask intersection of any two to-be-mosaicked images with intersection;
[0009] assigning a pixel value to each pixel in the updated mosaic line raster file until all intersecting images are assigned values;
[0010] vectorizing the mosaic line raster file to generate a mosaic line vector file.
[0011] The present application also provides a mask-guided image mosaic line generation device, comprising:
[0012] a mask image file generation module for generating a mask image file in a standard format;
[0013] An initial tessellation line raster file generation module is configured to generate an initial tessellation line raster file according to a merged image range of the images to be tessellated;
[0014] A mark image file generation module is configured to generate a mark image file of each image to be tessellated according to a position of an image range of the image to be tessellated in the mask image file;
[0015] A tessellation line raster file updating module is configured to split the images and update the tessellation line raster file according to a mask intersection of any two intersected images to be tessellated;
[0016] A pixel value assigning module is configured to assign a pixel value to each pixel in the updated tessellation line raster file until all intersected images are assigned with the pixel value;
[0017] A tessellation line vector file generation module is configured to vectorize the tessellation line raster file to generate a tessellation line vector file.
[0018] The application further discloses a computer device for generating mask-guided image tessellation lines, which comprises:
[0019] A processor is configured to store a memory for storing processor-executable instructions and a computer program stored on the memory and executable on the processor, and the processor implements the above method when executing the program.
[0020] The application further discloses a computer-readable storage medium having a computer program stored thereon, and the computer program is executed by a processor to implement the above method.
[0021] The application has the following advantages: the mask-guided image tessellation line generation method disclosed by the application considers the pixel value relationship between any point and a neighborhood position point in the mask intersection of the intersected images, obtains an adjustment weight of the pixel, performs stitching line calculation on the intersected images according to the adjustment weight, generates a binary mask, and obtains the pixel value of the intersected images in the tessellation, and updates the tessellation line raster file according to the pixel value, so that the tessellation line is more accurate, and the generation efficiency is greatly improved since the tessellation line is generated by a computer program. BRIEF DESCRIPTION OF DRAWINGS
[0022] Figure 1 is a flow block diagram of the mask-guided image tessellation line generation method of the embodiment of the application;
[0023] Figure 2 is a schematic diagram of converting the interpreted vector or raster file into a standard mask image file;
[0024] Figure 3ais a schematic diagram of the actual range of the three-scene image to be inlaid in the embodiment of the present application;
[0025] Figure 3b is a schematic diagram of the circumscribed rectangular range of the three-scene image to be inlaid in the embodiment of the present application;
[0026] Figure 3c is a schematic diagram of the merged range of the three-scene image to be inlaid in the embodiment of the present application;
[0027] Figure 4 is a schematic diagram of the positions of the inlaid image range and the local image range in the inlaid line grid file and the mask file in the embodiment of the present application;
[0028] Figure 5 is a schematic diagram of the modification of the connection weight of the graph cut energy function using a mask in the embodiment of the present application;
[0029] Figure 6 is a schematic diagram of the inlaid line after the intersection image is given different pixel values in the embodiment of the present application. DETAILED DESCRIPTION
[0030] The technical solutions of the embodiments of the present application will be described clearly and completely below with reference to the drawings of the present application.
[0031] The method for generating an image inlaid line guided by a mask disclosed in the embodiments of the present application, as shown in Figure 1 includes the following steps:
[0032] Step one, converting the existing interpreted data into a standard grid format mask image file, specifically including:
[0033] Judging the format type of the interpreted data, if it is a vector format, converting it according to the predefined classification system of the mask image rules, and then rasterizing it. If the interpreted data is a raster file and is already in a standard format, it is not processed, if it is not in a standard format, converting it according to the predefined rules to generate a standard raster format mask image file Mask. In combination with Figure 2 , the first column of data SrcClassA ~ SrcClassH is the vector data of the ground object categories such as buildings and roads, the second column of data SrcValueA ~ SrcValueH is the pixel value corresponding to the ground object category, and the third and fourth columns are the mask raster files converted into a standard format.
[0034] The rules of the mask image are defined according to actual needs, such as the following definitions:
[0035] Representative types Pixel value Meaning Building 1 Avoid tessellation line crossing Road 2 Priority crossing Water area 3 Priority crossing Other 255 Adapt general rule
[0036] Step two, generating an initial inlaid line grid file, in combination withFigures 3a-3c As shown, the specific method includes:
[0037] S21. Calculate the bounding rectangle of each scene to be mosaicked ( Figure 3b The three rectangles shown are denoted as the image range E to be mosaicked. i , where i = 1, 2, ..., n;
[0038] S22, Set the image range E of each scene to be mosaicked. i The images are merged to obtain the merged image range E. rst ( Figure 3c (The largest rectangle shown);
[0039] S23. Create an empty raster file, with the range and merged image range E. rst Similarly, if the resolution of the initial mosaic raster file (MosaicFile) is several times that of the image to be mosaicked, then this file is the initial mosaic line raster file (MosaicFile). For example, if the resolution of the initial mosaic line raster file (MosaicFile) is 10 times that of the image to be mosaicked, and the resolution of the image to be mosaicked is 2 meters, then the resolution of this file is 20 meters.
[0040] Step 3: Generate a labeled image file for each scene to be mosaicked. Specific methods include:
[0041] S31. Calculate the position of the image region Ei to be mosaicked in the mask image file Mask, such as... Figure 4 As shown, in this embodiment, this position includes the top-left row and column number (x). tl y tl ) and the row and column number in the lower right corner (x br y br );
[0042] S32. Based on the position calculated in step S31, crop out the local image from the mask image file Mask;
[0043] S33. Sample the resolution of the local image to be consistent with that of the initial mosaic raster file MosaicFile.
[0044] Step 4: Image segmentation and updating of the mosaic raster file, including the following methods:
[0045] S41. For any two intersecting images img(i) and img(j), calculate the intersection region ∩ij of the images img(i) and img(j);
[0046] S42. Find the marker image files corresponding to the images img(i) and img(j) to be mosaicked, and crop out the part covered by the intersection region ∩ij to obtain the mask intersection IntersectMask;
[0047] S43, calculate the unmasked graph cut algorithm energy function edge connection weight, the specific formula is:
[0048]
[0049] Where, Vec(I p ) represents a vector composed of three waveband p point eigenvalues, Vec(I p )-Vec(I q ) represents the eigenvalues of p, q two points corresponding to the waveband, dot represents the dot product of two vectors; σ3 is an index to evaluate the dispersion of the image, for calculating the energy function of the second order neighborhood, has
[0050]
[0051] Where, (p,q)∈N L Indicates that q is the point located in the left, left upper, upper, and right upper directions of p point;
[0052] S44, for any point (p, q) in the mask intersection IntersectMask, compare its relationship with the neighborhood pixels, such as the four fields (p, q+1), (p, q-1), (p+1, q), (p-1, q) pixel values, according to the pre-set rule of any point and field position point pixel value relationship, adjust the weight weight calculated in step S43, combined with Figure 5 As shown, the method is to multiply a coefficient λ on the calculated weight, such as the rule can be defined as:
[0053]
[0054] S45, based on the weight calculated in step S44, using graph cut algorithm to calculate the intersection region ∩ij of the images img(i) and img(j) to be mosaicked, generate binary mask BinaryMosaic(i,j), if the pixel value of binary mask BinaryMosaic(i,j) is i, then the mask corresponding region adopts the pixel value of img(i) in mosaicking, on the contrary, if the pixel value of binary mask BinaryMosaic(i,j) is j, then the mask corresponding region adopts the pixel value of img(j) in mosaicking.
[0055] Step five, write the segmentation results of two images into the initial mosaic line raster file MosaicFile generated in step two, until each pixel of the mosaic line raster file is assigned a value, combined with Figure 6 As shown, the specific steps are:
[0056] S51, find the range E iAt the position in the initial mosaic line grid file MosaicFile, if E i If any pixel in the range of MosaicFile has not been assigned, set the pixel value to i;
[0057] S52, find the position of the to-be-mosaicked image range E j At the position in the initial mosaic line grid file MosaicFile, if E j If any pixel in the range of MosaicFile has not been assigned, set the pixel value to j;
[0058] S53, find the position of the binary mask BinaryMosaic(i,j) in the initial mosaic line grid file MosaicFile, and set the pixel value of the range of MosaicFile to the value of BinaryMosaic(i,j).
[0059] Step six, process the next pair of mosaicked images according to step five until all intersecting images are processed.
[0060] Step seven, perform vectorization processing on the mosaic line grid file to generate a mosaic line vector file, and obtain the mosaic line of the image. For example, the GDALPolygonize function provided by GDAL (Geospatial Data Abstraction Library) is used to perform vectorization on the mosaic line grid file MosaicFile to generate a mosaic line vector file MosaicShp, and obtain the mosaic line of the image.
[0061] The technical content and technical features of the present application have been disclosed above, however, those skilled in the art can make various substitutions and modifications based on the teachings and disclosures of the present application without departing from the spirit of the present application, therefore, the protection scope of the present application should not be limited to the disclosed content of the embodiments, but should include various substitutions and modifications without departing from the present application, and is covered by the claims of the present patent application.
Claims
1. A method for generating a mask-guided image stitch line, characterized in that, The method comprises the following steps: generating a mask image file according to the interpreted data; generating an initial tessellation line raster file according to the image to be tessellated; calculating the position of the image range of the image to be tessellated in the mask image file, and generating a mark image file of each image to be tessellated; segmenting the images and updating the tessellation line raster file according to the mask intersection of any two intersecting images to be tessellated; assigning pixel values to each image in the updated tessellation line raster file until all intersecting images are assigned values; vectorizing the tessellation line raster file to generate a tessellation line vector file; wherein the step of segmenting the images and updating the tessellation line raster file comprises: for any two intersecting images to be tessellated, calculating the intersection image; finding the mark image file corresponding to the image to be tessellated, and cutting out the part covered by the intersection image to obtain the mask intersection; calculating the edge connection weight of the energy function of the graph cut algorithm without mask; for any point in the mask intersection, adjusting the weight according to the relationship between the pixel value of the point and the pixel value of the neighboring position point to obtain the adjusted weight; based on the adjusted weight, calculating the stitching line of the intersection image by the graph cut algorithm, generating a binary mask, and obtaining the pixel value of the intersection image in the tessellation, and updating the tessellation line raster file according to the pixel value.
2. The method of claim 1, wherein the mask-guided image stent line generation method is characterized by, The mask image file is a standard format mask image file, and its creation comprises: judging the format of the existing interpreted data: if the existing data is in vector format, converting it to a classification system according to a predefined rule, and then rasterizing it; if the existing interpreted data is in a non-standard format of a raster file, converting it to a classification system according to a predefined rule to generate a standard raster format mask image file; if the existing interpreted data is in a standard format of a raster file, it is not processed.
3. The method of claim 1, wherein the method further comprises: The initial tessellation line raster file is an empty raster file with a range equal to the merged image range of the image to be tessellated, and the resolution of the initial tessellation line raster file is several times that of the image to be tessellated.
4. The method of claim 1, wherein the method further comprises: The step of generating a mark image file of each image to be tessellated comprises: calculating the position of the image range of the image to be tessellated in the mask image file, and cutting out the local image at the position; sampling the resolution of the local image to be consistent with the initial tessellation line raster file.
5. The method of claim 1, wherein the method further comprises: The method for calculating the edge connection weight of the energy function of the graph cut algorithm without mask comprises: Weight= where denotes the three wavebands the vector of eigenvalues at a point, denotes , the difference between the eigenvalues of the two points for the corresponding waveband, denotes the dot product of two vectors; is an index that evaluates the image dispersion and is used to compute the energy function of the second order neighborhood: wherein denotes is a point located the left, top-left, top, top-right of the point.
6. The method of claim 1, wherein the method further comprises: The adjusted weight is obtained by multiplying a coefficient on the calculated weight according to the relationship between the pixel value of any point in the mask intersection and the pixel value of the neighboring position point.
7. A device for generating a mask-guided image mosaic line, characterized in that The method comprises the following steps: a mask image file generation module for generating a standard format mask image file; an initial tessellation line raster file generation module for generating an initial tessellation line raster file according to the merged image range of the image to be tessellated; a mark image file generation module for generating a mark image file of each image to be tessellated according to the position of the image range of the image to be tessellated in the mask image file; a tessellation line raster file updating module for segmenting the images and updating the tessellation line raster file according to the mask intersection of any two intersecting images to be tessellated; The pixel value assigning module is configured to assign pixel values to each image in the updated tessellation line raster file until all intersecting images are assigned values. The tessellation line vector file generating module is configured to vectorize the tessellation line raster file to generate a tessellation line vector file. The method comprises: For any two intersecting images to be tessellated, an intersecting image is calculated. A marked image file corresponding to the images to be tessellated is found, and the part covered by the intersecting image is cropped to obtain a mask intersection. The edge connection weight of the energy function of the graph cut algorithm without the mask is calculated. For any point in the mask intersection, the weight is adjusted according to the relationship between the pixel value of the point and the pixel values of the neighboring position points to obtain an adjusted weight. Based on the adjusted weight, the graph cut algorithm is used to calculate the stitching line of the intersecting image to generate a binary mask and obtain the pixel value of the intersecting image in the tessellation, and the tessellation line raster file is updated according to the pixel value.
8. A computer apparatus for generating mask-guided image mosaic lines, characterized in that, The processor is configured to store a memory storing processor-executable instructions and a computer program stored on the memory and executable on the processor, and the processor implements the method of any one of claims 1 to 6 when executing the program. The computer program is executed by the processor to implement the method of any one of claims 1 to 6.
9. A computer readable storage medium having stored thereon a computer program, characterized in that,
Citation Information
Patent Citations
A method for automatically generating splicing lines of large-scale remote sensing data network
CN109087373A
Embedded line network global optimization method based on constraint triangulation network
CN111311750A