Automatic splicing method of geographic wiring diagram based on canvas

Through the image processing method of canvas technology, the geographical wiring diagram of Northeast China is automatically spliced, which solves the speed and accuracy problems caused by manual splicing and achieves efficient image processing and display.

CN113034360BActive Publication Date: 2024-10-29STATE GRID CORP NORTHEAST DIVISION +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011265547.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-13
Publication Date
2024-10-29
Estimated Expiration
2040-11-13

AI Technical Summary

Technical Problem

In the existing technology, the splicing of geographical wiring diagrams in Northeast China requires manual operations, resulting in slow, untimely and inaccurate mapping, which affects the efficiency of compiling and displaying geographical wiring diagrams of power systems.

Method used

Using an image processing method based on canvas technology, by reading and analyzing the geographical wiring image files of each region, identifying district boundaries, comparing overlapping parts, and automatically splicing, using JavaScript and HTML5 canvas elements for pixel-by-pixel operations and rendering. Export lossless compressed PNG format images.

Benefits of technology

It realizes the automatic splicing of geographical wiring diagrams in Northeast China, improves the splicing speed and accuracy, reduces the dependence on professional image processing software, and improves work efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113034360B_ABST
    Figure CN113034360B_ABST
Patent Text Reader

Abstract

The present invention relates to a canvas-based automatic splicing method for geographic wiring diagrams, comprising the following steps: Step 1: Reading the image files of geographic wiring diagrams of various regions, creating a canvas element to import the image into it; Step 2: Parsing to obtain image pixel information, and sorting the pixel information; Step 3: According to the image characteristics of the provincial boundary, identifying the provincial boundary outline of each regional map, and then comparing the provincial boundary information of each image, determining the overlapping part of the provincial boundary between different regional maps; Step 4: According to the overlapping part, splicing the maps of various regions in turn, and finally obtaining a complete geographic wiring diagram and exporting it. The present invention analyzes the image pixels of the wiring diagrams of various regions, identifies the provincial boundaries in the image, compares the overlapping parts of the provincial boundaries of the wiring diagrams of different regions, and automatically splices them according to the overlapping positions, while maintaining the image data unchanged during image processing, and the image content is clear and accurate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to image processing, in particular to a method for automatically splicing multi-regional geographic wiring diagrams by performing image processing through canvas technology. Background Art

[0002] With the continuous development of the power grid system in Northeast China, the number of power equipment and transmission lines in the power system is also increasing. As a visual form of expression, the geographic wiring diagram of Northeast China can conveniently provide office staff with intuitive information such as power generation, transmission, and substation equipment, as well as the relative position relationship of equipment and lines, equipment parameters, etc. After the geographic wiring diagram drawing personnel in various regions complete the drawing of the geographic wiring diagram, relevant personnel are required to manually splice the geographic wiring diagrams of Liaoning, Jilin, Heilongjiang, and East Mengdong to obtain a complete geographic wiring diagram of Northeast China. This not only slows down the mapping speed and makes it difficult to ensure timeliness and accuracy, but also requires staff to have certain image processing skills. It has a certain impact on the efficiency of the compilation and display of the geographic wiring diagram of the power system. Summary of the invention

[0003] Based on the current demand for drawing, maintaining and displaying geographic wiring diagrams of the Northeast region, the present invention provides a method for automatically splicing geographic wiring diagrams based on canvas image processing technology, which solves the problem that in the past, relevant personnel were required to use professional image processing software (such as Photoshop) to perform the splicing work of maps of various regions, and the problem that the geographic wiring diagram of the Northeast region could not be displayed in a timely and accurate manner.

[0004] The technical solution adopted by the present invention to achieve the above-mentioned purpose is: a canvas-based automatic splicing method of geographic wiring diagrams, comprising the following steps:

[0005] Step 1: Read several geographic wiring image files to be spliced ​​and import them into the canvas;

[0006] Step 2: Obtain image information of each image respectively;

[0007] Step 3: Identify the zoning boundaries of each map based on the image information;

[0008] Step 4: Compare the boundaries of each map, obtain the overlapping parts, and complete the map stitching;

[0009] Step 5: Export the image and save it in the desired format.

[0010] It uses JavaScript and HTML5's canvas element to draw and render each pixel on a rectangular canvas.

[0011] The image information includes a pixel color information set and a pixel position information set;

[0012] The image pixel color information set is a set with single pixel information as an element, and the single pixel information is (R i ,G i ,B i ,A i ), where the parameters R, G, and B are RGB color spaces, A is the Alpha channel representing the opacity parameter, and i is the pixel sequence number of the current image;

[0013] The image pixel position information set is a set with a single pixel position information as an element, and the single pixel position information is (X i ,Y i ), where parameters X and Y are the width and height of the image respectively, and i is the pixel sequence number of the current image;

[0014] A mapping relationship table is established to store corresponding mapping lines of pixel color information and pixel position information, which is used to find the pixel position of the current pixel color through the pixel serial number i.

[0015] The pixel color information is obtained by using the getImageData() method of HTML5-canvas to obtain the pixel color information of the image.

[0016] The pixel color information at the partition boundary of the image to be stitched is known in advance. According to the pixel color information of the partition boundary, a matching pixel point is searched in the image pixel color information set, and according to the pixel point serial number, a matching pixel position is searched in the image pixel position information set, and the results are stored as the pixel color information set and the pixel position information set of the partition boundary.

[0017] The comparing of the demarcation lines of the various maps to obtain the overlapping parts includes:

[0018] For the pixel color information set and pixel position information set of the boundary lines of the two stitched images, a starting pixel point is selected and the direction of the adjacent pixels is judged. If the direction judgment is true, it is judged that the current pixel meets the direction of the boundary line. If the direction judgment of several consecutive pixels is true, it is judged that the two sections of the boundary lines on the current two stitched images are overlapping parts.

[0019] The map stitching is to locate the relative displacement according to the overlapping parts, superimpose the layers and remove the duplication.

[0020] The exported image format adopts a bitmap format with a lossless compression algorithm.

[0021] The geographic wiring diagram of each region includes the provincial boundaries of the region, the city boundaries of the municipal areas under the region, and the locations of the power generation, transmission and transformation equipment contained in the region are located in the relative positions and connection lines of the geographic wiring diagram.

[0022] Beneficial effects and advantages of the present invention:

[0023] The present invention provides a method for automatically splicing geographic wiring diagrams based on canvas image processing technology, which solves the problem that in the past, relevant personnel were required to use professional image processing software (such as Photoshop) to perform the splicing work of maps of various regions, and the problem that the geographic wiring diagram of the Northeast region could not be displayed in a timely and accurate manner was not guaranteed. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 is a flow chart of the method of the present invention. DETAILED DESCRIPTION

[0025] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific implementation method of the present invention is described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the invention, so the present invention is not limited by the specific implementation disclosed below.

[0026] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.

[0027] The present invention is described in detail below based on the specific process and in combination with the method flow chart of the present invention.

[0028] Attached Figure 1 The present invention is a flow chart of the method.

[0029] First, import the image files of the geographical wiring diagrams of each region, then use JavaScript to create a canvas element, import the geographical wiring diagrams of Liaoning, Jilin, Heilongjiang, and East Meng into the corresponding canvas elements, and read the pixel information of each pixel in the imported image. Then analyze the pixel information and pixel arrangement rules of each image, analyze the provincial boundary information of the geographical wiring diagrams of each region, and compare the provincial boundary information of the geographical wiring diagrams of Liaoning and East Meng, Jilin and East Meng, Heilongjiang and East Meng in turn, splice the overlapping positions of the provincial boundaries, and merge the geographical wiring diagrams of the four regions into a complete geographical wiring diagram of the Northeast region. Finally, display the image information of the geographical wiring diagram of the Northeast region on the web page, or generate a PNG format image for image file export.

[0030] The details are as follows:

[0031] Canvas refers to an HTML5 tag canvas. The HTML5 canvas element can be used to draw 2D images on a web page. By using JavaScript, the HTML5 canvas element controls each pixel on a rectangular canvas and performs pixel-by-pixel operations and rendering.

[0032] Image import: Create an Image object through JavaScript and import the geographic wiring diagram image files of Liaoning, Jilin, Heilongjiang and Eastern Menggu that need to be processed and spliced.

[0033] Implementation code sample:

[0034]

[0035] Pixel analysis: Use JavaScript to create a canvas object, and use the getImageData() method of HTML5-canvas to obtain the pixel information of the image. The information obtained at this time is an array containing the RGBA pixel information of all pixels in the image. For example: for each original image, obtain the pixel information array [R 1 ,G 1 ,B 1 ,A 1 ,R 2 ,G 2 ,B 2 ,A 2 ,R 3 ,G 3 ,B 3 ,A 3 ,……].

[0036] Image pixel information refers to the RGBA information of each pixel in the image, which consists of RGB color space and Alpha channel.

[0037] The RGB color space is also generally called the RGB color standard. Various colors are formed by superimposing R (Red), G (Green), and B (Blue). This method can cover almost all colors that can be perceived by human vision. The color of each pixel in the image is obtained by superimposing these three colors.

[0038] The Alpha channel is generally used as the opacity parameter of a pixel. For example, if the Alpha channel value of a pixel is 0%, then it is a completely transparent pixel; and if the Alpha channel value of a pixel is 100%, then it is a completely opaque pixel.

[0039] Implementation code sample:

[0040]

[0041] Boundary identification: The boundaries here refer to the provincial boundaries of Liaoning, Jilin, Heilongjiang, and Eastern Mengdong. The significance of identifying provincial boundaries is to prepare for the next step of image stitching. In the process of drawing the geographic wiring diagrams of each region, the provincial boundaries are drawn using the same color scheme, and the transparency of the provincial boundaries is 100%, that is, completely opaque, and the Alpha channel values ​​contained are all 100%. According to the same boundary color rule, the pixel information in the image is checked to identify the provincial boundary information of the geographic wiring diagrams of each region.

[0042] The specific process is as follows:

[0043] The array of image pixel information obtained in the previous step is sorted into a collection form. The pixel values ​​of the image width and height can be obtained through ImageData.width and ImageData.height. When traversing the array to make a collection, the position information (w, h) of each pixel in the image is stored in the elements of the collection. In the sorting process, only the pixel information belonging to the provincial boundary is retained. Previously, in the image drawing stage, the provincial boundary was drawn with a solid opaque line with a color of FFDCFF (its corresponding RGBA value is R: 255; G: 220; B: 255; A: 255), and there was no line of the same color in the rest of the part. After sequentially taking out the RGBA information of each pixel point, it is judged according to the above color information, and only the pixel position information that meets the requirements is retained. In this way, in the newly created collection, each element stores the position information of the pixel point in the image, and this collection is the position information of all the provincial boundary pixel points in the map image.

[0044] Implementation code sample:

[0045]

[0046]

[0047] Image stitching: Analyze the pixel distribution of provincial boundaries in the geographic wiring diagram of each region, and stitch the geographic wiring diagrams of Liaoning and Eastern Inner Mongolia, Jilin and Eastern Inner Mongolia, and Heilongjiang and Eastern Inner Mongolia in turn. When stitching the geographic wiring diagrams of two regions, first organize and analyze the provincial boundary information of each image, summarize it through the arrangement rules of pixels, and then compare the provincial boundary pixel information of the two images to find the part where the pixel arrangement rules overlap. This part is the overlap of the provincial boundaries of the two regions.

[0048] The specific process is as follows:

[0049] Take the image stitching of Liaoning and Jilin as an example to illustrate.

[0050] From the previous step of "boundary identification", we get the coordinate sets of the provincial boundary points in Liaoning and Jilin. Compare each pixel point in the two sets in turn, and find the parts or a small part of the two sets that have the same direction through the relationship between the pixel point positions (similar to the horizontal and vertical coordinate differences of two points in the plane rectangular coordinate system). Because the provincial boundary line on the map is a curved curve with a changeable and complex direction, 300 pixels are used for judgment during the analysis process. When there are 300 consecutive pixels with the same direction, it means that the overlapping part has been found.

[0051] Simple example:

[0052] Take two consecutive points of information A1, A2 and B1, B2 from the set of images A and B. Their positions in their respective images are A1(X A1 ,Y A1 ),A2(X A2 ,Y A2 ) and B1(X B1 ,Y B1 ),B2(X B2 ,Y B2 ). When X A2 -X A1 =X B2 -X B1 And Y A2 -Y A1 =Y B2 -Y B1When , it can be considered that the relative positions of the two corresponding pixel points in the image, that is, the curve direction, are consistent. If the equation does not hold, it means that the relative positions of the two corresponding pixel points, that is, the curve direction, are inconsistent. When there are 300 consecutive relative pixel points in the two sets that make the equation true, it means that this is a section of the overlapping part of the provincial boundary in the two pictures. At this time, select one pair of relative pixel points and find the coordinate difference of the two points, that is, X 差 =X B1 -X A1 and Y 差 =Y B1 -Y A1 , thus obtaining the positional relationship of image B relative to image A. Finally, all the pixels in image B are translated according to the obtained horizontal and vertical coordinate differences, and then the contents of the two image pixel sets are merged and deduplicated, thus completing the splicing of the pixel data of the two images.

[0053] Image export: Export the processed image through the putImageData() method of HTML5-canvas. The image can be displayed on the web page directly. The pixel information of the obtained image can also be exported as a PNG format image for download and storage.

[0054] Implementation code sample:

[0055] context.putImageData(pixel information,0,0);

[0056] The standard format image is PNG (file suffix .png), which is a bitmap format that uses a lossless compression algorithm. It is widely used in JAVA programs and web pages. It has the characteristics of high compression ratio, small generated file size, and optimized network transmission and display.

[0057] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any way. Any simple modification, change and equivalent structural change made to the above embodiment based on the technical essence of the present invention still falls within the protection scope of the technical solution of the present invention.

Claims

1. A canvas-based automatic splicing method for geographic wiring diagrams, characterized in that: The steps include: Step 1: Read several geographic wiring image files to be spliced ​​and import them into the canvas; Step 2: Obtain image information of each image respectively; the image information includes a pixel color information set and a pixel position information set; The pixel color information set is a set with single pixel information as an element, and the single pixel information is (R i ,G i ,B i ,A i ), where the parameters R, G, and B are RGB color spaces, A is the Alpha channel representing the opacity parameter, and i is the pixel sequence number of the current image; The pixel position information set is a set with a single pixel position information as an element, and the single pixel position information is (X i ,Y i ), where parameters X and Y are the width and height of the image respectively, and i is the pixel sequence number of the current image; Establish a mapping relationship table to store corresponding mapping lines of pixel color information and pixel position information, which is used to find the pixel position of the current pixel color through the pixel sequence number i; Step 3: Identify the demarcation lines of each map according to the image information; wherein the pixel color information at the demarcation lines of the image to be stitched is known in advance, and a matching pixel point is searched in the image pixel color information set according to the pixel color information of the demarcation line, and a matching pixel position is searched in the image pixel position information set according to the pixel point sequence number, and the pixel positions are stored as the demarcation line pixel color information set and the pixel position information set; Step 4: Compare the boundaries of each map, obtain the overlapping parts, and complete the map stitching; Step 5: Export the image and save it in the desired format.

2. The method for automatically splicing a geographic wiring diagram based on canvas according to claim 1, characterized in that: It uses JavaScript and HTML5's canvas element to draw and render each pixel on a rectangular canvas.

3. The method for automatically splicing a geographic wiring diagram based on canvas according to claim 1, characterized in that: The pixel color information of the image is obtained by using the getImageData() method of HTML5-canvas.

4. The method for automatically splicing a geographic wiring diagram based on canvas according to claim 1, characterized in that: The comparing of the demarcation lines of the various maps to obtain the overlapping parts includes: For the pixel color information set and pixel position information set of the boundary lines of the two stitched images, a starting pixel point is selected and the direction of the adjacent pixels is judged. If the direction judgment is true, it is judged that the current pixel meets the direction of the boundary line. If the direction judgment of several consecutive pixels is true, it is judged that the two sections of the boundary lines on the current two stitched images are overlapping parts.

5. The method for automatically splicing a geographic wiring diagram based on canvas according to claim 1, characterized in that: The map stitching is to locate the relative displacement according to the overlapping parts, superimpose the layers and remove the duplication.

6. The method for automatically splicing a geographic wiring diagram based on canvas according to claim 1, characterized in that: The exported image format uses a bitmap format with a lossless compression algorithm.

7. The method for automatically splicing a geographic wiring diagram based on canvas according to claim 1, characterized in that: The geographic wiring diagram of each region includes the provincial boundaries of the region, the city boundaries of the municipal areas under the region, and the locations of the power generation, transmission and transformation equipment contained in the region are located in the relative positions and connection lines of the geographic wiring diagram.

Citation Information

Patent Citations

  • Parallel splicing method of polygonal vector data files

    CN103106254A

  • Display processing method and device of map

    CN104834723A