A Binary Image Boundary Tracking Method Based on Line-by-line Scanning

The row-wise scanning method for binary image edge tracking addresses the challenge of balancing speed and accuracy by implementing pixel marking and edge segment operations, enhancing the precision and efficiency of boundary contour extraction.

CN115359084BActive Publication Date: 2025-07-15UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211031324.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-26
Publication Date
2025-07-15
Estimated Expiration
2042-08-26

AI Technical Summary

Technical Problem

Existing binary image boundary tracking algorithms have difficulty in taking into account both speed and accuracy, especially when choosing appropriate termination conditions.

Method used

By using progressive scanning, the molar neighborhood points of the current pixel point are marked, and new boundary fragments, boundary connection judgments and boundary fragments are performed to obtain the coordinate information of the ordered boundary contour point of the target shape.

Benefits of technology

Improved boundary tracking speed and accuracy, achieving more efficient boundary tracking effects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115359084B_ABST
    Figure CN115359084B_ABST
Patent Text Reader

Abstract

The present invention discloses a binary image boundary tracking method based on line-by-line scanning, which is applied to the field of image processing. Aiming at the problem that the existing image boundary tracking algorithms cannot simultaneously take into account the speed and accuracy of boundary tracking; firstly, the present invention marks the pixel points on the target contour; then, scans the binary image line by line from top to bottom in the order of pixel points from left to right in each row. When encountering a boundary contour point that has not been placed in any boundary segment, successively perform boundary connection judgment operations on the boundary contour points at positions P1, P2, P3, and P6 in its Moore neighborhood. Finally, after the line-by-line scanning is completed, the ordered boundary contour of the target is output.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of image processing, and particularly relates to a binary image boundary tracking technology. Background Art

[0002] A binary image is a special form of image representation, and each pixel constituting the image has only two colors, black and white. Binary images play a very important role in the field of image processing, such as facilitating the analysis, matching, recognition, etc. of the image contour.

[0003] Boundary tracking is a method for obtaining the target contour in a binary image. In some image processing applications, such as pattern recognition based on contour features, the target boundary contour pixel points arranged in a specific order are required, and the boundary tracking algorithm can solve this problem. The Moore neighborhood tracking method is a classic and practical boundary tracking algorithm. The principle of this algorithm is that whenever a pixel point belonging to the target is encountered, it returns to the pixel point where it was in the previous step, and then traverses the Moore neighborhood of this pixel point in a clockwise direction until the next pixel point belonging to the target is encountered, and the above operations are repeated until the set termination condition is met. The performance of this algorithm is relatively excellent, but there is a relatively large problem, that is, it is difficult to select a suitable algorithm termination condition to balance both the speed and accuracy of boundary tracking. Summary of the Invention

[0004] The present invention proposes a binary image boundary tracking method based on line-by-line scanning, which solves the problem of difficultly selecting a suitable boundary tracking algorithm termination condition to balance both the boundary tracking speed and accuracy in principle.

[0005] The technical solution adopted by the present invention is: a binary image boundary tracking method based on line-by-line scanning, including:

[0006] S1. Scan the pixel points in the binary image row by row from left to right and from top to bottom. If there is at least one black pixel point and one white pixel point among the Moore neighborhood points in the four positions above, below, in front of, and behind the current pixel point, then mark the current pixel point as a pixel point on the target contour;

[0007] S2. Determine whether the pixel point on the current target contour is connected to a certain point in its Moore neighborhood. If it is connected, execute step S4; otherwise, execute step S3;

[0008] S3. Execute the operation of adding a new boundary segment, and then return to step S2;

[0009] S4. Execute the operation of adding to the boundary segment, and add the pixel point on the current target contour to the boundary segment;

[0010] S5. When all the pixel points on the target contour are scanned, the coordinate information of the ordered boundary contour points with a complete target shape is obtained.

[0011] Advantages of the present invention: The method of the present invention defines three basic operations, namely adding new boundary segments, boundary connection judgment, and adding boundary segments, to track the boundary of a binary image. First, the pixels on the target contour are marked according to the number of black and white pixels among the 4 Moore neighborhood points (up, down, left, and right) of the current pixel point. Then, for the marked pixels on the target contour, new boundary segments are added according to the boundary connection judgment operation, and then the operation of adding boundary segments is executed. Finally, the coordinate information of the ordered boundary contour points of the complete target shape is obtained. The method of the present invention improves the problem existing in the existing binary image boundary tracking algorithm that it is difficult to balance the boundary tracking speed and accuracy simultaneously in principle. Brief Description of the Drawings

[0012] Figure 1 Schematic diagram of marking Moore neighborhood points of point P;

[0013] Figure 2 Schematic diagram of the first type of situation where P is connected to P2;

[0014] Among them, (a) is the situation where P1 and P5 are white, and P3 and P6 are all black, (b) is the situation where P1 and P5 are white, P3 is black, and P6 is white, and (c) is the situation where P1 and P5 are white, P3 is black, and P6 is white;

[0015] Figure 3 Schematic diagram of the second type of situation where P is connected to P2;

[0016] Among them, (a) is the situation where P3 and P6 are white, and P1 and P5 are all black, (b) is the situation where P3 and P6 are white, P1 is black, and P5 is white, and (c) is the situation where P3 and P6 are white, P1 is black, and P5 is white;

[0017] Figure 4 Schematic diagram of the diagonal connection between P and P1;

[0018] Among them, (a) is the situation where P2 is black and P5 is white, and (b) is the situation where P2 is white and P5 is black;

[0019] Figure 5 Schematic diagram of the diagonal connection between P and P3;

[0020] Among them, (a) is the situation where P2 is black and P6 is white, and (b) is the situation where P2 is white and P6 is black;

[0021] Figure 6 Flowchart of the method of the present invention;

[0022] Figure 7Schematic diagram of boundary tracking for binary image targets;

[0023] Among them, (a) shows a situation where there are two boundary segments at a certain moment during the boundary tracking process, (b) shows a situation where the current pixel point can be connected to the tail of one boundary segment and the head of the other boundary segment respectively, and (c) shows a schematic diagram after the two boundary segments are connected. Specific implementation manner

[0024] To facilitate those skilled in the art to understand the technical content of the present invention, the content of the present invention will be further explained below with reference to the accompanying drawings.

[0025] The present invention provides the following technical solutions:

[0026] First, for convenience of description, the pixel points in the Moore neighborhood of any pixel point P are marked, as Figure 1 shown.

[0027] Then, several basic operations designed in the method of the present invention are introduced, which are respectively adding a new boundary segment, boundary connection judgment, and adding to the boundary segment.

[0028] Adding a new boundary segment: A boundary segment is a data structure defined in the method of the present invention, which includes the following three parts: an array storing the positions of ordered pixel points in the boundary contour segment, a head pointer, and a tail pointer. The length of the array is fixed, and all elements in the array are null values when it is just declared. The valid elements of the array refer to the array elements occupied by the position information of consecutive directed boundary contour pixel points that have been put into the array. The head pointer points to the valid element closest to the head of the array. The tail pointer points to the valid element closest to the tail of the array.

[0029] When performing the operation of adding a new boundary segment, declare a new boundary segment, then place the data in the middle position of the array and make the head pointer point to this position, and then assign a null value to the tail pointer.

[0030] Boundary connection judgment: Boundary connection judgment is divided into two types: straight-line connection and diagonal connection.

[0031] (1) Straight-line connection means that P is connected to P2 or P is connected to P6. For the case of being connected to P2, first, P2 should meet the following conditions: it is the head or tail of any boundary segment, and P is the point to be marked. Figure 2 is a schematic diagram of a type of situation where P is connected to P2. The common condition for this type of situation is that P1 and P5 are white. There are a total of three different situations in this type of situation, as Figure 2 (a) In situation 1 shown, P3 and P6 are both black, as Figure 2 (b) Situation 2 shown and as Figure 2 (c) Situation 3 shown are that the colors of P3 and P6 are different respectively.Figure 3 It is a schematic diagram of another type of situation where P is connected to P2. The common condition for this type of situation is that P3 and P6 are white. There are also three different situations in this category, such as Figure 3 In situation 4 shown in (a), both P1 and P5 are black, as Figure 3 In situations 5 and 6 shown in (b) and (c), respectively, the colors of P1 and P5 are different. If any of the above 6 situations is satisfied, then P is connected to P2.

[0032] For the situation where P is connected to P6, first, P6 should meet the following conditions: it is the head or tail of any boundary segment, and P is the point to be marked. The common condition for a type of situation where P is connected to P6 is that P2 and P3 are white. There are a total of three different situations in this category. In situation 1, both P8 and P9 are black. In situations 2 and 3, the colors of P8 and P9 are different. The common condition for another type of situation where P is connected to P6 is that P8 and P9 are white. There are also three different situations in this category. In situation 4, both P2 and P3 are black. In situations 5 and 6, the colors of P2 and P3 are different. If any of the above 6 situations is satisfied, then P is connected to P6.

[0033] (2) Diagonal connection, that is, P is connected to P1 or P is connected to P3. For the situation where P is connected to P1, first, P1 should meet the following conditions: it is the head or tail of any boundary segment. As Figure 4 shown in (a) and (b), P is connected to P1 when the colors of P2 and P5 are different. For the situation where P is connected to P3, P3 should meet the following conditions: it is the head or tail of any boundary segment. As Figure 5 shown in (a) and (b), P is connected to P3 when the colors of P2 and P6 are different.

[0034] Adding boundary segments:

[0035] After the boundary connection judgment operation, when P is connected to a point P_end in its Moore neighborhood, the operation of adding a boundary segment is executed. Let Segment represent the boundary segment where P_end is located.

[0036] (1) First, judge whether the tail pointer of this Segment is empty. If it is a null value, put the coordinate information of the pixel point P into the element at the position one position to the right of the effective element pointed to by the head pointer, and then make the tail pointer point to the position of this new effective element; if it is not a null value, then go to (2).

[0037] (2) If P_end is the tail of the Segment, for the position of the valid element pointed to by the tail pointer of the Segment, find the element corresponding to moving one position backward, put the coordinate information of the pixel point P into this element, and finally make the tail pointer point to the position of this element; if P_end is the head of the Segment, for the position of the valid element pointed to by the head pointer of the Segment, find the element corresponding to moving one position forward, put the coordinate information of the pixel point P into this element, and finally make the head pointer point to the position of this element.

[0038] Algorithm flow:

[0039] S1: First, mark the pixel points on the target contour. Scan each pixel point row by row from top to bottom in the order from left to right. For the pixel point Pij at the i-th row and j-th column with black color, if among the four pixel points at the positions of P(i - 1)j, P(i + 1)j, Pi(j - 1), and Pi(j + 1), there is at least one black pixel point and one white pixel point, then mark Pij as a pixel point on the target contour.

[0040] S2: Then, generate boundary contour segments.

[0041] (1) Scan the binary image row by row in the order of pixel points from left to right from top to bottom.

[0042] (2) When encountering a boundary contour point that has not been placed in any boundary segment, perform boundary connection judgment operations on the boundary contour points at the P1, P2, P3, and P6 positions in its Moore neighborhood in sequence. Figure 7 (a) is a schematic diagram at a certain moment during the boundary tracking process. At this time, there are two boundary segments, represented by Seg1 and Seg2 respectively.

[0043] (3) During the row-by-row scanning process, there are the following special cases: among the pixel points at the P1, P2, P3, and P6 positions of the pixel point currently undergoing boundary connection judgment, there are two boundary contour pixel points that have been placed in boundary segments, and these two boundary contour pixel points belong to different boundary segments respectively. At this time, perform the operation of merging the two boundary segments. As Figure 7 (b) shows, for the point with a cross in the circle, it meets the condition of being connected to the boundary contour point at its P1 position and also meets the condition of being connected to the boundary contour point at its P3 position. According to the order of boundary connection judgment, first perform the operation of adding to Seg2; then encounter the tail of Seg1, and perform the operation of adding to the boundary segment on the boundary contour points stored in Seg1 in sequence from the tail to the head. Thus, the operation of merging the boundary segments is completed, as Figure 7As shown in (c), all the contour points in Seg1 are put into Seg2 at this time, and the head of the original Seg1 becomes the head of Seg2.

[0044] S3: The line-by-line scanning ends, and the ordered boundary contour of the target is output.

[0045] Through the above steps, the coordinate information of the ordered boundary contour points of the complete target shape can be obtained. The algorithm flow of the present invention is as Figure 6 shown.

[0046] Those of ordinary skill in the art will realize that the embodiments described herein are to assist the reader in understanding the principles of the present invention and should be understood that the scope of protection of the present invention is not limited to such specific statements and embodiments. Various changes and modifications can be made to the present invention by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the scope of the claims of the present invention.

Claims

1. A binary image boundary tracking method based on line-by-line scanning, characterized in that, Including: S1. Scan the pixel points in the binary image row by row from top to bottom and from left to right. For the current pixel point Pij, if there is at least one black pixel point and one white pixel point among the four pixel points at positions P(i - 1)j, P(i + 1)j, Pi(j - 1), and Pi(j + 1) in its neighborhood, then mark the current pixel point Pij as a pixel point on the target contour; where i represents the i-th row and j represents the j-th column. S2. Determine whether the pixel point on the current target contour is connected to a certain point in its Moore neighborhood. If it is connected, execute step S4; otherwise, execute step S3; the connection described in step S2 includes straight-line connection and diagonal connection. The specific straight-line connection is that the current pixel point Pij is connected to the pixel point at position P(i - 1)j or Pi(j - 1) in its neighborhood. The process of determining whether there is a straight-line connection is as follows: The pixel point at position P(i - 1)j in the neighborhood of the current pixel point Pij is the head or tail of any boundary segment, and the current pixel point Pij is the point to be marked. When any of the following conditions is met, the current pixel point Pij is connected to the pixel point at position P(i - 1)j in its neighborhood: The two pixel points at positions P(i - 1)(j + 1) and Pi(j + 1) in the neighborhood of the current pixel point Pij are white, and at least one of the two pixel points at positions P(i - 1)(j - 1) and Pi(j - 1) in the neighborhood of the current pixel point Pij is black. The two pixel points at positions P(i - 1)(j - 1) and Pi(j - 1) in the neighborhood of the current pixel point Pij are white, and at least one of the two pixel points at positions P(i - 1)(j + 1) and Pi(j + 1) in the neighborhood of the current pixel point Pij is black. The pixel point at position Pi(j - 1) in the neighborhood of the current pixel point Pij is the head or tail of any boundary segment, and the current pixel point Pij is the point to be marked. When any of the following conditions is met, the current pixel point Pij is connected to the pixel point at position Pi(j - 1) in its neighborhood: The two pixel points at positions P(i + 1)(j - 1) and P(i + 1)j in the neighborhood of the current pixel point Pij are white, and at least one of the two pixel points at positions P(i - 1)(j - 1) and P(i - 1)j in the neighborhood of the current pixel point Pij is black. The two pixel points at positions P(i - 1)(j - 1) and P(i - 1)j in the neighborhood of the current pixel point Pij are white, and at least one of the two pixel points at positions P(i + 1)(j - 1) and P(i + 1)j in the neighborhood of the current pixel point Pij is black. S3. Perform the operation of adding a new boundary segment, and then return to step S2. S4. Perform the operation of adding to the boundary segment, and add the pixel point on the current target contour to the boundary segment. S5. When all the pixel points on the target contour are scanned, obtain the coordinate information of the ordered boundary contour points of the complete target shape.

2. A boundary tracking method for binary images based on line-by-line scanning according to claim 1, characterized in that, The diagonal connection specifically refers to the connection between the current pixel point Pij and its neighborhood P(i - 1)(j - 1) or P(i - 1)(j + 1). The process of determining whether there is a diagonal connection is as follows: The pixel point at the neighborhood P(i - 1)(j - 1) of the current pixel point Pij is the head or tail of any boundary segment, and the current pixel point Pij is the point to be marked. When the two pixel points at the neighborhoods P(i - 1)j and Pi(j - 1) of the current pixel point Pij have different colors, the current pixel point Pij is connected to the pixel point at its neighborhood P(i - 1)(j - 1). The pixel point at the neighborhood P(i - 1)(j + 1) of the current pixel point Pij is the head or tail of any boundary segment, and the current pixel point Pij is the point to be marked. When the two pixel points at the neighborhoods P(i - 1)j and Pi(j + 1) of the current pixel point Pij have different colors, the current pixel point Pij is connected to the pixel point at its neighborhood P(i - 1)(j + 1).

3. A boundary tracking method for binary images based on line-by-line scanning according to claim 1, characterized in that, If there are two boundary contour pixel points that have been placed in the boundary segments among the four pixel points at the neighborhoods P(i - 1)j, P(i + 1)j, Pi(j - 1), and Pi(j + 1) of the current pixel point Pij, and these two boundary contour pixel points belong to different boundary segments respectively, and each is the head or tail of its own boundary segment; then these two boundary segments are merged.

4. A boundary tracking method for binary images based on line-by-line scanning according to claim 3, characterized in that, It also includes defining a data structure for storing boundary segments. The data structure includes: an array, a head pointer, and a tail pointer. The array is used to store data. The head pointer points to the head of the position where valid data is stored in the array, and the tail pointer points to the tail of the position where valid data is stored in the array.

5. A boundary tracking method for binary images based on line-by-line scanning according to claim 4, characterized in that, The operation of adding a new boundary segment is specifically as follows: When performing the operation of adding a new boundary segment, declare a new boundary segment; Place the data in the middle position of the new array, and make the head pointer point to the position of this data in the array, and assign a null value to the tail pointer.

6. A boundary tracking method for binary images based on line-by-line scanning according to claim 5, characterized in that The operation of adding to a boundary segment is specifically as follows: A1. First, determine whether the tail pointer of the boundary segment where the neighboring pixel point to be connected of the current pixel point Pij is located is null. If it is null, execute step A2; Otherwise, if the neighboring pixel point to be connected of the current pixel point Pij is at the tail of the boundary segment where it is located, execute step A3; if the neighboring pixel point to be connected of the current pixel point Pij is at the head of the boundary segment where it is located, execute step A4; A2. For the position pointed to by the tail pointer, find the element corresponding to moving one position backward, put the coordinate information of the pixel point Pij into this element, and finally make the tail pointer point to the position of this element; A3. For the position pointed to by the head pointer, find the element corresponding to moving one position forward, put the coordinate information of the pixel point Pij into this element, and finally make the head pointer point to the position of this element; A4. Place the coordinate information of the current pixel point Pij to the left of the position pointed to by the head pointer of the boundary segment where its neighboring pixel point to be connected is located, and then make the head pointer point to the new head position.

Citation Information

Patent Citations

  • Method for tracking binary image profile, and device thereof

    CN103218808A

  • Method for extracting gesture contour in augmented reality system

    CN106326872A