Line width measurement method, apparatus, computing processing device, computer program, and computer readable medium

By acquiring line images and performing edge detection and region connectivity processing, the problem of large line width measurement error and low efficiency in the line preparation process is solved, realizing automated and high-precision line width measurement.

CN116391204BActive Publication Date: 2026-03-03BOE TECHNOLOGY GROUP CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202180003210.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-29
Publication Date
2026-03-03
Estimated Expiration
2041-10-29

Smart Images

  • Figure CN116391204B_ABST
    Figure CN116391204B_ABST
Patent Text Reader

Abstract

A linewidth measurement method, apparatus, computing processing device, computer program, and computer-readable medium are disclosed for measuring the width of a line. The linewidth measurement method includes: acquiring a target image of the line, the line comprising a first line segment; performing region connectivity processing on an edge image or a binarized image of the target image to obtain a region connectivity image; wherein the region connectivity image includes a target connected region corresponding to the shape of the line, and the pixel values ​​of each pixel within the target connected region are different from the pixel values ​​of each pixel outside the target connected region; based on the region connectivity image, determining a first edge point and a second edge point of the first line segment, the first edge point being located on a first edge line of the first line segment, and the second edge point being located on a second edge line of the second line segment, the first edge line and the second edge line being positioned opposite each other in a first direction; determining the width of the first line segment based on the first edge point and the second edge point; and determining the width of the line based on the width of the first line segment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a linewidth measurement method, apparatus, computing processing device, computer program, and computer-readable medium. Background Technology

[0002] During the fabrication of circuits, it is necessary to measure the line width of each batch of products to determine whether the batch is qualified, or to adjust the fabrication process based on the line width measurement results. Summary of the Invention

[0003] This disclosure provides a line width measurement method for measuring the width of a line, the line width measurement method comprising:

[0004] Obtain a target image of the route, wherein the route includes a first line segment;

[0005] The edge image or binarized image of the target image is subjected to region connectivity processing to obtain a region connected image; wherein, the edge image is an image obtained by edge detection of the target image, the binarized image is an image obtained by image binarization of the target image, and the region connected image includes a target connected region corresponding to the pattern of the line, wherein the pixel value of each pixel within the target connected region is different from the pixel value of each pixel outside the target connected region;

[0006] Based on the region connectivity image, a first edge point and a second edge point of the first line segment are determined. The first edge point is located on the first edge line of the first line segment, and the second edge point is located on the second edge line of the second line segment. The first edge line and the second edge line are set opposite to each other in a first direction.

[0007] The width of the first line segment is determined based on the first edge point and the second edge point; and the width of the line is determined based on the width of the first line segment.

[0008] In one optional implementation, the step of performing region connectivity processing on the edge image or binarized image of the target image to obtain a region-connected image includes:

[0009] The edge image or the binarized image is sequentially subjected to dilation and flooding filling to obtain a dilated image;

[0010] The dilated image is subjected to erosion processing to obtain an eroded image; wherein, the eroded image includes multiple connected regions, the pixel value of each pixel within the multiple connected regions is a first pixel value, and the pixel value of each pixel outside the multiple connected regions is a second pixel value; the multiple connected regions include isolated connected regions and target connected regions, the isolated connected regions are connected regions with a region area less than a preset threshold, and the target connected regions are connected regions with a region area greater than or equal to the preset threshold;

[0011] The pixel values ​​of each pixel within the isolated connected region in the eroded image are set to the second pixel value to obtain the region connected image.

[0012] In one alternative implementation, the convolution kernel used in the dilation process is the same size as the convolution kernel used in the erosion process.

[0013] In one optional implementation, the target connected region includes a first connected region corresponding to the first line segment, and the step of determining the first edge point and the second edge point of the first line segment based on the region connected image includes:

[0014] Pixels on the two opposite sides of the first connected region in the first direction are extracted to obtain the first edge point and the second edge point.

[0015] In one optional implementation, the line further includes a second line segment intersecting the first line segment. The first line segment includes a first branch located on one side of the intersection point of the first and second line segments. The second line segment includes a second branch located on one side of the intersection point. Multiple pixels of the connected region image are arranged in an array along the row and column directions. The step of extracting pixels on two opposite sides of the first connected region in the first direction to obtain the first edge point and the second edge point includes:

[0016] A sampling region is determined in the region connected image. The sampling region includes a first sampling region, which includes a first boundary and a second boundary that are set opposite to each other in the column direction, and a third boundary and a fourth boundary that connect the first boundary and the second boundary. The target connected region within the first sampling region includes only a first sub-connected region corresponding to the first branch and a second sub-connected region corresponding to the second branch. The two sides of the first sub-connected region that are set opposite to each other in the first direction, and the two sides of the second sub-connected region that are set opposite to each other in the second direction, are connected to both the first boundary and the second boundary. The first sub-connected region is located on the side of the second sub-connected region closer to the third boundary.

[0017] A first scanning process is performed on the pixels within the first sampling area. The first scanning process includes: scanning from the third boundary to the fourth boundary within the same row of pixels, and determining the first pixel with a pixel value of the first pixel value as the first edge point; scanning from the fourth boundary to the third boundary, and determining the first pixel with a pixel value of the first pixel value as the fourth edge point of the second line segment; determining the first center point of the first edge point and the fourth edge point within the same row of pixels; scanning from the first center point to the third boundary, and determining the first pixel with a pixel value of the first pixel value as the second edge point; scanning from the first center point to the fourth boundary, and determining the first pixel with a pixel value of the first pixel value as the third edge point of the second line segment.

[0018] The third edge point is located on the third edge line of the second line segment, the fourth edge point is located on the fourth edge line of the second line segment, and the third edge line and the fourth edge line are arranged opposite to each other in the second direction.

[0019] In one optional implementation, the first line segment further includes a third branch line located on the other side of the intersection point, and the second line segment further includes a fourth branch line located on the other side of the intersection point; the sampling area further includes a second sampling area, which includes a fifth boundary and a sixth boundary arranged opposite to each other in the column direction, and a seventh boundary and an eighth boundary connecting the fifth boundary and the sixth boundary. The target connected region within the second sampling area includes only a third sub-connected region corresponding to the third branch line and a fourth sub-connected region corresponding to the fourth branch line. The two sides of the third sub-connected region arranged opposite to each other in the first direction, and the two sides of the fourth sub-connected region arranged opposite to each other in the second direction, are connected to both the fifth boundary and the sixth boundary. The third sub-connected region is located on the side of the fourth sub-connected region closer to the eighth boundary.

[0020] The step of extracting pixels on two opposite sides of the first connected region in the first direction to obtain the first edge point and the second edge point further includes:

[0021] A second scanning process is performed on the pixels within the second sampling area. The second scanning process includes: scanning from the seventh boundary to the eighth boundary within the same row of pixels, and determining the first pixel with a pixel value of the first pixel value as the third edge point; scanning from the eighth boundary to the seventh boundary, and determining the first pixel with a pixel value of the first pixel value as the second edge point; determining the second center point of the third edge point and the second edge point within the same row of pixels; scanning from the second center point to the seventh boundary, and determining the first pixel with a pixel value of the first pixel value as the fourth edge point; scanning from the second center point to the eighth boundary, and determining the first pixel with a pixel value of the first pixel value as the first edge point.

[0022] In one optional implementation, the step of determining the width of the first line segment based on the first edge point and the second edge point includes:

[0023] A first edge line is obtained by fitting a straight line to multiple first edge points; a second edge line is obtained by fitting a straight line to multiple second edge points.

[0024] Calculate the first distance from the first edge point to the second edge line, and the second distance from the second edge point to the first edge line;

[0025] Calculate the average of the first distance and the second distance to obtain the width of the first line segment;

[0026] Before the step of determining the width of the line based on the width of the first line segment, the method further includes:

[0027] A straight line is fitted to multiple third edge points to obtain the third edge line; a straight line is fitted to multiple fourth edge points to obtain the fourth edge line.

[0028] Calculate the third distance from the third edge point to the fourth edge line, and the fourth distance from the fourth edge point to the third edge line;

[0029] Calculate the average of the third distance and the fourth distance to obtain the width of the second line segment;

[0030] The step of determining the width of the line based on the width of the first line segment includes:

[0031] The width of the line is determined based on the width of the first line segment and the width of the second line segment; wherein the width of the line includes at least one of the following: the average of the width of the first line segment and the width of the second line segment, the width of the first line segment and the width of the second line segment.

[0032] In one optional implementation, the target connected region further includes a second connected region corresponding to the second line segment, and the step of determining the sampling region in the connected image includes:

[0033] Based on the region connectivity image, the overlap coordinates of the first connected region and the second connected region are determined, and the overlap coordinates are the coordinates of the overlapping pixels located within the overlap region of the first connected region and the second connected region;

[0034] Based on the overlapping coordinates and the ninth and tenth boundaries of the region connected image relative to each other in the column direction, the first sampling region and the second sampling region are determined; wherein, the first boundary is determined by translating the ninth boundary in the column direction towards the overlapping pixels by a first preset distance; the second boundary is determined by translating the first dividing line in the column direction towards the ninth boundary by a second preset distance; the fifth boundary is determined by translating the first dividing line in the column direction towards the tenth boundary by a third preset distance; the sixth boundary is determined by translating the tenth boundary in the column direction towards the overlapping pixels by a fourth preset distance; the first dividing line is a straight line passing through the overlapping pixels and extending along the row direction.

[0035] In one optional implementation, the region connectivity image further includes a reference boundary connecting the ninth boundary and the tenth boundary, wherein the extension direction of the first line segment and / or the second line segment is different from the column direction, and the step of determining the overlap coordinates of the first connected region and the second connected region based on the region connectivity image includes:

[0036] Starting from the ninth boundary, the pixels within the connected region image are scanned line by line. The line-by-line scanning process includes: if the distance between the reference pixel of the current scan line and the reference boundary is greater than or equal to the distance between the reference pixel of the previous scan line and the reference boundary, and is greater than or equal to the distance between the reference pixel of the next scan line and the reference boundary, then the coordinates of the reference pixel of the current scan line are determined as the overlapping coordinates; wherein, the reference pixel is the first pixel in the same row of pixels, scanned starting from the reference boundary, and whose pixel value is the first pixel value.

[0037] In one optional implementation, the step of determining the overlap coordinates of the first connected region and the second connected region based on the region connectivity image includes:

[0038] Line detection is performed on pixels within the first connected region and the second connected region to obtain multiple detection line segments;

[0039] The multiple detection line segments are clustered to obtain two clusters;

[0040] The coordinates of the intersection of the two line segments corresponding to the cluster centers of the two clusters are determined as the overlapping coordinates.

[0041] In one optional implementation, the first line segment includes a fifth branch, and the multiple pixels of the region connected to the image are arranged in an array along the row and column directions. The step of extracting pixels on two opposite sides of the first connected region in the first direction to obtain the first edge point and the second edge point includes:

[0042] A third sampling region is determined in the region connectivity image. The third sampling region includes an eleventh boundary and a twelfth boundary that are set opposite to each other in the column direction, and a thirteenth boundary and a fourteenth boundary that connect the eleventh boundary and the twelfth boundary. The target connectivity region within the third sampling region includes only the fifth sub-connected region corresponding to the fifth branch. The two sides of the fifth sub-connected region that are set opposite to each other in the first direction are connected to both the eleventh boundary and the twelfth boundary.

[0043] A third scanning process is performed on the pixels within the third sampling area. The third scanning process includes: scanning from the thirteenth boundary to the fourteenth boundary within the same row of pixels, and determining the first pixel with a pixel value of the first pixel value as the first edge point; scanning from the fourteenth boundary to the thirteenth boundary, and determining the first pixel with a pixel value of the first pixel value as the second edge point.

[0044] In one optional implementation, the target connected region includes a third connected region corresponding to the first line segment, the first edge line includes a first outer edge line and a first inner edge line, the second edge line includes a second outer edge line and a second inner edge line, and the convolution kernel used in the dilation process is smaller than the convolution kernel used in the erosion process, so that one of the two opposite sides of the third connected region in the first direction is located between the first outer edge line and the first inner edge line, and the other side is located between the second outer edge line and the second inner edge line.

[0045] In an optional implementation, the line further includes a second line segment intersecting the first line segment, the first line segment including a sixth branch located on one side of the intersection of the first line segment and the second line segment, and after the step of obtaining the region connectivity image, the method further includes:

[0046] Extract the skeleton image of the region connected image. The skeleton image includes a skeleton, the pixel values ​​of each pixel within the skeleton are different from the pixel values ​​of each pixel outside the skeleton, and the skeleton includes a center line corresponding to the sixth branch.

[0047] Before the step of determining the first edge point and the second edge point of the first line segment based on the region connectivity image, the method further includes:

[0048] Line detection is performed on the edge image to obtain multiple edge line segments;

[0049] Determine the target line segment corresponding to the sixth branch from the plurality of edge line segments;

[0050] The step of determining the first edge point and the second edge point of the first line segment based on the region connected image includes:

[0051] Based on the relationship between the position of the target line segment in the edge image, the position of the third connected region in the region connected image, and the position of the center line in the skeleton image, the first outer edge line, the first inner edge line, the second outer edge line, and the second inner edge line are determined from the target line segment.

[0052] In one optional implementation, the step of determining the first outer edge line, the first inner edge line, the second outer edge line, and the second inner edge line from the target line segment based on the relationship between the position of the target line segment in the edge image, the position of the third connected region in the region connected image, and the position of the center line in the skeleton image includes:

[0053] Based on the position of the target line segment in the edge image, a first mapping region corresponding to the target line segment is determined at the corresponding position in the region connectivity image, and a second mapping region corresponding to the target line segment is determined at the corresponding position in the skeleton image;

[0054] If the first mapping region is located on the first side outside the third connected region, then the target line segment corresponding to the first mapping region is determined to be the first outer edge line;

[0055] If the first mapping region is located on the second side outside the third connected region, then the target line segment corresponding to the first mapping region is determined to be the second outer edge line;

[0056] If the first mapping region is located inside the third connected region, and the second mapping region is located on the first side of the center line, then the target line segment corresponding to the first mapping region and the second mapping region is determined to be the first inner edge line;

[0057] If the first mapping region is located inside the third connected region, and the second mapping region is located on the second side of the center line, then the target line segment corresponding to the first mapping region and the second mapping region is determined to be the second inner edge line.

[0058] In an optional implementation, the region connected image includes a fifteenth boundary and a sixteenth boundary set relative to each other. Prior to the step of determining the first outer edge line, the first inner edge line, the second outer edge line, and the second inner edge line from the target line segment based on the relationship between the position of the target line segment in the edge image, the position of the third connected region in the region connected image, and the position of the centerline in the skeleton image, the method further includes:

[0059] The pixel values ​​of each pixel in the region between the target connected region and the fifteenth boundary, and in the region between the target connected region and the sixteenth boundary in the region connected image are set to the third pixel value;

[0060] If the pixel value of each pixel in the first mapping region is the third pixel value, then it is determined that the first mapping region is located on the first side outside the third connected region;

[0061] If the pixel value of each pixel in the first mapping region is the second pixel value, then it is determined that the first mapping region is located on the second side outside the third connected region;

[0062] If the pixel value of each pixel in the first mapping region is the same as the first pixel value, then the first mapping region is determined to be located inside the third connected region.

[0063] In an optional implementation, before the step of determining the first outer edge line, the first inner edge line, the second outer edge line, and the second inner edge line from the target line segment based on the relationship between the position of the target line segment in the edge image, the position of the third connected region in the region connected image, and the position of the center line in the skeleton image, the method further includes:

[0064] The connected region image and the dilated image are XORed to obtain an intermediate image. The intermediate image includes multiple discrete complementary regions. The pixel value of each pixel within the multiple discrete complementary regions is the fourth pixel value, and the pixel value of each pixel outside the multiple discrete complementary regions is the fifth pixel value. The intermediate image includes a seventeenth boundary and an eighteenth boundary that are set relative to each other.

[0065] The pixel values ​​of each pixel in the complementary region adjacent to the seventeenth boundary and the complementary region adjacent to the eighteenth boundary in the intermediate image are set to the sixth pixel value.

[0066] Based on the position of the target line segment in the edge image, a third mapping region corresponding to the target line segment is determined at the corresponding position in the intermediate image;

[0067] If the pixel value of each pixel in the third mapping region is the sixth pixel value, then it is determined that the first mapping region is located on the first side outside the third connected region;

[0068] If the pixel value of each pixel in the third mapping region is the fourth pixel value, then it is determined that the first mapping region is located on the second side outside the third connected region.

[0069] In one optional implementation, the skeleton image includes a nineteenth boundary and a twentieth boundary set relative to each other, the pixel value of each pixel within the skeleton is a seventh pixel value, and the pixel value of each pixel outside the skeleton is an eighth pixel value; before the step of determining the first outer edge line, the first inner edge line, the second outer edge line, and the second inner edge line from the target line segment based on the relationship between the position of the target line segment in the edge image, the position of the third connected region in the region connected image, and the position of the center line in the skeleton image, the method further includes:

[0070] Set the pixel values ​​of each pixel in the region between the skeleton and the nineteenth boundary, and the region between the skeleton and the twentieth boundary in the skeleton image to the ninth pixel value;

[0071] If the pixel value of each pixel in the second mapping region is the ninth pixel value, then the second mapping region is determined to be located on the first side of the center line;

[0072] If the pixel value of each pixel in the second mapping region is the eighth pixel value, then the second mapping region is determined to be located on the second side of the center line.

[0073] In one optional implementation, the step of determining the width of the first line segment based on the first edge point and the second edge point includes:

[0074] Calculate the fifth distance from the endpoint of the first outer edge line to the second outer edge line;

[0075] Calculate the sixth distance from the endpoint of the second outer edge line to the first outer edge line;

[0076] Calculate the seventh distance from the endpoint of the first inner edge line to the second inner edge line;

[0077] Calculate the eighth distance from the endpoint of the second inner edge line to the first inner edge line;

[0078] The width of the first line segment is obtained by calculating the average of the fifth distance, the sixth distance, the seventh distance, and the eighth distance.

[0079] In one optional implementation, the step of acquiring the target image of the line includes:

[0080] Obtain the original image of the line;

[0081] The original image is preprocessed to obtain the target image; wherein the preprocessing includes at least one of the following: grayscale conversion, contrast enhancement, brightness enhancement, and noise reduction.

[0082] In one optional implementation, the step of preprocessing the original image includes:

[0083] The original image is subjected to noise reduction processing to obtain a noise-reduced image;

[0084] Extract the edge pixels of the denoised image and count the total number of edge pixels;

[0085] If the total number is less than or equal to the preset number, then the original image is subjected to contrast enhancement processing.

[0086] This disclosure provides a line width measuring device for measuring the width of a line, the line width measuring device comprising:

[0087] An image acquisition module is configured to acquire a target image of the line, the line including a first line segment;

[0088] The connectivity processing module is configured to perform region connectivity processing on the edge image or binarized image of the target image to obtain a region connected image; wherein, the edge image is an image obtained by edge detection of the target image, the binarized image is an image obtained by image binarization processing of the target image, and the region connected image includes a target connected region corresponding to the pattern of the line, wherein the pixel value of each pixel within the target connected region is different from the pixel value of each pixel outside the target connected region;

[0089] An edge determination module is configured to determine a first edge point and a second edge point of the first line segment based on the region connectivity image. The first edge point is located on the first edge line of the first line segment, and the second edge point is located on the second edge line of the second line segment. The first edge line and the second edge line are arranged opposite to each other in a first direction.

[0090] The width calculation module is configured to determine the width of the first line segment based on the first edge point and the second edge point; and to determine the width of the line based on the width of the first line segment.

[0091] This disclosure provides a computing processing device, including:

[0092] Memory containing computer-readable code;

[0093] One or more processors, when the computer-readable code is executed by the one or more processors, the computing processing device performs the method described in any embodiment.

[0094] This disclosure provides a computer program including computer-readable code that, when run on a computing processing device, causes the computing processing device to perform the method according to any embodiment.

[0095] This disclosure provides a computer-readable medium storing the methods described in any embodiment.

[0096] The above description is merely an overview of the technical solution disclosed herein. In order to better understand the technical means of this disclosure and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this disclosure more apparent and understandable, specific embodiments of this disclosure are described below. Attached Figure Description

[0097] To more clearly illustrate the technical solutions in the embodiments or related technologies of this disclosure, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. It should be noted that the scale in the drawings is for illustration only and does not represent the actual scale.

[0098] Figure 1 A schematic diagram illustrating a linewidth measurement method is shown.

[0099] Figure 2 A schematic diagram illustrating pixel value fluctuations before and after contrast enhancement is shown.

[0100] Figure 3 A schematic diagram of a set of erosion images and region connectivity images is shown;

[0101] Figure 4a A schematic diagram of a region connectivity image is shown.

[0102] Figure 4b A schematic diagram of another type of region connectivity image is shown;

[0103] Figure 5 A schematic diagram illustrating a process for determining overlapping coordinates is shown.

[0104] Figure 6 A schematic diagram of the inner and outer edges of a line segment is shown.

[0105] Figure 7 A schematic diagram illustrating a process for obtaining a region connectivity image is shown.

[0106] Figure 8 This schematically illustrates another process for obtaining a region connectivity image;

[0107] Figure 9 The diagram illustrates the results of XOR operation and padding processing on a region-connected image and a dilated image.

[0108] Figure 10 The diagram illustrates the results of filtering outer edge pixels and inner edge pixels.

[0109] Figure 11 A schematic diagram of the edge segment, outer edge line, and inner edge line is shown.

[0110] Figure 12 A skeleton image and a schematic diagram of filling the skeleton image are shown schematically;

[0111] Figure 13 This diagram illustrates an image processing procedure.

[0112] Figure 14 This schematically illustrates another image processing step.

[0113] Figure 15 A schematic block diagram of a linewidth measuring device is shown.

[0114] Figure 16 A block diagram of a computing processing apparatus for performing the method according to the present disclosure is shown schematically;

[0115] Figure 17A storage unit for holding or carrying program code that implements the method according to this disclosure is illustrated schematically. Detailed Implementation

[0116] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.

[0117] In related technologies, high-magnification images of the sample under test are usually taken using an electron microscope, and then the width of the line is manually measured using professional software. This method is not only prone to large errors, but also inefficient.

[0118] In order to automatically measure the width of the line, Figure 1 A flowchart illustrating a linewidth measurement method is shown schematically, such as... Figure 1 As shown, the method may include the following steps.

[0119] Step S11: Obtain the target image of the line, which includes the first line segment.

[0120] The execution subject of this embodiment can be a computer device, which has a linewidth measuring device, and the linewidth measuring method provided in this embodiment is executed through the linewidth measuring device. The computer device can be, for example, a smartphone, tablet computer, personal computer, etc., and this embodiment does not limit it to this type.

[0121] In a specific implementation, this step may include: first, acquiring the original image of the line; and then preprocessing the original image to obtain the target image. The preprocessing may include at least one of the following: grayscale conversion, contrast enhancement, brightness enhancement, and noise reduction.

[0122] The execution entity in this embodiment can be connected to a camera device to acquire the original image captured by the camera device. The original image can be an image whose resolution and exposure both meet the requirements; for example, the resolution can be 480×640, and the exposure can be set according to actual needs.

[0123] Optionally, the preprocessing step of the original image may specifically include: first, performing noise reduction processing on the original image to obtain a noise-reduced image; then, extracting the edge pixels of the noise-reduced image and counting the total number of edge pixels; if the total number is less than or equal to a preset number, then performing contrast enhancement processing on the original image.

[0124] In practical implementation, the original image can first be processed with Gaussian filtering to remove obvious salt-and-pepper noise. Then, edge detection can be performed using operators such as Canny to obtain edge pixels. Afterward, the total number of edge pixels can be counted. If the total number is greater than a preset number, the edges are relatively clear, and contrast enhancement is not required. If the total number is less than or equal to the preset number, the edges are relatively blurry, and contrast enhancement can be performed on the original image. The preset number can be obtained by averaging the edge pixel counts from multiple images.

[0125] In practical implementation, a low-amplitude filtering method can be used for contrast enhancement. (Refer to...) Figure 2 This diagram schematically illustrates pixel value fluctuations before and after low-amplitude filtering. For example... Figure 2 In the diagram, 'a' represents the pixel value distribution of a row of pixels in the original image before low-amplitude filtering. The curve represents the pixel values, the horizontal line represents the average value, and the location with the largest amplitude fluctuation corresponds to the edge region. For example... Figure 2 In the figure, b represents the pixel value fluctuation curve of a row of pixels after low-amplitude filtering of the original image.

[0126] Specifically, a sliding window of W pixels can be set and slid along a row of pixels from left to right. When the fluctuation amplitude within the sliding window is greater than 80% of the maximum fluctuation amplitude, no filtering is required; otherwise, mean filtering is applied to obtain a result with a uniform background and enhanced contrast. Figure 2 As shown in b in the diagram. The sliding window W can take values ​​such as 3, 5, or 7.

[0127] Step S12: Perform region connectivity processing on the edge image or binarized image of the target image to obtain a region connected image; wherein, the edge image is the image obtained by edge extraction of the target image, the binarized image is the image obtained by image binarization processing of the target image, and the region connected image includes the target connected region corresponding to the graphic of the line, and the pixel value of each pixel in the target connected region is different from the pixel value of each pixel outside the target connected region.

[0128] In practical implementation, the grayscale histogram of the RGB three channels of the target image can be calculated first. Then, based on the grayscale histogram, an adaptive threshold edge detection algorithm or the Canny algorithm can be used for edge detection to obtain the edge image of the target image. (Refer to...) Figure 8 The image 'a' in the figure shows an edge image of an X-shaped line. Figure 8 The 'e' in the figure represents the region connectivity image corresponding to this edge image.

[0129] To obtain a binarized image, the target image can first be processed by Gaussian filtering and grayscale conversion, and then an adaptive threshold binarization algorithm can be used to binarize the image to obtain the binarized image of the target image. Figure 7 The d in the figure shows the region connectivity image corresponding to the binarized image of an X-shaped line.

[0130] In practical implementation, various methods can be used to achieve region connectivity processing. (See reference...) Figure 7 Figures a to d illustrate a flowchart of obtaining a region-connected image from a binarized image of the original image, where the lines in the original image are X-shaped. Specifically, step S12 may include: first, performing dilation and flooding filling processes sequentially on the binarized image of the original image to obtain a dilated image (e.g., ...). Figure 7 (as shown in b in the image); then the dilated image is eroded to obtain an eroded image (as shown in b in the image); Figure 7 (as shown in c); where the eroded image includes multiple connected regions, the pixel value of each pixel within the multiple connected regions is the first pixel value, and the pixel value of each pixel outside the multiple connected regions is the second pixel value; the multiple connected regions include isolated connected regions and target connected regions, the isolated connected regions are connected regions with a region area less than a preset threshold, and the target connected regions are connected regions with a region area greater than or equal to the preset threshold; then, the pixel values ​​of each pixel within the isolated connected regions in the eroded image are set to the second pixel value to obtain the region connected image (as shown in c); Figure 7 (as shown in d).

[0131] The first pixel value can be, for example, 255, such as... Figure 7 The white area shown. The second pixel value can be 0, such as... Figure 7 The black area shown. Figure 7 Figure 'a' shows the image obtained after dilating the binarized image of the original image. During dilution, smaller holes or slits can be connected. If larger holes (such as...) still exist within the dilated connected region after dilution... Figure 7 The center position of image a) can be filled using a flooding fill algorithm to fill the holes in the dilated connected regions, resulting in a dilated image, such as... Figure 7 As shown in b in the figure. It should be noted that if there are no large holes in the expanded connected area after the expansion treatment, flood filling treatment is not necessary. Flood filling treatment is not required and can be selected according to the actual situation.

[0132] Erosion images obtained by eroding a dilated image may contain isolated connected regions, such as... Figure 7In the image c, the white dots within the dashed box in the upper right corner are used to eliminate isolated connected regions. The area of ​​each connected region can be calculated, and then the pixel values ​​within regions with areas less than a preset threshold are set to a second pixel value (e.g., 0). Only pixels within the target connected region are set to the first pixel value (e.g., 255). Figure 7 The white area shown by d in the diagram), the pixel value of each pixel outside the target connected region is the second pixel value (e.g., 0 corresponds to...). Figure 7 (The black area shown by d in the figure) yields the following result: Figure 7 The region connected in the image is shown as d. The preset threshold can be set to, for example, 50, but the specific value can be set according to actual needs.

[0133] Reference Figure 3 A set of comparison images of erosion and region connectivity is schematically shown. For example... Figure 3 The image shown in Figure 'a' is an erosion image where multiple isolated connected regions exist within the black areas. Figure 3 Figure 'b' shows the region connectivity image after removing isolated connected regions from the eroded image. By removing isolated connected regions, the edge interference of these regions can be avoided in the extraction of line edge points, thus improving the accuracy of linewidth measurement.

[0134] Reference Figure 8 Figures a to e illustrate a flowchart of obtaining a region-connected image based on the edge image of the original image, where the lines in the original image are X-shaped. Specifically, step S12 may include: first processing the edge image of the original image (e.g., ... Figure 8 As shown in a), dilation and flooding filling processes are performed sequentially to obtain the dilated image (as shown in a diagram). Figure 8 (as shown in c); then the dilated image is eroded to obtain an eroded image (as shown in c); Figure 8 (as shown in d); the eroded image includes multiple connected regions, where the pixel value of each pixel within each connected region is a first pixel value, and the pixel value of each pixel outside each connected region is a second pixel value; the multiple connected regions include isolated connected regions and target connected regions, where isolated connected regions are connected regions with an area less than a preset threshold, and target connected regions are connected regions with an area greater than or equal to the preset threshold; then, the pixel values ​​of each pixel within the isolated connected regions in the eroded image are set to the second pixel values ​​to obtain a region connected image (as shown in d); the eroded image includes multiple connected regions, where each pixel within each isolated connected region in the eroded image is a first pixel value, and the pixel value of each pixel outside each connected region in the eroded image is a second pixel value, to obtain a region connected image (as shown in d); Figure 8 (as shown in e).

[0135] The first pixel value can be, for example, 255, such as... Figure 8 The white area shown. The second pixel value can be 0, such as... Figure 8 The black area shown. Figure 8 'a' in the image shows the edge image of the original image. Figure 8b in the image shows the image obtained after dilation of the edge image. During dilation, smaller holes or slits can be connected. If larger holes (such as...) still exist within the dilated connected region after dilation... Figure 8 The center position of image b in the image can be filled using a flooding fill algorithm to fill the holes in the dilated connected regions, resulting in a dilated image, such as... Figure 8 As shown in c in the diagram. It should be noted that if there are no large pores after the expansion treatment, flood filling treatment is not necessary and can be selected based on the actual situation.

[0136] The eroded image obtained by eroding a dilated image may contain isolated connected regions. To eliminate these isolated connected regions, the area of ​​each connected region can be calculated. Then, the pixel values ​​of connected regions with areas less than a preset threshold are set as the second pixel value. This results in only pixels within the target connected region having the first pixel value (e.g., 255, corresponding to...). Figure 8 The white area in the image), the pixel value of each pixel outside the target connected region is the second pixel value (e.g., 0, corresponding to...). Figure 8 (the black area in the image), to obtain as follows Figure 8 The region connectivity image shown in 'e' is as follows.

[0137] Since edge images or binarized images may have discontinuities, this implementation first performs dilation processing on the edge image or binarized image and then performs erosion processing. This can achieve broken line connection or region connectivity, which helps to extract complete edge lines and improve the accuracy of line width measurement.

[0138] Dilation and erosion are known as morphological operations, and they are typically performed on binary images. Dilation expands the white areas of an image by adding pixels to the perceptual boundaries of objects within the image. Erosion, on the other hand, removes pixels along the object boundaries, reducing the size of the object.

[0139] In practical implementation, both dilation and erosion processes require setting a convolution kernel of a certain size to perform convolution operations on the image. The size of the convolution kernel can be determined based on the number of pixels between two edge lines. For example, when the distance between two edge lines is 5 to 10 pixels, the size of the convolution kernel can be set to 3×3 or 5×5. This disclosure does not limit this.

[0140] In this embodiment, the size of the convolution kernel used in the dilation process and the size of the convolution kernel used in the corrosion process can be the same or different.

[0141] Step S13: Based on the region connected image, determine the first edge point and the second edge point of the first line segment. The first edge point is located on the first edge line of the first line segment, and the second edge point is located on the second edge line of the second line segment. The first edge line and the second edge line are set relative to each other in the first direction.

[0142] In practice, the specific method for extracting the first and second edge points can be determined based on the size relationship between the convolution kernel used in the dilation process and the convolution kernel used in the erosion process.

[0143] For example, when the convolution kernel used in dilation is the same size as that used in erosion, the width of the first connected region corresponding to the first line segment in the connected region image is the same as the width of the first line segment. Therefore, the pixels on a pair of opposite sides of the first connected region in the connected region image in the first direction can be extracted as the first edge point and the second edge point of the first line segment. When the convolution kernel used in dilation is different from that used in erosion, straight line detection can be performed on the edge pixels in the edge image first to obtain edge line segments; then, based on the positional relationship between the edge line segments and the target connected region in the connected region image, the first edge line and the second edge line can be determined from the edge line segments. Subsequent embodiments will describe these two cases in detail.

[0144] Step S14: Determine the width of the first line segment based on the first edge point and the second edge point; and determine the width of the line based on the width of the first line segment.

[0145] In a practical implementation, the distance from the first edge point to the second edge line and the distance from the second edge point to the first edge line can be calculated. The average of the calculated distances can then be used to obtain the width of the first line segment.

[0146] If the line consists of only the first segment, the width of the first segment can be determined as the width of the line; if the line consists of multiple segments, such as the first segment, the widths of the multiple segments can be calculated separately, and the average width of the multiple segments can be determined as the width of the line.

[0147] The line width measurement method provided in this embodiment can automate the measurement of line width, is highly operable in mass production processes, and can significantly improve measurement efficiency and accuracy. Using the method provided in this embodiment, micro-measurement of lines in nanoscale microscopic images can be performed.

[0148] In one alternative implementation, the convolution kernel used in the dilation process is the same size as the convolution kernel used in the erosion process. When the convolution kernel used in the dilation process is the same size as the convolution kernel used in the erosion process, the width of the first connected region corresponding to the first line segment in the region-connected image is the same as the width of the first line segment. Therefore, the pixels on a pair of opposite sides of the first connected region in the region-connected image in the first direction can be used as the first edge point and the second edge point of the first line segment.

[0149] In this implementation, the target connected region includes the first connected region corresponding to the first line segment. Step S13 may specifically include: extracting pixels on two opposite sides of the first connected region in the first direction to obtain the first edge point and the second edge point.

[0150] Reference Figure 4a A schematic diagram of a region connectivity image is shown. For example... Figure 4a As shown, the first connected region has two opposite sides L1 and L2 in the first direction. Pixel P1 on L1 can be used as the first edge point, and pixel P2 on L2 can be used as the second edge point.

[0151] When the line also includes a second line segment that intersects with the first line segment, the second line segment has a third edge line and a fourth edge line that are arranged opposite to each other in the second direction. The target connected region also includes a second connected region corresponding to the second line segment. Step S13 may also include: extracting pixels on two opposite sides of the second connected region in the second direction to obtain a third edge point located on the third edge line and a fourth edge point located on the fourth edge line.

[0152] like Figure 4a As shown, the second connected region has two opposite sides L3 and L4 in the second direction. Pixel P3 on L3 can be used as the third edge point, and pixel P4 on L4 can be used as the fourth edge point.

[0153] When a line includes a first line segment and a second line segment, the first line segment may include a first branch located on one side of the intersection of the first and second line segments, and the second line segment may include a second branch located on one side of the intersection. Neither the first nor the second branch includes the intersection. Multiple pixels of a region-connected image can be arranged in an array along the row and column directions.

[0154] Accordingly, refer to Figure 4a Step S13 may specifically include:

[0155] First, the sampling region in the region connected image is determined. The sampling region includes a first sampling region, which includes a first boundary H1 and a second boundary H2 set opposite to each other in the column direction, and a third boundary V1 and a fourth boundary V2 connecting the first boundary H1 and the second boundary H2. The target connected region within the first sampling region includes only a first sub-connected region corresponding to the first branch and a second sub-connected region corresponding to the second branch. The two sides of the first sub-connected region set opposite to each other in the first direction and the two sides of the second sub-connected region set opposite to each other in the second direction are connected to both the first boundary H1 and the second boundary H2. The first sub-connected region is located on the side of the second sub-connected region closer to the third boundary V1.

[0156] Then, a first scanning process is performed on the pixels within the first sampling area. The first scanning process includes: within the same row of pixels, scanning from the third boundary V1 to the fourth boundary V2, and determining the first pixel with a pixel value of the first pixel value as the first edge point P1; scanning from the fourth boundary V2 to the third boundary V1, and determining the first pixel with a pixel value of the first pixel value as the fourth edge point P4 of the second line segment; determining the first center point P of the first edge point P1 and the fourth edge point P4 within the same row of pixels. (中心)上 From the first center point P (中心)上 Scanning towards the third boundary V1, the first pixel with the first pixel value is identified as the second edge point P2; from the first center point P... (中心)上 Scan towards the fourth boundary V2, and determine the first pixel with a pixel value of the first pixel value as the third edge point P3 of the second line segment.

[0157] It should be noted that, in Figure 4a In the image, the target connected region is a dark gray region, which is the pixel region corresponding to the first pixel value.

[0158] exist Figure 4a In the diagram, the first sub-connected region is the portion of the first connected region located to the upper left of intersection point O, and the second sub-connected region is the portion of the second connected region located to the upper right of intersection point O. Neither the first nor the second sub-connected region includes the overlapping region between the first and second connected regions.

[0159] like Figure 4a As shown, the two sides of the first sub-connected region, which are positioned opposite each other in the first direction, are connected to the first boundary H1 and the second boundary H2, respectively. By ensuring that the two sides of the first sub-connected region, which are positioned opposite each other in the first direction, are connected to both the first boundary H1 and the second boundary H2, it is possible to avoid extracting pixels on other sides of the first sub-connected region, thereby improving the extraction accuracy of the first edge point and the second edge point, and improving the accuracy of line width measurement.

[0160] like Figure 4aAs shown, the two sides of the second sub-connected region, which are positioned opposite each other in the second direction, are connected to the first boundary H1 and the second boundary H2, respectively. By ensuring that the two sides of the second sub-connected region, which are positioned opposite each other in the second direction, are connected to both the first boundary H1 and the second boundary H2, it is possible to avoid extracting pixels on other sides of the second sub-connected region, thereby improving the extraction accuracy of the third and fourth edge points and enhancing the accuracy of line width measurement.

[0161] Specifically, within the first sampling area, the first scanning process can start from the row of pixels where the first boundary H1 is located and scan downwards sequentially. During the downward scanning process, it can scan row by row or scan every other row, etc.

[0162] Within each row of pixels or scan line, scan from the third boundary V1 on the left to the fourth boundary V2 on the right, as follows: Figure 4a As shown, since the initially passed pixel is outside the target connected region, the pixel value of that pixel is the second pixel value. During the rightward scan, the first pixel with the first pixel value is determined as the first edge point P1; the scan starts from the fourth boundary V2 on the right and moves towards the third boundary V1 on the left, as follows. Figure 4a As shown, since the initially passed pixel is outside the target connected region, the pixel value of that pixel is the second pixel value. During the leftward scan, the first pixel with the first pixel value is determined as the fourth edge point P4 of the second line segment; the first center point P1 of the first edge point P1 and the fourth edge point P4 within the same row of pixels is determined. (中心)上 From the first center point P (中心)上 Scan towards the third boundary V1 on the left, as follows: Figure 4a As shown, since the initially passed pixel is outside the target connected region, the pixel value of that pixel is the second pixel value. During the leftward scan, the first pixel with the first pixel value is determined as the second edge point P2; from the first center point P... (中心)上 Scan to the fourth boundary V2 on the right, as follows Figure 4a As shown, since the pixel that is initially passed is outside the target connected region, the pixel value of the pixel is the second pixel value. During the rightward scanning process, the first pixel with the first pixel value is determined as the third edge point P3 of the second line segment.

[0163] Among them, P (中心)上 The x-coordinate can be the average of the x-coordinate of the first edge point P1 and the x-coordinate of the fourth edge point P4 within the same row of pixels.

[0164] After performing the first scan on the first sampling area, we can obtain the first edge point P1, the second edge point P2, the third edge point P3 and the fourth edge point P4 corresponding to multiple scan lines.

[0165] The above process can be applied to the width measurement of V-shaped, X-shaped, Y-shaped lines, etc.

[0166] When the line shape is X-shaped, the first line segment also includes a third branch located on the other side of the intersection, and the second line segment also includes a fourth branch located on the other side of the intersection.

[0167] To fully measure the width of an X-shaped line, such as Figure 4a As shown, the sampling region in the region connected image may also include a second sampling region. The second sampling region includes a fifth boundary H3 and a sixth boundary H4 that are set opposite each other in the column direction, and a seventh boundary V1 and an eighth boundary V2 that connect the fifth boundary H3 and the sixth boundary H4. The target connected region within the second sampling region includes only the third sub-connected region corresponding to the third branch and the fourth sub-connected region corresponding to the fourth branch. The two sides of the third sub-connected region that are set opposite each other in the first direction, and the two sides of the fourth sub-connected region that are set opposite each other in the second direction, are connected to both the fifth boundary H3 and the sixth boundary H4. The third sub-connected region is located on the side of the fourth sub-connected region closer to the eighth boundary V2.

[0168] Accordingly, step S13 may further include:

[0169] A second scanning process is performed on the pixels within the second sampling area. This second scanning process includes: within the same row of pixels, scanning from the seventh boundary V1 to the eighth boundary V2, identifying the first pixel with the first pixel value as the third edge point P3; scanning from the eighth boundary V2 to the seventh boundary V1, identifying the first pixel with the first pixel value as the second edge point P2; and determining the second center point P of the third edge point P3 and the second edge point P2 within the same row of pixels. (中心)下 From the second center point P (中心)下 Scanning towards the seventh boundary V1, the first pixel with the first pixel value is identified as the fourth edge point P4; from the second center point P... (中心)下 Scan towards the eighth boundary V2, and determine the first pixel with the first pixel value as the first edge point P1.

[0170] exist Figure 4a In the diagram, the third sub-connected region is a portion of the first connected region located to the lower right of intersection point O, and the fourth sub-connected region is a portion of the second connected region located to the lower left of intersection point O. Neither the third nor the fourth sub-connected region includes the overlapping region between the first and second connected regions.

[0171] like Figure 4aAs shown, the two sides of the third sub-connected region, which are positioned opposite each other in the first direction, are connected to the fifth boundary H3 and the sixth boundary H4, respectively. By ensuring that the two sides of the third sub-connected region, which are positioned opposite each other in the first direction, are connected to both the fifth boundary H3 and the sixth boundary H4, it is possible to avoid extracting pixels on other sides of the third sub-connected region, thereby improving the extraction accuracy of the first and second edge points and enhancing the accuracy of line width measurement.

[0172] like Figure 4a As shown, the two sides of the fourth sub-connected region, which are positioned opposite each other in the second direction, are connected to the fifth boundary H3 and the sixth boundary H4, respectively. By ensuring that the two sides of the fourth sub-connected region, which are positioned opposite each other in the second direction, are connected to both the fifth boundary H3 and the sixth boundary H4, it is possible to avoid extracting pixels on other sides of the fourth sub-connected region, thereby improving the extraction accuracy of the third and fourth edge points and enhancing the accuracy of line width measurement.

[0173] Specifically, within the second sampling area, the second scanning process can start from the row of pixels where the fifth boundary H3 is located and scan downwards sequentially. During the downward scanning process, it can scan row by row or scan every other row, etc.

[0174] Within each row of pixels or scan line, scan from the seventh boundary V1 on the left to the eighth boundary V2 on the right, as follows: Figure 4a As shown, since the initially passed pixel is outside the target connected region, the pixel value of that pixel is the second pixel value. During the rightward scan, the first pixel with the first pixel value is determined as the third edge point P3; the scan proceeds from the eighth boundary V2 on the right to the seventh boundary V1 on the left, as follows. Figure 4a As shown, since the initially passed pixel is located outside the target connected region, the pixel value of that pixel is the second pixel value. During the leftward scanning process, the first pixel with the first pixel value is determined as the second edge point P2; the third edge point P3 within the same row of pixels is determined as the second center point P of the second edge point P2. (中心)下 From the second center point P (中心)下 Scan towards the seventh boundary V1 on the left, as follows: Figure 4a As shown, since the initially passed pixel is outside the target connected region, the pixel value of that pixel is the second pixel value. During the leftward scan, the first pixel with the first pixel value is determined as the fourth edge point P4; from the second center point P... (中心)下 Scan to the eighth boundary V2 on the right, as follows Figure 4a As shown, since the pixel that is initially passed is outside the target connected region, the pixel value of the pixel is the second pixel value. During the rightward scanning process, the first pixel with the first pixel value is determined as the first edge point P1.

[0175] Among them, P (中心)下 The x-coordinate can be the average of the x-coordinate of the third edge point P3 and the x-coordinate of the second edge point P2 within the same row of pixels.

[0176] After performing the second scan on the second sampling area, we can obtain the first edge point P1, the second edge point P2, the third edge point P3 and the fourth edge point P4 corresponding to multiple scan lines.

[0177] In practical applications, the sampling regions in a regionally connected image, such as the first sampling region and the second sampling region, can be pre-set or determined during the line width measurement process. This disclosure does not limit this.

[0178] In a specific implementation, the step of determining the sampling region in the connected region image may include: firstly, determining the overlap coordinates (O0, O2, O3) of the first connected region and the second connected region based on the connected region image. x O y The overlapping coordinates are the coordinates of the overlapping pixel O located within the overlapping region of the first connected region and the second connected region; then, based on the overlapping coordinates (O... x O y The first sampling region and the second sampling region are determined by the ninth boundary H5 and the tenth boundary H6 of the region connected image set relative to each other in the column direction.

[0179] like Figure 4a As shown, the first dividing line H0 is a straight line that passes through the overlapping pixel O and extends along the row direction, that is, a straight line that passes through the overlapping pixel O and is parallel to the ninth boundary H5 and the tenth boundary H6.

[0180] Specifically, the first boundary H1 is determined by translating the ninth boundary H5 along the column direction towards the overlapping pixel O by a first preset distance; the second boundary H2 is determined by translating the first dividing line H0 along the column direction towards the ninth boundary H5 by a second preset distance; the fifth boundary H3 is determined by translating the first dividing line H0 along the column direction towards the tenth boundary H6 by a third preset distance; and the sixth boundary H4 is determined by translating the tenth boundary H6 along the column direction towards the overlapping pixel O by a fourth preset distance.

[0181] By shifting the first boundary H1 a first preset distance from the ninth boundary H5 in the column direction toward the overlapping pixel O, pixels on other sides of the first sub-connected region (sides different from L1 and L2) and other sides of the second sub-connected region (sides different from L3 and L4) can be avoided, thus improving the accuracy of linewidth measurement. By shifting the second boundary H2 a second preset distance from the first dividing line H0 in the column direction toward the ninth boundary H5, it can be ensured that the first sampling area does not include the overlapping area of ​​the first and second connected regions, avoiding mutual interference and improving the accuracy of edge point extraction.

[0182] By shifting the sixth boundary H4 a fourth preset distance from the tenth boundary H6 in the column direction towards the overlapping pixel O, pixels on other sides of the third sub-connected region (sides different from L1 and L2) and other sides of the fourth sub-connected region (sides different from L3 and L4) can be avoided, improving the accuracy of linewidth measurement. By shifting the fifth boundary H3 a third preset distance from the first dividing line H0 in the column direction towards the tenth boundary H6, it can be ensured that the second sampling area does not include the overlapping area of ​​the first and second connected regions, avoiding mutual interference and improving the accuracy of edge point extraction.

[0183] The specific values ​​of the first, second, third, and fourth preset distances mentioned above can be determined based on the resolution of the connected region image. For example, when the resolution of the connected region image is 480×640, in order to obtain a larger sampling area, the first, second, third, and fourth preset distances can be set to 10, 50, 10, and 50 pixels respectively. The specific values ​​can be adjusted as needed.

[0184] like Figure 4a As shown, the third boundary and the seventh boundary are the same, both being the left boundary V1 of the region connected image; the third boundary and the seventh boundary may also be different, and this disclosure does not limit this. The fourth boundary and the eighth boundary are the same, both being the right boundary V2 of the region connected image; the fourth boundary and the eighth boundary may also be different, and this disclosure does not limit this.

[0185] In practical applications, determining the overlapping coordinates (O) x O y There are several ways to determine the coordinates of overlapping pixel O. In the first method, such as... Figure 4a As shown, the region-connected image also includes a reference boundary connecting the ninth boundary H5 and the tenth boundary H6. The reference boundary could be, for example, the left boundary of the region-connected image, i.e. Figure 4aV1 extends along the column direction. The extension direction of the first segment and / or the second segment is different from the column direction. That is, at least one of the first segment and the second segment extends in a different direction than the column direction.

[0186] Accordingly, the step of determining the overlapping coordinates of the first connected region and the second connected region based on the region connected image may include: starting from the ninth boundary H5, performing a line-by-line scanning process on the pixels within the region connected image. The line-by-line scanning process includes: if the distance between the reference pixel of the current scan line and the reference boundary V1 is greater than or equal to the distance between the reference pixel of the previous scan line and the reference boundary V1, and greater than or equal to the distance between the reference pixel of the next scan line and the reference boundary V1, then the coordinates of the reference pixel of the current scan line are determined as the overlapping coordinates. Here, the reference pixel is the first pixel in the same row of pixels, scanned starting from the reference boundary V1, with a pixel value of the first pixel value.

[0187] When the x-coordinate of reference boundary V1 is 0, the distance between the reference pixel and reference boundary V1 is the x-coordinate of the reference pixel, i.e., the coordinate in the row direction. Correspondingly, the overlap coordinate (O... x O y () represents the coordinates of the reference pixel with the largest x-coordinate.

[0188] Specifically, such as Figure 4a As shown, the pixel row containing the ninth boundary H5 can be used as the first scan row. Scanning begins from the reference boundary V1 and proceeds to the right. During the scan, the first pixel with the first pixel value is determined as the reference pixel for that scan row. The overlapping coordinates can also be temporarily stored as the coordinates of the reference pixel for the first scan row. If the x-coordinate of the reference pixel in the second scan row is greater than the x-coordinate of the reference pixel in the first scan row, the overlapping coordinates are updated to the coordinates of the reference pixel in the second scan row, and this process continues downwards. When the overlapping coordinates are the coordinates of the reference pixel in the Nth scan row, and the x-coordinate of the reference pixel in the (N+1)th scan row is less than or equal to the x-coordinate of the reference pixel in the Nth scan row, the coordinates of the reference pixel in the Nth scan row can be determined as the final overlapping coordinates. Here, N is a positive integer.

[0189] In the second approach, the step of determining the overlapping coordinates of the first connected region and the second connected region based on the region connected image may include: performing line detection on the pixels in the first connected region and the second connected region to obtain multiple detected line segments; clustering the multiple detected line segments to obtain two clusters; and determining the coordinates of the intersection point of the two line segments corresponding to the cluster centers of the two clusters as the overlapping coordinates.

[0190] Reference Figure 5 The diagram illustrates the process of determining overlapping coordinates using clustering. For example... Figure 5In the diagram, 'a' represents multiple detected line segments obtained from line detection; for example... Figure 5 In the diagram, b shows the clustering results based on the intercept and slope of the detected line segments, i.e., the two clusters obtained by clustering the detected line segments; for example... Figure 5 The two thick black lines shown in 'c' represent the two line segments corresponding to the cluster centers of the two clusters.

[0191] In practical implementation, the Hough transform can be used to detect lines between pixels in the first and second connected regions, resulting in multiple detected line segments, such as... Figure 5 As shown in 'a', each detection line segment contains a set of parameters [rho, theta]. Based on the parameter theta, the slope 'a' and intercept 'b' of the detection line segment can be determined, where a = cos(theta) and b = sin(theta), yielding another set of parameters [a, b] for the detection line segment. Then, k-means can be used to perform cluster analysis on the parameters [a, b] of multiple detection line segments, setting the cluster center to 2 to obtain two clusters (e.g., rho, theta). Figure 5 (as shown in b) and the slope and intercept of the two line segments corresponding to the cluster centers of the two clusters, i.e., [a k1 b k1 ], [a k2 b k2 Then, based on the equation of the straight line connecting these two line segments: y = a k1 x+b k1 and y = a k2 x+b k2 Solving the equations yields the coordinates of the intersection points, i.e., the overlapping coordinates.

[0192] In this implementation, step S14, which involves determining the width of the first line segment based on the first edge point and the second edge point, may include: performing a straight line fitting on multiple first edge points to obtain a first edge line L1; performing a straight line fitting on multiple second edge points to obtain a second edge line L2; calculating a first distance from the first edge point to the second edge line and a second distance from the second edge point to the first edge line; and calculating the average of the first distance and the second distance to obtain the width of the first line segment.

[0193] Before determining the width of the line based on the width of the first line segment, step S14 may further include: performing straight line fitting on multiple third edge points to obtain a third edge line L3; performing straight line fitting on multiple fourth edge points to obtain a fourth edge line L4; calculating the third distance from the third edge point to the fourth edge line and the fourth distance from the fourth edge point to the third edge line; and calculating the average of the third distance and the fourth distance to obtain the width of the second line segment.

[0194] Accordingly, the step of determining the width of the line based on the width of the first line segment in step S14 may include: determining the width of the line based on the width of the first line segment and the width of the second line segment; wherein the width of the line includes at least one of the following: the average of the width of the first line segment and the width of the second line segment, the width of the first line segment and the width of the second line segment.

[0195] One method that can be used is the least squares method for line fitting.

[0196] Taking the calculation of the first distance from the first edge point on the first edge line L1 to the second edge line L2 as an example, the distance from the edge point to the edge line is calculated according to the following formula:

[0197]

[0198] Where d represents the first distance, (x, y) are the coordinates of the first edge point, and a and b are the slope and intercept of the second edge line L2, respectively.

[0199] When a line consists of multiple line segments, the width of the line can be the average of the widths of the multiple line segments:

[0200]

[0201] Where, d mean d is the width of the line. i Let be the width of the i-th line segment, and n be the number of line segments.

[0202] The first or second sampling region described above includes a connected region of both the first and second line segments. In practical applications, each sampling region may also include a connected region of only one line segment. Optionally, the first line segment includes a fifth branch, and step S13 may include:

[0203] First, determine the third sampling region in the connected image, such as... Figure 4b As shown, the third sampling region includes the eleventh boundary H7 and the twelfth boundary H8 that are set opposite to each other in the column direction, and the thirteenth boundary V3 and the fourteenth boundary V4 that connect the eleventh boundary H7 and the twelfth boundary H8. The target connected region within the third sampling region only includes the fifth sub-connected region corresponding to the fifth branch. The two sides of the fifth sub-connected region that are set opposite to each other in the first direction are connected to both the eleventh boundary H7 and the twelfth boundary H8.

[0204] Then, a third scanning process is performed on the pixels in the third sampling area. The third scanning process includes: scanning from the thirteenth boundary V3 to the fourteenth boundary V4 within the same row of pixels, and determining the first pixel with the first pixel value as the first edge point P1; scanning from the fourteenth boundary V4 to the thirteenth boundary V3, and determining the first pixel with the first pixel value as the second edge point P2.

[0205] It should be noted that, in Figure 4b In the image, the target connected region is a dark gray region, which is the pixel region corresponding to the first pixel value.

[0206] like Figure 4b As shown, the two sides L1 and L2 of the fifth sub-connected region, which are positioned opposite each other in the first direction, are connected to the eleventh boundary H7, and L1 and L2 are connected to the twelfth boundary H8. By ensuring that the two sides of the fifth sub-connected region, which are positioned opposite each other in the first direction, are connected to both the eleventh boundary H7 and the twelfth boundary H8, it is possible to avoid extracting pixels on other sides of the fifth sub-connected region, thereby improving the extraction accuracy of the first and second edge points and enhancing the accuracy of linewidth measurement.

[0207] Specifically, within the third sampling area, the third scanning process can start from the row of pixels where the eleventh boundary H7 is located and scan downwards sequentially. During the downward scanning process, it can scan row by row or scan every other row, etc.

[0208] Within each row of pixels or scan line, scan from the thirteenth boundary V3 on the left to the fourteenth boundary V4 on the right, as follows: Figure 4b As shown, since the initially passed pixel is outside the target connected region, the pixel value of that pixel is the second pixel value. During the rightward scan, the first pixel with the first pixel value is determined as the first edge point P1; the scan proceeds from the fourteenth boundary V4 on the right to the thirteenth boundary V3 on the left, as follows... Figure 4b As shown, since the pixel that is initially passed is outside the target connected region, the pixel value of the pixel is the second pixel value. During the leftward scanning process, the first pixel with the first pixel value is determined as the second edge point P2.

[0209] After completing the third scan processing of the third sampling area, the first edge point P1 and the second edge point P2 corresponding to multiple scan lines can be obtained.

[0210] In practical applications, if the line consists of only one line segment, the first line segment can be that line segment; if the line consists of multiple line segments that do not intersect, the first line segment can be any one of the multiple line segments that do not intersect; correspondingly, the fifth branch is all or part of the middle section of the first line segment, excluding the two endpoints.

[0211] If the line includes multiple intersecting line segments, the first line segment can be any one of the multiple intersecting line segments; correspondingly, the fifth branch can be a part of the first line segment excluding the two endpoints and intersections.

[0212] For example, when the line includes intersecting first and second segments, the fifth branch is equivalent to the aforementioned first branch, and the fifth sub-connected region is equivalent to the aforementioned first sub-connected region. In this case, the third sampling region can be obtained by dividing the aforementioned first sampling region by the second boundary line V0, such as... Figure 4a As shown, the second dividing line V0 passes through the overlapping coordinates (O). x O y And a straight line extending along the column direction. Accordingly, the first boundary H1, the second boundary H2 and the third boundary V1 of the first sampling area can be successively used as the eleventh boundary H7, the twelfth boundary H8 and the thirteenth boundary V3 of the third sampling area, and the fourteenth boundary V4 of the third sampling area is the second dividing line V0.

[0213] Figure 4b The corresponding third sampling area and third scanning process are applicable to the width measurement of lines of any shape, such as I-shaped, V-shaped, X-shaped, Y-shaped lines.

[0214] In another alternative implementation, the convolution kernel used in the dilation process is different in size from that used in the erosion process. Specifically, the convolution kernel used in the dilation process is smaller than that used in the erosion process. In this case, the width of the first connected region in the region-connected image is smaller than the width of the first line segment.

[0215] In this implementation, such as Figure 6 As shown, the first edge line L1 includes a first outer edge line and a first inner edge line, and the second edge line L2 includes a second outer edge line and a second inner edge line. The target connected region includes a third connected region corresponding to the first line segment. The convolution kernel used in the dilation process is smaller than the convolution kernel used in the erosion process, so that one side of the two opposite sides of the third connected region in the first direction is located between the first outer edge line and the first inner edge line, and the other side is located between the second outer edge line and the second inner edge line.

[0216] For example, the convolution kernel used in the expansion treatment can be 5×5, and the convolution kernel used in the corrosion treatment can be 7×7. This disclosure does not limit this.

[0217] The line may also include a second line segment intersecting the first line segment, and the first line segment may include a sixth branch located on one side of the intersection point of the first and second line segments. Accordingly, after step S12, the process may further include: extracting a skeleton image of the region connectivity image, the skeleton image including a skeleton, such as... Figure 12 The white line 'a' in the diagram shows that the pixel values ​​of each pixel within the skeleton are different from those of each pixel outside the skeleton. The skeleton includes the center line corresponding to the sixth branch.

[0218] Accordingly, before step S13, the method may further include: performing line detection on the edge image to obtain multiple edge segments; and determining the target line segment corresponding to the sixth branch from the multiple edge segments.

[0219] Specifically, the Hough transform can be used to detect straight lines in the edge image, resulting in multiple edge line segments, such as... Figure 11 As shown in 'a', the corresponding edge image is as follows: Figure 8 As shown in 'a'.

[0220] Since the edge segments corresponding to the same branch are close in position, multiple edge segments can be divided into regions based on their positions to obtain the target segment corresponding to the sixth branch.

[0221] It should be noted that the treatment method for all branches in the line can be the same as that for the sixth branch. Here, only the sixth branch is used as an example to illustrate the scheme. Here, a branch is a segment of a line located on one side of the intersection point, and the intersection point is not included on the branch.

[0222] The number of zones can be the same as the number of branches in the line, with each zone corresponding to a different branch. For example, when the line shape formed by the first and second segments is V-shaped, it contains two branches, which can divide multiple edge segments into two regions; when the line shape formed by the first and second segments is Y-shaped, it contains three branches, which can divide multiple edge segments into three regions; and when the line shape formed by the first and second segments is X-shaped, it contains four branches, which can divide multiple edge segments into four regions.

[0223] Specifically, when the line shape formed by the first and second line segments is X-shaped, the intersection points of multiple edge line segments can be determined first. Then, based on the coordinates of the intersection points, the edge image can be divided into four regions: the upper left region, the lower left region, the upper right region, and the lower right region. To improve the accuracy of line width measurement, each region may exclude the intersection points and their vicinity.

[0224] In practical applications, each edge segment can be traversed. If all pixels on the edge segment are located within the region corresponding to the sixth branch, then the edge segment is the target segment corresponding to the sixth branch. In this embodiment, taking the region corresponding to the sixth branch as the upper left region as an example, the target segment is the edge segment located within the upper left region.

[0225] In practical applications, the average slope of all target line segments can be calculated, and then the difference between each target line segment and the average slope can be determined. If the difference is less than or equal to a specified value, the target line segment is retained; otherwise, the target line segment is discarded.

[0226] It should be noted that when the line consists of only one line segment, the processing procedure for that line segment is the same as that for the sixth branch. In this case, multiple edge line segments obtained from the line detection can all be used as target line segments.

[0227] Accordingly, step S13 may include: determining the first outer edge line, the first inner edge line, the second outer edge line, and the second inner edge line from the target line segment based on the relationship between the position of the target line segment in the edge image, the position of the third connected region in the region connected image, and the position of the center line in the skeleton image.

[0228] The step of determining the first outer edge line, the first inner edge line, the second outer edge line, and the second inner edge line from the target line segment based on the relationship between the position of the target line segment in the edge image, the position of the third connected region in the region connected image, and the position of the center line in the skeleton image may include:

[0229] Based on the position of the target line segment in the edge image, a first mapping region corresponding to the target line segment is determined at the corresponding position in the region connected image, and a second mapping region corresponding to the target line segment is determined at the corresponding position in the skeleton image.

[0230] Specifically, based on the positions of the two endpoints of the target line segment in the edge image, the corresponding positions in the connected region image can be used to determine the first mapping region corresponding to the target line segment, and the corresponding positions in the skeleton image can be used to determine the second mapping region corresponding to the target line segment. Since two endpoints can define a line segment, the positions of the two endpoints of the target line segment in the edge image can be used to represent the position of the target line segment in the edge image, which can reduce the amount of computation and improve measurement efficiency.

[0231] If the first mapping region is located on the first side outside the third connected region, then the target line segment corresponding to the first mapping region is determined to be the first outer edge line;

[0232] If the first mapping region is located on the second side outside the third connected region, then the target line segment corresponding to the first mapping region is determined to be the second outer edge line;

[0233] If the first mapping region is located inside the third connected region, and the second mapping region is located on the first side of the center line, then the target line segment corresponding to the first mapping region and the second mapping region is determined as the first inner edge line.

[0234] If the first mapping region is located inside the third connected region, and the second mapping region is located on the second side of the center line, then the target line segment corresponding to the first mapping region and the second mapping region is determined as the second inner edge line.

[0235] In this implementation, since one of the two opposite sides of the third connected region in the first direction is located between the first outer edge line and the first inner edge line, and the other side is located between the second outer edge line and the second inner edge line, the target line segment can be determined to be the inner edge line or the outer edge line of the first line segment based on the relationship between the first mapping region corresponding to the target line segment and the third connected region.

[0236] Specifically, if the first mapping region is located inside the third connected region, then the target line segment corresponding to the first mapping region is the inner edge line of the first line segment; if the first mapping region is located outside the third connected region, then the target line segment corresponding to the first mapping region is the outer edge line of the first line segment.

[0237] like Figure 10 In the image, 'a' shows the outer edge pixels obtained by filtering the edge image using the target connected region; for example... Figure 10 In the diagram, 'b' represents the inner edge pixels obtained by filtering the edge image using the target connected region. For example... Figure 11 b in the figure shows the outer edge line obtained by filtering multiple edge segments using the target connected region; such as Figure 11 c in the figure shows the inner edge line obtained by filtering multiple edge segments using the target connected region.

[0238] Furthermore, if the first mapping region is located on the first side outside the third connected region, then the target line segment corresponding to the first mapping region is the first outer edge line; if the first mapping region is located on the second side outside the third connected region, then the target line segment corresponding to the first mapping region is the second outer edge line.

[0239] After selecting the inner edge lines from the target line segments, the first inner edge line and the second inner edge line can be distinguished based on the positional relationship between the second mapping area corresponding to each inner edge line and the center line. Specifically, if the second mapping area is located on the first side of the center line, the corresponding inner edge line is the first inner edge line; if the second mapping area is located on the second side of the center line, the corresponding inner edge line is the second inner edge line.

[0240] To determine the aforementioned positional relationships, in the first implementation, the region connectivity image may include a relatively set fifteenth boundary V5 and a sixteenth boundary V6, such as... Figure 7 As shown in d in the figure. Before the step of determining the first outer edge line, the first inner edge line, the second outer edge line, and the second inner edge line from the target line segment based on the relationship between the position of the target line segment in the edge image, the position of the third connected region in the region connected image, and the position of the center line in the skeleton image, the following may be included:

[0241] The pixel values ​​of each pixel in the first filling region and the second filling region are set to the third pixel value. The first filling region is the region in the region connected image located between the target connected region and the fifteenth boundary V5, and the second filling region is the region located between the target connected region and the sixteenth boundary V6.

[0242] like Figure 7 As shown in 'e', ​​the pixel value of each pixel within the target connected region (including the third connected region) is the first pixel value (e.g., 255), corresponding to... Figure 7 The white area indicated by d or e in the diagram; the pixel value of each pixel in the first and second filled areas is the third pixel value (e.g., 64), corresponding to... Figure 7 The gray area is indicated by 'e'; the pixel values ​​of each pixel in other areas are the second pixel value (e.g., 0), corresponding to... Figure 7 The black area indicated by 'e' in the diagram.

[0243] In a practical implementation, to set the pixel values ​​of each pixel in the first and second filled regions to the third pixel value, the connected image of the regions can be traversed (e.g., Figure 7 For each row of pixels (as shown in d), starting from the left (corresponding to...) Figure 7 V5 (shown in d) and the right side (corresponding to) Figure 7 As shown in Figure d (V6), the process iterates towards the center, traversing the pixel values ​​of each pixel within the row. It sets the pixel values ​​of all pixels traversed before the first pixel whose pixel value is the first pixel value to the third pixel value. The same operation is performed on the left and right sides until the entire image is traversed, resulting in the image shown. Figure 7 The image shown in e.

[0244] Then, in the upper left partition corresponding to the third connected region, the pixel values ​​on both sides outside the third connected region are different, with one side being the second pixel value (corresponding to...). Figure 7 The black area shown by 'e' in the diagram), and the third pixel value on the other side (corresponding to...). Figure 7 (The gray area shown as 'e' in the diagram). Therefore, the positional relationship between the first mapping region and the third connected region can be determined based on the pixel values ​​of each pixel within the first mapping region corresponding to the target line segment.

[0245] Specifically, if the pixel value of each pixel in the first mapping region is the third pixel value, then the first mapping region is determined to be located on the first side outside the third connected region; if the pixel value of each pixel in the first mapping region is the second pixel value, then the first mapping region is determined to be located on the second side outside the third connected region; if the pixel value of each pixel in the first mapping region is the first pixel value, then the first mapping region is determined to be located inside the third connected region.

[0246] In this implementation, the fifteenth boundary V5 and the sixteenth boundary V6 are two boundaries that are set opposite each other in the row direction of the region connected image. In a specific implementation, these two boundaries can also be two boundaries that are set opposite each other in the column direction of the region connected image.

[0247] In the second implementation, before the step of determining the first outer edge line, the first inner edge line, the second outer edge line, and the second inner edge line from the target line segment based on the relationship between the position of the target line segment in the edge image, the position of the third connected region in the region connected image, and the position of the center line in the skeleton image, the following may be included:

[0248] Perform an XOR operation between the region-connected image and the dilated image to obtain an intermediate image. This intermediate image comprises multiple discrete complementary regions, where each pixel within these complementary regions has a fourth pixel value (e.g., 255). Figure 9 (The white area shown in 'a') has multiple discrete complementary regions, and the pixel value of each pixel outside these regions is the fifth pixel value (e.g., 0, ...). Figure 9 (The black area shown in a) The intermediate image includes the seventeenth boundary V7 and the eighteenth boundary V8 set relative to each other;

[0249] The complementary region adjacent to the seventeenth boundary V7 in the intermediate image is defined as the third filling region, and the complementary region adjacent to the eighteenth boundary V8 is defined as the fourth filling region. The pixel values ​​of each pixel within the third and fourth filling regions are set to the sixth pixel value (e.g., 64). Figure 9 (The gray area shown in b).

[0250] Based on the position of the target line segment in the edge image, the corresponding third mapping region in the middle image is determined.

[0251] like Figure 8 As shown in c, the dilated image includes dilated connected regions. The pixel value of each pixel within the dilated connected region is the first pixel value, and the pixel value of each pixel outside the dilated connected region is the second pixel value. This is achieved by comparing the dilated image with a region-connected image (such as...). Figure 8 Perform an XOR operation on (e as shown in the image) to obtain the intermediate image, as shown in the image below. Figure 9As shown in 'a', the XOR operation can extract the region between the boundary of the target connected region and the boundary of the expanded connected region, i.e., the complementary region (e.g., ...). Figure 9 (The white area indicated by 'a' in the diagram).

[0252] In this implementation, since one of the two opposite sides of the third connected region in the first direction is located between the first outer edge line and the first inner edge line, and the other side is located between the second outer edge line and the second inner edge line, the target line segment can be determined to be the inner edge line or the outer edge line of the first line segment based on the relationship between the third mapping region and the complementary region corresponding to the target line segment.

[0253] Specifically, if the third mapping region is located inside the complementary region, then the target line segment corresponding to the third mapping region is the outer edge line of the first line segment; if the third mapping region is located outside the complementary region, then the target line segment corresponding to the third mapping region is the inner edge line of the first line segment.

[0254] Since the complementary regions corresponding to the third connected region are located on both sides of the third connected region, each outer edge line can be divided into a first outer edge line and a second outer edge line according to the complementary regions where each outer edge line is located.

[0255] To determine which complementary region each outer edge line belongs to, the pixels of the two complementary regions (located in the upper left region) corresponding to the third connected region can be set to different pixel values, such as... Figure 9 As shown in b, the pixel values ​​in the two complementary regions of the upper left area are the fourth pixel values ​​(e.g., ...). Figure 9 The white area shown in b) and the sixth pixel value (as shown in the image) Figure 9 (The gray area shown in b).

[0256] To set the pixel values ​​of each pixel in the third and fourth padding regions to the sixth pixel value, we can iterate through each row of pixels in the connected image. For each row of pixels, starting from the left (corresponding to...) Figure 9 V7 (as shown in a) and the right side (corresponding to) Figure 9 As shown in Figure a, V8) iterates towards the center, counting the pixel values ​​of each pixel in the row. When it encounters the first pixel with the fourth pixel value, it sets the pixel values ​​of all pixels in the region containing that pixel with the fourth pixel value to the sixth pixel value. The same operation is performed on the left and right sides until the entire image is traversed, resulting in the image shown. Figure 9 Image b in the image.

[0257] After filling, the positional relationship between the first mapping region and the third connected region can be determined based on the pixel values ​​of each pixel in the third mapping region corresponding to the target line segment.

[0258] Specifically, if the pixel value of each pixel in the third mapping region is the sixth pixel value, then the first mapping region is determined to be located on the first side outside the third connected region; if the pixel value of each pixel in the third mapping region is the fourth pixel value, then the first mapping region is determined to be located on the second side outside the third connected region.

[0259] In this implementation, the seventeenth boundary V7 and the eighteenth boundary V8 are two boundaries set relative to each other in the row direction of the intermediate image. In a specific implementation, these two boundaries can also be two boundaries set relative to each other in the column direction of the intermediate image.

[0260] In the third implementation, such as Figure 12 As shown in 'a', the skeleton image includes a nineteenth boundary V9 and a twentieth boundary V10 set relatively. The pixel value of each pixel within the skeleton is the seventh pixel value (e.g., 255, corresponding to...). Figure 12 (as shown by the white line 'a' in the diagram), the pixel value of each pixel outside the skeleton is the eighth pixel value (e.g., 0 corresponds to...). Figure 12 (The black area shown as 'a' in the diagram).

[0261] Before determining the first outer edge line, the first inner edge line, the second outer edge line, and the second inner edge line from the target line segment based on the relationship between the position of the target line segment in the edge image, the position of the third connected region in the region connected image, and the position of the center line in the skeleton image, the following may be included:

[0262] Set the pixel values ​​of all pixels in the regions between the skeleton and the nineteenth boundary V9 (the fifth filling region) and between the skeleton and the twentieth boundary V10 (the sixth filling region) in the skeleton image to the ninth pixel value (e.g., 64, corresponding to...). Figure 12 (The gray area shown in b).

[0263] To determine whether the second mapped region is located on the first or second side of the center line, the pixels on either side of the center line within the upper left region where the third connected region is located can be set to different pixel values. Specifically, each row of pixels in the region-connected image can be traversed, and for each row of pixels, starting from the left (corresponding to...) Figure 12 V9 (as shown in a) and the right side (corresponding to) Figure 12 As shown in Figure a, V10) iterates towards the center, traversing the pixel value of each pixel in the row. When it encounters the first pixel with the value of the seventh pixel, it sets the previously traversed pixel value to the ninth pixel value. The same operation is performed on the left and right sides until the entire image is traversed, resulting in the following: Figure 12 Image b in the image.

[0264] After the filling is complete, the location of the second mapping region on the first or second side of the center line can be determined based on the pixel values ​​of each pixel within the second mapping region. Specifically, if the pixel value of each pixel within the second mapping region is the ninth pixel value, then the second mapping region is determined to be on the first side of the center line; if the pixel value of each pixel within the second mapping region is the eighth pixel value, then the second mapping region is determined to be on the second side of the center line.

[0265] In this implementation, the nineteenth boundary V9 and the twentieth boundary V10 are two boundaries that are set opposite to each other in the row direction of the skeleton image. In a specific implementation, these two boundaries can also be two boundaries that are set opposite to each other in the column direction of the skeleton image.

[0266] In this implementation, step S14, which involves determining the width of the first line segment based on the first edge point and the second edge point, may include: calculating a fifth distance from the endpoint of the first outer edge line to the second outer edge line; calculating a sixth distance from the endpoint of the second outer edge line to the first outer edge line; calculating a seventh distance from the endpoint of the first inner edge line to the second inner edge line; calculating an eighth distance from the endpoint of the second inner edge line to the first inner edge line; and calculating the average of the fifth, sixth, seventh, and eighth distances to obtain the width of the first line segment.

[0267] To obtain appropriate exposure dosage and improve the accuracy of linewidth measurement, the exposure dosage value can be adjusted experimentally, and then the average ratio of the predicted distance (linewidth) of the images taken before and after the experiment can be calculated.

[0268] Specifically, the predicted mean before the experiment:

[0269]

[0270] Where d is the standard value, This is the average predicted distance for all images under the same exposure meter. Let be the predicted distance of the i-th image, n be the number of images with the same exposure meter, and m be the number of exposure meters.

[0271] The average of the ratios of the predicted distance after the experiment to the predicted mean before the experiment:

[0272]

[0273] Where K represents the image data size. In practical applications, the value of eval can be used to determine whether the exposure adjustment is appropriate.

[0274] In this embodiment, the target image can be grayscaled and then binarized to obtain a binarized image. During the binarization process, a binarization threshold can be determined first. Pixels with values ​​less than the binarization threshold are set to the minimum grayscale value, such as 0, while pixels with values ​​greater than or equal to the binarization threshold are set to the maximum grayscale value, such as 255.

[0275] In practical implementations, methods such as gray-scale averaging, percentage thresholding, thresholding based on the minimum valley value, iterative determination of the optimal threshold based on bimodal averaging, and Otsu's method can be used to determine the binarization threshold. However, the inventors found that a single binarization thresholding method performs poorly in processing images with high noise levels and diverse lighting conditions.

[0276] To obtain a more accurate binarization threshold, the image itself can be binarized based on its features. For example, for a target image that is predominantly green, binarization can be performed based on the green channel image of the target image.

[0277] like Figure 13 In the image, 'a' shows a greenish target image, and 'b' shows the green channel image of that target image. Figure 14 In the image, 'a' shows another greenish target image, and 'b' shows the green channel image of that target image.

[0278] Specifically, the steps for determining the binarization threshold based on the G-channel image of the target image may include: determining a first threshold using the Otsu method; determining a second threshold based on the proportion of the circuit pattern in the target image, and then based on that proportion and the pixel value of each pixel in the circuit pattern; and performing a weighted summation of the first threshold and the second threshold to obtain the binarization threshold.

[0279] Otsu's method, also known as the maximum inter-class variance method, is an algorithm for determining the threshold for image binarization segmentation. After binarizing the image using the threshold obtained by Otsu's method, the inter-class variance between the foreground and background images is maximized. Otsu's method is considered the optimal algorithm for threshold selection in image segmentation; it is computationally simple and unaffected by image brightness and contrast, thus finding widespread application in digital image processing. Otsu's method divides the image into background and foreground based on its grayscale characteristics. Since variance is a measure of the uniformity of grayscale distribution, a larger inter-class variance between the background and foreground indicates a greater difference between the two parts of the image. Misclassifying part of the foreground as background or vice versa will reduce the difference between the two parts. Therefore, segmentation that maximizes the inter-class variance implies a minimum misclassification probability.

[0280] In the process of determining the second threshold, for example, when the proportion of the line pattern in the target image is 8%, the pixel values ​​of each pixel in the line pattern can be sorted in descending order, and then the ratio of the number of pixels with pixel values ​​between the median value and the maximum pixel value to the total number of pixels can be calculated. When the ratio is 8%, the median value can be determined as the second threshold.

[0281] When the target image has a lot of noise, the binarization threshold can be calculated using the following formula:

[0282] t = w1 × t1 + w2 × t2

[0283] Where: t1 is the first threshold, w1 is the weight of the first threshold, t2 is the second threshold, w2 is the weight of the second threshold, and t is the binarization threshold.

[0284] Reference Figure 13 c and Figure 14 c in the diagram represents the binarized image obtained using the method described above. Figure 13 c in the figure shows the pair Figure 13 The image shown in b is a binary image obtained by binarizing the green channel image. Figure 14 c in the figure shows the pair Figure 14 The image shown in b is a binary image obtained by binarizing the green channel image.

[0285] The above binarization method selects the green channel image based on the characteristics of the image itself, and combines Otsu's method and the proportion of the line in the image to calculate the binarization threshold. This can reduce the influence of uneven brightness in the image, reduce noise in the binarized image, and improve the quality of the binarized image.

[0286] It should be noted that when the target image is reddish, binarization can be performed based on the red channel of the target image; when the target image is bluish, binarization can be performed based on the blue channel of the target image.

[0287] In this embodiment, median filtering can be used to denoise the image. Median filtering is a nonlinear signal processing technique based on sorting statistics theory that can effectively suppress noise. The basic principle of median filtering is to replace the value of a pixel in a digital image or digital sequence with the median value of all pixels in its neighborhood, making the surrounding pixel values ​​closer to the true value, thereby eliminating isolated noise points. Specifically, a two-dimensional sliding template of a certain structure is used to sort the pixels within the template according to their pixel values, generating a monotonically increasing (or decreasing) two-dimensional data sequence. The output of the two-dimensional median filter is:

[0288] g(x, y)=med(f(xk, yl)), (k, l∈W)

[0289] Where f(x, y) and g(x, y) are the image before and after processing, respectively, (x, y) are the pixel coordinates in the image, and W is a two-dimensional template, which can be 3×3 or 5×5 in size and can be in the shape of a rectangle, line, circle, cross, or ring.

[0290] In practical applications, the median filtering method described above can be used to denoise binarized images, resulting in denoised images. For example... Figure 13 d in the figure shows the pair Figure 13 The denoised image is obtained by median filtering the binarized image shown in 'c'. Figure 14 d in the figure shows the pair Figure 14 The denoised image is obtained by performing median filtering on the binarized image shown in c.

[0291] In this embodiment, the Canny edge detection operator can be used to perform edge detection on the image. The Canny edge detection operator is a multi-level detection algorithm. The criteria for edge detection by the Canny edge detection operator are as follows: (1) Low error rate edge detection: The detection algorithm should accurately find as many edges as possible in the image and minimize missed detections and false detections; (2) Optimal localization: The detected edge points should be accurately located at the center of the edge; (3) Any edge in the image should be marked only once, and image noise should not produce false edges.

[0292] The Canny edge detection operator performs edge detection using the following steps: smoothing the image with a Gaussian filter; calculating the magnitude and direction of the gradient using finite differences of the first-order partial derivatives; performing non-maximum suppression on the gradient magnitude; and detecting and connecting edges using a double thresholding algorithm.

[0293] In practical applications, the Canny edge detection operator can be used to extract edges from denoised images. For example... Figure 13 The 'e' in the figure shows the... Figure 13 The edge image is obtained by edge extraction from the denoised image shown by d in the figure. Figure 14 The 'e' in the figure shows the... Figure 14 The edge image is obtained by edge extraction of the denoised image shown in d.

[0294] Line detection in edge images can be divided into two modes: top-down and bottom-up. Top-down line detection includes Hough transform, which transforms the line from coordinate space to parameter space, and then uses voting to detect the line. Bottom-up line detection includes chain code tracking and phase grouping. Bottom-up line detection methods mainly detect short line segments, which can be clustered into long lines through clustering.

[0295] The step of using Hough transform to detect lines in an edge image may include:

[0296] Step 1: Randomly select a feature point in the image, i.e. an edge point. If the point has already been marked as a point on a certain straight line, continue to randomly select an edge point from the remaining edge points until all edge points have been selected.

[0297] Step 2: Perform a Hough transform on the point and then accumulate the results.

[0298] Step 3: Select the largest point in the Hough space. If the point is greater than the specified threshold, proceed to Step 4; otherwise, return to Step 1.

[0299] Step 4: Based on the maximum value obtained from the Hough transform, start from that point and move along the direction of the line to find the two endpoints of the line;

[0300] Step 5: Calculate the length of the line, output the line whose length meets the preset condition, and return to Step 1.

[0301] In practical applications, the steps of the Hough transform described above can be used to... Figure 13 and Figure 14 Line detection is performed on the edge image. For example... Figure 13 f in the figure shows the pair Figure 13 The straight line image is obtained by performing line detection on the edge image shown by 'e' in the figure. Figure 14 f in the figure shows the pair Figure 14 The straight line image is obtained by performing line detection on the edge image shown in 'e'.

[0302] Then, the width of the line can be determined based on the lines in the line image. Specific steps may include: fitting all detected lines using the least squares method with the Hough transform to obtain the reference slope k (for...). Figure 13 and Figure 14 As shown, two reference slopes are obtained (corresponding to two intersecting line segments); the slope and intercept of each line detected by the Hough transform are calculated; lines with slopes less than kt or greater than k+t are filtered out, that is, lines with slopes greater than or equal to kt and less than or equal to k+t are taken as target lines; where t is the slope threshold, which can be preset based on experience; then a hierarchical clustering algorithm can be used to cluster the intercepts of the target lines to obtain mutually parallel target lines (for Figure 13 and Figure 14 As shown, clustering yields four intercepts (two sets of parallel target lines). The distance between these parallel target lines is then calculated to determine the line width.

[0303] like Figure 13 g in the figure shows the value of Figure 13 Clustering the lines shown by f in the image yields images of mutually parallel target lines. For example... Figure 14 g in the figure shows the value of Figure 14 Clustering the lines shown in f in the image yields images of mutually parallel target lines.

[0304] The least squares method fits a straight line according to the following formula:

[0305] Standard number = ∑(observed value - theoretical value) 2

[0306] Here, the observed values ​​are the pixels that make up the straight line, and the theoretical values ​​are the assumed fitting function.

[0307] Hierarchical clustering is a type of clustering algorithm that creates a hierarchical nested clustering tree by calculating the similarity between data points of different categories. In the clustering tree, the original data points of different categories are the lowest level of the tree, and the top level is the root node of a cluster. There are two methods for creating clustering trees: bottom-up merging and top-down splitting.

[0308] Thus, combining Hough transform, least squares method and hierarchical clustering for line detection can improve the accuracy of edge line detection.

[0309] Figure 15 A block diagram of a line width measuring device is schematically shown, which is used to measure the width of a line. (Refer to...) Figure 15 It can include:

[0310] Image acquisition module 1501 is configured to acquire a target image of the line, the line including a first line segment;

[0311] The connectivity processing module 1502 is configured to perform region connectivity processing on the edge image or binarized image of the target image to obtain a region connected image; wherein, the edge image is an image obtained by edge detection of the target image, the binarized image is an image obtained by image binarization processing of the target image, and the region connected image includes a target connected region corresponding to the pattern of the line, wherein the pixel value of each pixel within the target connected region is different from the pixel value of each pixel outside the target connected region;

[0312] The edge determination module 1503 is configured to determine a first edge point and a second edge point of the first line segment based on the region connectivity image. The first edge point is located on the first edge line of the first line segment, and the second edge point is located on the second edge line of the second line segment. The first edge line and the second edge line are arranged opposite to each other in a first direction.

[0313] The width calculation module 1504 is configured to determine the width of the first line segment based on the first edge point and the second edge point; and to determine the width of the line based on the width of the first line segment.

[0314] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments of the linewidth measurement method, for example, by using software, hardware, firmware, etc., and will not be elaborated here.

[0315] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0316] The various component embodiments of this disclosure can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components in the computing processing device according to embodiments of this disclosure. This disclosure can also be implemented as a device or apparatus program (e.g., a computer program and computer program product) for performing some or all of the methods described herein. Such an implementation of this disclosure can be stored on a computer-readable medium or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.

[0317] For example, Figure 16A computing processing apparatus is shown that can implement the methods according to this disclosure. The computing processing apparatus conventionally includes a processor 1010 and a computer program product or computer-readable medium in the form of a memory 1020. The memory 1020 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. The memory 1020 has a storage space 1030 for program code 1031 for performing any of the method steps described above. For example, the storage space 1030 for program code may include various program codes 1031 respectively for implementing the various steps in the methods described above. These program codes can be read from or written to one or more computer program products. These computer program products include program code carriers such as hard disks, CDs, memory cards, or floppy disks. Such computer program products are typically as described in the references. Figure 17 The portable or fixed storage unit is described above. This storage unit may have the same characteristics as... Figure 16 The memory 1020 in the computing processing device is arranged similarly to storage segments, storage spaces, etc. Program code can be compressed, for example, in an appropriate form. Typically, the storage unit includes computer-readable code 1031', that is, code that can be read by a processor such as 1010, which, when run by the computing processing device, causes the computing processing device to perform the various steps in the methods described above.

[0318] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0319] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0320] The foregoing has provided a detailed description of a linewidth measurement method, apparatus, computing device, computer program, and computer-readable medium provided in this disclosure. Specific examples have been used to illustrate the principles and implementation methods of this disclosure. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this disclosure. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this disclosure. Therefore, the content of this specification should not be construed as a limitation of this disclosure.

[0321] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0322] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.

[0323] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.

[0324] The terms "an embodiment," "embodiment," or "one or more embodiments" as used herein mean that a particular feature, structure, or characteristic described in connection with an embodiment is included in at least one embodiment of this disclosure. Furthermore, please note that the examples of the phrase "in one embodiment" do not necessarily all refer to the same embodiment.

[0325] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of this disclosure may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.

[0326] In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. This disclosure can be implemented by means of hardware comprising a plurality of different elements and by means of a suitably programmed computer. In a unit claim enumerating a plurality of means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words may be interpreted as names.

[0327] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this disclosure, and are not intended to limit them. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure.

Claims

1. A method for measuring line width, wherein, The method for measuring the width of a line includes: Obtain a target image of the route, wherein the route includes a first line segment; The edge image or binarized image of the target image is subjected to region connectivity processing to obtain a region-connected image; wherein, the edge image is an image obtained by edge detection of the target image, the binarized image is an image obtained by image binarization processing of the target image, and the region-connected image includes a target connected region corresponding to the graphic of the line, wherein the pixel value of each pixel within the target connected region is different from the pixel value of each pixel outside the target connected region; the step of performing region connectivity processing on the edge image or binarized image of the target image to obtain a region-connected image includes: sequentially performing dilation processing and flooding filling processing on the edge image or the binarized image to obtain a dilated image; performing erosion processing on the dilated image to obtain an eroded image; wherein, the eroded image includes multiple connected regions, the pixel value of each pixel within the multiple connected regions is a first pixel value, and the pixel value of each pixel outside the multiple connected regions is a second pixel value; Based on the region connectivity image, a first edge point and a second edge point of the first line segment are determined. The first edge point is located on the first edge line of the first line segment, and the second edge point is located on the second edge line of the second line segment. The first edge line and the second edge line are set opposite to each other in a first direction. The width of the first line segment is determined based on the first edge point and the second edge point; and the width of the line is determined based on the width of the first line segment. The target connected region includes a first connected region corresponding to the first line segment, the first line segment includes a fifth branch, and multiple pixels of the region connected image are arranged in an array along the row and column directions. The step of determining the first edge point and the second edge point of the first line segment based on the region connected image includes: Extract the pixels on the two opposite sides of the first connected region in the first direction to obtain the first edge point and the second edge point; The step of extracting pixels on two opposite sides of the first connected region in the first direction to obtain the first edge point and the second edge point includes: A third sampling region is determined in the region connectivity image. The third sampling region includes an eleventh boundary and a twelfth boundary that are set opposite to each other in the column direction, and a thirteenth boundary and a fourteenth boundary that connect the eleventh boundary and the twelfth boundary. The target connectivity region within the third sampling region includes only the fifth sub-connected region corresponding to the fifth branch. The two sides of the fifth sub-connected region that are set opposite to each other in the first direction are connected to both the eleventh boundary and the twelfth boundary. A third scanning process is performed on the pixels within the third sampling area. The third scanning process includes: scanning from the thirteenth boundary to the fourteenth boundary within the same row of pixels, and determining the first pixel with a pixel value of the first pixel value as the first edge point; scanning from the fourteenth boundary to the thirteenth boundary, and determining the first pixel with a pixel value of the first pixel value as the second edge point.

2. The line width measurement method according to claim 1, wherein, The step of performing region connectivity processing on the edge image or binarized image of the target image to obtain a region-connected image further includes: The plurality of connected regions include isolated connected regions and target connected regions. The isolated connected regions are connected regions with a region area less than a preset threshold, and the target connected regions are connected regions with a region area greater than or equal to the preset threshold. The pixel values ​​of each pixel within the isolated connected region in the eroded image are set to the second pixel value to obtain the region connected image.

3. The line width measurement method according to claim 2, wherein, The convolution kernel used in the expansion treatment is the same size as the convolution kernel used in the corrosion treatment.

4. The line width measurement method according to claim 1, wherein, The line further includes a second line segment intersecting the first line segment. The first line segment includes a first branch located on one side of the intersection point of the first line segment and the second line segment. The second line segment includes a second branch located on one side of the intersection point. Multiple pixels of the connected region image are arranged in an array along the row and column directions. The step of extracting pixels on two opposite sides of the first connected region in the first direction to obtain the first edge point and the second edge point includes: A sampling region is determined in the region connected image. The sampling region includes a first sampling region, which includes a first boundary and a second boundary that are set opposite to each other in the column direction, and a third boundary and a fourth boundary that connect the first boundary and the second boundary. The target connected region within the first sampling region includes only a first sub-connected region corresponding to the first branch and a second sub-connected region corresponding to the second branch. The two sides of the first sub-connected region that are set opposite to each other in the first direction, and the two sides of the second sub-connected region that are set opposite to each other in the second direction, are connected to both the first boundary and the second boundary. The first sub-connected region is located on the side of the second sub-connected region closer to the third boundary. A first scanning process is performed on the pixels within the first sampling area. The first scanning process includes: scanning from the third boundary to the fourth boundary within the same row of pixels, and determining the first pixel with a pixel value of the first pixel value as the first edge point; scanning from the fourth boundary to the third boundary, and determining the first pixel with a pixel value of the first pixel value as the fourth edge point of the second line segment; determining the first center point of the first edge point and the fourth edge point within the same row of pixels; scanning from the first center point to the third boundary, and determining the first pixel with a pixel value of the first pixel value as the second edge point; scanning from the first center point to the fourth boundary, and determining the first pixel with a pixel value of the first pixel value as the third edge point of the second line segment. The third edge point is located on the third edge line of the second line segment, the fourth edge point is located on the fourth edge line of the second line segment, and the third edge line and the fourth edge line are arranged opposite to each other in the second direction.

5. The line width measurement method according to claim 4, wherein, The first line segment further includes a third branch line located on the other side of the intersection point, and the second line segment further includes a fourth branch line located on the other side of the intersection point; the sampling area further includes a second sampling area, which includes a fifth boundary and a sixth boundary arranged opposite to each other in the column direction, and a seventh boundary and an eighth boundary connecting the fifth boundary and the sixth boundary. The target connected region within the second sampling area includes only a third sub-connected region corresponding to the third branch line and a fourth sub-connected region corresponding to the fourth branch line. The two sides of the third sub-connected region arranged opposite to each other in the first direction, and the two sides of the fourth sub-connected region arranged opposite to each other in the second direction, are connected to both the fifth boundary and the sixth boundary. The third sub-connected region is located on the side of the fourth sub-connected region closer to the eighth boundary. The step of extracting pixels on two opposite sides of the first connected region in the first direction to obtain the first edge point and the second edge point further includes: A second scanning process is performed on the pixels within the second sampling area. The second scanning process includes: scanning from the seventh boundary to the eighth boundary within the same row of pixels, and determining the first pixel with a pixel value of the first pixel value as the third edge point; scanning from the eighth boundary to the seventh boundary, and determining the first pixel with a pixel value of the first pixel value as the second edge point; determining the second center point of the third edge point and the second edge point within the same row of pixels; scanning from the second center point to the seventh boundary, and determining the first pixel with a pixel value of the first pixel value as the fourth edge point; scanning from the second center point to the eighth boundary, and determining the first pixel with a pixel value of the first pixel value as the first edge point.

6. The line width measurement method according to claim 5, wherein, The step of determining the width of the first line segment based on the first edge point and the second edge point includes: A first edge line is obtained by fitting a straight line to multiple first edge points; a second edge line is obtained by fitting a straight line to multiple second edge points. Calculate the first distance from the first edge point to the second edge line, and the second distance from the second edge point to the first edge line; Calculate the average of the first distance and the second distance to obtain the width of the first line segment; Before the step of determining the width of the line based on the width of the first line segment, the method further includes: A straight line is fitted to multiple third edge points to obtain the third edge line; a straight line is fitted to multiple fourth edge points to obtain the fourth edge line. Calculate the third distance from the third edge point to the fourth edge line, and the fourth distance from the fourth edge point to the third edge line; Calculate the average of the third distance and the fourth distance to obtain the width of the second line segment; The step of determining the width of the line based on the width of the first line segment includes: The width of the line is determined based on the width of the first line segment and the width of the second line segment; wherein the width of the line includes at least one of the following: the average of the width of the first line segment and the width of the second line segment, the width of the first line segment and the width of the second line segment.

7. The line width measurement method according to claim 5, wherein, The target connected region further includes a second connected region corresponding to the second line segment, and the step of determining the sampling region in the connected image includes: Based on the region connectivity image, the overlap coordinates of the first connected region and the second connected region are determined, and the overlap coordinates are the coordinates of the overlapping pixels located within the overlap region of the first connected region and the second connected region; Based on the overlapping coordinates and the ninth and tenth boundaries of the region connected image relative to each other in the column direction, the first sampling region and the second sampling region are determined; wherein, the first boundary is determined by translating the ninth boundary in the column direction towards the overlapping pixels by a first preset distance; the second boundary is determined by translating the first dividing line in the column direction towards the ninth boundary by a second preset distance; the fifth boundary is determined by translating the first dividing line in the column direction towards the tenth boundary by a third preset distance; the sixth boundary is determined by translating the tenth boundary in the column direction towards the overlapping pixels by a fourth preset distance; the first dividing line is a straight line passing through the overlapping pixels and extending along the row direction.

8. The line width measurement method according to claim 7, wherein, The region connectivity image further includes a reference boundary connecting the ninth boundary and the tenth boundary, wherein the extension direction of the first line segment and / or the second line segment is different from the column direction, and the step of determining the overlap coordinates of the first connected region and the second connected region based on the region connectivity image includes: Starting from the ninth boundary, the pixels within the connected region image are scanned line by line. The line-by-line scanning process includes: if the distance between the reference pixel of the current scan line and the reference boundary is greater than or equal to the distance between the reference pixel of the previous scan line and the reference boundary, and is greater than or equal to the distance between the reference pixel of the next scan line and the reference boundary, then the coordinates of the reference pixel of the current scan line are determined as the overlapping coordinates; wherein, the reference pixel is the first pixel in the same row of pixels, scanned starting from the reference boundary, and whose pixel value is the first pixel value.

9. The line width measurement method according to claim 7, wherein, The step of determining the overlap coordinates of the first connected region and the second connected region based on the region connectivity image includes: Line detection is performed on pixels within the first connected region and the second connected region to obtain multiple detection line segments; The multiple detection line segments are clustered to obtain two clusters; The coordinates of the intersection of the two line segments corresponding to the cluster centers of the two clusters are determined as the overlapping coordinates.

10. The line width measurement method according to claim 2, wherein, The target connected region includes a third connected region corresponding to the first line segment. The first edge line includes a first outer edge line and a first inner edge line. The second edge line includes a second outer edge line and a second inner edge line. The convolution kernel used in the dilation process is smaller than the convolution kernel used in the erosion process, so that one side of the two opposite sides of the third connected region in the first direction is located between the first outer edge line and the first inner edge line, and the other side is located between the second outer edge line and the second inner edge line.

11. The line width measurement method according to claim 10, wherein, The line also includes a second line segment intersecting the first line segment, the first line segment including a sixth branch line located on one side of the intersection point of the first line segment and the second line segment, and after the step of obtaining the region connectivity image, the line further includes: Extract the skeleton image of the region connected image. The skeleton image includes a skeleton, the pixel values ​​of each pixel within the skeleton are different from the pixel values ​​of each pixel outside the skeleton, and the skeleton includes a center line corresponding to the sixth branch. Before the step of determining the first edge point and the second edge point of the first line segment based on the region connectivity image, the method further includes: Line detection is performed on the edge image to obtain multiple edge line segments; Determine the target line segment corresponding to the sixth branch from the plurality of edge line segments; The step of determining the first edge point and the second edge point of the first line segment based on the region connected image includes: Based on the relationship between the position of the target line segment in the edge image, the position of the third connected region in the region connected image, and the position of the center line in the skeleton image, the first outer edge line, the first inner edge line, the second outer edge line, and the second inner edge line are determined from the target line segment.

12. The line width measurement method according to claim 11, wherein, The step of determining the first outer edge line, the first inner edge line, the second outer edge line, and the second inner edge line from the target line segment based on the relationship between the position of the target line segment in the edge image, the position of the third connected region in the region connected image, and the position of the center line in the skeleton image includes: Based on the position of the target line segment in the edge image, a first mapping region corresponding to the target line segment is determined at the corresponding position in the region connectivity image, and a second mapping region corresponding to the target line segment is determined at the corresponding position in the skeleton image; If the first mapping region is located on the first side outside the third connected region, then the target line segment corresponding to the first mapping region is determined to be the first outer edge line; If the first mapping region is located on the second side outside the third connected region, then the target line segment corresponding to the first mapping region is determined to be the second outer edge line; If the first mapping region is located inside the third connected region, and the second mapping region is located on the first side of the center line, then the target line segment corresponding to the first mapping region and the second mapping region is determined to be the first inner edge line; If the first mapping region is located inside the third connected region, and the second mapping region is located on the second side of the center line, then the target line segment corresponding to the first mapping region and the second mapping region is determined to be the second inner edge line.

13. The line width measurement method according to claim 12, wherein, The region connectivity image includes a fifteenth boundary and a sixteenth boundary that are set relative to each other. Before the step of determining the first outer edge line, the first inner edge line, the second outer edge line, and the second inner edge line from the target line segment based on the relationship between the position of the target line segment in the edge image, the position of the third connected region in the region connectivity image, and the position of the center line in the skeleton image, the method further includes: The pixel values ​​of each pixel in the region between the target connected region and the fifteenth boundary, and in the region between the target connected region and the sixteenth boundary in the region connected image are set to the third pixel value; If the pixel value of each pixel in the first mapping region is the third pixel value, then it is determined that the first mapping region is located on the first side outside the third connected region; If the pixel value of each pixel in the first mapping region is the second pixel value, then it is determined that the first mapping region is located on the second side outside the third connected region; If the pixel value of each pixel in the first mapping region is the same as the first pixel value, then the first mapping region is determined to be located inside the third connected region.

14. The line width measurement method according to claim 12, wherein, Before the step of determining the first outer edge line, the first inner edge line, the second outer edge line, and the second inner edge line from the target line segment based on the relationship between the position of the target line segment in the edge image, the position of the third connected region in the region connected image, and the position of the center line in the skeleton image, the method further includes: The connected region image and the dilated image are XORed to obtain an intermediate image. The intermediate image includes multiple discrete complementary regions. The pixel value of each pixel within the multiple discrete complementary regions is the fourth pixel value, and the pixel value of each pixel outside the multiple discrete complementary regions is the fifth pixel value. The intermediate image includes a seventeenth boundary and an eighteenth boundary that are set relative to each other. Set the pixel value of each pixel in the complementary region adjacent to the seventeenth boundary and the complementary region adjacent to the eighteenth boundary in the intermediate image to the sixth pixel value. Based on the position of the target line segment in the edge image, a third mapping region corresponding to the target line segment is determined at the corresponding position in the intermediate image; If the pixel value of each pixel in the third mapping region is the sixth pixel value, then it is determined that the first mapping region is located on the first side outside the third connected region; If the pixel value of each pixel in the third mapping region is the fourth pixel value, then it is determined that the first mapping region is located on the second side outside the third connected region.

15. The line width measurement method according to claim 12, wherein, The skeleton image includes a nineteenth boundary and a twentieth boundary set relative to each other. The pixel value of each pixel within the skeleton is a seventh pixel value, and the pixel value of each pixel outside the skeleton is an eighth pixel value. Before the step of determining the first outer edge line, the first inner edge line, the second outer edge line, and the second inner edge line from the target line segment based on the relationship between the position of the target line segment in the edge image, the position of the third connected region in the region connected image, and the position of the center line in the skeleton image, the method further includes: Set the pixel values ​​of each pixel in the region between the skeleton and the nineteenth boundary, and the region between the skeleton and the twentieth boundary in the skeleton image to the ninth pixel value; If the pixel value of each pixel in the second mapping region is the ninth pixel value, then the second mapping region is determined to be located on the first side of the center line; If the pixel value of each pixel in the second mapping region is the eighth pixel value, then the second mapping region is determined to be located on the second side of the center line.

16. The line width measurement method according to claim 11, wherein, The step of determining the width of the first line segment based on the first edge point and the second edge point includes: Calculate the fifth distance from the endpoint of the first outer edge line to the second outer edge line; Calculate the sixth distance from the endpoint of the second outer edge line to the first outer edge line; Calculate the seventh distance from the endpoint of the first inner edge line to the second inner edge line; Calculate the eighth distance from the endpoint of the second inner edge line to the first inner edge line; The width of the first line segment is obtained by calculating the average of the fifth distance, the sixth distance, the seventh distance, and the eighth distance.

17. The line width measurement method according to any one of claims 1 to 16, wherein, The step of acquiring the target image of the line includes: Obtain the original image of the line; The original image is preprocessed to obtain the target image; wherein the preprocessing includes at least one of the following: grayscale conversion, contrast enhancement, brightness enhancement, and noise reduction.

18. The line width measurement method according to claim 17, wherein, The step of preprocessing the original image includes: The original image is subjected to noise reduction processing to obtain a noise-reduced image; Extract the edge pixels of the denoised image and count the total number of edge pixels; If the total number is less than or equal to the preset number, then the original image is subjected to contrast enhancement processing.

19. A linewidth measuring device, wherein, The line width measuring device is used to measure the width of a line and includes: An image acquisition module is configured to acquire a target image of the line, the line including a first line segment; A connectivity processing module is configured to perform region connectivity processing on the edge image or binarized image of the target image to obtain a region connected image; wherein the edge image is an image obtained by edge detection of the target image, the binarized image is an image obtained by image binarization processing of the target image, and the region connected image includes a target connected region corresponding to the graphic of the line, wherein the pixel value of each pixel within the target connected region is different from the pixel value of each pixel outside the target connected region; the step of performing region connectivity processing on the edge image or binarized image of the target image to obtain a region connected image includes: sequentially performing dilation processing and flooding filling processing on the edge image or the binarized image to obtain a dilated image; performing erosion processing on the dilated image to obtain an eroded image; wherein the eroded image includes multiple connected regions, the pixel value of each pixel within the multiple connected regions is a first pixel value, and the pixel value of each pixel outside the multiple connected regions is a second pixel value; An edge determination module is configured to determine a first edge point and a second edge point of the first line segment based on the region connectivity image. The first edge point is located on a first edge line of the first line segment, and the second edge point is located on a second edge line of the second line segment. The first edge line and the second edge line are positioned opposite each other in a first direction. The target connected region includes a first connected region corresponding to the first line segment. The first line segment includes a fifth branch. Multiple pixels of the region connectivity image are arranged in an array along the row and column directions. The step of determining the first edge point and the second edge point of the first line segment based on the region connectivity image includes: extracting pixels on two opposite sides of the first connected region in the first direction to obtain the first edge point and the second edge point; extracting pixels on two opposite sides of the first connected region in the first direction to obtain the first edge point and the second edge point. The steps for determining the edge point include: determining a third sampling region in the connected image of the region, the third sampling region including an eleventh boundary and a twelfth boundary that are opposite to each other in the column direction, and a thirteenth boundary and a fourteenth boundary connecting the eleventh boundary and the twelfth boundary, wherein the target connected region within the third sampling region includes only a fifth sub-connected region corresponding to the fifth branch, and the two sides of the fifth sub-connected region that are opposite to each other in the first direction are connected to both the eleventh boundary and the twelfth boundary; performing a third scanning process on the pixels within the third sampling region, the third scanning process including: scanning from the thirteenth boundary to the fourteenth boundary within the same row of pixels, determining the first pixel with a pixel value of the first pixel value as the first edge point; scanning from the fourteenth boundary to the thirteenth boundary, determining the first pixel with a pixel value of the first pixel value as the second edge point; The width calculation module is configured to determine the width of the first line segment based on the first edge point and the second edge point; and to determine the width of the line based on the width of the first line segment.

20. A computing processing device, wherein, include: Memory containing computer-readable code; One or more processors, wherein when the computer-readable code is executed by the one or more processors, the computing processing device performs the method as described in any one of claims 1 to 18.

21. A computer program product comprising computer-readable code that, when executed on a computing processing device, causes the computing processing device to perform the method according to any one of claims 1 to 18.

22. A computer-readable medium storing computer-readable code that, when executed on a computing processing device, causes the computing processing device to perform the method according to any one of claims 1 to 18.

Citation Information

Patent Citations

  • Tobacco or stem width measuring method, system and server with same

    CN107798672A