Line scanning image splicing method, electronic equipment and computer readable storage medium
By acquiring and stitching line scan sub-images in real time during the scanning process, the problems of insufficient real-time performance and accuracy of line scan images are solved, achieving efficient real-time image processing and complete detection.
Patent Information
- Application Number
- CN202511379314.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-24
- Publication Date
- 2026-02-10
AI Technical Summary
In existing technologies, line scan images lack real-time performance and accuracy. Directly processing the complete image is time-consuming and impractical. Furthermore, when processing sub-images in real time, the target is easily segmented into different sub-images, leading to inaccurate detection.
During the scanning process, the current and previous line scan sub-maps are acquired in real time. The target line scan map is generated by connecting the connected components, which improves real-time performance and completeness.
It achieves efficient real-time processing of line scan images, ensuring the integrity of the target and the accuracy of detection, reducing the amount of computation and improving processing efficiency.
Smart Images

Figure CN121504715A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method for stitching line scan images, an electronic device, and a computer-readable storage medium. Background Technology
[0002] Line scan images are images captured and combined using a line scan camera. These images are widely used for imaging long, narrow objects that require continuous imaging, such as fabric and paper, and can generate large-size images.
[0003] Currently, target detection for line scan images often involves acquiring the complete line scan image and then performing detection on the entire image. This approach has a long processing time and low real-time performance and practicality. On the other hand, using real-time processing of a segment of the image presents the problem that a target may be captured separately in different sub-images, leading to inaccurate detection.
[0004] Therefore, there is an urgent need for a line scan image stitching method, an electronic device, and a computer-readable storage medium. Summary of the Invention
[0005] The main technical problem addressed by this application is to provide a method for stitching line scan images, an electronic device, and a computer-readable storage medium that can ensure the real-time performance and accuracy of the line scan images.
[0006] To solve the above-mentioned technical problems, one technical solution adopted in this application is: to provide a line scan image stitching method, the line scan image stitching method comprising: during the scanning of a target area, acquiring a current line scan sub-image and a previous line scan sub-image, wherein the sub-regions included in the current line scan sub-image and the previous line scan sub-image are adjacent regions in the target area; and performing connected component stitching processing on the current line scan sub-image and the previous line scan sub-image to obtain a target line scan image.
[0007] To solve the above-mentioned technical problems, another technical solution adopted in this application is: to provide an electronic device, including a memory and a processor, wherein the memory stores program instructions, and the processor retrieves the program instructions from the memory to execute the above-mentioned line scan image stitching method.
[0008] To solve the above-mentioned technical problems, another technical solution adopted in this application is to provide a computer-readable storage medium including program data, which, when executed by a processor, is used to implement the above-mentioned line scan image stitching method.
[0009] The line scan image stitching method of this application acquires the current line scan sub-image and the previous line scan sub-image during the scanning of the target area. The sub-regions included in the current line scan sub-image and the previous line scan sub-image are adjacent regions in the target area. Connected component stitching is performed on the current line scan sub-image and the previous line scan sub-image to obtain the target line scan image. This method generates sub-images in real time during the scanning of the target area, ensuring the high efficiency and real-time nature of segmented processing. Subsequently, connected component stitching is performed on each sub-image, improving the integrity of the image. Attached Figure Description
[0010] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly described below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort, wherein:
[0011] Figure 1 This is a schematic flowchart of an exemplary embodiment of the line scan image stitching method shown in this application;
[0012] Figure 2 This is a schematic diagram of an exemplary embodiment of the upper line scan sub-pattern shown in this application;
[0013] Figure 3 This is a schematic diagram of an exemplary embodiment of the current line scan sub-graph shown in this application;
[0014] Figure 4 This is a schematic diagram of an exemplary embodiment of the connected component labeling shown in this application;
[0015] Figure 5 This is a schematic diagram of another exemplary embodiment of the connected component labeling shown in this application;
[0016] Figure 6 This is a schematic diagram of another exemplary embodiment of the connected component labeling shown in this application;
[0017] Figure 7 This is a schematic diagram of an exemplary embodiment of the image stitching result shown in this application;
[0018] Figure 8 This is a schematic diagram of another exemplary embodiment of the connected component labeling shown in this application;
[0019] Figure 9 This is a schematic diagram of another exemplary embodiment of the connected component labeling shown in this application;
[0020] Figure 10 This is a flowchart illustrating another exemplary embodiment of the line scan image stitching method shown in this application;
[0021] Figure 11 This is a schematic diagram of an exemplary embodiment of the line scan image stitching device shown in this application;
[0022] Figure 12 This is a schematic diagram of the structure of an embodiment of the electronic device provided in this application;
[0023] Figure 13 This is a schematic diagram of an embodiment of the computer-readable storage medium provided in this application. Detailed Implementation
[0024] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It is understood that the specific embodiments described herein are only for explaining this application and not for limiting it. Furthermore, it should be noted that, for ease of description, only the parts related to this application are shown in the accompanying drawings, not all structures. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0025] First, it's important to clarify that a line scan image is an image captured and combined by a line scan camera. It is typically composed of multiple lines stitched together and is widely used in industrial inspection, printing quality inspection, and other fields. A line scan camera's sensor has only one row of pixels and can only capture the image information of one line at a time. To obtain a complete line scan image of the target object, the object can be moved continuously in front of the line scan camera, or the line scan camera itself can be moved. Common movement methods include: object movement, where the object moves on a conveyor belt through the line scan camera's field of view; and camera movement, where the line scan camera moves on a fixed track, scanning a stationary object. As the object or camera moves, the line scan camera continuously captures the image information of multiple lines and combines this information to form a complete two-dimensional image.
[0026] Since it takes time for line scan images to form a complete image, directly processing the complete image is time-consuming and impractical. Processing real-time segment images, on the other hand, results in the target not being fully displayed in a segment of the image, leading to a decrease in detection accuracy.
[0027] Based on this, embodiments of this application propose a line scan image stitching method, an electronic device, and a computer-readable storage medium. Sub-images can improve the real-time performance of image output, and stitching can ensure the integrity of the segmented target. For details, please refer to... Figure 1 , Figure 1 This is a schematic flowchart of an exemplary embodiment of the line scan image stitching method shown in this application.
[0028] The execution entity of the line scan image stitching method can be a terminal device, a server, or other processing device. The terminal device can be a user equipment (UE), computer, mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (PDA), handheld device, computing device, in-vehicle device, wearable device, etc. The execution entity of the line scan image stitching method can also be a line scan image stitching device. In some possible implementations, the line scan image stitching method can be implemented by a processor calling computer-readable instructions stored in memory.
[0029] Specifically, the line scan image stitching method of this embodiment includes the following steps:
[0030] S110: During the scanning of the target area, obtain the current line scan sub-map and the previous line scan sub-map. The sub-regions included in the current line scan sub-map and the previous line scan sub-map are the adjacent regions in the target area.
[0031] The target area is the region where an image is to be generated. For example, the target area can be the placement area of the object to be scanned. Line scan images are widely used in industrial inspection fields, such as quality inspection of printed materials (including detecting the color and pattern integrity of printed materials); material inspection (including detecting surface defects in materials such as rubber, paper, and metal plates); electronic product inspection (including detecting whether components on circuit boards are correctly installed); food processing inspection (including detecting the shape and color of food); and packaging inspection (including detecting the integrity of packaging and the correctness of labels). The target area is associated with the object to be inspected; the target area can be the placement area of the object to be inspected.
[0032] To improve the real-time performance of image output, this embodiment acquires a sub-image in real time during the scanning of the target area. This allows for processing of the acquired sub-images during the scanning process, improving detection efficiency. The current line scan sub-image is the one currently being processed, while the previous line scan sub-image is the one being processed previously. The current and previous line scan sub-images are acquired within adjacent time periods, with the current sub-image acquired later than the previous one. In some embodiments, the line scan image stitching device can determine the number of pixel rows in each sub-image based on the total number of pixel rows in the target line scan image. For example, for a target line scan image with 1000 pixel rows, a sub-image can be generated every 200 pixel rows scanned. In other embodiments, the line scan image stitching device can also generate sub-images based on a preset time period, generating a sub-image at preset time intervals during the scanning of the target area.
[0033] Since the current line scan submap and the previous line scan submap are obtained from adjacent time periods, the sub-regions included in the current line scan submap and the sub-regions included in the previous line scan submap are adjacent regions within the target region. It should be noted that adjacent regions can be two sub-regions that are geographically close to each other.
[0034] S120: Perform connected component splicing on the current line scan subgraph and the previous line scan subgraph to obtain the target line scan graph.
[0035] A connected component can be a pixel region in an image composed of adjacent pixels that share common characteristics. Adjacent pixels are those pixels centered on a given pixel in all directions. A line scan sub-image can include one or more connected components. For example, target recognition can be performed on the current line scan sub-image and the previous line scan sub-image to obtain the target objects in the current line scan sub-image and the target objects in the previous line scan sub-image. Then, each target object is used as a connected component of the corresponding line scan sub-image.
[0036] The target line scan image is a line scan image obtained by stitching the current line scan sub-image and the previous line scan sub-image. For example, the line scan image stitching device obtains the connected components in the current line scan sub-image and the previous line scan sub-image, and performs stitching processing based on the connected components of the current line scan sub-image and the previous line scan sub-image to obtain the target line scan image.
[0037] As can be seen, the line scan image stitching method of this application acquires the current line scan sub-image and the previous line scan sub-image during the scanning of the target area. The sub-regions included in the current line scan sub-image and the previous line scan sub-image are adjacent regions in the target area. Connected component stitching is performed on the current line scan sub-image and the previous line scan sub-image to obtain the target line scan image. Thus, sub-images are generated in real time during the scanning of the target area, ensuring the high efficiency and real-time performance of segmented processing. Then, connected component stitching is performed on each sub-image to improve the integrity of the image.
[0038] In some embodiments, step S120, which involves concatenating the connected components of the current line-scanned subgraph and the previous line-scanned subgraph to obtain the target line-scanned graph, may include the following steps: obtaining the boundary connected component information of the current line-scanned subgraph and the boundary connected component information of the previous line-scanned subgraph; and concatenating the boundary connected component information of the current line-scanned subgraph and the boundary connected component information of the previous line-scanned subgraph to obtain the target line-scanned graph. This method, by using only the boundary connected component information for concatenation, reduces computational load and improves concatenation efficiency.
[0039] Boundary connected component information can refer to information belonging to connected components within the image boundary in a line scan sub-image. In some embodiments, pixel information in the current line scan sub-image whose scan time is earlier than a first preset time, and pixel information in the previous line scan sub-image whose scan time is later than a second preset time, can be obtained from the scan time from early to late. Boundary connected component information of the current line scan sub-image can be obtained from the pixel information in the current line scan sub-image whose scan time is earlier than the first preset time, and boundary connected component information of the previous line scan sub-image can be obtained from the pixel information in the previous line scan sub-image whose scan time is later than the second preset time. In other embodiments, boundary connected component information of the current line scan sub-image can be obtained from the first N rows of pixels in the current line scan sub-image, and boundary connected component information of the previous line scan sub-image can be obtained from the last N rows of pixels in the previous line scan sub-image. Here, N can be 1, that is, the boundary connected component information of the current line scan sub-image can be obtained from the first row of pixels in the current line scan sub-image, and the boundary connected component information of the previous line scan sub-image can be obtained from the last row of pixels in the previous line scan sub-image.
[0040] In other embodiments, the line scan image stitching device may first perform integrity checks on the connected components in the current line scan sub-image and the previous line scan sub-image to obtain a check result. If the check result indicates that the connected components in the current line scan sub-image and the previous line scan sub-image are both complete, then no stitching processing is required. If the check result indicates that the connected components in the current line scan sub-image or the previous line scan sub-image are incomplete, then stitching processing is required based on the boundary connected component information of the current line scan sub-image and the boundary connected component information of the previous line scan sub-image to obtain the target line scan image.
[0041] Specifically, the connected components of the current and previous line-scan sub-images can be quickly determined using binary images. The line-scan image stitching device performs target recognition on both the current and previous line-scan sub-images to obtain at least one target object. Binarization is then performed on both the current and previous line-scan sub-images based on each target object, resulting in current and previous line-scan binary images. In these binary images, the pixel values of the pixel regions containing the target objects differ from the pixel values of other regions, while the pixel values of the pixel regions containing each target object are the same. The boundary connected component information of the current line-scan sub-image is determined based on the current line-scan binary image, and the boundary connected component information of the previous line-scan binary image is also determined based on the previous line-scan binary image. Thus, the boundary connected component information in the current and previous line-scan sub-images can be quickly found using binary images.
[0042] The target object refers to the object of interest. For example, the target object to be identified can be determined based on the actual application scenario. For instance, in an industrial inspection scenario, the target object could be an industrial component to be inspected; in a food processing scenario, the target object could be the food to be inspected. In some embodiments, the line scan image stitching device can use a target detection algorithm to identify the target object from the line scan sub-image. In real-time detection, since the current line scan sub-image and the previous line scan sub-image are images generated from a portion of the scanning process, a target object may be split into two parts, presented separately in the current line scan sub-image and the previous line scan sub-image, thus affecting the accuracy of subsequent target object information detection. See details in [link to relevant documentation]. Figure 1 As can be seen in the real-time captured line scan sub-images, the same paperclip cannot be fully displayed in one line scan sub-image and is split and displayed in multiple line scan sub-images.
[0043] After acquiring the target object in each line scan sub-image, the line scan image stitching device can change the pixel values of the pixel regions belonging to the target object in the current line scan sub-image to a first pixel value, and the pixel values of the pixel regions belonging to non-target objects to a second pixel value; similarly, it can change the pixel values of the pixel regions belonging to the target object in the previous line scan sub-image to the first pixel value, and the pixel values of the pixel regions belonging to non-target objects to the second pixel value. The first pixel value can be greater than the second pixel value; typically, the first pixel value can be set to 255, and the second pixel value can be set to 0.
[0044] After obtaining the binarized current line-scan binary image and the previous line-scan binary image, connected component analysis is performed on both images to obtain the connected components of the current and previous line-scan sub-images. Boundary connected component information of the current line-scan sub-image and the previous line-scan sub-image are then obtained from their respective connected components. It should be noted that if the previous line-scan sub-image is not the first line-scan sub-image, the line-scan image stitching device has already performed target recognition, binarization, and connected component analysis on the previous line-scan sub-image during the processing of the previous line-scan sub-image and its adjacent line-scan sub-image. Therefore, no further processing is needed, and the previous processing result can be used directly.
[0045] In some embodiments, boundary connected component information can be obtained through run-length encoding. This boundary connected component information includes initial connected component labels and run-length encoding. Specifically, for the previous line scan sub-image, after obtaining the connected components in the previous line scan sub-image, the line scan image stitching device performs run-length encoding on the pixel region where each connected component is located. Each run consists of a pixel row number, a pixel column start position, and a pixel column end position. The runs are sorted by pixel row number from smallest to largest, and if the pixel row numbers are the same, they are sorted by pixel column start position. The connected components in the previous line scan image are numbered according to the run-length order to obtain the initial connected component label for each connected component. The earlier the run-length order, the smaller the initial connected component label. Figure 2 As shown, the stroke ordering prioritizes pixel row numbers, and the initial label of a connected component is proportional to the pixel row number of the first stroke in that connected component. The line scan image stitching device then traverses along the initial labels of the connected components from largest to smallest. For a single initial label of a connected component, the traversal starts from the end of the stroke ordering relative to the initial label. For example, assuming the pixel row number of the previous line scan sub-image is y, and there are M connected components in the previous line scan sub-image, the traversal starts from the Mth connected component. Assuming a connected component has L strokes, the traversal starts from the Lth stroke. If the pixel row number of that stroke is y, the stroke and its corresponding initial label are recorded, and the process continues to the next stroke. If the pixel row number of the Lth stroke is less than y, the stroke traversal is stopped, and the process continues to the next connected component. This backward-looking approach allows for the rapid determination of the boundary connected component information of the bottom edge in the previous line scan sub-image.
[0046] For the current line scan sub-image, after obtaining the connected components in the current line scan sub-image, the line scan image stitching device performs run encoding on the pixel regions where the connected components are located. Each run consists of a pixel row number, a pixel column start position, and a pixel column end position. The runs are sorted by pixel row number from smallest to largest, and if the pixel row numbers are the same, they are sorted by pixel column start position. The connected components of the current line scan sub-image are then numbered according to the run order to obtain the initial connected component label for each component. The earlier the connected component is in the run order, the smaller its initial connected component label. Figure 3As shown, the stroke order prioritizes pixel row number, and the initial label of a connected component is proportional to the pixel row number of the first stroke in that connected component. The line scan image stitching device then traverses along the initial labels of the connected components from smallest to largest. For a single initial label, the stroke order is traversed from front to back. For example, assuming there are M connected components in the current line scan sub-image, the traversal starts from the first connected component (the initial label of the first connected component can be 0). Assuming a connected component has L strokes, the traversal starts from the first stroke. If the pixel row number of that stroke is 0, the stroke and its corresponding initial label are recorded, and the process continues to the next stroke. If the pixel row number of the first stroke is greater than 0, the stroke traversal is stopped, and the process continues to the next connected component. This front-to-back approach allows for the rapid determination of the top edge boundary connected component information in the current line scan sub-image.
[0047] Therefore Figure 2 Boundary connectivity information of the top and middle line sweep subgraphs and Figure 3 The results are displayed by analyzing the boundary connectivity information of the current line scan subgraph, such as... Figure 4 As shown, the stroke is represented by an equivalent pixel grid. The number of equivalent pixel grids is determined by the number of actual pixels occupied by the stroke. The more actual pixels the stroke occupies, the more equivalent pixel grids there are. The previous stroke is the stroke of the connected region located at the image boundary in the previous line scan sub-image, and the current stroke is the stroke of the connected region located at the image boundary in the current line scan sub-image.
[0048] After obtaining the boundary connected component information of the current and previous line scan sub-images, the line scan image stitching device can determine whether the boundary connected component information of the current or previous line scan sub-image is 0. If it is, it means that there are no regions that need to be connected in the current and previous line scan sub-images, and no stitching processing is required; the results of each line scan sub-image can be directly output. For example, if counting the number of connected components, the initial connected component labels of the historical line scan sub-images can be kept unchanged, and the total number of the initial connected component labels of the current and historical line scan sub-images can be used as the final result. If the boundary connected component information of the current and previous line scan sub-images is not 0, then the current and previous line scan sub-images need to be stitched according to the relationship between the boundary connected component information of the current and previous line scan sub-images to obtain the target line scan sub-image.
[0049] In some embodiments, the line scan image stitching device can determine the boundary connected component pairs between the current line scan sub-image and the previous line scan sub-image based on the boundary connected component information in the current line scan sub-image and the previous line scan sub-image; stitch the boundary connected component pairs to obtain the target line scan image.
[0050] Boundary connected component pairs are connected components in the current line scan sub-image and the previous line scan sub-image that are considered to belong to the same target object. In some embodiments, boundary connected component pairs can be determined by the positions of each boundary connected component in the boundary connected component information. Specifically, the line scan image stitching device obtains the positions of each boundary connected component in the current line scan sub-image and the previous line scan sub-image from the boundary connected component information; and determines the boundary connected component pairs based on the positions of each boundary connected component in the current line scan sub-image and the previous line scan sub-image. Thus, the corresponding connected components can be quickly found by the positions of the boundary connected components, improving stitching efficiency.
[0051] When determining the location of the boundary connected component, the above run-length encoding can be used as the location of the boundary connected component. That is, the location of the boundary connected component includes the pixel row number, the pixel column start position, and the pixel column end position. In this embodiment, the first row of pixels in the current line scan sub-image is mainly concatenated with the last row of pixels in the previous line scan sub-image. Therefore, the pixel row number of the boundary connected component in the current line scan sub-image can be the 1st row, and the pixel row number of the boundary connected component in the previous line scan sub-image can be the yth row, where y is the total number of pixel rows in the previous line scan sub-image.
[0052] After obtaining the start and end positions of the pixel columns of each boundary connected component in the current line scan subgraph, and the start and end positions of the pixel columns of each boundary connected component in the previous line scan subgraph, if the start position of the pixel column of the boundary connected component in the current line scan subgraph is the same as the start position of the pixel column of the middle boundary connected component in the previous line scan subgraph, and the end position of the pixel column of the boundary connected component in the current line scan subgraph is the same as the end position of the pixel column of the middle boundary connected component in the previous line scan subgraph, then the two boundary connected components are confirmed as a boundary connected component pair.
[0053] In other embodiments, the line scan image stitching device can also encode the boundary connected components in the current line scan sub-image and the previous line scan sub-image respectively to obtain the label value of each boundary connected component; adjust the label value of the corresponding boundary connected component according to the position of each boundary connected component so that the label value of the connected components belonging to the same target object is the same in the current line scan sub-image and the previous line scan sub-image; and determine the boundary connected components with the same label value as boundary connected component pairs.
[0054] The line scan image stitching device can sequentially encode the boundary connected components in the previous and current line scan sub-images based on the size relationship of the initial labels of the boundary connected components in the current and previous line scan sub-images, so that the size relationship of the label values of each boundary connected component is the same as the size relationship of the initial labels of the connected components. For example, with Figure 4 Taking the initial labeling of connected components in the example, Figure 4There are 10 boundary connected components in total. The values 0-9 are assigned to each boundary connected component as their label values, such as... Figure 5 As shown, firstly, the boundary connected components in the previous line-scan subgraph are encoded. It can be seen that the initial labels of the boundary connected components in the previous line-scan subgraph are 0, 5, 6, 7, and 8 in ascending order. Therefore, the initial label of the connected component with initial label 0 is still assigned the value 0, the initial label of the connected component with initial label 5 is assigned the value 1, the initial label of the connected component with initial label 6 is assigned the value 2, the initial label of the connected component with initial label 7 is assigned the value 3, and the initial label of the connected component with initial label 8 is assigned the value 4. Then, the boundary connected components in the current line-scan subgraph are encoded. It can be seen that the initial labels of the boundary connected components in the current line-scan subgraph are 0, 1, 2, 3, and 4 in ascending order. Therefore, the initial label of the connected component with initial label 0 is still assigned the value 5, the initial label of the connected component with initial label 1 is assigned the value 6, the initial label of the connected component with initial label 2 is assigned the value 7, the initial label of the connected component with initial label 3 is assigned the value 8, and the initial label of the connected component with initial label 4 is assigned the value 9.
[0055] Then, the label values of each boundary connected component are adjusted according to their positional relationships, so that the label values of connected components belonging to the same target object are the same in the current line scan sub-image and the previous line scan sub-image. For example, in response to the existence of a pixel column position of a boundary connected component in the current line scan sub-image that is the same as the pixel column position of a boundary connected component in the previous line scan sub-image, but the corresponding label values of the boundary connected components are different, the line scan image stitching device adjusts the label value of the corresponding boundary connected component in the previous line scan sub-image to the label value of the corresponding boundary connected component in the current line scan sub-image; or, it adjusts the label value of the corresponding boundary connected component in the current line scan sub-image to the label value of the corresponding boundary connected component in the previous line scan sub-image. Thus, the correspondence between connected components in the current line scan sub-image and the previous line scan sub-image is quickly determined through simple label value adjustment.
[0056] The pixel column position includes the start position and the end position of the pixel column. In some embodiments, when the start position of the pixel column of the boundary connected component of the current line scan subgraph is the same as the start position of the pixel column of the boundary connected component of the previous line scan subgraph, and the end position of the pixel column of the boundary connected component of the current line scan subgraph is the same as the end position of the pixel column of the boundary connected component of the previous line scan subgraph, if the label values of the two boundary connected components are different, then the label value of one of the boundary connected components needs to be adjusted to ensure that the label values of the two boundary connected components are the same. For example, the label value of the corresponding boundary connected component in the previous line scan subgraph can be adjusted to the label value of the corresponding boundary connected component in the current line scan subgraph, or the label value of the corresponding boundary connected component in the current line scan subgraph can be adjusted to the label value of the corresponding boundary connected component in the previous line scan subgraph.
[0057] In other embodiments, the line scan image stitching device constructs an adjacency list based on the positional relationships of the boundary connected components in the current line scan sub-image and the previous line scan sub-image. Figure 5 Taking the marker values in the adjacency list as an example, firstly, for the first boundary connected component of the previous line sweep subgraph, the corresponding marker value is 0. We determine its positional relationship with each boundary connected component in the current line sweep subgraph. In this example, it only corresponds to the first boundary connected component in the current line sweep subgraph, and its marker value is 5. Therefore, we add element 5 to row 0 of the adjacency list. Secondly, for the second boundary connected component of the previous line sweep subgraph, the corresponding marker value is 4. We determine its positional relationship with each boundary connected component in the current line sweep subgraph. In this example, it only corresponds to the second boundary connected component in the current line sweep subgraph. The second boundary connected component includes two passes, and its marker values are 6 and 6. Therefore, we add element 6 and 6 to row 4 of the adjacency list. We then iterate through all boundary connected components in this manner, resulting in the adjacency list shown in Table 1 below.
[0058] Adjacency list 0 5 1 8 8 2 7 7 3 9 9 4 6 6 5 0 6 8 8 7 6 6 8 1 1 9 3 3
[0059] Table 1
[0060] The adjacency list can then be processed using a breadth-first search algorithm to assign a unique label value to each boundary connected component. The specific process is as follows:
[0061] The line scan image stitching device sequentially traverses each row of the adjacency list. Taking Table 1 as an example, it first traverses the boundary connected components with a flag value of 0, finding that the corresponding value in the adjacency list is 5. Since there is a difference, the flag value 5 of the boundary connected component in the current line scan sub-image in the adjacency list can be changed to the flag value 0 of the corresponding boundary connected component in the previous line scan sub-image. Then, it traverses the boundary connected components with a flag value of 1, finding that the corresponding values in the adjacency list are 8 and 8. Since there is a difference, the flag values 8 and 8 of the boundary connected component in the current line scan sub-image in the adjacency list can be changed to the flag value 1 of the corresponding boundary connected component in the previous line scan sub-image. And so on.
[0062] In other embodiments, when the line scan image stitching device traverses the adjacency list, if it finds that the marker value of the boundary connected component in the current line scan sub-image differs from the marker value of the corresponding boundary connected component in the previous line scan sub-image, and the marker value of the boundary connected component in the previous line scan sub-image differs from the corresponding initial connected component marker, then both the marker values of the boundary connected components in the previous line scan sub-image and the current line scan sub-image can be modified to the initial connected component marker of the corresponding boundary connected component in the previous line scan sub-image. For example, when traversing the boundary connected components with a marker value of 1, it finds that the corresponding values in the adjacency list are 8, 8, and the initial connected component marker of the boundary connected component with a marker value of 1 is 5. In this case, both the marker values of the boundary connected components in the current line scan sub-image and the previous line scan sub-image can be modified to 5. And so on. The final marker result is as follows. Figure 6 As shown.
[0063] This yields the influence of the previous line sweep subgraph on all connected components of the current line sweep subgraph, and identifies boundary connected components with the same label value as boundary connected component pairs. Subsequently, image stitching can be quickly completed based on these boundary connected component pairs, resulting in an image as follows: Figure 7 As shown.
[0064] After obtaining the boundary connected component pairs, the number of target objects can be counted based on the marker values. Specifically, the line scan image stitching device identifies boundary connected components with the same marker value as the same target object; it then performs statistical processing on the target objects based on the current and previous line scan sub-images to obtain the number of target objects. This prevents over-counting and under-counting issues. The line scan image stitching device outputs boundary connected components with the same marker value as the same target object, while other connected components in each line scan sub-image are output normally, resulting in the final output result.
[0065] In other application scenarios, it may also occur Figure 8 As shown, multiple boundary connected components in the previous line sweep subgraph belong to the same target object as a single boundary connected component in the current line sweep subgraph, or... Figure 9 This illustrates the case where a single boundary connected component in the previous line sweep subgraph and multiple boundary connected components in the current line sweep subgraph belong to the same target object. This process is repeated for each boundary connected component, and the label values of boundary connected components with connectivity relationships are changed to the same value. Figure 8 For example, first, traverse the first boundary connected component in the previous line sweep subgraph, initially labeled as 10. Find that the first boundary connected component of the previous line sweep subgraph corresponds to the first boundary connected component of the current line sweep subgraph, and change the label value of the first boundary connected component in the current line sweep subgraph to 10. Then, traverse the second boundary connected component in the previous line sweep subgraph, finding that the second boundary connected component of the previous line sweep subgraph corresponds to the first boundary connected component of the current line sweep subgraph, and change the label value of the second boundary connected component of the previous line sweep subgraph to 10 as well. Continue in this manner... Figure 8 The indicated marker value.
[0066] To illustrate in detail the line scan image stitching method of this application, Figure 10 The flowchart shown below provides further explanation, as detailed below:
[0067] First, the control parameter N of the line scan image stitching device is the maximum number of line scan sub-images to be retained.
[0068] The line scan image stitching device performs connected component analysis on the current line scan sub-image to obtain multiple connected components; and performs run-length encoding on the multiple connected components to obtain multiple run-length codes. Each run consists of a pixel row number, a pixel column initial position, and a pixel column ending position. The runs are sorted first by the pixel row number, and if the pixel row numbers are the same, they are sorted according to the pixel column initial position; then, the multiple connected components are labeled based on the run-length to obtain the initial connected component label for each connected component in each line scan sub-image. The initial connected component label is proportional to the pixel row number of the first run corresponding to the connected component.
[0069] Next, the previous line scan subgraph is traversed. The traversal method is to start from the largest to the smallest connected component initial label of the previous line scan subgraph, and for each connected component, the traversal starts from the back to the front of the connected component's path to obtain the boundary connected components of the previous line scan subgraph, or the connected component information of the last row of the image; the current line scan subgraph is traversed. The traversal method is to start from the smallest to the largest connected component initial label of the current line scan subgraph, and for each connected component, the traversal starts from the front to the back of the connected component's path to obtain the boundary connected components of the current line scan subgraph, or the connected component information of the first row of the image;
[0070] Based on the initial connected component labels of the previous and current line sweep subgraphs, the boundary connected components of the previous and current line sweep subgraphs are encoded sequentially to obtain the label values of the boundary connected components in the previous and current line sweep subgraphs. The label values of each boundary connected component are then adjusted according to the travel relationship between the boundary connected components in the previous and current line sweep subgraphs, so that the label values of connected components belonging to the same target object are the same in both the current and previous line sweep subgraphs.
[0071] Based on the connected components with the same label value, the historical line scan subgraph and the current line scan subgraph are stitched together, and the image stitching result is output.
[0072] The above method completes the connected component stitching of the line scan image by using the two lines of travel information at the boundary, which reduces the computational load of image stitching, ensures efficient and real-time segmented processing of the line scan image, and solves the problem of incomplete detection targets caused by segmented processing.
[0073] Please see Figure 11 , Figure 11This is a schematic diagram of an exemplary embodiment of the line scan image stitching device shown in this application. The line scan image stitching device 1100 includes an acquisition module 1110 and a stitching module 1120. The acquisition module 1110 is used to acquire the current line scan sub-image and the previous line scan sub-image during the scanning of the target area. The sub-regions included in the current line scan sub-image and the previous line scan sub-image are adjacent regions in the target area. The stitching module 1120 is used to perform connected component stitching processing on the current line scan sub-image and the previous line scan sub-image to obtain the target line scan image.
[0074] In the above scheme, the line scan image stitching device acquires the current line scan sub-image and the previous line scan sub-image during the scanning of the target area. The sub-regions included in the current line scan sub-image and the previous line scan sub-image are adjacent regions in the target area. Connected component stitching is performed on the current line scan sub-image and the previous line scan sub-image to obtain the target line scan image. This real-time generation of sub-images during the scanning of the target area ensures the high efficiency and real-time nature of segmented processing. Subsequently, connected component stitching is performed on each sub-image, improving the integrity of the image.
[0075] The functions of each module can be found in the embodiment of the line scan image stitching method, and will not be repeated here.
[0076] To implement the line scan image stitching method of the above embodiments, this application proposes another electronic device, please refer to [link / reference needed]. Figure 12 , Figure 12 This is a schematic diagram of the structure of an embodiment of the electronic device provided in this application.
[0077] Electronic device 1200 includes memory 1210 and processor 1220, wherein memory 1210 and processor 1220 are coupled together.
[0078] The memory 1210 is used to store program data, and the processor 1220 is used to execute the program data to implement the line scan image stitching method of the above embodiment.
[0079] In this embodiment, processor 1220 can also be referred to as a CPU (Central Processing Unit). Processor 1220 may be an integrated circuit chip with signal processing capabilities. Processor 1220 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The general-purpose processor can be a microprocessor, or processor 1220 can be any conventional processor.
[0080] This application also provides a computer-readable storage medium, such as Figure 13 As shown, the computer-readable storage medium 1300 is used to store program data 1310, which, when executed by the processor, is used to implement the line scan image stitching method as described in the method embodiments of this application.
[0081] The methods involved in the line scan image stitching method embodiments of this application, when implemented as software functional units and sold or used as independent products, can be stored in a device, such as a computer-readable storage medium. Based on this understanding, the technical solution of this application, essentially, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0082] The above description is merely an embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A method for stitching line-scanned images, characterized in that, The line scan image stitching method includes: During the scanning of the target area, the current line scan sub-map and the previous line scan sub-map are obtained. The sub-regions included in the current line scan sub-map and the previous line scan sub-map are the adjacent regions in the target area. The current line scan subgraph and the previous line scan subgraph are connected component splicing to obtain the target line scan graph.
2. The line scan image stitching method according to claim 1, characterized in that, The step of performing connected component concatenation processing on the current line scan subgraph and the previous line scan subgraph to obtain the target line scan subgraph includes: Obtain the boundary connected component information of the current line-scanned subgraph and the boundary connected component information of the previous line-scanned subgraph; The boundary connected component information of the current line scan subgraph and the boundary connected component information of the previous line scan subgraph are spliced together to obtain the target line scan map.
3. The line scan image stitching method according to claim 2, characterized in that, The step of obtaining the boundary connected component information of the current line-scanned subgraph and the boundary connected component information of the previous line-scanned subgraph includes: Target identification is performed on the current line scan sub-map and the previous line scan sub-map respectively to obtain at least one target object; The current line scan sub-image and the previous line scan sub-image are binarized according to each target object to obtain the current line scan binary image and the previous line scan binary image. The pixel value of the pixel region where the target object is located in the line scan binary image is different from the pixel value of other regions except the target object, and the pixel value of the pixel region where each target object is located is the same. The boundary connectivity information of the current line-scanned subgraph is determined based on the current line-scanned binary graph, and the boundary connectivity information of the previous line-scanned subgraph is determined based on the previous line-scanned binary graph.
4. The line scan image stitching method according to claim 2, characterized in that, The step of concatenating the boundary connected component information of the current line scan subgraph and the boundary connected component information of the previous line scan subgraph to obtain the target line scan graph includes: The boundary connectivity pair between the current line sweep graph and the previous line sweep graph is determined based on the boundary connectivity information in the current line sweep graph and the previous line sweep graph. By concatenating the boundary connected component pairs, the target line scan map is obtained.
5. The line scan image stitching method according to claim 4, characterized in that, The boundary connectivity information includes the positions of each boundary connectivity in the current line sweep subgraph and the previous line sweep subgraph. The step of determining the boundary connectivity pair between the current line sweep subgraph and the previous line sweep subgraph based on the boundary connectivity information in the current line sweep subgraph and the previous line sweep subgraph includes: The positions of each boundary connected region in the current line sweep subgraph and the positions of each boundary connected region in the previous line sweep subgraph are obtained from the boundary connected region information in the current line sweep subgraph and the previous line sweep subgraph. The boundary connectivity pairs are determined based on the positions of each boundary connectivity in the current line sweep subgraph and the positions of each boundary connectivity in the previous line sweep subgraph.
6. The line scan image stitching method according to claim 5, characterized in that, The step of determining the boundary connected component pairs based on the positions of each boundary connected component in the current line sweep subgraph and the positions of each boundary connected component in the previous line sweep subgraph includes: The boundary connected components in the current line scan subgraph and the previous line scan subgraph are encoded respectively to obtain the label value of each boundary connected component; The label values of the corresponding boundary connected components are adjusted according to their positions so that the label values of connected components belonging to the same target object are the same in the current line scan subgraph and the previous line scan subgraph. Boundary connected components with the same label value are identified as the boundary connected component pairs.
7. The line scan image stitching method according to claim 6, characterized in that, The position of each boundary connected component includes the pixel column position of each boundary connected component in the line scan subgraph. The step of adjusting the label value of the corresponding boundary connected component according to the position of each boundary connected component, so that the label value of connected components belonging to the same target object is the same in the current line scan subgraph and the previous line scan subgraph, includes: In response to the situation where the pixel column position of a boundary connected component in the current line scan sub-image is the same as the pixel column position of a boundary connected component in the previous line scan sub-image, and the corresponding boundary connected component's label value is different, then the label value of the corresponding boundary connected component in the previous line scan sub-image is adjusted to the label value of the corresponding boundary connected component in the current line scan sub-image; or, Adjust the label value of the boundary connected region corresponding to the current line scan subgraph to the label value of the boundary connected region corresponding to the previous line scan subgraph.
8. The line scan image stitching method according to claim 6, characterized in that, After the step of determining the boundary connected components with the same label value as the boundary connected component pair, the method further includes: Connected domains with the same tag value are identified as the same target object; The number of target objects is obtained by statistical processing based on the current line sweep sub-map and the previous line sweep sub-map.
9. An electronic device, characterized in that, include: A memory and a processor, wherein the memory stores program instructions, and the processor retrieves the program instructions from the memory to perform the method as claimed in any one of claims 1-8.
10. A computer-readable storage medium, characterized in that, include: The system stores program data, which, when executed by a processor, is used to implement the method as described in any one of claims 1-8.