Method and apparatus for thinning and computer-readable program
By detecting and adjusting run lengths in specific groups within binary images, the method and device address the issue of whiskers in thinning, enhancing processing speed and image quality.
Patent Information
- Application Number
- JP2023096957
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-06-13
- Publication Date
- 2024-12-25
AI Technical Summary
Existing methods for thinning run-length encoded binary images often result in the occurrence of branch-like unnecessary lines (whiskers) at connection portions between lines, slowing down the processing and degrading image quality.
A method and device that detect specific run groups in binary images, adjust the run lengths of these groups to reduce whiskers, and apply predetermined thinning processes to enhance image quality and speed up processing.
The method and device achieve faster thinning with reduced occurrence of whiskers, resulting in a high-quality thinned image suitable for inspections and other applications.
Smart Images

Figure 2024178654000001_ABST
Abstract
Description
[Technical field]
[0001] The present invention relates to a technique for thinning a run-length encoded binary image. [Background technology]
[0002] Conventionally, binary images are run-length coded and converted into run-length data to speed up processing. Patent Document 1 discloses a method of performing one of horizontal thinning processing and vertical thinning processing when transmitting image data, and performing the other processing when receiving the image data. [Prior art documents] [Patent documents]
[0003] [Patent Document 1] Japanese Patent Application Publication No. 59-122178 Summary of the Invention [Problem to be solved by the invention]
[0004] Incidentally, when thinning a run-length coded binary image, it is possible to first perform thinning in the left-right direction corresponding to the run length, and then perform overall thinning to obtain a thinned image. Since run-length data allows for high-speed thinning in the left-right direction, the above method makes it possible to speed up the thinning process of a binary image. However, the above method is prone to abnormalities such as unnecessary branch-like lines (so-called whiskers) at the connection points between lines.
[0005] The present invention has been made in consideration of the above problems, and aims to speed up the thinning process of a binary image and to obtain a beautiful thinned image in which the occurrence of abnormalities such as whiskers is reduced. [Means for solving the problem]
[0006] A first aspect of the present invention is a thinning method for thinning a run-length encoded binary image, comprising the steps of: a) detecting, in the binary image, a run indicating a pattern to be thinned as a target run, and detecting, as a specific run group, a group of target runs which indicate linear regions intersecting in a left-right direction corresponding to the run length and which are connected in order in an up-down direction perpendicular to the left-right direction; b) shortening the run lengths of the specific run group so that, in the specific run group, the run lengths of target runs included at both ends in the up-down direction become shorter the closer they are to the center, and the run lengths of target runs located between the ends are a set width, thereby obtaining a run-length encoded partial thinned image; and c) performing a predetermined thinning process on the partial thinned image to obtain a thinned image.
[0007] A second aspect of the present invention is the thinning method of the first aspect, wherein in the step a), the object run group in which each object run is connected to one or less object runs above and below is detected as the specific run group.
[0008] A third aspect of the present invention is a thinning method according to the first aspect (which may be either first or second aspect), in which in step a), a group of target runs in which the left-right distance between the left ends and the right-left distance between the right ends in each combination of two target runs connected to each other in the vertical direction are less than a predetermined number of pixels are detected as the specific group of runs.
[0009] A fourth aspect of the present invention is a thinning method according to the first aspect (which may be any one of the first to third aspects), in which in the step a), the group of target runs in which the direction of movement of the center of gravity of the target runs is constant from the upper end to the lower end is detected as the specific group of runs.
[0010] A fifth aspect of the present invention is a thinning method according to any one of the first to fourth aspects, wherein the a) step comprises: a1) detecting, in the binary image, a group of target runs that are connected in order in the vertical direction while satisfying predetermined conditions, as a specific run group candidate; and a2) determining whether the specific run group candidate is the specific run group by comparing the length along the vertical direction and the thickness along the horizontal direction in the area indicated by the specific run group candidate.
[0011] A sixth aspect of the present invention is a thinning method according to any one of the first to fourth aspects (which may be any one of the first to fifth aspects), in which, when the shortening of the run length of the specific run group in step b) causes two target runs adjacent to each other in the vertical direction to move apart in the horizontal direction, the run length of at least one of the two target runs is extended.
[0012] A seventh aspect of the present invention is a thinning device that thins a run-length encoded binary image, and includes a specific run group detection unit that detects, as a specific run group, a run that indicates a pattern to be thinned in the binary image, as a target run, and a target run group that indicates a linear region that intersects in the left-right direction corresponding to the run length and is connected in sequence in an up-down direction perpendicular to the left-right direction, the specific run group; a first thinning unit that acquires a run-length encoded partial thinned image by shortening the run lengths of the specific run groups so that the run lengths of the target runs included at both ends in the up-down direction become shorter the closer they are to the center and the run lengths of the target runs located between the ends are a set width; and a second thinning unit that acquires a thinned image by performing a predetermined thinning process on the partial thinned image.
[0013] An eighth aspect of the present invention is a computer-readable program that causes a computer to execute thinning of a run-length encoded binary image, and execution of the program by a computer causes the computer to execute the following steps: a) detecting, in the binary image, a run that indicates a pattern to be thinned as a target run, a group of target runs that indicate linear regions that intersect in the left-right direction corresponding to the run length and that are connected in order in an up-down direction perpendicular to the left-right direction, as a specific run group; b) shortening the run lengths of the specific run group so that, in the specific run group, the run lengths of the target runs included at both ends in the up-down direction become shorter the closer they are to the center, and the run lengths of the target runs located between the ends are a set width, thereby obtaining a run-length encoded partial thinned image; and c) performing a predetermined thinning process on the partial thinned image to obtain a thinned image. Effect of the Invention
[0014] According to the present invention, it is possible to speed up the thinning process of a binary image and obtain a beautiful thinned image in which the occurrence of abnormalities such as whiskers is reduced. [Brief description of the drawings]
[0015] [Figure 1] FIG. 2 is a diagram illustrating a functional configuration of a thinning device. [Diagram 2] FIG. 1 illustrates a configuration of a computer. [Diagram 3] FIG. 1 is a diagram for explaining run-length coding of a binary image. [Figure 4] FIG. 13 is a diagram showing a flow of processing for thinning a binary image. [Diagram 5] FIG. 1 is a diagram showing a binary image. [Figure 6] 11A and 11B are diagrams for explaining detection of specific run group candidates; [Figure 7] FIG. 13 is a diagram showing specific run group candidates. [Figure 8] FIG. 1 is a diagram showing a binary image. [Figure 9]11A and 11B are diagrams for explaining shortening of the run length of a specific run group. [Figure 10] 13A and 13B are diagrams for explaining the extension of the run length of a specific run group. [Figure 11] FIG. 13 is a diagram showing a partially thinned image. [Figure 12] FIG. 13 is a diagram showing a thinned image. [Figure 13] FIG. 13 is a diagram for explaining processing of a comparative example for thinning a binary image. [Figure 14] FIG. 1 is a diagram showing a binary image. [Figure 15] FIG. 13 is a diagram showing a partially thinned image obtained by processing in a comparative example. [Figure 16] FIG. 13 is a diagram showing a partially thinned image. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0016] FIG. 1 is a diagram showing a functional configuration of a thinning device 1 according to an embodiment of the present invention. The thinning device 1 is a device that thins a binary image that has been run-length coded (run-length compressed). The binary image to be thinned by the thinning device 1 is an image in which the line connection relationship, angle, thickness, and other conditions are diverse. For example, the binary image is an image showing a pattern on a board such as a circuit pattern of a printed circuit board, or a cell image showing a cell such as a neurite cell, and the thinned binary image (i.e., the thinned image) is used for inspecting the pattern on the board, inspecting the cell, and the like.
[0017] FIG. 2 is a diagram showing the configuration of a computer 3 that realizes the thinning device 1. The computer 3 has a configuration of a general computer system including a CPU 31, a ROM 32, a RAM 33, a storage device 34, a display 35, an input unit 36, a reading device 37, a communication unit 38, a GPU 39, and a bus 30. The CPU 31 performs various arithmetic processing. The GPU 39 performs various arithmetic processing related to image processing and the like. The ROM 32 stores a basic program. The RAM 33 stores various information. The storage device 34 stores information. The display 35 displays various information such as images. The input unit 36 includes a keyboard 36a and a mouse 36b that accept input from an operator. The reading device 37 reads information from a computer-readable recording medium 81 such as an optical disk, a magnetic disk, a magneto-optical disk, or a memory card. The communication unit 38 transmits and receives signals to and from an external device. The bus 30 is a signal circuit that connects the CPU 31, the GPU 39, the ROM 32, the RAM 33, the storage device 34, the display 35, the input unit 36, the reading device 37, and the communication unit 38.
[0018] In the computer 3, the program 811 is read in advance from the recording medium 81 via the reading device 37 and stored in the storage device 34. The program 811 may be computer-readable and may be stored in the storage device 34 via a network. The CPU 31 and the GPU 39 execute arithmetic processing while using the RAM 33 and the storage device 34 in accordance with the program 811. The CPU 31 and the GPU 39 function as a calculation unit in the computer 3. Other configurations functioning as a calculation unit other than the CPU 31 and the GPU 39 may be employed.
[0019] In the thinning device 1, the computer 3 executes arithmetic processing and the like according to the program 811, thereby realizing the functional configuration shown in Fig. 1. That is, the CPU 31, GPU 39, ROM 32, RAM 33, storage device 34, and their peripheral configuration of the computer 3 realize the specific run group detection unit 20, the first thinning unit 21, and the second thinning unit 22. The functions of the specific run group detection unit 20, the first thinning unit 21, and the second thinning unit 22 will be described in detail later. All or part of these functions may be realized by dedicated electric circuits. Furthermore, these functions may be realized by multiple computers.
[0020] FIG. 3 is a diagram for explaining run-length encoding of a binary image 4. The left side of FIG. 3 shows a part of the binary image 4, and the right side shows data obtained by run-length encoding of the binary image 4 (hereinafter referred to as "run-length data"). In the binary image 4, a plurality of pixels are arranged in two mutually orthogonal directions, and in this specification, the two directions are referred to as the "left-right direction" and the "up-down direction". The left-right direction and the up-down direction are the left-right direction and the up-down direction in the binary image 4 on the left side of FIG. 3. On the left side of FIG. 3, the coordinates of the left-right direction and the up-down direction are written on the upper and left sides of the binary image 4.
[0021] In the binary image 4, a set of pixels having the same value that are continuous in the left-right direction is called a "run", and the number of pixels included in the set of pixels is called a "run length". The run length is the length of the run in the left-right direction. In the binary image 4 in this embodiment, white pixels indicate a pattern, and the pattern is the target of thinning, so in the following description, the run 41 indicating the pattern is called a "target run 41". The target run 41 is a set of white pixels that are continuous in the left-right direction. On the left side of FIG. 3, the target run 41 is surrounded by a thick rectangle. In the actual binary image 4, more pixels are arranged in the left-right direction and the up-down direction than on the left side of FIG. 3, and multiple target runs 41 may exist at each position in the up-down direction. In the run-length coding of the binary image 4, conceptually, the array of values of pixels that are arranged in the left-right direction at each position in the up-down direction in the binary image 4 is represented by the positions of the start and end points of each target run 41 included in the array of values (see the right side of FIG. 3).
[0022] FIG. 4 is a diagram showing a flow of processing for thinning a run-length encoded binary image 4. In the thinning processing of the binary image 4, first, a run-length encoded binary image 4 is prepared and input to the specific run group detection unit 20 of FIG. 1 (step S11). FIG. 5 is a diagram showing a part of the binary image 4 on which thinning processing is performed. In reality, the binary image 4 of FIG. 5 is expressed as run-length data. In this embodiment, a binary image run-length encoded in an external device is input to the thinning device 1 as run-length data, but the run-length data may be prepared by run-length encoding the binary image 4 in the thinning device 1.
[0023] In the specific run group detection unit 20, target runs that are connected in order in the vertical direction while satisfying a predetermined condition are detected as specific run group candidates in the binary image 4 (step S12). FIG. 6 is a diagram for explaining the detection of specific run group candidates 42, and shows a plurality of target runs 41 (some of the target runs are labeled with reference characters 41a to 41l) included in the binary image 4. The processing in the specific run group detection unit 20 is actually performed on the run length data of the binary image 4, but for the sake of convenience, the contents of the processing will be explained with reference to the decoded (expanded) binary image 4. In detecting specific run group candidates, first, it is confirmed whether or not there is another target run 41 that is connected (contacted) below each target run 41, in order from the top to the bottom of the binary image 4. Here, when two target runs 41 are "connected," this includes not only when the two target runs 41 contain pixels that are located at the same left-right position, but also when the left end of one of the two target runs 41 and the right end of the other are located within one pixel of each other in the left-right direction.
[0024] When a target run 41 is present that is connected below one target run 41, it is checked whether the combination of these two target runs 41 (hereinafter referred to as a "connected run pair") satisfies conditions 1 to 3 described below. For a connected run pair that satisfies conditions 1 to 3, the connection relationship is recorded in the specific run group detection unit 20. As a result, a target run group that is a predetermined number or more (for example, Yt or more in number 2 described below) of target runs 41 that are connected in order in the vertical direction and that are included in the connected run pair and each of which satisfies all of conditions 1 to 3 is detected as a specific run group candidate 42. In FIG. 6, one arrow with reference numeral 42 is superimposed on multiple target runs 41 included in one specific run group candidate 42.
[0025] Condition 1 is that each target run 41 included in the connected run pair is connected to only one or less target runs 41 above and below (i.e., connected to only one target run 41, or connected to no target runs 41). For example, in the connected run pair of two target runs denoted by symbols 41a and 41b in FIG. 6, each target run 41a and 41b is connected to only one or less target runs 41 above and below, so the connected run pair of target runs 41a and 41b satisfies condition 1.
[0026] 6, the connected run pair of the two target runs 41d and 41e does not satisfy condition 1 because the target run 41e is connected to the two target runs 41 and 41f on the lower side. In other words, the connected run pair of the target runs 41d and 41e does not satisfy condition 1 because the target run 41e branches into two target runs 41 and 41f on the lower side. In addition, in the connected run pair of the target run 41d and the target run 41c above it, each of the target runs 41c and 41d connects to only one or less target runs 41 on the upper and lower sides, so the connected run pair of the target runs 41c and 41d satisfies condition 1. As described above, condition 1 excludes the branched target runs 41 from the specific run group candidate 42 and includes the non-branched target runs 41 in the specific run group candidate 42.
[0027] Condition 2 is that, in two target runs 41 included in the connected run pair, the horizontal distance between the leftmost pixels (difference in the start coordinates of the runs) and the horizontal distance between the rightmost pixels (difference in the end coordinates of the runs) are equal to or less than a predetermined number of determination pixels. For example, in the connected run pair of target runs 41f and 41g in FIG. 6, the horizontal distance between the leftmost pixels of the target runs 41f and 41g and the horizontal distance between the rightmost pixels of the target runs 41f and 41g are both equal to or less than the number of determination pixels, so the connected run pair of target runs 41f and 41g satisfies condition 2. On the other hand, in the connected run pair of target runs 41h and 41i, the horizontal distance D1 between the leftmost pixels of the target runs 41h and 41i exceeds the number of determination pixels, so the connected run pair of target runs 41h and 41i does not satisfy condition 2. As described above, condition 2 excludes target runs 41 that are significantly deviated from the upper target run 41 from the specific run group candidate 42, and includes target runs 41 that are slightly deviated from the upper target run 41 in the specific run group candidate 42.
[0028] Condition 3 is that, assuming that the two target runs 41 included in the connected run pair are included in the specific run group candidate 42, when the moving direction of the center of gravity of the target run 41 is sequentially identified from the upper end of the specific run group candidate 42 downward, the moving direction of the center of gravity is constant. For example, assume that the connected run pair of target runs 41j and 41k in FIG. 6 is included in the specific run group candidate 42 together with target runs 41f and 41g. In this case, since the moving direction of the center of gravity in the target runs 41j and 41k is the same (to the right) as the moving direction of the center of gravity up to that point (i.e., the moving direction of the target runs 41f and 41g and the moving direction of the target runs 41g and 41j), the connected run pair of the target runs 41j and 41k satisfies condition 3.
[0029] 6 is included in the specific run group candidate 42 together with the target runs 41f, 41g, and 41j, the movement direction of the center of gravity in the target runs 41k and 41l will be opposite to the previous movement direction of the center of gravity, i.e., the specific run group candidate 42 will bend. In this case, the connection run pair of the target runs 41k and 41l does not satisfy condition 3. As described above, condition 3 excludes the target run 41 that will form a bent portion from the specific run group candidate 42.
[0030] FIG. 7 is a diagram showing one specific run group candidate 42. When at least one specific run group candidate 42 is detected, the specific run group detection unit 20 compares the length along the vertical direction and the width along the horizontal direction in the area indicated by each specific run group candidate 42. In the example of FIG. 7, first, the number of target runs 41 included in the specific run group candidate 42 is calculated as the length L, and the average run length of the target runs 41 is calculated as the width T. Furthermore, the shift amount R (which can also be considered as the inclination) of the center of gravity between the upper end target run 41 and the lower end target run 41 included in the specific run group candidate 42 is calculated. Then, if the length L, width T, and shift amount R satisfy the relationship of equation 1, the specific run group candidate 42 is determined to be a specific run group, and if they do not satisfy the relationship of equation 1, the specific run group candidate 42 is determined to not be a specific run group (step S13).
[0031]
number
[0032] The left side of Equation 1 indicates the thickness of the specific run group candidate 42 in a direction perpendicular to the line L1 (shown by a dashed line in FIG. 7) connecting the center of gravity of the upper target run 41 and the center of gravity of the lower target run 41. In other words, the left side of Equation 1 indicates the thickness of the specific run group candidate 42 after correcting the slope. In FIG. 7, this thickness is shown by an arrow with the symbol T0. α in Equation 1 is an adjustment coefficient, and in Equation 1, if the corrected thickness T0 of the specific run group candidate 42 is smaller than the value obtained by multiplying the length L by the coefficient α, the specific run group candidate 42 is determined to be a specific run group.
[0033] The larger the coefficient α, the more likely it is that the specific run group candidate 42 is adopted as a specific run group. The formula 1 for determining whether the specific run group candidate 42 is a specific run group is merely a preferred example. For example, instead of the length L in the formula 1, a length corrected for the inclination of the specific run group candidate 42 (for example, (L 2 +R 2 ) may be used. Alternatively, the thickness T may be used simply as the left side of equation 1. As described above, in step S13, in the area indicated by specific run group candidate 42, the length along the up-down direction and the thickness along the left-right direction are compared to determine whether specific run group candidate 42 is a specific run group.
[0034] 8 is a diagram showing the same binary image 4 as in FIG. 5, in which the specific runs detected by the specific run detection unit 20 are enclosed in a rectangle denoted by reference numeral 43. In the following description, the specific runs are denoted by reference numeral 43. The specific runs 43 are linear regions that intersect in the left-right direction, i.e., vertical and diagonal line regions.
[0035] When the specific run group 43 is detected, the first thinning unit 21 shortens the run length of the specific run group 43 (step S14). Reducing the run length of the specific run group 43 means reducing the number of pixels of the target run 41 included in the specific run group 43, and can be considered as thinning processing. The processing in the first thinning unit 21, like the specific run group detection unit 20, is actually performed on the run length data of the binary image 4, but for convenience of explanation, the contents of the processing will be explained with reference to the decoded binary image 4.
[0036] FIG. 9 is a diagram for explaining the shortening of the run length of a specific run group 43. The left side of FIG. 9 shows a specific run group 43 before the run length is shortened, and the right side shows the specific run group 43 after the run length is shortened. Here, in the binary image 4 in the present embodiment, the position in the vertical direction is represented by the Y coordinate whose value increases from the upper end to the lower end. If one target run 41 included in the specific run group 43 is called the "target run 41 of interest", the Y coordinate of the target run 41 at the upper end of the specific run group 43 is Y0, the Y coordinate of the target run 41 at the lower end is Y1, the Y coordinate of the target run 41 of interest is Yr, and the run length of the target run 41 of interest is Lr, then the shortened run length Ln of the target run 41 of interest is obtained by Equation 2. As will be described later, Yt in Equation 2 is a value that defines the range where a special thinning process is performed in the specific run group 43 and is set in advance.
[0037]
Equation
[0038] The formula on the right side of Equation 2 is divided into the cases of "Yr < Y0 + Yt", "Y1 - Yt < Yr", and "others". The formula for the case of "Yr < Y0 + Yt" is used when the target run 41 of interest is included in a part 431 (hereinafter referred to as the "upper end part 431") that is in the range of Yt downward from the target run 41 at the upper end in the specific run group 43. As shown on the right side of FIG. 9, in this formula, the farther the target run 41 of interest included in the upper end part 431 is from the target run 41 at the upper end, that is, the more the target run 41 of interest is located on the central side, the shorter the shortened run length Ln of the target run 41 of interest becomes. Thus, in the upper end part 431, the width in the left - right direction gradually decreases downward. In the present embodiment, the set width, which is the minimum value of the shortened run length Ln, is set to 1. When the calculation result of this formula is less than 1, the shortened run length Ln of the target run 41 of interest is set to 1. The same applies to the formula in the case of "Y1 - Yt < Yr" described later. Typically, the target run 41 after the run length is shortened is arranged approximately in the center of the target run 41 before the run length is shortened (shown by the dashed - double - dotted line on the right side of FIG. 9).
[0039] The formula for the case of "Y1 - Yt < Yr" is used when the target run 41 at the lower end is included in the part 432 (hereinafter referred to as the "lower end part 432") within the range of Yt from the lower end target run 41 upward in the specific run group 43. In this formula, the farther the target run 41 included in the lower end part 432 is from the lower end target run 41, that is, the more the target run 41 is located on the central side, the shorter the shortened run length Ln of the target run 41 becomes. Thus, at the lower end part 432, the width in the left - right direction gradually decreases upward.
[0040] When the target run 41 is located between the upper end part 431 and the lower end part 432, it falls under the case of "others", and the shortened run length Ln becomes 1 which is the set width. As described above, in the first thinning part 21, a special thinning process with a gradually changing width in the left - right direction is performed on the upper end part 431 and the lower end part 432 of the specific run group 43. Note that depending on the type of pattern shown in the binary image 4, etc., the set width may be larger than 1. Also, the width in the left - right direction at the upper end part 431 and the lower end part 432 does not necessarily have to change linearly and may change non - linearly.
[0041] FIG. 10 is a diagram showing a part of the specific run group 43. The upper row of FIG. 10 shows the specific run group 43 before run length shortening, the middle row shows the specific run group 43 after run length shortening, and the lower row shows the specific run group 43 after run length extension to be described later. As shown in the upper and middle rows of FIG. 10, depending on the inclination of the specific run group 43 with respect to the vertical direction, etc., in the specific run group 43 after run length shortening, two adjacent target runs 41 in the vertical direction may be separated by one or more pixels in the left - right direction (that is, the runs are interrupted). Thus, when a gap 49 of one or more pixels occurs between the two target runs 41 when only the left - right direction is focused on, in the first thinning part 21, as shown in the lower row of FIG. 10, the run length of at least one of the two target runs 41 is extended, and the gap 49 is filled (eliminated). In other words, the two target runs 41 are connected in the diagonal direction.
[0042] Extending the run length of a target run 41 means increasing the number of pixels in the target run 41. In the lower part of FIG. 10, the extended portion (pixels) of each target run 41 is surrounded by a dashed rectangle. For the two target runs 41, the run length of either the upper target run 41 or the lower target run 41 may be extended, or both run lengths may be extended. In the example in the lower part of FIG. 10, the two target runs 41 after the run lengths are extended do not include pixels that are located at the same position in the left-right direction (i.e., pixels that are connected in the up-down direction). The two target runs 41 after the run lengths are extended may include pixels that are located at the same position in the left-right direction.
[0043] FIG. 11 is a diagram showing a binary image 4a after processing by the first thinning unit 21, and corresponds to FIG. 8. In FIG. 11, only the target runs 41 included in the specific run group 43 are subjected to run length shortening, i.e., thinning processing, and the target runs 41 not included in the specific run group 43 are not subjected to thinning processing. Hereinafter, the binary image 4a after processing by the first thinning unit 21 is referred to as a "partial thinned image 4a." The above processing in the first thinning unit 21 is actually performed at high speed by changing the positions (values) of the start and end points of each target run 41 included in the specific run group 43 in the run length data of the binary image 4. As described above, the first thinning unit 21 shortens the run length of the specific run group 43 to obtain a run-length-encoded partial thinned image 4a.
[0044] When the run-length data of the partial thinned image 4a is acquired, the second thinning unit 22 performs a predetermined thinning process on the partial thinned image 4a to acquire a thinned image (step S15). The second thinning unit 22 uses a general thinning algorithm such as Zhang Suen, Hilditch, NWG (Nagendraprasad-Wang-Gupta) or Tamura's method. These thinning algorithms are well known, so detailed explanations will be omitted.
[0045] FIG. 12 is a diagram showing a thinned image 4b acquired by the second thinning unit 22, and corresponds to FIG. 11. In the second thinning unit 22, for example, a thinning process is performed on the entire binary image obtained by decoding the run length data of the partial thinned image 4a. In one example, in the binary image, confirmation is made as to whether or not a 3×3 pixel array centered on each pixel satisfies a predetermined condition, and confirmation is made as to whether or not the 3×3 pixel array satisfies a predetermined pattern, and the like, and whether or not the value of the pixel needs to be changed is determined. These processes are repeated until the thinning is completed. At this time, in the partial thinned image 4a, the partial thinning process for the specific run group 43 has been completed, so that it is possible to shorten the time required for the thinning process in the second thinning unit 22. In fact, the thinning device 1 using the first thinning unit 21 and the second thinning unit 22 can obtain the thinned image 4b in a short time compared to the case where the first thinning unit 21 is omitted and the entire binary image 4 is thinned only by the second thinning unit 22. With the above, the process of thinning the run-length encoded binary image 4 is completed.
[0046] FIG. 13 is a diagram for explaining a comparative example of processing for thinning a run-length encoded binary image. In the processing of the comparative example, first, thinning in the left-right direction is performed on the binary image 9 shown on the left side of FIG. 13. In the thinning in the left-right direction, for example, a linear area (corresponding to the specific run group 43) extending in the up-down direction is detected in the same manner as the processing of steps S12 and S13 in FIG. 4, and then the run lengths of all the target runs included in the linear area are set to 1, which is the set width. As a result, a partial thinned image 9a shown in the center of FIG. 13 is acquired. Thereafter, as in step S15, thinning processing is performed on the entire partial thinned image 9a, and a thinned image 9b is acquired. In the processing of the comparative example, a break in the line occurs in the thinned image 9b as surrounded by a circle with a reference symbol A1. In reality, the break in the line occurs during thinning in the left-right direction (when the partial thinned image 9a is acquired). Furthermore, unwanted branch-like lines, called whiskers, are generated as shown in the circle marked with the symbol A2. In a character image of a facsimile, it may be possible to ignore such abnormalities, but when an inspection is performed using the thinned image 9b, it is not possible to ignore such abnormalities.
[0047] Next, the reason why whiskers are generated in the process of the comparative example will be described. For example, when the binary image 9 shown in Fig. 14 is subjected to left-right thinning by the process of the comparative example, a partial thinned image 9a shown in Fig. 15 is obtained. In the left-right thinning, the entire width of the linear region 91 extending in the up-down direction is set as the set width, so that in the partial thinned image 9a, a protrusion 92 protruding from the upper end of the thinned linear region 91 to the left in Fig. 15 is generated. As a result, in the thinned image obtained by performing the thinning process on the entire partial thinned image 9a, whiskers 931 corresponding to the protrusion 92 are generated in the thinning pattern 93 shown by the dashed line in Fig. 15.
[0048] On the other hand, in the thinning process of Fig. 4, the first thinning unit 21 shortens the run length of the specific run group 43 so that the width in the left-right direction at the upper end 431 of the specific run group 43 gradually decreases toward the lower side, as shown in Fig. 16, and a partial thinned image 4a is acquired. This suppresses the occurrence of the protrusion 92 in the partial thinned image 4a. Also, in the thinned image acquired from the partial thinned image 4a by the second thinning unit 22, the occurrence of whiskers 931 is suppressed as shown in the thinning pattern 44 indicated by the dashed line in Fig. 16. In this way, the first thinning unit 21 shortens the run length of the specific run group 43 while suppressing the influence on the thinning process by the second thinning unit 22, that is, the influence on the final thinned image.
[0049] 4 includes the steps of detecting, as a specific run group 43, a line region that intersects with the left-right direction corresponding to the run length and that is connected in order in the up-down direction in the run-length-encoded binary image 4 (steps S12 and S13), shortening the run length of the specific run group 43 to obtain a run-length-encoded partial thinned image 4a (step S14), and performing a predetermined thinning process on the partial thinned image 4a to obtain a thinned image 4b (step S15). In shortening the run length of the specific run group 43 in step S14, the run lengths of the target runs 41 included in both ends 431 and 432 in the up-down direction in the specific run group 43 become shorter toward the center, and the run length of the target run 41 located between the ends 431 and 432 becomes the set width. This speeds up the thinning process of the binary image 4, and also makes it possible to obtain a beautiful thinned image 4b with reduced occurrence of abnormalities such as whiskers, even when the pattern shown in the binary image 4 has a complex shape. As a result, it becomes possible to appropriately perform inspections and the like using the thinned image 4b. In step S15, various thinning algorithms can be adopted, and this thinning method can be used for general purposes.
[0050] Preferably, when detecting the specific run group 43, the following steps are performed: a step (step S12) of detecting target runs that are connected in order in the vertical direction while satisfying a predetermined condition in the binary image 4 as specific run group candidates 42; and a step (step S13) of determining whether the specific run group candidate 42 is a specific run group 43 by comparing the length along the vertical direction and the width along the horizontal direction in the area indicated by the specific run group candidate 42. This makes it easy to detect the specific run group 43.
[0051] Preferably, an object run group in which each object run 41 is connected to one or less object runs 41 above and below is detected as the specific run group 43. By detecting an object run group that does not include a branch as the specific run group 43 in this manner, it is possible to avoid complicating the process of shortening the run length of the specific run group 43, and it is possible to easily obtain an appropriate thinned image 4b.
[0052] Preferably, a group of object runs in which the left and right distances between the left and right ends of each combination of two object runs 41 connected to each other in the up-down direction are equal to or less than a predetermined number of pixels are detected as the specific run group 43. If two object runs 41 whose left or right ends are excessively separated from each other in the left-right direction are included in the specific run group 43, the portions of the thinned image corresponding to the two object runs 41 may deviate from the ideal shape of the thinned pattern. On the other hand, in the above steps S12 and S13, such two object runs 41 are prevented from being included in the specific run group 43, thereby making it possible to obtain an appropriate thinned image 4b.
[0053] Preferably, a group of target runs in which the direction of movement of the center of gravity of the target run 41 is constant from the upper end to the lower end is detected as the specific run group 43. This makes it possible to prevent an abnormality from occurring in the thinned image 4b due to the end portions 431, 432 of the specific run group 43 including a bent portion in which the direction of movement of the center of gravity changes. Also, for example, when detecting a specific run group candidate 42 in step S12, by detecting a group of target runs in which the direction of movement of the center of gravity is constant, i.e., a group of target runs that does not include a bent portion, as the specific run group candidate 42, it is possible to easily compare the length and width of the area indicated by the specific run group candidate 42 in step S13.
[0054] Preferably, when two target runs 41 adjacent in the vertical direction are separated in the horizontal direction by shortening the run lengths of the specific run group 43 in step S14, the run length of at least one of the two target runs 41 is extended. This makes it possible to prevent a gap between the runs in the partial thinned image 4a.
[0055] The thinning device 1 includes a specific run group detection unit 20, a first thinning unit 21, and a second thinning unit 22. The specific run group detection unit 20 detects, in the run-length-encoded binary image 4, a target run group that indicates a linear region intersecting in the left-right direction corresponding to the run length and is connected in order in the up-down direction as a specific run group 43. The first thinning unit 21 shortens the run length of the specific run group 43 so that the run length of the target run 41 included in both ends 431, 432 in the up-down direction becomes shorter toward the center and the run length of the target run 41 located between the ends 431, 432 is a set width, thereby acquiring a run-length-encoded partial thinned image 4a. The second thinning unit 22 acquires a thinned image 4b by performing a predetermined thinning process on the partial thinned image 4a. This makes it possible to speed up the thinning process of the binary image 4 and to obtain a beautiful thinned image 4b with reduced occurrence of abnormalities such as whiskers.
[0056] In the above formula 2, the size of the ends 431, 432 of the specific run group 43 in the vertical direction is determined by Yt. By reducing Yt, it is possible to increase the processing speed. By increasing Yt, abnormalities such as whiskers are more unlikely to occur, and the quality of the thinned image 4b is improved. In addition, in the above formula 1, the larger the coefficient α, the more likely the specific run group candidate 42 is to be adopted as the specific run group 43, and the processing speed can be increased. In addition, the smaller the coefficient α, the more unlikely the specific run group candidate 42 is to be adopted as the specific run group 43, and the occurrence of abnormalities in the thinned image 4b is suppressed. Furthermore, with regard to the above condition 2, the larger the number of judged pixels, the higher the processing speed, and the smaller the number of judged pixels, the more the occurrence of abnormalities is suppressed. As described above, in the thinning process, there is a trade-off between increasing the processing speed and improving the quality of the thinned image 4b, so the above Yt, coefficient α, number of judged pixels, etc. may be appropriately determined according to the processing speed required for the thinning process and the quality of the thinned image.
[0057] The above-described thinning method and thinning device 1 can be modified in various ways.
[0058] In the specific run group detection unit 20, all or some of the conditions 1 to 3 used for detecting the specific run group candidate 42 may be omitted, or other conditions may be used. Also, the specific run group 43 may be detected directly without detecting the specific run group candidate 42.
[0059] In step S13, if a specific run group candidate 42 in which the inclination of a line L1 (see FIG. 7) connecting the center of gravity of the uppermost target run 41 and the center of gravity of the lowermost target run 41 is greater than a predetermined value is determined to be a specific run group 43, two target runs 41 adjacent in the vertical direction are likely to be separated by one pixel or more in the horizontal direction when shortening the run length in step S14. As a result, the time required for the run length extension process may increase. Therefore, a specific run group candidate 42 in which the inclination is greater than a predetermined value may be determined not to be a specific run group 43, and the increase in the time required for the run length extension process may be suppressed.
[0060] When the binary image 4 to be subjected to the thinning process contains many linear patterns extending in the left-right direction, the process of FIG. 4 may be performed after transposing the image in the left-right and up-down directions.
[0061] The above-described thinning method and thinning device 1 may be used for purposes other than inspection of patterns or cells on a substrate.
[0062] The configurations in the above-described embodiment and each of the modified examples may be combined as appropriate as long as they are not mutually inconsistent. [Explanation of symbols]
[0063] 1 Thinning device 3. Computer 4. Binary Images 4a Partially thinned image 4b Thinned image 20 Specific run group detection unit 21 1st thinning section 22 2nd thinning section 41, 41a~41l Target Run 42 Specific orchid group candidates 43 Specific orchid group 431,432 (end of a particular run group) 811 Program S11~S15 steps
Claims
1. 1. A thinning method for thinning a run-length coded binary image, comprising the steps of: a) detecting, as a specific run group, a run indicating a pattern to be thinned in the binary image, which indicates a linear region intersecting in a left-right direction corresponding to a run length and which is connected in order in an up-down direction perpendicular to the left-right direction; b) shortening the run lengths of the specific run group so that the run lengths of the target runs included at both ends in the vertical direction become shorter toward the center and the run lengths of the target runs located between the ends are within a set width, thereby acquiring a run-length-encoded partial thinned image; c) performing a predetermined thinning process on the partial thinned image to obtain a thinned image; The thinning method comprises:
2. 2. A thinning method according to claim 1, comprising the steps of: In the step a), the object run group in which each object run is connected to one or less object runs above and below is detected as the specific run group.
3. 2. A thinning method according to claim 1, comprising the steps of: In the thinning method, in step a), a group of target runs in which the left-right distance between the left ends and the left-right distance between the right ends in each combination of two target runs connected to each other in the vertical direction are less than a predetermined number of pixels are detected as the specific run group.
4. 2. A thinning method according to claim 1, comprising the steps of: In the step a), the group of object runs whose center of gravity moves in a constant direction from an upper end to a lower end is detected as the group of specific runs.
5. 5. A thinning method according to claim 1, further comprising the steps of: The step a) comprises: a1) detecting, in the binary image, a group of target runs that are connected in order in the vertical direction while satisfying a predetermined condition, as a specific group of run candidates; a2) determining whether the specific run group candidate is the specific run group by comparing a length along the up-down direction with a width along the left-right direction in an area indicated by the specific run group candidate; The thinning method comprises:
6. 5. A thinning method according to claim 1, further comprising the steps of: A thinning method in which, when two target runs adjacent to each other in the vertical direction are separated in the horizontal direction by shortening the run length of the specific run group in step b), the run length of at least one of the two target runs is extended.
7. A thinning device for thinning a run-length encoded binary image, comprising: a specific run group detection unit that detects, as a specific run group, a run indicating a pattern to be thinned in the binary image as a target run, the target run group indicating a linear region intersecting in a left-right direction corresponding to a run length and connected in order in an up-down direction perpendicular to the left-right direction; a first thinning unit that acquires a run-length-encoded partial thinned image by shortening the run lengths of the specific run group so that the run lengths of target runs included in both ends in the vertical direction become shorter toward the center and the run lengths of target runs located between the ends are within a set width; a second thinning unit that performs a predetermined thinning process on the partial thinned image to obtain a thinned image; A thinning device comprising:
8. 1. A computer readable program for causing a computer to perform thinning of a run-length encoded binary image, the execution of the program by the computer comprising: a) detecting, as a specific run group, a run indicating a pattern to be thinned in the binary image, which indicates a linear region intersecting in a left-right direction corresponding to a run length and which is connected in order in an up-down direction perpendicular to the left-right direction; b) shortening the run lengths of the specific run group so that the run lengths of the target runs included at both ends in the vertical direction become shorter toward the center and the run lengths of the target runs located between the ends are within a set width, thereby acquiring a run-length-encoded partial thinned image; c) performing a predetermined thinning process on the partial thinned image to obtain a thinned image; A computer-readable program that causes a computer to execute
Citation Information
Patent Citations
Linear graphic polygonal line conversion processing system
JP1992095178A
Disk cartridge and disk changer
JP1996031130A
Ruled line extraction method and ruled line elimination method
JP1999232382A
Image processor and image processing program
JP2012123463A
Picture data transmitting system
JP1984122178A
Cited By
Thermoplastic-based building panel comprising a balancing layer
US12320131B2
