Warp and weft extraction method, device and equipment and readable storage medium
By performing threshold segmentation, convolution kernel linear extraction and morphological calculation processing on the original image printed with grid pattern materials, the problems of slow extraction speed and low accuracy in the prior art are solved, and fast and accurate extraction of longitude and latitude contours and accurate cutting path optimization are achieved.
Patent Information
- Application Number
- CN202510198877.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-21
- Publication Date
- 2025-05-13
AI Technical Summary
In the prior art, the longitude and latitude extraction method has a slow speed and low accuracy, making it difficult to effectively identify and extract the longitude and latitude contours in printed grid pattern materials.
By threshold segmenting the original image containing the net format material, a binarized graph is obtained; a linear extraction method based on the convolution kernel is used to convolutional graph to obtain a convolutional graph; a convolutional graph is processed based on morphological operations and contour width and height ratio to obtain the processed image; the processed image is extracted and deduplicated to obtain the pixel coordinates of each longitude and latitude skeleton.
It realizes rapid and accurate extraction of the contours of the longitude and latitude line, eliminates irrelevant features, accurately locates the latitude and latitude line skeleton coordinates in the mesh-format material images, optimizes the cutting path, and improves cutting quality and efficiency.
Smart Images

Figure CN119991721A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to a method, device, equipment and readable storage medium for extracting longitude and latitude lines. Background Art
[0002] Image contour detection is one of the hot topics in current image processing technology. Its purpose is to separate the region of interest from the image. For materials printed with grid patterns, in order to improve cutting efficiency, it is necessary to identify the contours of the longitude and latitude lines, further identify the longitude and latitude line skeletons, and cut along the longitude and latitude line skeletons. Traditional longitude and latitude line extraction methods (such as Hough line extraction) are slow and have low accuracy.
[0003] Therefore, how to provide a method for extracting longitude and latitude with high speed and accuracy is a technical problem that needs to be solved urgently. Summary of the invention
[0004] In view of this, the purpose of the present invention is to provide a longitude and latitude extraction method, device, equipment and readable storage medium, which solves the problems of slow speed and low accuracy of the longitude and latitude extraction method in the prior art.
[0005] In order to solve the above technical problems, the present invention provides a method for extracting longitude and latitude, comprising:
[0006] Perform threshold segmentation on the original image containing grid-like materials to obtain a binary image;
[0007] Performing a convolution operation on the binary image based on a line extraction method of a convolution kernel to obtain a convolution image;
[0008] Processing the convolution image based on morphological operations and contour aspect ratio to obtain a processed image;
[0009] The processed image is subjected to longitude and latitude skeleton extraction and deduplication processing to obtain pixel coordinates of each longitude and latitude skeleton.
[0010] Optionally, the convolution kernel-based straight line extraction method performs a convolution operation on the binary image to obtain a convolution image, including:
[0011] Set the longitude and latitude preprocessing convolution kernel according to the longitude and latitude width;
[0012] The convolution operation is performed on the binary image using the longitude and latitude preprocessing convolution kernel to obtain the convolution image.
[0013] Optionally, the processing of the convolution image based on morphological operation and contour aspect ratio to obtain a processed image includes:
[0014] Performing a subtraction operation and a morphological closing operation based on the convolution image to remove the interference of noise around the longitude and latitude lines in the convolution image, so as to obtain an image after the interference is removed;
[0015] Searching for longitude and latitude contours on the image after interference removal, filtering the found longitude and latitude contours using the contour aspect ratio, and generating a longitude and latitude contour filling map based on the filtered image;
[0016] A morphological dilation operation is performed on the latitude and longitude contour filling image to obtain the processed image.
[0017] Optionally, after performing a morphological dilation operation on the latitude and longitude contour filling map, the method further includes:
[0018] Performing addition operation based on the image after morphological dilation operation to obtain a merged image;
[0019] Searching for longitude and latitude contours on the merged image, filtering the found longitude and latitude contours using the contour aspect ratio, and finding the convex hull based on the filtered image to generate a convex hull contour filling map;
[0020] A subtraction operation is performed based on the image after the morphological dilation operation and the convex hull contour filling image to obtain the processed image.
[0021] Optionally, after searching for longitude and latitude contours on the image after interference removal, filtering the found longitude and latitude contours using the contour aspect ratio, and generating a longitude and latitude contour filling map based on the filtered image, the method further includes:
[0022] The circumscribed matrix data of the longitude and latitude contours are generated based on the filtered image and saved.
[0023] Optionally, the extracting and deduplicating longitude and latitude skeletons of the processed image to obtain pixel coordinates of each longitude and latitude skeleton includes:
[0024] Cutting the processed image based on the external matrix data of the longitude and latitude contours to obtain a matrix region of interest;
[0025] Extract longitude and latitude skeletons in the matrix region of interest to obtain a preliminary longitude and latitude skeleton map;
[0026] Based on the preliminary longitude and latitude skeleton diagram, multiple Ys corresponding to the same X along the longitude direction and multiple Xs corresponding to the same Y along the latitude direction are deduplicated to obtain pixel coordinates of each longitude and latitude skeleton.
[0027] Optionally, before performing threshold segmentation on the original image containing the grid-like material to obtain a binary image, the method further includes:
[0028] Read the background color and longitude and latitude color in the original image;
[0029] If the background color is the same as the longitude and latitude color, the background color is filled with a color opposite to the longitude and latitude color.
[0030] The present invention also provides a longitude and latitude extraction device, comprising:
[0031] The first processing module is used to perform threshold segmentation on the original image containing grid-like materials to obtain a binary image;
[0032] A second processing module is used to perform a convolution operation on the binary image based on a straight line extraction method of a convolution kernel to obtain a convolution image;
[0033] A third processing module is used to process the convolution image based on morphological operations and contour aspect ratio to obtain a processed image;
[0034] The fourth processing module is used to extract the longitude and latitude skeleton and perform deduplication processing on the processed image to obtain the pixel coordinates of each longitude and latitude skeleton.
[0035] The present invention also provides a longitude and latitude extraction device, comprising:
[0036] Memory for storing computer programs;
[0037] A processor is used to implement the longitude and latitude extraction method as described above when executing the computer program.
[0038] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are loaded and executed by a processor, the longitude and latitude extraction method as described above is implemented:
[0039] It can be seen that the present invention obtains a binary image by performing threshold segmentation on the original image containing the grid material; performs convolution operation on the binary image based on the straight line extraction method of the convolution kernel to obtain a convolution image; processes the convolution image based on morphological operations and contour aspect ratio to obtain a processed image; performs longitude and latitude skeleton extraction and deduplication processing on the processed image to obtain the pixel coordinates of each longitude and latitude skeleton. The present invention can quickly extract the longitude and latitude contours using the straight line extraction method of the convolution kernel; eliminate irrelevant features using morphological operations and contour aspect ratio; and accurately locate the longitude and latitude skeleton coordinates in the grid material image by performing longitude and latitude skeleton extraction and deduplication processing on the image, so as to effectively optimize the cutting path in the later stage and improve the cutting quality and efficiency.
[0040] In addition, the present invention also provides a longitude and latitude extraction device, equipment and readable storage medium, which also have the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0042] Figure 1 A flow chart of a method for extracting longitude and latitude provided in an embodiment of the present invention;
[0043] Figure 2 An original image provided by an embodiment of the present invention;
[0044] Figure 3 A background color processing diagram provided by an embodiment of the present invention;
[0045] Figure 4 A binarized image provided by an embodiment of the present invention;
[0046] Figure 5 An example diagram of a latitude direction convolution kernel provided by an embodiment of the present invention;
[0047] Figure 6 An example diagram of a convolution kernel in a meridian direction provided by an embodiment of the present invention;
[0048] Figure 7 A latitude convolution graph provided by an embodiment of the present invention;
[0049] Figure 8 A warp convolution graph provided by an embodiment of the present invention;
[0050] Fig. 9 A latitude direction-independent feature local map provided by an embodiment of the present invention;
[0051] Fig.10 A longitudinal direction-independent feature local map provided by an embodiment of the present invention;
[0052] Fig.11 A latitude image after interference removal provided by an embodiment of the present invention;
[0053] Fig.12 A meridian image after interference removal provided by an embodiment of the present invention;
[0054] Fig.13 A latitude image after morphological dilation operation provided by an embodiment of the present invention;
[0055] Fig.14A meridian image after morphological dilation operation provided by an embodiment of the present invention;
[0056] Fig.15 A merged image provided by an embodiment of the present invention;
[0057] Fig.16 A convex hull contour filling diagram provided by an embodiment of the present invention;
[0058] Fig.17 A precisely extracted latitude contour map provided by an embodiment of the present invention;
[0059] Fig.18 A finely extracted meridian contour map provided by an embodiment of the present invention;
[0060] Fig.19 A latitude contour skeleton diagram provided by an embodiment of the present invention;
[0061] Fig. 20 A meridian contour skeleton diagram provided by an embodiment of the present invention;
[0062] Fig.21 A local example diagram of a latitude skeleton overlap point provided by an embodiment of the present invention;
[0063] Fig. 22 A local example diagram of a warp skeleton coincidence point provided by an embodiment of the present invention;
[0064] Fig.23 A local example diagram of a weft skeleton after duplication removal provided by an embodiment of the present invention;
[0065] Fig.24 A partial example diagram of a warp skeleton after deduplication provided by an embodiment of the present invention;
[0066] Fig.25 An example diagram of longitude and latitude skeleton extraction results provided by an embodiment of the present invention;
[0067] Fig.26 A schematic diagram of the structure of a longitude and latitude extraction device provided by an embodiment of the present invention;
[0068] Fig. 27 A schematic diagram of the structure of a longitude and latitude extraction device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0069] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0070] First, several nouns involved in this application are analyzed, and the details can be seen in Table 1:
[0071] Table 1 Contour extraction and skeleton extraction description
[0072]
[0073] Image contour search is one of the hot topics in current image processing technology. Its purpose is to separate the area of interest from the image. For materials printed with grid patterns, in order to improve cutting efficiency, it is necessary to identify the contours of the longitude and latitude lines and cut along the longitude and latitude skeletons. Image contour extraction method is based on computer technology. It uses computer technology to extract representative features in the image based on image content analysis, such as using high thresholds to detect important lines and contours in the image; straight line extraction method: based on image segmentation, the Hough line detection algorithm is used to extract straight lines; this method is slow and has low accuracy.
[0074] In order to solve the above problems, this application provides a method for extracting longitude and latitude lines. Figure 1 , Figure 1 A flow chart of a method for extracting longitude and latitude provided in an embodiment of the present invention. The method may include:
[0075] S101: Perform threshold segmentation on the original image containing grid-like materials to obtain a binary image.
[0076] The execution subject of this embodiment is a terminal. This embodiment does not limit the type of terminal, as long as it can complete the operation of the longitude and latitude extraction method. This embodiment does not limit the threshold segmentation. For example, global threshold segmentation or local threshold segmentation can be adopted. Such as the simple threshold method and OTSU (also known as the maximum between-class variance method or Otsu algorithm) algorithm in global threshold segmentation, and the adaptive threshold method in local threshold segmentation. Figure 2 An original image containing grid-like materials is provided in an embodiment of the present invention.
[0077] Furthermore, in order to improve the efficiency of longitude and latitude extraction, before performing threshold segmentation on the original image containing the grid material to obtain a binary image, the following steps may be further included:
[0078] Step 21: Read the background color and longitude and latitude color in the original image;
[0079] Step 22: If the background color is the same as the longitude and latitude color, fill the background color with a color opposite to the longitude and latitude color.
[0080] by Figure 2 For example, the white foreground is the material and the dark background is the felt. In order to improve the speed and accuracy of subsequent longitude and latitude extraction, the background is filled with a color opposite to the longitude and latitude. If the longitude and latitude are dark, the background is filled with white. Figure 3 As shown, Figure 3 A background color processing diagram provided by an embodiment of the present invention, and vice versa. Figure 3 Perform threshold segmentation to obtain a binary image, such as Figure 4 As shown, Figure 4 A binarized image is provided in an embodiment of the present invention.
[0081] S102: Perform a convolution operation on the binary image based on a straight line extraction method of a convolution kernel to obtain a convolution image.
[0082] The purpose of the straight line extraction method of the convolution kernel in this embodiment is to roughly extract the longitude and latitude lines in the binary image. The size of the convolution kernel is related to the width of the longitude and latitude lines.
[0083] Further, in order to improve the efficiency of longitude and latitude extraction, the above-mentioned straight line extraction method based on convolution kernel performs a convolution operation on the binary image to obtain a convolution image, which may include the following steps:
[0084] Step 31: Set the longitude and latitude preprocessing convolution kernel according to the longitude and latitude width;
[0085] Step 32: Use the longitude and latitude preprocessing convolution kernel to perform a convolution operation on the binary image to obtain a convolution image.
[0086] Specifically, according to the warp width W1 and the weft width W2, the weft preprocessing convolution kernel (W1, 1) and the warp preprocessing convolution kernel (1, W2) are respectively set. For details, please refer to Figure 5 and Figure 6 , Figure 5 An example diagram of a latitude direction convolution kernel provided by an embodiment of the present invention, Figure 6 This is an example of a convolution kernel in the longitudinal direction provided by an embodiment of the present invention. The binary image is processed using the latitude preprocessing convolution kernel to obtain a latitude convolution image, such as Figure 7 As shown, Figure 7 A latitude convolution map is provided in an embodiment of the present invention; a convolution operation is performed on the binary map using a warp preprocessing convolution kernel to obtain a warp convolution map, such as Figure 8 As shown, Figure 8A warp convolution graph provided by an embodiment of the present invention.
[0087] S103: Process the convolution image based on morphological operations and contour aspect ratio to obtain a processed image.
[0088] The purpose of this step is to further denoise the above convolutional image. There are irrelevant features along the latitude and longitude directions, such as Fig. 9 and Fig.10 As shown, Fig. 9 A latitude direction-independent feature local map provided by an embodiment of the present invention, Fig.10 This is a local map of features that are irrelevant to the direction of the longitude provided by the embodiment of the present invention, so it is necessary to remove redundant irrelevant features. This embodiment uses morphological operations and contour aspect ratios for denoising, wherein the kernel size in the morphological operation is strongly correlated with the width of the longitude and latitude lines.
[0089] Further, in order to improve the efficiency of longitude and latitude extraction, the above-mentioned processing of the convolution image based on morphological operation and contour aspect ratio to obtain a processed image may include the following steps:
[0090] Step 41: Perform subtraction operation and morphological closing operation based on the convolution image to remove the interference of noise around the longitude and latitude lines in the convolution image, and obtain an image after the interference is removed.
[0091] Specifically, the convolution map includes a meridian convolution map and a latitude convolution map. Subtraction operation and morphological closing operation can be performed on the two to obtain the meridian image and latitude image after interference removal. Figure 7 and Figure 8 Perform a subtraction operation, and then perform a morphological closing operation with the kernel (2*W1+1, 1), and we get Fig.11 , Fig.11 A latitude image after interference removal provided by an embodiment of the present invention; Figure 8 and Figure 7 Perform a subtraction operation, and then perform a morphological closing operation with the kernel (1, 2*W2+1), and we get Fig.12 , Fig.12 A meridian image after interference removal provided by an embodiment of the present invention. Fig.11 and Fig.12 It can be seen that irrelevant features and other interference along the longitude and latitude lines are significantly reduced, and useful features are enhanced.
[0092] Step 42: Search for longitude and latitude contours on the image after interference removal, filter the found longitude and latitude contours using the contour aspect ratio, and generate a longitude and latitude contour filling map based on the filtered image.
[0093] Specifically, this embodiment does not limit the longitude and latitude contour search algorithm. This embodiment uses the longitude and latitude contour aspect ratio to perform contour filtering, removes non-longitude and latitude contours, and further generates a longitude and latitude contour filling map based on the filtered image. Fig.11 Perform contour search, filter by contour width and height, and generate latitude contour filling map; Fig.12 Perform contour search, filter using contour width and height, and generate a meridian contour fill map.
[0094] Step 43: Perform morphological dilation operation on the latitude and longitude contour filling map to obtain a processed image.
[0095] The latitude contour filling image generated in the above steps is further subjected to a morphological dilation operation with a kernel of (2*W1+1, 1) to obtain a latitude image after the morphological dilation operation, as shown in FIG. Fig.13 As shown, Fig.13 A latitude image after morphological dilation operation is provided in an embodiment of the present invention; further a morphological dilation operation with a kernel of (1, 2*W2+1) is performed on the meridian contour filling map generated in the above step to obtain a meridian image after morphological dilation operation, such as Fig.14 As shown, Fig.14 A meridian image after morphological dilation operation provided by an embodiment of the present invention, Fig.13 and Fig.14 They are the roughly extracted latitude image and longitude image, respectively, which can be used as processed images.
[0096] Furthermore, for the accuracy of longitude and latitude extraction, after the morphological dilation operation is performed on the longitude and latitude contour filling map, the following steps may be further included:
[0097] Step 51: performing an addition operation based on the image after the morphological dilation operation to obtain a merged image;
[0098] Step 52: searching for longitude and latitude contours on the merged image, filtering the longitude and latitude contours found using the contour aspect ratio, and finding the convex hull based on the filtered image to generate a convex hull contour filling map;
[0099] Step 53: Perform a subtraction operation based on the image after the morphological dilation operation and the convex hull contour filling image to obtain a processed image.
[0100] Specifically, this embodiment further performs fine extraction based on the coarsely extracted latitude image and meridian image to obtain finely extracted latitude image and meridian image, which are used as processed images. For example, the latitude image ( Fig.13 ) and the meridian image after morphological dilation operation ( Fig.14) to perform addition operation and obtain the merged image (such as Fig.15 ); for the merged image ( Fig.15 ) to find the contour, and filter it by the contour aspect ratio, find the convex hull of the retained contour, and generate the convex hull contour filling map (such as Fig.16 ); The latitude image after morphological dilation operation ( Fig.13 ) and the convex hull contour filling map ( Fig.16 ) to obtain the finely extracted latitude contour map (such as Fig.17 ); The meridian image after morphological dilation operation ( Fig.14 ) and the convex hull contour filling map ( Fig.16 ) to obtain the finely extracted meridian contour map (such as Fig.18 ).
[0101] Furthermore, for the accuracy of longitude and latitude extraction, after searching for longitude and latitude contours on the image after interference removal, filtering the found longitude and latitude contours using the contour aspect ratio, and generating a longitude and latitude contour filling map based on the filtered image, the following steps may also be included:
[0102] Generate and save the external matrix data of the longitude and latitude contours based on the filtered image.
[0103] Specifically, when searching and filtering the latitude and longitude contours, this embodiment can generate circumscribed matrix data of the latitude and longitude contours based on the filtered image, exemplarily, circumscribed rectangle data vecRectsH for each latitude contour and vecRectsV for each longitude contour.
[0104] S104: extracting longitude and latitude skeletons and performing deduplication processing on the processed image to obtain pixel coordinates of each longitude and latitude skeleton.
[0105] The purpose of this step is to extract the skeletons of each longitude and latitude line in preparation for the later cutting. Since the image resolution (10000*10000) is relatively high, if the longitude and latitude skeleton is directly extracted for the entire image, the speed will be relatively slow. Therefore, the ROI (Region of Interest) skeleton extraction algorithm is used, that is, the region of interest is first obtained based on the processed image, and the longitude and latitude skeleton is extracted and deduplicated in the region of interest. This reduces the amount of calculation and the extraction speed is faster.
[0106] Further, in order to improve the cutting accuracy, the above-mentioned longitude and latitude skeleton extraction and deduplication processing of the processed image to obtain the pixel coordinates of each longitude and latitude skeleton may include the following steps:
[0107] Step 61: cropping the processed image based on the external matrix data of the longitude and latitude contours to obtain a matrix region of interest;
[0108] Step 62: extract longitude and latitude skeletons in the matrix region of interest to obtain a preliminary longitude and latitude skeleton map;
[0109] Step 63: Based on the preliminary longitude and latitude skeleton map, multiple Ys corresponding to the same X along the longitude direction and multiple Xs corresponding to the same Y along the latitude direction are deduplicated to obtain pixel coordinates of each longitude and latitude skeleton.
[0110] Specifically, traverse the rectangular data in vecRectsH, and after processing the image ( Fig.17 ) to cut out the ROI rectangular area and perform skeleton extraction to obtain the latitude contour skeleton map (such as Fig.19 ); traverse the rectangular data in vecRectsV, and after processing the image ( Fig.17 ) to cut out the ROI rectangular area and perform skeleton extraction to obtain the meridian contour skeleton map (such as Fig. 20 ); Fig.19 and Fig. 20 In the figure, the grayscale value of the skeleton is 255, and the grayscale value of the background is 0. Fig.21 and Fig. 22 As shown, Fig.21 A local example diagram of a latitude skeleton overlap point provided by an embodiment of the present invention, Fig. 22 A local example diagram of a warp skeleton coincidence point provided by an embodiment of the present invention. Define the latitude direction as the X-axis, the longitude direction as the Y-axis, and the latitude contour skeleton diagram ( Fig.19 ) will exist locally Fig.21 In the meridian direction, the same X corresponds to multiple Y, and the meridian contour skeleton diagram ( Fig. 20 ) will exist locally Fig. 22 In the latitude direction, the same Y corresponds to multiple X points. In order to ensure smooth cutting and reduce the number of times the knife is lifted, the redundant points must be removed: extract the coordinates of the pixel points with a grayscale value of 255 from left to right. If there are multiple pixel points with a grayscale value of 255 along the Y direction of the current point, only the current point is retained and other redundant points are deleted. After deduplication, the local Fig.23 As shown, Fig.23 This is a local example image after deduplication of a latitude skeleton provided by an embodiment of the present invention. The pixel coordinates of each latitude skeleton are output; the coordinates of the pixel points with a grayscale value of 255 are extracted from top to bottom. If there are multiple pixel points with a grayscale value of 255 along the X direction at the current point, only the current point is retained and other redundant points are deleted. The local image after deduplication is as follows Fig.24 , Fig.24 A local example image after deduplication of a warp skeleton is provided in an embodiment of the present invention, and the pixel coordinates of each warp skeleton are output.
[0111] Finally, the pixel coordinates of the output longitude and latitude skeleton can be converted to the cutting table coordinates for cutting, such as Fig.25 As shown, Fig.25 An example diagram of longitude and latitude skeleton extraction results provided in an embodiment of the present invention.
[0112] The longitude and latitude extraction method provided by the embodiment of the present invention is applied to obtain a binary image by performing threshold segmentation on the original image containing the grid material; the binary image is convolved based on the line extraction method of the convolution kernel to obtain a convolution image; the convolution image is processed based on morphological operations and contour aspect ratio to obtain a processed image; the processed image is subjected to longitude and latitude skeleton extraction and deduplication processing to obtain the pixel coordinates of each longitude and latitude skeleton. The present invention can quickly extract the longitude and latitude contours by using the line extraction method of the convolution kernel; irrelevant features can be eliminated by using morphological operations and contour aspect ratio; the longitude and latitude skeleton extraction and deduplication processing of the image can accurately locate the longitude and latitude skeleton coordinates in the grid material image, which is convenient for effectively optimizing the cutting path in the later stage to improve the cutting quality and efficiency.
[0113] The following is an introduction to a longitude and latitude extraction device provided by an embodiment of the present invention. The longitude and latitude extraction device described below and the longitude and latitude extraction method described above can be referred to each other.
[0114] Please refer to Fig.26 , Fig.26 A schematic diagram of a longitude and latitude extraction device provided in an embodiment of the present invention may include:
[0115] The first processing module 100 is used to perform threshold segmentation on the original image containing grid-like materials to obtain a binary image;
[0116] The second processing module 200 is used to perform a convolution operation on the binary image based on a line extraction method of a convolution kernel to obtain a convolution image;
[0117] A third processing module 300 is used to process the convolution image based on morphological operations and contour aspect ratio to obtain a processed image;
[0118] The fourth processing module 400 is used to extract longitude and latitude skeletons and perform deduplication processing on the processed image to obtain pixel coordinates of each longitude and latitude skeleton.
[0119] Based on the above embodiment, the second processing module 200 may include:
[0120] A convolution kernel setting unit, used to set the longitude and latitude preprocessing convolution kernel according to the longitude and latitude width;
[0121] A convolution unit is used to perform a convolution operation on the binary image using the longitude and latitude preprocessing convolution kernel to obtain the convolution image.
[0122] Based on the above embodiment, the third processing module 300 may include:
[0123] A first processing unit is used to perform a subtraction operation and a morphological closing operation based on the convolution image to remove the interference of noise around the longitude and latitude lines in the convolution image, so as to obtain an image after the interference is removed;
[0124] A second processing unit is used to search for longitude and latitude contours on the image after interference removal, filter the searched longitude and latitude contours using the contour aspect ratio, and generate a longitude and latitude contour filling map based on the filtered image;
[0125] The third processing unit is used to perform a morphological dilation operation on the latitude and longitude contour filling map to obtain the processed image.
[0126] Based on the above embodiment, the longitude and latitude extraction device may further include:
[0127] A merging module, used for performing an addition operation based on the images after the morphological dilation operation to obtain a merged image;
[0128] A filling module is used to search for longitude and latitude contours on the merged image, filter the found longitude and latitude contours using the contour aspect ratio, and calculate the convex hull based on the filtered image to generate a convex hull contour filling map;
[0129] The operation processing module is used to perform a subtraction operation based on the image after the morphological dilation operation and the convex hull contour filling image to obtain the processed image.
[0130] Based on the above embodiment, the longitude and latitude extraction device may further include:
[0131] The data generation module is used to generate and save the external matrix data of the longitude and latitude contours based on the filtered image.
[0132] Based on the above embodiment, the fourth processing module may include:
[0133] A cropping unit, used for cropping the processed image based on the external matrix data of the longitude and latitude contours to obtain a matrix region of interest;
[0134] A skeleton extraction unit, used for performing longitude and latitude skeleton extraction in the matrix region of interest to obtain a preliminary longitude and latitude skeleton map;
[0135] The deduplication unit is used to perform deduplication processing on multiple Ys corresponding to the same X along the longitude direction and multiple Xs corresponding to the same Y along the latitude direction based on the preliminary longitude and latitude skeleton map to obtain the pixel coordinates of each longitude and latitude skeleton.
[0136] Based on the above embodiment, the longitude and latitude extraction device may further include:
[0137] A color reading module, used to read the background color and longitude and latitude color of the original image;
[0138] The background filling module is used to fill the background color with a color opposite to the color of the longitude and latitude lines if the background color is the same as the color of the longitude and latitude lines.
[0139] It should be noted that the order of the modules and units in the above-mentioned longitude and latitude extraction device can be changed without affecting the logic.
[0140] The longitude and latitude extraction device provided by the embodiment of the present invention is applied, through the first processing module 100, for performing threshold segmentation on the original image containing the grid material to obtain a binary image; the second processing module 200 is used to perform a convolution operation on the binary image based on the straight line extraction method of the convolution kernel to obtain a convolution image; the third processing module 300 is used to process the convolution image based on morphological operations and contour aspect ratio to obtain a processed image; the fourth processing module 400 is used to extract the longitude and latitude skeleton and perform deduplication processing on the processed image to obtain the pixel coordinates of each longitude and latitude skeleton. The present invention can quickly extract the longitude and latitude contours by using the straight line extraction method of the convolution kernel; irrelevant features can be eliminated by using morphological operations and contour aspect ratio; the longitude and latitude skeleton extraction and deduplication processing of the image can accurately locate the longitude and latitude skeleton coordinates in the grid material image, which is convenient for effectively optimizing the cutting path in the later stage to improve the cutting quality and efficiency.
[0141] The following is an introduction to a longitude and latitude extraction device provided by an embodiment of the present invention. The longitude and latitude extraction device described below and the longitude and latitude extraction method described above can be referenced to each other.
[0142] Please refer to Fig. 27 , Fig. 27 A schematic diagram of a longitude and latitude extraction device provided in an embodiment of the present invention may include:
[0143] A memory 10, used for storing computer programs;
[0144] The processor 20 is used to execute a computer program to implement the above-mentioned longitude and latitude extraction method.
[0145] The memory 10 , the processor 20 , and the communication interface 31 all communicate with each other via the communication bus 32 .
[0146] In the embodiment of the present invention, the memory 10 is used to store one or more programs, and the program may include program code, and the program code includes computer operation instructions. In the embodiment of the present invention, the memory 10 may store programs for implementing the following functions:
[0147] Perform threshold segmentation on the original image containing grid-like materials to obtain a binary image;
[0148] The convolution operation is performed on the binary image based on the line extraction method of the convolution kernel to obtain a convolution image;
[0149] The convolution image is processed based on morphological operations and contour aspect ratio to obtain a processed image;
[0150] The processed image is subjected to longitude and latitude skeleton extraction and deduplication processing to obtain the pixel coordinates of each longitude and latitude skeleton.
[0151] In a possible implementation, the memory 10 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function, etc.; the data storage area may store data created during use.
[0152] In addition, the memory 10 may include a read-only memory and a random access memory, and provide instructions and data to the processor. A portion of the memory may also include an NVRAM. The memory stores an operating system and operating instructions, executable modules or data structures, or a subset thereof, or an extended set thereof, wherein the operating instructions may include various operating instructions for implementing various operations. The operating system may include various system programs for implementing various basic tasks and processing hardware-based tasks.
[0153] The processor 20 may be a central processing unit (CPU), an application specific integrated circuit, a digital signal processor, a field programmable gate array or other programmable logic device, a microprocessor or any conventional processor, etc. The processor 20 may call a program stored in the memory 10 .
[0154] The communication interface 31 may be an interface of a communication module, and is used to connect to other devices or systems.
[0155] Of course, it should be noted that Fig. 27 The structure shown does not constitute a limitation on the longitude and latitude extraction device in the embodiment of the present invention. In actual applications, the longitude and latitude extraction device may include Fig. 27 More or fewer components than shown, or combinations of certain components.
[0156] The computer-readable storage medium provided in an embodiment of the present invention is introduced below. The computer-readable storage medium described below and the longitude and latitude extraction method described above can be referenced to each other.
[0157] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the longitude and latitude extraction method are implemented.
[0158] The computer-readable storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0159] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0160] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0161] Finally, it should be noted that, in this article, relationships such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variations are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0162] The above is a detailed introduction to a longitude and latitude extraction method, device, equipment and computer-readable storage medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for extracting longitude and latitude, characterized in that: include: Perform threshold segmentation on the original image containing grid-like materials to obtain a binary image; Performing a convolution operation on the binary image based on a line extraction method of a convolution kernel to obtain a convolution image; Processing the convolution image based on morphological operations and contour aspect ratio to obtain a processed image; The processed image is subjected to longitude and latitude skeleton extraction and deduplication processing to obtain pixel coordinates of each longitude and latitude skeleton.
2. The method for extracting longitude and latitude according to claim 1, characterized in that: The convolution kernel-based straight line extraction method performs a convolution operation on the binary image to obtain a convolution image, including: Set the longitude and latitude preprocessing convolution kernel according to the longitude and latitude width; The convolution operation is performed on the binary image using the longitude and latitude preprocessing convolution kernel to obtain the convolution image.
3. The method for extracting longitude and latitude according to claim 1, characterized in that: The convolution image is processed based on morphological operation and contour aspect ratio to obtain a processed image, including: Performing a subtraction operation and a morphological closing operation based on the convolution image to remove the interference of noise around the longitude and latitude lines in the convolution image, so as to obtain an image after the interference is removed; Searching for longitude and latitude contours on the image after interference removal, filtering the found longitude and latitude contours using the contour aspect ratio, and generating a longitude and latitude contour filling map based on the filtered image; A morphological dilation operation is performed on the latitude and longitude contour filling image to obtain the processed image.
4. The method for extracting longitude and latitude according to claim 3, characterized in that: After performing morphological dilation operation on the latitude and longitude contour filling map, the method further includes: Performing addition operation based on the image after morphological dilation operation to obtain a merged image; Searching for longitude and latitude contours on the merged image, filtering the found longitude and latitude contours using the contour aspect ratio, and finding the convex hull based on the filtered image to generate a convex hull contour filling map; A subtraction operation is performed based on the image after the morphological dilation operation and the convex hull contour filling image to obtain the processed image.
5. The method for extracting longitude and latitude according to claim 3, characterized in that: After searching for longitude and latitude contours on the image after interference removal, filtering the found longitude and latitude contours using the contour aspect ratio, and generating a longitude and latitude contour filling map based on the filtered image, the method further includes: The circumscribed matrix data of the longitude and latitude contours are generated based on the filtered image and saved.
6. The method for extracting longitude and latitude according to claim 5, characterized in that: The step of extracting longitude and latitude skeletons and performing deduplication processing on the processed image to obtain pixel coordinates of each longitude and latitude skeleton includes: Cutting the processed image based on the external matrix data of the longitude and latitude contours to obtain a matrix region of interest; Extract longitude and latitude skeletons in the matrix region of interest to obtain a preliminary longitude and latitude skeleton map; Based on the preliminary longitude and latitude skeleton diagram, multiple Ys corresponding to the same X along the longitude direction and multiple Xs corresponding to the same Y along the latitude direction are deduplicated to obtain pixel coordinates of each longitude and latitude skeleton.
7. The method for extracting longitude and latitude according to claim 1, characterized in that: Before threshold segmentation is performed on the original image containing grid-like materials to obtain a binary image, the following steps are also included: Read the background color and longitude and latitude color in the original image; If the background color is the same as the longitude and latitude color, the background color is filled with a color opposite to the longitude and latitude color.
8. A longitude and latitude extraction device, characterized in that: include: The first processing module is used to perform threshold segmentation on the original image containing grid-like materials to obtain a binary image; A second processing module is used to perform a convolution operation on the binary image based on a straight line extraction method of a convolution kernel to obtain a convolution image; A third processing module is used to process the convolution image based on morphological operations and contour aspect ratio to obtain a processed image; The fourth processing module is used to extract and remove duplicate longitude and latitude skeletons from the processed image to obtain pixel coordinates of each longitude and latitude skeleton.
9. A longitude and latitude extraction device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the longitude and latitude extraction method as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are loaded and executed by the processor, the longitude and latitude extraction method according to any one of claims 1 to 7 is implemented.