Image processing apparatus, image processing method, and image processing program
The method of run-length encoding and paired confirmation processing with label integration on binary images using a GPU with multiple threads addresses the long processing times in labeling, achieving a 2/5 reduction in processing time.
Patent Information
- Application Number
- JP2021105878
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2021-06-25
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2041-06-25
AI Technical Summary
The existing labeling processes for binary images require a significant amount of processing time due to increased pixel data accesses and restricted parallel processing, leading to potential long processing times.
A method involving run-length encoding, paired confirmation processing of adjacent rows in binary images, and label integration to assign labels to connected components, utilizing a GPU with multiple threads for parallel operations.
This approach significantly reduces processing time by enabling efficient parallel processing of binary images, avoiding access conflicts and reducing the overall processing time by 2/5 compared to sequential scanning methods.
Smart Images

Figure 0007707686000001 
Figure 0007707686000002 
Figure 0007707686000003
Abstract
Description
Technical Field
[0001] The present disclosure relates to an image processing apparatus, an image processing method, and an image processing program.
Background Art
[0002] In recent years, for example, in the manufacturing process of products, inspections have been carried out to check for defects or non-conformities by acquiring images of products and extracting feature amounts on the images. One of the image processing techniques used in such cases is labeling processing. The labeling processing is a process of assigning individual numbers (labels) to each connected component (a collection of continuous pixels) in a binary image. For example, Patent Document 1 discloses labeling processing used for defect inspection.
Prior Art Documents
Patent Documents
[0003]
Patent Document 1
Summary of the Invention
Problems to be Solved by the Invention
[0004] When the labeling process is performed by sequentially scanning each pixel constituting the binary image, the number of accesses to pixel data increases, and a very long processing time is required. Although Patent Document 1 describes the acceleration of the labeling process by parallel processing, even in the technology disclosed in Patent Document 1, since the simultaneous processing of the same run (data) by a plurality of threads is restricted under exclusive control, there is a possibility that a long processing time may result.
[0005] An object of the present disclosure is to provide a technique that is very suitable for shortening the processing time of the labeling process.
Means for Solving the Problems
[0006] According to one aspect of the present disclosure, a run-length encoding unit that performs run-length encoding on binary image data to be processed to obtain labeled run data for a plurality of rows; a first confirmation processing unit that pairs the run data of the (2n - 1)-th row (where n is an integer) and the run data of the 2n-th row among the plurality of rows and checks for connection within the image for each pair; a second confirmation processing unit that pairs the run data of the 2m-th row (where m is an integer) and the run data of the (2m + 1)-th row among the plurality of rows and checks for connection within the image for each pair; a label integration processing unit that updates the labels assigned to the run data for which connection within the image has been confirmed to the same label; An image processing apparatus including the above is provided.
[0007] Moreover, according to another aspect of the present disclosure, a run-length encoding step of performing run-length encoding on binary image data to be processed to obtain labeled run data for a plurality of rows; a first confirmation processing step of pairing the run data of the (2n - 1)-th row (where n is an integer) and the run data of the 2n-th row among the plurality of rows and checking for connection within the image for each pair; a second confirmation processing step of pairing the run data of the 2m-th row (where m is an integer) and the run data of the (2m + 1)-th row among the plurality of rows and checking for connection within the image for each pair; a label integration processing step of updating the labels assigned to the run data for which connection within the image has been confirmed to the same label; An image processing method including the above is provided.
[0008] Furthermore, according to still another aspect of the present disclosure, causing a computer to perform a run-length encoding step of performing run-length encoding on binary image data to be processed to obtain labeled run data for a plurality of rows; perform a first confirmation processing step of pairing the run data of the (2n - 1)-th row (where n is an integer) and the run data of the 2n-th row among the plurality of rows and checking for connection within the image for each pair; A second confirmation processing step of pairing the run data of the 2m-th (m is an integer) row and the run data of the (2m + 1)-th row among the plurality of rows and checking the presence or absence of connection within the image for each pair; A label integration processing step of updating the labels assigned to the run data for which connection on the image has been confirmed to the same label; An image processing program for executing the above is provided.
Effect of the Invention
[0009] According to the present disclosure, it is possible to realize shortening of the processing time of the labeling process.
Brief Description of the Drawings
[0010]
Figure 1
Figure 2
Figure 3
Figure 4
Figure 5
Figure 6
Figure 7
Figure 8
Figure 9
Figure 10
Mode for Carrying Out the Invention
[0011] <An Embodiment of the Present Invention> Hereinafter, an embodiment of the present invention will be described with reference to the drawings.
[0012] (1) Configuration of the Image Processing Apparatus First, a configuration example of an image processing apparatus according to an embodiment of the present disclosure will be described.
[0013] The image processing apparatus exemplified here is configured to perform labeling processing on a binary image. The labeling processing is performed, for example, for defect inspection to inspect the presence or absence of defects, defects, etc. using an image of a product, but is not necessarily limited to this, and may be performed for other purposes. Further, as long as the image processing apparatus has at least a function of performing labeling processing, it may have a function of performing other image processing in addition to this.
[0014] The labeling processing is performed using the following functions of the image processing apparatus. FIG. 1 is a block diagram showing a functional configuration example of the image processing apparatus according to the present embodiment. As shown in the figure example, the image processing apparatus according to the present embodiment includes a GPU (Graphics Processing Unit) 1.
[0015] GPU1 is a processor (semiconductor chip) that performs the arithmetic processing required for image processing. The image processing apparatus equipped with GPU1 functions as a computer apparatus that executes a predetermined program by operating according to the predetermined program pre-installed in the GPU1.
[0016] GPU1 includes a data storage unit 10 that stores and holds various data, and is configured to store and hold binary image data 11 to be processed in the data storage unit 10. The binary image data 11 to be processed is, for example, a binarized image of a product to be inspected for defects. Such binary image data 11 is given from an external device and stored and held in the data storage unit 10.
[0017] In addition, GPU1 includes a plurality of processor cores (arithmetic circuits), and is configured such that a plurality of threads (units of processing instructions) can be processed in parallel and simultaneously by these. That is, in GPU1, a plurality of threads (specifically, the first thread 20-1, the second thread 20-2, ···, and the Nth (N is a natural number of 2 or more) thread 20-n) perform parallel simultaneous processing. Note that the number of threads 20-1 to 20-n is not particularly limited.
[0018] Each of the threads 20-1 to 20-n functions as a run-length conversion unit 21-1 to 21-n, a first confirmation processing unit 22-1 to 22-n, and a second confirmation processing unit 23-1 to 23-n under the control instructions of the operation control unit 30.
[0019] The run-length conversion units 21-1 to 21-n have the function of converting the binary image data 11 to be processed into run-lengths to obtain labeled run data 12 for a plurality of rows. The run data 12 for a plurality of rows obtained by the run-length conversion units 21-1 to 21-n is stored and held in the data storage unit 10. Note that the run-length conversion may be performed by a known method, and the detailed description thereof is omitted here.
[0020] The first confirmation processing units 22-1 to 22-n have a function of pairing the run data 12 for a plurality of lines, taking the run data of the (2n - 1)-th line (where n is an integer), which is an odd-numbered line, and the run data of the 2n-th line, which is the even-numbered line adjacent to the odd-numbered line, and checking the presence or absence of connection within the image for each pair. The presence or absence of connection here refers to whether there are connected components (pixels that will be continuous due to adjacent arrangement) between adjacent lines. The confirmation result of the presence or absence of connection is stored and held in the data storage unit 10 as label update data 13 as necessary.
[0021] The second confirmation processing units 23-1 to 23-n have a function of pairing the run data 12 for a plurality of lines, taking the run data of the 2m-th line (where m is an integer), which is an even-numbered line, and the run data of the (2m + 1)-th line, which is the odd-numbered line adjacent to the even-numbered line, and checking the presence or absence of connection within the image for each pair. The presence or absence of connection here is the same as in the case of the first confirmation processing units 22-1 to 22-n. The storage and holding of the label update data 13 in the data storage unit 10 is also the same as in the case of the first confirmation processing units 22-1 to 22-n.
[0022] Also, the GPU 1 includes an operation control unit 30 that controls the processing operations in each of the threads 20-1 to 20-n.
[0023] Furthermore, the GPU 1 includes a label integration processing unit 40 that updates the labeling result of the run data 12 obtained by the run length conversion units 21-1 to 21-n based on the processing results of the first confirmation processing units 22-1 to 22-n and the second confirmation processing units 23-1 to 23-n in each of the threads 20-1 to 20-n. The label integration processing unit 40 updates the label assigned to the run data 12 to the same label based on the label update data 13, which is the confirmation result, for the run data 12 for which connection within the image has been confirmed by the first confirmation processing units 22-1 to 22-n and the second confirmation processing units 23-1 to 23-n.
[0024] The functions of each part 10 to 40 by the GPU1 described above are realized by specifically performing information processing by a predetermined program (software) using the hardware resource of the GPU1. That is, the predetermined program that realizes these functions corresponds to an embodiment of the "image processing program" in the present disclosure. In that case, the image processing program is provided from the outside via a communication line or a storage medium and installed in a predetermined storage area in the image processing apparatus.
[0025] (2) Procedure of the image processing method Next, a specific example will be given and described for the procedure of the processing operation when performing labeling processing using the image processing apparatus having the above-described configuration, that is, the procedure of the image processing method according to an embodiment of the present disclosure.
[0026] FIG. 2 is a flowchart showing an example of the procedure of the image processing method according to the present embodiment. FIG. 3 is an explanatory diagram showing a specific example of binary image data to be processed in the present embodiment. FIGS. 4 and 5 are explanatory diagrams showing a specific example of run data obtained by run-length encoding the binary image data of FIG. 3. FIGS. 6 and 8 are explanatory diagrams showing a specific example of a processing unit when confirming the presence or absence of connection of run data in the present embodiment. FIGS. 7 and 9 are explanatory diagrams showing a specific example of label update data obtained by confirming the presence or absence of connection of run data in the present embodiment. FIG. 10 is an explanatory diagram showing a specific example of run data after performing label integration processing in the present embodiment.
[0027] When performing labeling processing in the present embodiment, as shown in FIG. 2, first, binary image data to be processed is acquired (step 1, hereinafter steps are abbreviated as "S"). Then, the acquired binary image data is stored and held in the data storage unit 10.
[0028] Here, as shown in FIG. 3, a case where binary image data in which each pixel is arranged in 6 rows × 12 columns is acquired is taken as an example.
[0029] After acquiring such binary image data, while accessing the binary image data in the data storage unit 10, the GPU 1 performs run-length encoding on the binary image data to generate run data from the binary image data (S2). At this time, since the GPU 1 is provided with a plurality of threads 20-1 to 20-n capable of parallel operation, under the control instruction from the operation control unit 30, each of the threads 20-1 to 20-n functions as a run-length encoding unit 21-1 to 21-n. Then, each row of the binary image data 11 is set as one processing unit area, and each of the run-length encoding units 21-1 to 21-n processes a separate processing unit area, enabling parallel processing of each of the run-length encoding units 21-1 to 21-n.
[0030] Specifically, in the run-length encoding unit 21-1 by the first thread 20-1, run data is generated for the first row of the 6-row × 12-column binary image data (S21). Also, in the run-length encoding unit 21-2 by the second thread 20-2, run data is generated for the second row of the 6-row × 12-column binary image data (S22). Further, in the run-length encoding unit 21-n by the Nth thread 20-n, run data is generated for the Nth row of the 6-row × 12-column binary image data (S23).
[0031] Through such parallel processing, the processing efficiency of run-length encoding can be improved. Moreover, since each of the run-length encoding units 21-1 to 21-n processes different rows of the binary image data, there is no access conflict to the same row of the binary image data, and a processing waiting state due to access conflict does not occur.
[0032] In the case where the number of rows of the binary image data to be processed is larger than the number of the plurality of threads 20-1 to 20-n, the processing for the same number of rows as the number of threads can be taken as one unit, and after the processing of one unit is completed, the processing of the next unit can be repeated.
[0033] When the above-described processing is performed on the binary image data in FIG. 3, as shown in FIG. 4, run data labeled for a plurality of rows can be obtained. The run data of the legend specifies the arrangement of black pixels that make up the binary image data, and is composed of the row number where the black pixel is located, the start position in the horizontal direction (main scanning direction in the image), the end position in the horizontal direction, and the label number (ID number). Among these, the ID number is assigned a non-duplicated number in one binary image data for each connected component of black pixels in each row of multiple rows. That is, the run data is labeled for each connected component of black pixels. Note that non-duplicated ID numbers can be realized by assigning the values obtained by the following formula (1). The unique thread number of each thread for run-length conversion × the full width of the binary image (the number of pixels in the main scanning direction) / 2 + the order in which run data (black pixels) is found within each row...(1)
[0034] Figure 5 schematically shows the state in which the ID numbers in Figure 4 are attached to each black pixel in the binary image data.
[0035] The run data obtained in this way is stored and held in the data storage unit 10.
[0036] After generating the run data, as shown in Figure 2, the GPU 1 accesses the run data in the data storage unit 10, and performs, as the first confirmation process, a process of confirming the presence or absence of connection within the image for the odd-numbered rows of the run data and the adjacent even-numbered rows (S3). At this time, since the GPU 1 is equipped with a plurality of threads 20-1 to 20-n that can operate in parallel, under the control instruction from the operation control unit 30, each of the threads 20-1 to 20-n functions as the first confirmation processing units 22-1 to 22-n. Then, the (2n-1)th row, which is an odd-numbered row, and the 2nth row, which is the even-numbered row adjacent to the odd-numbered row, are paired as one pair, and each of the first confirmation processing units 22-1 to 22-n processes a different pair, enabling parallel processing of each of the first confirmation processing units 22-1 to 22-n.
[0037] Specifically, as shown in FIG. 6, in the first confirmation processing unit 22-1 by the first thread 20-1, the run data of the first row and the run data of the second row are paired as pair 51, and the presence or absence of connection within the image for the pair 51 is confirmed (S31). Also, in the first confirmation processing unit 22-2 by the second thread 20-2, the run data of the third row and the run data of the fourth row are paired as pair 52, and the presence or absence of connection within the image for the pair 52 is confirmed (S32). In the first confirmation processing unit 22-3 by the third thread 20-3, the run data of the fifth row and the run data of the sixth row are paired as pair 53, and the presence or absence of connection within the image for the pair 53 is confirmed (S33). That is, in each of the first confirmation processing units 22-1 to 22-n, the run data of the (2n-1)-th row which is an odd-numbered row and the run data of the 2n-th row which is an even-numbered row are paired as pairs 51, 52, 53,..., and the presence or absence of connection within the image for the pairs 51, 52, 53,... is confirmed. And each of the first confirmation processing units 22-1 to 22-n processes the confirmation of the presence or absence of connection for each of the pairs 51, 52, 53,... in parallel.
[0038] By such parallel processing, the processing efficiency of the first confirmation processing can be improved. Moreover, since each of the first confirmation processing units 22-1 to 22-n processes different pairs 51, 52, 53,... in the run data of multiple rows, there is no access conflict to the same row in the run data, and there will be no processing waiting state due to access conflict. That is, each of the first confirmation processing units 22-1 to 22-n does not access the run data of the same row simultaneously.
[0039] When the number of pairs of the run data of the (2n-1)-th row and the run data of the 2n-th row to be processed is larger than the number of the plurality of threads 20-1 to 20-n, the processing for the same number of pairs as the number of threads may be taken as one unit, and after the processing of one unit is completed, the processing of the next unit may be repeated.
[0040] The confirmation of the presence or absence of connection within the image may be performed by determining whether the following equations (2) and (3) are satisfied simultaneously. The horizontal start position of the run data in the (2n - 1)-th row ≤ the horizontal end position of the run data in the 2n-th row ··· (2) The horizontal start position of the run data in the 2n-th row ≤ the horizontal end position of the run data in the (2n - 1)-th row ··· (3) If both equations (2) and (3) are satisfied, there is an overlapping part between the horizontal start position and the horizontal end position. Therefore, for the (2n - 1)-th row and the 2n-th row, it can be determined that there is a connected component in the image. By using such an overlapping part between the horizontal start position and the horizontal end position to check for connection, it becomes possible to perform the check with a very simple process.
[0041] The result of the connection check is stored and held in the data storage unit 10 as label update data if necessary. The label update data is for reassigning (updating) the ID numbers so that the ID numbers assigned to the run data for which connection in the image is confirmed are the same. The reassigning of the ID numbers may be performed according to a predetermined rule, such as unifying to the number with the smaller value, unifying to the number with the larger value, or newly assigning a unique non-overlapping number.
[0042] Specifically, for the run data in FIG. 4, no connection is confirmed between the 1st row and the 2nd row and between the 5th row and the 6th row, and connection is confirmed between the 3rd row and the 4th row. Accordingly, the first confirmation processing unit 22-2 generates the following label update data for the ID number "3" of the run data in the 3rd row and the ID number "5" of the run data in the 4th row so that these become the same ID number. That is, as shown in FIG. 7, the first confirmation processing unit 22-2 generates label update data for reassigning the ID number "5" before update to the ID number "3" after update according to the rule of unifying to the number with the smaller value. Then, the first confirmation processing unit 22-2 registers the generated label update data in the ID conversion table constructed in the data storage unit 10 and stores and holds it.
[0043] When the label update data is stored and held in the data storage unit 10, the first confirmation processing units 22-1 to 22-n end the first confirmation processing.
[0044] After the end of the first confirmation processing, subsequently, as shown in FIG. 2, the GPU 1 accesses the random data in the data storage unit 10 and performs, as the second confirmation processing, a process of confirming the presence or absence of connection within the image for the even-numbered lines and the adjacent odd-numbered lines of the random data (S4). At this time, since the GPU 1 is provided with a plurality of threads 20-1 to 20-n capable of parallel operation, under the control instruction from the operation control unit 30, each of the threads 20-1 to 20-n functions as the second confirmation processing units 23-1 to 23-n. Then, the 2m-th line which is an even-numbered line and the (2m + 1)-th line which is the odd-numbered line adjacent to the even-numbered line are paired, and each of the second confirmation processing units 23-1 to 23-n processes a different pair, enabling parallel processing of each of the second confirmation processing units 23-1 to 23-n.
[0045] Specifically, as shown in FIG. 8, in the second confirmation processing unit 23-1 by the first thread 20-1, the random data of the second line and the random data of the third line are paired as pair 61, and the presence or absence of connection within the image is confirmed for the pair 61 (S41). Also, in the second confirmation processing unit 23-2 by the second thread 20-2, the random data of the fourth line and the random data of the fifth line are paired as pair 62, and the presence or absence of connection within the image is confirmed for the pair 62 (S42). That is, in each of the second confirmation processing units 23-1 to 23-n, the random data of the 2m-th line which is an even-numbered line and the random data of the (2m + 1)-th line which is an odd-numbered line are paired as pairs 61, 62,..., and the presence or absence of connection within the image is confirmed for the pairs 61, 62,.... Then, each of the second confirmation processing units 23-1 to 23-n processes the confirmation of the presence or absence of connection for each of the pairs 61, 62,... in parallel.
[0046] Through such parallel processing, the processing efficiency of the second confirmation process can be improved. Moreover, since each of the second confirmation processing units 23-1 to 23-n processes different pairs 61, 62,... in the run data for multiple lines, there is no access conflict to the same line in the run data, and there will be no processing waiting state due to access conflict. That is, each of the second confirmation processing units 23-1 to 23-n does not access the run data of the same line simultaneously.
[0047] In addition, when the number of pairs of the run data of the 2m-th line and the 2m+1-th line to be processed is larger than the number of the plurality of threads 20-1 to 20-n, the processing for the same number of pairs as the number of threads can be taken as one unit, and after the processing of one unit is completed, the processing of the next unit can be repeated.
[0048] The confirmation of the presence or absence of connection within the image may be performed in the same manner as in the case of the first confirmation process. Regarding the confirmation result of the presence or absence of connection, as in the case of the first confirmation process, if necessary, it will be generated as label update data and stored and held in the data storage unit 10.
[0049] Specifically, in the case of the run data in FIG. 4, connection will be confirmed both between the second line and the third line and between the fourth line and the fifth line. Accordingly, the second confirmation processing unit 23-1 generates the following label update data so that "1", which is the ID number for the first half part of the run data of the second line, and "3", which is the ID number for the run data of the third line, are made the same ID number, and further, "2", which is the ID number for the second half part of the run data of the second line, and "3", which is the ID number for the run data of the third line, are made the same ID number. That is, as shown in FIG. 9, the second confirmation processing unit 23-1 reassigns the ID number "3" before update to the ID number "1" after update and generates label update data indicating that the ID number "3" before update is re-assigned to the ID number "2" after update according to the rule of unifying to the number with the smaller value, for example. Further, the second confirmation processing unit 23-2 generates the following label update data to make the "5", which is the ID number for the run data in the fourth row, and the "6", which is the ID number for the run data in the fifth row, have the same ID number. That is, as shown in FIG. 9, the second confirmation processing unit 23-2 generates label update data to reassign the ID number "6" before update to the ID number "5" after update according to the rule of unifying to the number with the smaller value, for example. Then, the second confirmation processing unit 23-1 and the second confirmation processing unit 23-2 register the generated label update data in the ID conversion table constructed in the data storage unit 10 and store and hold it.
[0050] When the label update data is stored and held in the data storage unit 10, the second confirmation processing units 23-1 to 23-n end the second confirmation processing.
[0051] By sequentially performing the first confirmation processing and the second confirmation processing as described above, for the run data for multiple rows obtained from the binary image data, the connectivity within the image is confirmed for all the black pixels constituting the binary image data. That is, the first confirmation processing with the pair of the odd-numbered row and the adjacent even-numbered row as the processing target pair and the second confirmation processing with the pair of the even-numbered row and the adjacent odd-numbered row as the processing target pair cover the entire area of the binary image data with respect to the confirmation of the connectivity within the image.
[0052] In this way, by performing the first confirmation process and the second confirmation process in order, and moreover, processing each pair in parallel in each of the first confirmation process and the second confirmation process, it becomes possible to shorten the processing time. For example, in the case of the binary image data shown in FIG. 3, for confirming the connection presence or absence of each pixel in the image, if each pixel is scanned in order, 6 rows × 12 columns = 72 times of processing are required. Also, it is conceivable to perform the confirmation of the connection presence or absence between adjacent rows in order, but in that case, 5 times of processing for the 1st row and the 2nd row, the 2nd row and the 3rd row, the 3rd row and the 4th row, the 4th row and the 5th row, and the 5th row and the 6th row are required. On the other hand, in this embodiment, the processing for the entire region of the binary image data is completed in two times, namely the first confirmation process and the second confirmation process. Therefore, a significant shortening of the processing time can be achieved compared to the case of scanning each pixel in order, and also, it is possible to realize 2 / 5 of the processing time compared to the case of performing the confirmation of the connection presence or absence between adjacent rows in order.
[0053] When the first confirmation process and the second confirmation process are completed, then, in the GPU1, as shown in FIG. 2, in order to reflect the content of the label update data in the label data, for the random data in the data storage unit 10, the label integration processing unit 40 performs the label (ID) integration processing of the random data 12 (S5). As a result, the random data in the data storage unit 10 is updated with the ID number so that those confirmed to be connected on the image in the first confirmation process and the second confirmation process have the same ID number.
[0054] Specifically, the label integration processing unit 40 performs, as the label (ID) integration processing, an update process of reassigning the ID number before update to the ID number after update for the random data (for example, refer to FIG. 4) stored and held in the data storage unit 10 based on the label update data registered in the ID conversion table in the data storage unit 10.
[0055] The label integration process is not particularly limited in its method. As an example of a method, it is possible to process the label update data registered in the ID conversion table in order for each ID number to be updated. Specifically, for example, in the case of the label update data shown in FIG. 9, the ID number "5" is updated to "3", and then the ID number "3" is updated to "1", and so on. By the way, in the label update data of FIG. 9, it is stipulated that the ID number "3" is updated to "1" and the ID number "3" is updated to "2". In that case, while the ID number "3" before the update is common, among the ID numbers "1" and "2" after the update, "1" has a smaller number. Therefore, when updating the ID number "3", for example, in accordance with the rule of unifying to the number with the smaller number, a process such as further updating the ID number "2" after the update to "1" may be performed. Also, regarding the label update data of FIG. 9, if the process is terminated when the ID number "6" is updated to "5", there is a possibility that the random data connected in the image remains with different ID numbers. Specifically, although the ID number "5" should be updated to "3", it remains in the state of the ID number "5" as it is. Therefore, in the label integration process, after the completion of the update process performed in order, it is confirmed whether the ID number after the update is registered as the ID number before the update in the label update data. If it is registered, an update process of reattaching the ID number before the update to the ID number after the update is performed. And such an update process is repeated until no ID number registered as the ID number before the update is found. That is, for the ID numbers appearing in the label update data, the update process is repeated until all the updates of the ID numbers are reflected.
[0056] By performing the label integration process as described above, the same ID number is assigned to all the random data for which connection in the image has been confirmed. Therefore, after the label integration process, it will be shown that all the random data assigned the same ID number are all connected (in contact) and form one block.
[0057] Figure 10 schematically shows the state in which the ID numbers updated after performing label integration processing on the run data of FIG. 4 based on the label update data of FIG. 9 are attached to each black pixel in the binary image data. According to the illustration, it can be seen that all the run data that are connected in the image to form one block are given the same ID number.
[0058] (3) Effects obtained by this embodiment According to this embodiment, one or more of the following effects can be obtained.
[0059] In this embodiment, the labeling process for binary image data is performed through a first confirmation process (S3) that pairs the run data on the (2n - 1)-th row, which is an odd row, with the run data on the 2n-th row, which is the adjacent even row, and checks the connection status for each pair, a second confirmation process (S4) that pairs the run data on the 2m-th row, which is an even row, with the run data on the (2m + 1)-th row, which is the adjacent odd row, and checks the connection status for each pair, and a label integration process (S5) that updates the labels assigned to the run data confirmed to be connected in these processes to the same label. Therefore, in the labeling process, an individual number (label) is assigned to each connected component (a collection of continuous pixels). According to this embodiment, since the confirmation of the connection status is performed between the run data of adjacent rows, the processing efficiency can be improved compared to the case of scanning each pixel in order. Also, even when the confirmation of the connection status is performed between the run data of adjacent rows, since the rows targeted in the first confirmation process and the second confirmation process are shifted, the entire area of the binary image data can be covered without causing any hindrance to the confirmation. Moreover, in the first confirmation process and the second confirmation process, since the run data of adjacent rows are paired and the connection presence or absence is confirmed for each pair, there is no access conflict to the same row, and a processing wait state due to the access conflict does not occur. That is, according to the present embodiment, in the first confirmation process and the second confirmation process, access to the run data of the same row is not performed simultaneously, so that it is possible to avoid the situation where a large amount of processing time is required due to access restrictions. From the above, according to the present embodiment, it is possible to shorten the processing time of the labeling process.
[0060] In the present embodiment, a plurality of threads 20-1 to 20-n capable of parallel operation are used to perform the first confirmation process for different pairs in parallel. Similarly, the second confirmation process is also performed in parallel for different pairs. Therefore, according to the present embodiment, simultaneous processing of a plurality of pairs is possible for both the first confirmation process and the second confirmation process, and further improvement in the processing efficiency of the labeling process can be achieved. In particular, if the number of threads is equal to or more than the number of pairs of run data, it is not necessary to repeatedly process a plurality of units for the first confirmation process and the second confirmation process, so the effect of shortening the processing time due to further improvement in the processing efficiency is ensured.
[0061] (4) Modifications and the like Although one embodiment of the present disclosure has been specifically described above, the present disclosure is not limited to the above-described embodiment, and can be appropriately changed without departing from the gist thereof.
[0062] For example, in the above-described embodiment, binary image data in which each pixel is arranged in a 6-row × 12-column format is taken as an example for explanation, but it goes without saying that this is merely a specific example. That is, the binary image data to be processed in the present disclosure is not limited in the number of its constituent pixels. The present disclosure can process binary image data in various forms, and in particular, the greater the number of constituent pixels, the greater the effect of shortening the processing time of the labeling process.
Description of Symbols
[0063] 1…GPU, 10…Data storage unit, 11…Binary image data, 12…Run data, 13…Label update data, 20-1…First thread, 20-2…Second thread, 20-n…Nth thread, 21-1 to 21-n…Run length conversion units, 22-1 to 22-n…First confirmation processing units, 23-1 to 23-n…Second confirmation processing units, 30…Operation control unit, 40…Label integration processing unit, 51, 52, 53, 61, 62…Pairs
Claims
1. A run-length encoding unit that performs run-length encoding on binary image data to be processed to obtain labeled run data for a plurality of lines; A first confirmation processing unit that pairs the run data of the (2n - 1)-th (n is an integer) line and the run data of the 2n-th line among the plurality of lines and checks for connection within the image for each pair; A second confirmation processing unit that pairs the run data of the 2m-th (m is an integer) line and the run data of the (2m + 1)-th line among the plurality of lines and checks for connection within the image for each pair; A label integration processing unit that updates the labels assigned to the run data for which connection within the image has been confirmed to the same label; Comprising: The first confirmation processing unit and the second confirmation processing unit are each configured to perform processing on a plurality of said pairs in parallel. An image processing apparatus.
2. The first confirmation processing unit and the second confirmation processing unit are configured so as not to simultaneously access the run data of the same line. The image processing apparatus according to Claim 1.
3. A run-length encoding step of performing run-length encoding on binary image data to be processed to obtain labeled run data for a plurality of lines; A first confirmation processing step of pairing the run data of the (2n - 1)-th (n is an integer) line and the run data of the 2n-th line among the plurality of lines and checking for connection within the image for each pair; A second confirmation processing step of pairing the run data of the 2m-th (m is an integer) line and the run data of the (2m + 1)-th line among the plurality of lines and checking for connection within the image for each pair; A label integration processing step of updating the labels assigned to the run data for which connection on the image has been confirmed to the same label; Comprising: In the first confirmation processing step and the second confirmation processing step, processing on a plurality of said pairs is performed in parallel respectively. An image processing method.
4. Causing a computer to: Perform a run-length encoding step of performing run-length encoding on binary image data to be processed to obtain labeled run data for a plurality of lines; Perform a first confirmation processing step of pairing the run data of the (2n - 1)-th (n is an integer) line and the run data of the 2n-th line among the plurality of lines and checking for connection within the image for each pair; Perform a second confirmation processing step of pairing the run data of the 2m-th (m is an integer) line and the run data of the (2m + 1)-th line among the plurality of lines and checking for connection within the image for each pair; Perform a label integration processing step of updating the labels assigned to the run data for which connection on the image has been confirmed to the same label; And execute. In the first confirmation processing step and the second confirmation processing step, processing for a plurality of the pairs is performed in parallel, respectively. Image processing program.
Citation Information
Patent Citations
Loopback test system
JP1986052034A
Labeling processor, labeling processing method, labeling processing program and recording medium
JP2007128459A
Method, program, and device for processing image data
JP2008186123A