Implementation of a fast algorithm for binaryvalue image connection domain tagging

Source: Internet
Author: User

Implementation of a fast algorithm for binaryvalue image connection domain tagging

In the process of automatic image target recognition and tracking, the image target is first extracted by threshold value segmentation. The obtained binary image usually contains multiple connected areas, the system automatically identifies suspicious high-threat flight targets based on the Shape Characteristics of the image targets. Therefore, we need to detect and judge each connected region block separately. In this paper, we use the improved fast tag algorithm to detect and extract each connected region.

Two common methods are used to detect the connected body of a binary image: area growth.


Area Growth Method: first, the image is scanned row by row (Column). Each time an unlabeled "1" pixel is encountered, an unused label is assigned, then, it checks its fields. If there is an unlabeled "1"
Pixel, the same label is assigned. Repeat this operation until there is no "1" pixel that should be propagated. Then, continue the row (column) scan of the image. For example, if the unmarked "1" pixel is detected, the new label is assigned.
. After the entire image scan is completed, the algorithm is terminated. This method can accurately detect various types of connected objects, but it takes a long time to process them because each "1" image must be detected one by one.
And repeated scan of "1" pixels. Tracking Algorithm: each pixel with a value of "1" in a binary image
A coordinate-related label, for example, a number consisting of n and M strings. After the heat, scan the labeled image and change the label of every 10 pixels to the minimum label in the neighborhood. Execute this process repeatedly until you do not need it.
To mark the changes. When this method is used to process small and convex targets, the convergence speed is slow.

In this paper, we propose a new algorithm for Fast Binary Image intercommunication domain tagging with computational regularity. The processing speed is fast and can meet the requirements of most real-time target recognition systems. This algorithm can also be applied to Embedded DSP systems through software programming.

Algorithm Description

First, before the marking algorithm, the hardware was used to open up an independent array of image marking cache and connectivity relationships. Then, during the video stream collection and transmission process
The image performs a row-by-row pixel scan. Then, the adjacent areas of each pixel are detected in the counterclockwise and horizontal directions, and the equivalent mark relationship is merged, the detected results are used to mark the equivalent array and mark the cache.
Update: After an image is acquired and transmitted, the initial marking result and the connection relationship between the initial marking are obtained. Finally, the number is used to merge the numbers in the transfer process of the connected relationship array from small to large,
The merged connected relationship array is used to replace the labels in the Image Tag cache. The replaced image is the final mark result, and the connected domain is assigned a unique continuous natural number in the scanning order.

Figure 1 algorithm flow marking

In this article, the high-speed binary image connection domain tagging algorithm is divided into three steps:

1. Image initial Tag: assign a temporary tag to each pixel and record the equivalence relationship of the temporary tag in the equivalence table

2. Sort out equivalent tables: This step consists of two steps:

(1) Equivalent All temporary tags with Equivalence Relations to the minimum values;

(2) re-number the connected areas in the order of natural numbers to obtain the equivalent relationship between the temporary mark and the final mark.

3. image replacement: Performs pixel-by-pixel replacement for the image, replacing the temporary token with the final tag. after three steps of processing, the algorithm outputs the labeled image, and the connected domain in the image is marked as a continuous natural number in the order from top to bottom and from left to right.

1. Initial image tagging

Algorithm symbol Conventions: W1 and W2 are used to represent two consecutive lines of image data when the algorithm detects the connected domain in the back-clock direction, and K0 is used to detect the connected domain in the next instant clock direction, k indicates two consecutive
The row's image data marked against the clock direction. Its position in the work window is described in figure 2 and 3 respectively, and the initial counter-clockwise temporary mark is represented by Z. The initial Z mark value is 1.

The Intercommunication mark algorithm of Binary Images uses the eight-connection criterion to remove the Boundary Effect of images by narrowing the mark range. In order to simplify the tag processing process, the tag processing is performed on one frame of image transmission by hardware.
During the processing time, tag processing uses the intermediate data cache to be divided into two consecutive types. Type 1 is used for direct image sequence transmission, and when the hardware initiates Image Sequence transmission, type 1 adopts reverse clock sequential connection domain check
Testing: initial marking of binary pixels in a 2 × 3 Working window. Type 2 performs horizontal connection Domain Detection and merging on the initial labeled image data of type 1, and then stores the marked results to image storage.
.

Image initial tag type 1:

Step 1 read the pixel W1 (2), W1 (1), W1 (0), w0 (2), w0 (1), and the corresponding binary pixel value.

Step 2: Read the W0 pixel (1) and compare it with W1 (0), W1 (1), W1 (2), and w0 (2) in a counter-clockwise manner. If w0 (1) =
W1 (0), then K0 (1) = K (2); If w0 (1) = W1 (1), then K0 (1) = K (1 ); if w0 (1) =
W1 (2), then K0 (1) = K (0); If w0 (1) =
W0 (2), then K0 (1) = K0 (0); otherwise (that is, w0 (1) = (W1 (2), W1 (1), W1 (0), w0 (2), K0 (1) = z; Z ++.

Step 3: Write the equivalent link table and write the Z into the equivalent link array with the Z address.

Figure 2 working window for initial marking against the clock direction

Image initial tag type 2:

Step 1: If w0 (1) = w0 (2) = 1, and the gray-scale K0 (1) = K0 (0) are marked, proceed to the next step.

Step 2 assume that K0 (1)> K0 (0), and then determine whether Lab (K0 (1) = K0 (1) or lab (K0 (1) = K0 (0 ), then, lab (K0 (1) = K0 (0). Otherwise, the marked array is replaced by tracing. Go to step 3.

Step 3 assume that K0 (1) <K0 (0) is used to determine whether Lab (K0 (0) = K0 (0) or lab (K0 (0) = K0 (1 ), then, lab (K0 (0) = K0 (1). Otherwise, the marked array is replaced by tracing.

Tracking replacement method: the tracing replacement order t = Lab (K0 (0) in step 2; If lab (t) is less than T, the tracing replacement order t = Lab (t) is executed repeatedly, straight Lab (t) = T; Step 3's tracing replacement order T1 = Lab (K0 (1), the above tracing process is also executed for lab (K0 (1.

Figure 3 Working window for initial marking in horizontal direction

2 equivalent Table sorting and image replacement

First, scanning starts from equivalent Table address 1.
Price table. check whether there is an equivalence relationship between each temporary tag. If yes, update the equivalent table with the tag value as the address of the equivalent table. Since the sorting process starts from equivalent Table address 1, the scanning of the entire equivalent table can end once.

During the image replacement process, each pixel in the temporary Tagged Image is replaced to generate the final Tagged Image. The specific method is: Set the temporary value of the pixel whose coordinates are (n, m) to S
Lab (s) is written to the (n, m) position in the image. After replacement, the connected areas are marked with a unique natural number in the order from top to bottom and from left to right.

3. algorithm Feature Analysis

Algorithm design has the following features:

A. During Initial marking of images, the equivalent table is sorted out while the equivalent information is recorded. This arrangement ensures that, in the case of complex connectivity between regions, the equivalent table can be guaranteed
All the equivalence relationships have been detected. On the other hand, when the marking algorithm is implemented in hardware circuits, the initial marking process of the image and the preliminary sorting process of the equivalent table can be executed in parallel, can simplify the subsequent
Equivalent table sorting operations, equivalent to compressing the entire process of tag execution.

B. in this algorithm, two measures are taken to reduce the number of temporary tags: first, all the tag information generated in the 8-neighbor range is repeatedly used to mark the 8-neighbor range in a counter-clockwise order and then transmitted using the image.
To reduce the probability that new values need to be assigned. Second, when sorting out equivalent tables, when the equivalent mark is merged, the table addresses are compared and replaced in the ascending order,
Make the equivalent tag take a small value and do not omit the equivalent tag. Thirdly, combined with the video data stream transmission mode, the Table Tennis storage structure is used for pipeline processing, and image tagging are replaced at the same time. Mark Images
Achieve real-time processing.

Source code: http://download.csdn.net/source/1525472

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.