Method for detecting the center line
The method simplifies the detection of image center lines by converting images to grayscale and binarizing them, using positional relationships to identify center line pixels, thus overcoming the complexity of conventional pixel-based analysis.
Patent Information
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- MEIJO UNIVERSITY
- Filing Date
- 2023-11-30
- Publication Date
- 2026-04-23
AI Technical Summary
Conventional methods for detecting the center line of an image are complex and require intricate local feature analysis of individual pixels on the contour line.
A method that involves converting the target image to grayscale, smoothing, and binarizing it to detect specific pixels within the contour line, followed by identifying center line constituent pixels based on their positional relationships, such as distance and proximity to other pixels.
Simplifies the detection of the center line by focusing on the positional relationships between pixels, allowing for easy and accurate identification of center line pixels.
Smart Images

Figure 0007850454000001 
Figure 0007850454000002 
Figure 0007850454000003
Abstract
Description
Technical Field
[0001] The present invention relates to a method for detecting a center line.
Background Art
[0002] The image processing apparatus disclosed in Patent Document 1 includes a contour pixel extraction unit that determines whether a target pixel is a contour, and a thinning amount calculation unit that calculates the amount of thinning to be applied to the target pixel when the contour pixel extraction unit determines that the target pixel is a contour. Further, this image processing apparatus includes a rectangular region connectivity determination unit that determines whether a pixel region including the target pixel is a predetermined pixel pattern, and a selective correction output unit that applies thinning to the target pixel with the amount of thinning when the rectangular region connectivity determination unit does not determine that the pixel region including the target pixel is a predetermined pixel pattern, and applies thinning to the target pixel with an alternative amount of thinning different from the amount of thinning when the rectangular region connectivity determination unit determines that the pixel region including the target pixel is a predetermined pixel pattern.
Prior Art Documents
Patent Documents
[0003]
Patent Document 1
Summary of the Invention
Problems to be Solved by the Invention
[0004] In the conventional method for detecting the center line of an image, like the image processing performed by the image processing apparatus of Patent Document 1, it is determined whether each pixel on the contour line itself is a center line constituent pixel based on the result of local feature analysis of individual pixels on the contour line, and that process is complicated. Therefore, there is a need for a method that can detect the center line of the subject in the target image in a simpler way.
[0005] The present invention has been made in view of the above conventional circumstances, and can simply detect the center line of the subject in the target image.
Means for Solving the Problems
[0006] The centerline detection method of the first invention is: The first step is to load the target image, A second step involves converting the aforementioned target image to grayscale, smoothing it, and binarizing it to generate a binarized image. A third step involves detecting, as specific pixels, a first pixel which is the contour-forming pixel located at the shortest distance from each inner pixel within the contour-forming pixels that constitute the contour line of the subject in the binarized image, and a second pixel which is the contour-forming pixel located within a distance of the shortest distance plus a predetermined distance. For each of the inner pixels, if multiple specific pixels are detected, a fourth step is to detect them as centerline constituent pixels when the distance between the furthest pair of specific pixels among the multiple specific pixels is greater than or equal to a predetermined value, The system comprises a first detection method having [a certain characteristic].
[0007] The centerline detection method of the second invention is: The first step is to load the target image, A second step involves converting the aforementioned target image to grayscale, smoothing it, and binarizing it to generate a binarized image. A third step of detecting new contour-forming pixels by removing protruding pixels, which consist of two adjacent pixels that protrude outward at the pixel pitch distance or one pixel that protrudes outward, from among the contour-forming pixels that constitute the contour line of the subject in the binarized image, A fourth step involves detecting pixels that constitute a new contour line of the subject, which are composed of pixels inside the aforementioned contour line constituent pixels, as new contour line constituent pixels. A fifth step in which, if only two inner pixels exist between a pair of contour line constituent pixels, one of the inner pixels between them is detected as a center line constituent pixel, and if only one inner pixel exists between a pair of contour line constituent pixels, that inner pixel between them is detected as the center line constituent pixel. A method for detecting a center line comprising a second detection method that repeats the fourth and fifth steps. [Effects of the Invention]
[0008] The technology disclosed herein can easily detect the center line of a subject in a target image. [Brief explanation of the drawing]
[0009] [Figure 1] Figure 1 is a block diagram showing the electrical configuration of the image processing apparatus of the first embodiment. [Figure 2] Figure 2 is a flowchart showing the flow of the first image processing control performed by the image processing device. [Figure 3] Figure 3(A) shows a binarized image obtained by converting the target image to grayscale, smoothing it, and then binarizing it. Figure 3(B) shows the binarized image with the innermost pixels of the contour-forming pixels set to black pixels. [Figure 4] Figure 4(A) shows an image including contour line pixels and center line pixels when a predetermined distance of 0.5 times the pixel pitch is used. Figure 4(B) shows an image including contour line pixels and center line pixels when a predetermined distance of √2 times the pixel pitch is used. [Figure 5] Figure 5(A) shows the image obtained by smoothing the image in Figure 4(B). Figure 5(B) shows the image obtained by applying a second image processing control to the image in Figure 5(A). [Figure 6] Figure 6 is a flowchart showing the flow of the second image processing control performed by the image processing device. [Figure 7] Figure 7(A) is an image obtained by setting the inner pixels to black pixels, compared to the binarized image shown in Figure 3(A). Figure 7(B) is an image obtained by detecting new contour lines from the contour line image in Figure 7(A). [Figure 8] Figure 8(A) shows an image in which new contour lines have been detected from the contour line image in Figure 7(B). Figure 8(B) shows an image in which new contour lines have been detected from the contour line image in Figure 8(A). [Figure 9]FIG. 9(A) is a diagram showing an image in which a new contour line is detected from the image of the contour line in FIG. 8(B). FIG. 9(B) is a diagram showing an image in which a new contour line is detected from the image of the contour line in FIG. 9(A). [Figure 10] FIG. 10(A) is a diagram showing an image in which a new contour line is detected from the image of the contour line in FIG. 9(B). FIG. 10(B) is an image including contour line constituent pixels and center line constituent pixels specified in the images of FIGS. 7(B) - 10(A).
Embodiments for Carrying Out the Invention
[0010] Hereinafter, embodiments of the present disclosure will be listed and exemplified. [1] A first step of reading a target image, A second step of converting the target image to grayscale, smoothing it, and binarizing it to generate a binarized image, For each inner pixel inside the contour line constituent pixels that constitute the contour line of the subject in the binarized image, a first pixel that is the contour line constituent pixel located at the shortest distance, and a second pixel that is the contour line constituent pixel located within a distance obtained by adding a predetermined distance to the shortest distance are detected as specific pixels in a third step, A fourth step of detecting, as center line constituent pixels, when a plurality of the specific pixels are detected for each of the inner pixels and the distance between the pair of the most distant specific pixels among the plurality of the specific pixels is a predetermined value or more, A method for detecting a center line comprising a first detection method having the above.
[0011] According to this configuration, in the third step, specific pixels (first pixel and second pixel) corresponding to the inner pixels of the subject within the target pixel can be detected. In the fourth step, among a plurality of inner pixels, those in which the specific pixels (first pixel and second pixel) have a predetermined relationship can be detected as center line constituent pixels. Thus, the process of discriminating center line constituent pixels is greatly simplified as compared with the conventional method by a technique based on a simple principle. Therefore, after detecting the contour line of the binarized image of the target image, the center line of the subject can be easily detected based on the contour line.
[0012] [2] A first step of reading a target image, A second step of converting the target image into grayscale, smoothing it, and binarizing it to generate a binarized image, A third step of removing protruding pixels composed of two pixels that protrude outward adjacent to each other at a pixel pitch distance or one pixel that protrudes outward among the contour line constituent pixels constituting the contour line of the subject in the binarized image to detect new contour line constituent pixels, A fourth step of detecting pixels constituting a new contour line of the subject composed of pixels inside the contour line constituent pixels as the new contour line constituent pixels, A fifth step of detecting one of the inner pixels between a pair of pixels among the contour line constituent pixels as a center line constituent pixel when only two inner pixels exist between the pair of pixels, and detecting the inner pixel between the pair of pixels as the center line constituent pixel when only one inner pixel exists between the pair of pixels, A method for detecting a center line, comprising a second detection method having the above steps and repeating the fourth step and the fifth step.
[0013] According to this configuration, the third step can prevent the protruding pixels of the binarized image from affecting the detection of the contour line constituent pixels in the fourth step and the detection of the center line constituent pixels in the fifth step. By the fourth step and the fifth step, the center line constituent pixels can be detected based on the feature analysis of the pixels on each contour line while gradually shrinking the contour line of the binarized image from the outermost shell in order. Thus, the process of discriminating the center line constituent pixels is significantly simplified compared to the prior art by a method based on a simple principle. Therefore, by paying attention to the positional relationship between any two pixels on the contour line, the pixels outside the contour line sandwiched between these two pixels can be detected as center line constituent pixels, and the center line of the subject can be easily detected.
[0014] [3] A method for detecting a center line, which performs the third step of the second detection method described in [2] on the subject constituted by the center line constituent pixels detected by the first detection method described in [1], and repeats the fourth step and the fifth step.
[0015] With this configuration, in addition to the first detection method, the second detection method focuses on the positional relationship between any two pixels on the contour line and detects the pixels outside the contour line that are sandwiched between those two pixels as centerline constituent pixels, thereby enabling accurate detection of the centerline of the subject.
[0016] <First Embodiment> (Image processing device) Hereinafter, an image processing apparatus 10 of the first embodiment embodying the present invention will be described with reference to Figure 1. The image processing apparatus 10 performs a process to detect the center line of a subject in a target image. The image processing apparatus 10 is an information processing apparatus (computer) that executes an image processing program described later. The image processing program is a program that causes the image processing apparatus 10 to execute the "center line detection method comprising the first detection method" and the "center line detection method comprising the second detection method" of the present invention. The image processing apparatus 10 is a device that stores various image data and displays the stored various image data.
[0017] Image processing by the image processing device 10 can be used to detect the centerlines of biological samples (fibrous structures, etc.) contained in an image. Furthermore, this image processing can be used to detect shape distortion by detecting the centerlines of industrial products contained in an image. Additionally, this image processing can be used for character recognition by detecting the centerlines of characters contained in an image. Finally, this image processing can be used to extract road networks from map data images by detecting the centerlines of roads.
[0018] As shown in Figure 1, the image processing device 10 includes a control unit 11, a storage unit 12, an input unit 13, and a display unit 14.
[0019] The control unit 11 controls the entire image processing device 10. The control unit 11 includes, for example, an MCU (Micro Processor Unit) and other peripheral circuits, and can perform various controls and calculations. The control unit 11 performs controls based on, for example, a program (image processing program, etc.) stored in the memory unit 12.
[0020] The memory unit 12 is composed of a known storage device such as semiconductor memory, for example, RAM, ROM, or non-volatile memory. The memory unit 12 stores various programs, etc. The memory unit 12 stores programs that are executed by the control unit 11 (such as image processing programs that cause the control unit 11 to perform control in the flow shown in Figures 2 and 6, which will be described later).
[0021] The input unit 13 is an input interface for inputting data, consisting of, for example, a keyboard, touch panel, mouse, scanner, etc. The input unit 13 receives the target image and various setting values (such as "predetermined distance" and "predetermined value," which will be described later).
[0022] The display unit 14 is configured as a known image display device, such as a liquid crystal display, an organic electroluminescent display, or a touch panel. The display unit 14 displays various image data stored in the storage unit 12.
[0023] (First image processing control) The image processing device 10 performs the following first image processing control. The first image processing control is a control that causes the "centerline detection method comprising the first detection method" of the present invention to be executed.
[0024] Figure 2 is a flowchart showing the flow of the first image processing control performed by the control unit 11 of the image processing device 10. An example of the image processing program of the present invention is a program that causes the control unit 11 to perform control in the flow shown in Figure 2.
[0025] The control unit 11 starts the control shown in Figure 2 when a predetermined start condition is met. The fulfillment of the predetermined start condition is, for example, when an operation is performed in the image processing device 10 to execute an image processing program.
[0026] The control unit 11 first reads the target image (step S1). Step S1 corresponds to the "first step" of the present invention. The target image is, for example, stored in the storage unit 12 beforehand.
[0027] Next, the control unit 11 converts the target image read in step S1 to grayscale, smooths it, and binarizes it to generate a binarized image (step S2). Step S2 corresponds to the "second step" of the present invention. Smoothing can be performed based on a general smoothing process (such as an averaging filter). For binarization, white pixels and black pixels are set, for example, so that the subject is composed of white pixels. For example, the control unit 11 generates a binarized image as shown in Figure 3(A). In Figure 3(A), white squares represent white pixels, and the object composed of all white pixels corresponds to the subject.
[0028] Next, the control unit 11 obtains the coordinates of the white pixels in the binarized image, the contour line image, the grayscale image of the contour line, and the coordinates of the contour line constituent pixels (step S3). Here, the coordinates of a pixel are, for example, the coordinates (two-dimensional coordinates) of the pixel's position when a predetermined position in the binarized image is taken as the origin. The two-dimensional coordinates include, for example, the X coordinate (left-right direction when the image is viewed from the front) and the Y coordinate (up-down direction when the image is viewed from the front). The position of a pixel is expressed by the coordinates of the geometric center point of the pixel. The contour line image is, for example, an image extracted from the portion that constitutes the contour line of a subject in the target image (the outermost line that forms the outline of the subject). Contour line constituent pixels are pixels that constitute the contour line of the subject in the target image. For example, Figure 3(B) is an image obtained by treating the binarized image shown in Figure 3(A) as is, with the contour line constituent pixels remaining as white pixels, and all the inner pixels inside the contour line constituent pixels being black pixels. The control unit 11 stores the coordinates of the white pixels in the binarized image, the contour line image, the grayscale image of the contour line, and the coordinates of the contour line constituent pixels in the storage unit 12.
[0029] Next, the control unit 11 stores (stores) the grayscale image, binarized image, and contour image of the target image in the storage unit 12 (step S4). The grayscale image and binarized image of the target image are the images generated in step S1. The contour image is the image generated in step S2. These grayscale image, binarized image, and contour image are stored (stored) in the storage unit 12 as a composite image with the center point or center line image (also called the center image) in step S6, which will be described later, and can be displayed on the display unit 14.
[0030] Next, the control unit 11 performs a centerline detection process for the subject in the target image using the first detection method (step S5). First, the control unit 11 performs a third step in which it detects, for each inner pixel inside the contour line constituent pixels, a first pixel which is the contour line constituent pixel located at the shortest distance (excluding 0), and a second pixel which is the contour line constituent pixel located within a distance equal to the shortest distance plus a predetermined distance, as specific pixels. Here, the distance between pixels is the distance between the coordinates of the pixels (the geometric center point of the pixels). The shortest distance between pixels, and the distance between adjacent pixels that share one side, is called the pixel pitch. The value of the pixel pitch is set to 1.
[0031] Here, we show an example of identifying a contour line component pixel that is located within a distance equal to the shortest distance plus a predetermined distance of '0.5 times' the pixel pitch, in order to identify the second pixel. Figure 4(A) is an image that includes contour line component pixels (white pixels) and the identified center line component pixels (pixels shown by hatching), which will be described later. For example, as shown in Figure 4(A), focusing on the inner pixel A1, the contour-forming pixel located at the shortest distance (3) from the inner pixel A1 is the contour-forming pixel (first pixel) A2. Focusing on the inner pixel A1, the contour-forming pixels excluding the first pixel A2, which is located within a distance (3.5) that is the shortest distance (3) plus 0.5 times the pixel pitch (1), are the contour-forming pixels (second pixel) A3. Therefore, the specific pixels for the inner pixel A1 are the first pixel A2 and the second pixel A3. Similarly, focusing on the inner pixel B1, the contour-forming pixel located at the shortest distance (3√2) is the contour-forming pixel (first pixel) B2. Focusing on the inner pixel B1, the contour-forming pixels excluding the first pixel B2, which is located within a distance of the shortest distance (3√2) plus 0.5 times the pixel pitch (1), are the contour-forming pixels (second pixel) B3. Therefore, the specific pixels for the inner pixel B1 are the first pixel B2 and the second pixel B3. Similarly, focusing on the inner pixel C1, the contour-forming pixel located at the shortest distance (2√2) is the contour-forming pixel (first pixel) C2. Focusing on the inner pixel C1, the contour-forming pixels excluding the first pixel C2, which is located within a distance of the shortest distance (2√2) plus 0.5 times the pixel pitch (1), are the contour-forming pixels (second pixel) C3. Therefore, the specific pixels for the inner pixel C1 are the first pixel C2 and the second pixel C3. Similarly, focusing on the inner pixel D1, the contour-forming pixel located at the shortest distance (√5) is the contour-forming pixel (first pixel) D2. Focusing on the inner pixel D1, there are no contour-forming pixels other than the first pixel D2, which is located within a distance of the shortest distance (√5) plus 0.5 times the pixel pitch (1). Therefore, the specific pixel for the inner pixel D1 is the first pixel D2. The process of identifying specific pixels, as described above, is performed for all inner pixels.
[0032] Next, the control unit 11 performs a fourth step in which, for each inner pixel, if multiple specific pixels are detected, it detects the pixel as a centerline component pixel if the distance between the furthest pair of specific pixels among the multiple specific pixels is greater than or equal to a predetermined value. The predetermined value can be set arbitrarily and is, for example, 6. Alternatively, the predetermined value may be, for example, twice the minimum distance between an inner pixel and the specific pixel corresponding to that inner pixel among the multiple inner pixels for which specific pixels have been identified. For example, as shown in Figure 4(A), focusing on the inner pixel A1, the distance (2√10) between the pair of specific pixels that are furthest apart from a group of specific pixels (A2, A3) (for example, the pixels shown as A13 and A23 in Figure 4(A)) is greater than or equal to a predetermined value (6), so the inner pixel A1 is detected as a centerline constituent pixel. Similarly, focusing on the inner pixel B1, the distance between the pair of specific pixels that are furthest apart from each other (for example, the pixels shown as B13 and B23 in Figure 4(A)) is 5√2 Since the value is greater than or equal to a predetermined value (6), the inner pixel B1 is detected as a centerline constituent pixel. Similarly, focusing on the inner pixel C1, the distance (2√10) between the pair of specific pixels that are furthest apart from the other specific pixels (C2, C3) (for example, the pixels shown as C13 and C23 in Figure 4(A)) is greater than or equal to a predetermined value (6), so the inner pixel C1 is detected as a centerline component pixel. Similarly, focusing on the inner pixel D1, since multiple specific pixels are not detected, the centerline constituent pixels are not detected. The detection of the centerline-constituting pixels described above is performed for all inner pixels.
[0033] In the above-mentioned method of identifying the second pixel, in the example where contour line constituent pixels located within a distance equal to the shortest distance plus 0.5 times the pixel pitch are identified, the center line of the subject is composed of all the center line constituent pixels (center points) indicated by hatching in Figure 4(A). However, the center line in Figure 4(A) is interrupted and discontinuous. Therefore, in the above-mentioned method of identifying the second pixel, contour line constituent pixels located within a distance equal to the shortest distance plus a predetermined distance equal to √2 times the pixel pitch are identified. In this case, the center line (multiple center line constituent pixels) is detected as pixels indicated by hatching (center line image) as shown in Figure 4(B). This makes it possible to obtain a center line with high continuity.
[0034] Furthermore, the obtained image of the center point or center line may be smoothed, and a second image processing control described later (specifically, the second detection method which repeats the fourth and fifth steps after the third step described later) may be performed. Smoothing can be performed using general methods; for example, for each centerline component pixel, eight surrounding pixels can be identified as new centerline component pixels. In this case, as shown in Figure 5(A), the gray pixels are identified as new centerline component pixels. Alternatively, 24 pixels doubly surrounding each centerline component pixel may be identified as new centerline component pixels. After smoothing, a second image processing control (specifically, the second detection method, which repeats the fourth and fifth steps after the third step described later) is performed, resulting in the new centerline image shown in Figure 5(B).
[0035] Furthermore, when detecting centerline constituent pixels for all inner pixels, if the distance between detected centerline constituent pixels is within a predetermined value, new centerline constituent pixels may be set to connect the centerline constituent pixels with line segments (pixels) of line width 1. Alternatively, the number of times square roots appear in the calculation formulas can be minimized by raising the entire set of calculation formulas in the control unit 11 to a power as needed.
[0036] Next, the control unit 11 saves (stores) the coordinates of the center point (center line constituent pixels), the image of the center point or center line (also called the center image), a composite image of the center image and the target image, a composite image of the center image and the binarized image, and a composite image of the center image and the contour line image, based on the center line (multiple center line constituent pixels) detected in step S5 (step S6). The control unit 11 can display the center image, the composite image of the center image and the target image, the composite image of the center image and the binarized image, and the composite image of the center image and the contour line image on the display unit 14.
[0037] When the control unit 11 completes the processing in step S6, it terminates the first image processing control shown in Figure 2.
[0038] (Second image processing control) The image processing device 10 performs the following second image processing control. The second image processing control is a control that causes the "centerline detection method comprising the second detection method" of the present invention to be executed.
[0039] Figure 6 is a flowchart showing the flow of the second image processing control performed by the control unit 11 of the image processing device 10. An example of the image processing program of the present invention is a program that causes the control unit 11 to perform control in the flow shown in Figure 6.
[0040] The control unit 11 starts the control shown in Figure 6 when a predetermined start condition is met. The fulfillment of the predetermined start condition is, for example, when an operation is performed in the image processing device 10 to execute an image processing program.
[0041] The control unit 11 first reads the target image (step S21). Next, the control unit 11 converts the target image read in step S21 to grayscale, smooths it, and binarizes it to generate a binarized image (step S22). Steps S21 and S22 are the same processes as steps S1 and S2 of the first image processing control described above.
[0042] Next, the control unit 11 removes protruding pixels (step S23). The step of removing protruding pixels is a third step in which, among the contour-forming pixels that constitute the contour line of the subject in the binarized image, protruding pixels consisting of two adjacent pixels that protrude outward at the pixel pitch distance, or one pixel that protrudes outward, are removed and new contour-forming pixels are detected. Specifically, the protruding pixels (two or one pixel) are removed and two or one inner pixels adjacent to the protruding pixels are identified as new contour-forming pixels.
[0043] Next, the control unit 11 obtains the coordinates of the white pixels in the binarized image, the contour line image, the grayscale image of the contour line, and the coordinates of the contour line constituent pixels (step S24). For example, Figure 7(A) is an image obtained by treating the binarized image shown in Figure 3 as is, with the contour line constituent pixels remaining as white pixels, and all the inner pixels inside the contour line constituent pixels being treated as black pixels. Next, the control unit 11 saves (stores) the grayscale image, binarized image, and contour line image of the target image in the storage unit 12 (step S25). Steps S24 and S25 are the same processes as steps S3 and S4 of the first image processing control described above.
[0044] Next, the control unit 11 performs a centerline detection process for the subject in the target image using the second detection method (step S26). First, the control unit 11 performs a fourth step in which it detects pixels that constitute a new contour line of the subject, which are composed of pixels inside the contour line constituent pixels, as new contour line constituent pixels. That is, the control unit 11 subtracts the outermost contour line from the binarized image to obtain a new binarized image. Specifically, from the contour line constituent pixels, √2 less than Pixels located inside at a certain distance are detected as new contour line constituent pixels. Figure 7(B) is an image obtained by detecting new contour lines from the contour line image in Figure 7(A).
[0045] Next, the control unit 11 performs a fifth step in which, if only two inner pixels exist between a pair of contour line constituent pixels, it detects one of the inner pixels between them as a center line constituent pixel, and if only one inner pixel exists between a pair of contour line constituent pixels, it detects one of the inner pixels between them as a center line constituent pixel. Here, "one of the inner pixels between a pair of contour line constituent pixels when only two inner pixels exist between them" can be set arbitrarily, for example, the left inner pixel of two inner pixels aligned in the left-right direction (X-axis direction), or the upper inner pixel of two inner pixels aligned in the up-down direction (Y-axis direction). For example, in the image in Figure 7(B), since there are only two inner pixels between a pair of pixels (indicated by E) that make up the contour line, one of the inner pixels between them (the upper inner pixel indicated by hatching) is detected as a center line component pixel. The other inner pixels indicated by hatching in Figure 7(B) are similarly detected as center line component pixels. Figure 8(A) is an image in which a new contour line has been detected from the contour line image in Figure 7(B). For example, in the image in Figure 8(A), since there is only one inner pixel between a pair of contour-forming pixels (indicated by F), the inner pixel between them (indicated by hatching) is detected as a centerline-forming pixel. Similarly, other inner pixels indicated by hatching in Figure 8(A) are also detected as centerline-forming pixels. Note that in Figure 8(A), there are also cases where there are only two inner pixels between a pair of contour-forming pixels, so one of the inner pixels between them (the left or upper inner pixel indicated by hatching) is detected as a centerline-forming pixel.
[0046] The control unit 11 repeatedly performs the fourth and fifth steps described above. The repetition of the fourth and fifth steps ends when it becomes impossible to detect new contour line constituent pixels in the fourth step. For example, after generating the image in Figure 8(A) described above, the fourth and fifth steps are repeated to sequentially generate the images shown in Figures 8(B) to 10(A). In Figures 8(B) to 10(A), each inner pixel indicated by hatching is a pixel detected as a center line constituent pixel. In this case, the center line (multiple center line constituent pixels) is detected as a pixel (center line image) indicated by hatching, as shown in Figure 10(B).
[0047] Furthermore, when detecting centerline constituent pixels for all inner pixels, if the distance between detected centerline constituent pixels is within a predetermined value, new centerline constituent pixels may be set to connect the centerline constituent pixels with line segments (pixels) of line width 1. Alternatively, the number of times square roots appear in the calculation formulas can be minimized by raising the entire set of calculation formulas in the control unit 11 to a power as needed.
[0048] Next, the control unit 11 saves (stores) the coordinates of the center point (center line constituent pixels), the image of the center point or center line (also called the center image), a composite image of the center image and the target image, a composite image of the center image and the binarized image, and a composite image of the center image and the contour line image, based on the center line (multiple center line constituent pixels) detected in step S26 (step S27). The control unit 11 can also display the center image, the composite image of the center image and the target image, the composite image of the center image and the binarized image, and the composite image of the center image and the contour line image on the display unit 14.
[0049] When the control unit 11 finishes processing in step S27, it terminates the second image processing control shown in Figure 6.
[0050] (Effects of the first embodiment) The first embodiment of the centerline detection method (a method used for the first image processing control) comprises: a first step of reading a target image; a second step of converting the target image to grayscale, smoothing it, and binarizing it to generate a binarized image; a third step of detecting, for each inner pixel inside the contour line constituent pixels that constitute the contour line of the subject in the binarized image, a first pixel which is the contour line constituent pixel located at the shortest distance, and a second pixel which is the contour line constituent pixel located within a distance of the shortest distance plus a predetermined distance, as specific pixels; and a fourth step of detecting, for each inner pixel, if multiple specific pixels are detected, detecting the pixel as a centerline constituent pixel when the distance between the furthest pair of specific pixels among the multiple specific pixels is greater than or equal to a predetermined value. With this configuration, the third step allows for the detection of specific pixels (the first and second pixels) corresponding to the inner pixels of the subject within the target pixel. The fourth step allows for the detection of pixels from among multiple inner pixels that have a predetermined relationship with the specific pixels (the first and second pixels) as centerline constituent pixels. In this way, the process of identifying centerline constituent pixels is significantly simplified compared to conventional methods, based on a simple principle. Therefore, after detecting the contour line of the binarized image of the target image, the centerline of the subject can be easily detected based on that contour line.
[0051] The centerline detection method of the first embodiment (a method used for second image processing control) comprises a first step of reading a target image; a second step of converting the target image to grayscale, smoothing it, and binarizing it to generate a binarized image; a third step of removing protruding pixels from the contour line constituent pixels that constitute the contour line of the subject in the binarized image, which consist of two adjacent pixels that protrude outward at the distance of the pixel pitch, or one pixel that protrudes outward, to detect new contour line constituent pixels; a fourth step of detecting pixels that constitute a new contour line of the subject, which consist of pixels inside the contour line constituent pixels, as new contour line constituent pixels; and a fifth step of detecting one of the inner pixels between two contour line constituent pixels as a centerline constituent pixel when only two inner pixels exist between a pair of contour line constituent pixels, and detecting the inner pixel between two contour line constituent pixels as a centerline constituent pixel when only one inner pixel exists between a pair of contour line constituent pixels, and the second detection method comprises repeating the fourth and fifth steps.
[0052] With this configuration, the third step prevents protruding pixels in the binarized image from affecting the detection of contour line constituent pixels in the subsequent fourth step and the detection of center line constituent pixels in the fifth step. The fourth and fifth steps allow for the detection of center line constituent pixels by analyzing the features of pixels on each contour line while sequentially reducing the contour lines of the binarized image from the outermost layer. In this way, the process of identifying center line constituent pixels is significantly simplified compared to conventional methods, based on a simple principle. Therefore, by focusing on the positional relationship between any two pixels on the contour line, pixels outside the contour line sandwiched between those two pixels can be detected as center line constituent pixels, allowing for the simple detection of the center line of the subject.
[0053] In the centerline detection method of the first embodiment, the third step of the second detection method (the method used for the second image processing control) is performed on the subject composed of centerline constituent pixels detected by the first detection method (the method used for the first image processing control), and the fourth and fifth steps are repeated. With this configuration, in addition to the first detection method, the second detection method focuses on the positional relationship between any two pixels on the contour line and detects the pixels outside the contour line that are sandwiched between those two pixels as centerline constituent pixels, thereby enabling accurate detection of the centerline of the subject.
[0054] <Other Embodiments> The present invention is not limited to the embodiments described above and in the drawings, and the following embodiments, for example, are also included in the technical scope of the present invention. Furthermore, the various features of the embodiments described above and the embodiments described later may be combined in any way as long as they are not contradictory.
[0055] In the first embodiment described above, image processing control was performed on the entire target image. However, the target image may be divided, and image processing control may be performed on each of the divided images. Then, the centerline constituent pixels of each image may be joined together to generate the overall centerline.
[0056] It should be noted that the embodiments disclosed herein are illustrative and not restrictive in all respects. The scope of the present invention is not limited to the embodiments disclosed herein, and is intended to include all modifications within the scope set forth in the claims or equivalents thereof. [Explanation of Symbols]
[0057] 10: Image processing device 11: Control Unit 12: Storage section 13: Input section 14: Display section
Claims
1. The first step is to load the target image, A second step involves converting the aforementioned target image to grayscale, smoothing it, and binarizing it to generate a binarized image. A third step involves detecting, as specific pixels, a first pixel which is the contour-forming pixel located at the shortest distance from each inner pixel within the contour-forming pixels that constitute the contour line of the subject in the binarized image, and a second pixel which is the contour-forming pixel located within a distance of the shortest distance plus a predetermined distance. A fourth step in which, for each inner pixel, if multiple specific pixels are detected, the inner pixel is detected as a centerline constituent pixel when the distance between the furthest pair of specific pixels among the multiple specific pixels is greater than or equal to a predetermined value, A method for detecting a centerline comprising a first detection method having the following characteristics.
2. The first step is to load the target image, A second step involves converting the aforementioned target image to grayscale, smoothing it, and binarizing it to generate a binarized image. A third step of detecting new contour-forming pixels by removing protruding pixels, which consist of two adjacent pixels that protrude outward at the pixel pitch distance or one pixel that protrudes outward, from among the contour-forming pixels that constitute the contour line of the subject in the binarized image, A fourth step involves detecting pixels that constitute a new contour line of the subject, which are composed of pixels inside the aforementioned contour line constituent pixels, as new contour line constituent pixels. A fifth step in which, if only two inner pixels exist between a pair of contour line constituent pixels, one of the inner pixels between them is detected as a center line constituent pixel, and if only one inner pixel exists between a pair of contour line constituent pixels, that inner pixel between them is detected as the center line constituent pixel. A method for detecting a center line comprising a second detection method which repeats the fourth and fifth steps.
3. A method for detecting a center line, comprising performing the third step of the second detection method described in claim 2 on a subject composed of the center line constituent pixels detected by the first detection method described in claim 1, and repeating the fourth and fifth steps.
Citation Information
Patent Citations
Processor for thinning line
JP1994020041A
Method and device for measuring diameter distribution of fiber
JP2001174227A
Image processor, image forming apparatus, and thinning method of image processor
JP2009071829A
Image processing apparatus, image processing method, and image processing program
JP2021184165A
Image processing apparatus, image processing method, and image processing program
US20210366145A1