Disclosure of Invention
Therefore, it is necessary to provide a method and a system for counting the number of nanowires, which can avoid the generation of a large number of redundant short wires and improve the accuracy of the counting of the number of nanowires.
In order to achieve the purpose, the invention provides the following scheme:
a method of counting the number of nanowires, comprising:
acquiring a nanowire image to be counted;
preprocessing the nanowire image to obtain a preprocessed image;
thinning the preprocessed image, and extracting a nanowire framework to obtain a thinned nanowire image;
counting the number of end points and the number of isolated points in the thinned nanowire image;
identifying nodes in the refined nanowire image;
merging two nodes of which the node communication distance is smaller than a preset threshold value, and marking all the nodes subjected to merging processing as merged nodes;
identifying nodes of which neighborhoods contain odd number of foreground points in the merged nodes to obtain the number of odd-connection merged nodes;
calculating the number of the nanowires by using the number of the end points, the number of the isolated points and the number of the nodes after the odd connection combination, wherein a calculation formula is as follows:
m=∑(D+J odd )/2+G
wherein m is the number of nanowires, D is the number of endpoints, G is the number of isolated points, J odd The number of nodes after merging for odd connections.
Optionally, the preprocessing the nanowire image to obtain a preprocessed image specifically includes:
adjusting the nanowire image into a gray level image;
determining a gray threshold of the gray image by using a gray histogram;
converting the gray level image into a binary image by adopting a threshold segmentation method according to the gray level threshold;
and performing opening operation and closing operation on the binary image to obtain the preprocessed image.
Optionally, the step of refining the preprocessed image and extracting the nanowire framework to obtain a refined nanowire image specifically includes:
and changing edge pixel points of the nanowire area in the preprocessed image into background pixel points until the remaining pixel points of the nanowire area are all edge pixel points.
Optionally, the counting the number of end points and the number of isolated points in the refined nanowire image specifically includes:
for a target pixel point p, when p satisfies the following formula, it is marked as an end point:
wherein N (p) is the pixel sum of 8 neighborhood pixels of the target pixel p; p is a radical of i 8 neighborhood pixels of the target pixel point p, when p i P is a foreground point i Value takingIs 1 when p is i When p is a background point i The value is 0;
for a target pixel point p, when p satisfies the following formula, it is marked as an isolated point:
N(p)=0
and counting the number of the end points and the number of the isolated points.
Optionally, the identifying the node in the refined nanowire image specifically includes:
for a target pixel point p, when p satisfies the following formula, it is marked as a node:
C 4 (p)≥3,
or C 8 (p) ≠ 1 and N (p) ≥ 3
Wherein the content of the first and second substances,
when i =7, p
i+1 =p
0 ;
p 2j-2 、p 2j-1 、p 2j All the 8 neighborhood pixels are target pixels p.
A nanowire count system, comprising:
the image acquisition module is used for acquiring a nanowire image to be counted;
the preprocessing module is used for preprocessing the nanowire image to obtain a preprocessed image;
the thinning module is used for thinning the preprocessed image and extracting a nanowire framework to obtain a thinned nanowire image;
an end point isolated point counting module used for counting the number of end points and the number of isolated points in the thinned nanowire image;
a node identification module for identifying nodes in the refined nanowire image;
the node merging module is used for merging two nodes of which the node communication distance is smaller than a preset threshold value and marking all the nodes subjected to merging processing as merged nodes;
the odd connection merged node counting module is used for identifying nodes of which neighborhoods contain odd number of foreground points in the merged nodes to obtain the number of the odd connection merged nodes;
the nanowire number calculating module is used for calculating the number of the nanowires by using the number of the end points, the number of the isolated points and the number of the nodes after the odd connection combination, and the calculation formula is as follows:
m=∑(D+J odd )/2+G
wherein m is the number of nanowires, D is the number of endpoints, G is the number of isolated points, J odd The number of nodes after merging for odd connections.
Optionally, the preprocessing module includes:
a gray scale adjustment unit for adjusting the nanowire image into a gray scale image;
a gray threshold determination unit for determining a gray threshold of the gray image using a gray histogram;
a binarization unit for converting the grayscale image into a binary image by adopting a threshold segmentation method according to the grayscale threshold value;
and the opening and closing operation unit is used for performing opening operation and closing operation on the binary image to obtain the preprocessed image.
Optionally, the refining module includes:
and the thinning unit is used for changing the edge pixel points of the nanowire area in the preprocessed image into background pixel points until the remaining pixel points of the nanowire area are all edge pixel points.
Optionally, the endpoint outlier statistic module includes:
an endpoint marking unit, configured to mark, as an endpoint, for a target pixel point p when p satisfies the following equation:
wherein N (p) is the pixel sum of 8 neighborhood pixels of the target pixel p; p is a radical of i 8 neighborhood pixels of the target pixel point p, when p i P is a foreground point i A value of 1 when p i When being a background point p i The value is 0;
the isolated point marking unit is used for marking a target pixel point p as an isolated point when the p satisfies the following formula:
N(p)=0
and the endpoint isolated point counting unit is used for counting the number of the endpoints and the number of the isolated points.
Optionally, the node identification module includes:
the node identification unit is used for marking a target pixel point p as a node when the p satisfies the following formula:
C 4 (p)≥3,
or C 8 (p) ≠ 1 and N (p) ≥ 3
Wherein the content of the first and second substances,
when i =7, p
i+1 =p
0 ;
p 2j-2 、p 2j-1 、p 2j All the 8 neighborhood pixels are target pixels p.
Compared with the prior art, the invention has the beneficial effects that: the invention provides a method and a system for counting the number of nanowires, which are used for counting end points and isolated points of a thinned nanowire image, identifying nodes, combining the nodes with a short communication distance, thereby effectively reducing the generation of redundant short wires, and finally calculating the number of nanowires by using the number of the end points, the number of the isolated points and the number of the nodes after odd connection combination, thereby effectively improving the accuracy of nanowire counting.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
Example 1:
fig. 1 is a flowchart of a method of a nanowire number statistical method according to embodiment 1 of the present invention.
Referring to fig. 1, the method for counting the number of nanowires includes:
step 101: and acquiring a nanowire image to be counted.
Fig. 2 is a nanowire image obtained in this example 1.
Step 102: and preprocessing the nanowire image to obtain a preprocessed image.
The step 102 specifically includes:
and adjusting the nanowire image into a gray image by using a curve adjusting method in Photoshop software. Fig. 3 is a grayscale image obtained in this example 1.
And determining a gray threshold value of the gray image by utilizing the gray histogram.
And converting the gray level image into a binary image by adopting a threshold segmentation method according to the gray level threshold. Fig. 4 is a binary image obtained in this example 1.
And performing opening operation and closing operation on the binary image, thereby removing noise and obtaining the preprocessed image. Fig. 5 is a pre-processed image obtained in this example 1.
Step 103: and thinning the preprocessed image, and extracting a nanowire framework to obtain a thinned nanowire image.
The step 103 specifically includes:
and changing edge pixel points of the nanowire area in the preprocessed image into background pixel points until the remaining pixel points of the nanowire area are all edge pixel points.
Thinning is to use an image thinning algorithm with strict single-pixel width and rotation invariant characteristics to change edge pixel points of a white nanowire area in an image into a black background area until all the white pixel points of the rest nanowire areas are edge pixel points. Fig. 6 is a thinned nanowire image obtained in example 1.
The thinning algorithm with strict single-pixel width can ensure that the statistical result is more accurate, and the image thinning algorithm with the rotation invariant characteristic can ensure that the statistical result is kept unchanged when the image rotates.
Step 104: and counting the number of end points and the number of isolated points in the refined nanowire image.
The step 104 specifically includes:
for a target pixel point p, when p satisfies the following formula, it is marked as an end point:
wherein N (p) is the pixel sum of 8 neighborhood pixels of the target pixel p; p is a radical of i 8 neighborhood pixels of the target pixel p, FIG. 7 shows the target pixel p and 8 neighborhood pixels p i A graph of the relationship (c). When p is i P is a foreground point i A value of 1 when p i When being a background point p i The value is 0.
For a target pixel point p, when p satisfies the following formula, it is marked as an isolated point:
N(p)=0
and counting the number D of the end points and the number G of the isolated points.
Step 105: identifying nodes in the refined nanowire image.
For a target pixel point p, when p satisfies the following formula, it is marked as a node:
C 4 (p)≥3,
or C 8 (p) ≠ 1 and N (p) ≥ 3
Wherein the content of the first and second substances,
when i =7, p
i+1 =p
0 ;
p 2j-2 、p 2j-1 、p 2j All the 8 neighborhood pixels are target pixels p.
Step 106: and merging the two nodes of which the node communication distance is smaller than a preset threshold value, and marking all the nodes subjected to merging processing as merged nodes. The preset threshold W may be set to 1 to 10 pixels according to actual conditions.
The connection distance D of two nodes a and b E Is defined as: if there is a set of pixels with the smallest L value in the image skeleton { d 1 ,d 2 ,……,d L-1 Are such that a and d 1 D is arbitrary k And d k+1 ,d L-1 And b are both in 8-connectivity relation, then L is defined as the connectivity distance D of the two nodes a and b E 。
The two nodes a and b are defined jointly as: set { a, d 1 ,d 2 ,……,d L-1 B is identified as a new merge node containing multiple pixels.
Step 107: and identifying nodes of which the neighborhoods contain odd number of foreground points in the merged nodes to obtain the number of the nodes after odd connection merging.
Step 108: calculating the number of the nanowires by using the number of the end points, the number of the isolated points and the number of the nodes after the odd connection combination, wherein a calculation formula is as follows:
m=∑(D+J odd )/2+G
wherein m is the number of nanowires, D is the number of endpoints, G is the number of isolated points, J odd The number of nodes after merging for odd connections.
Fig. 8 is a partially enlarged view of fig. 6 in embodiment 1 of the present invention. Distance D of nodes in FIG. 8 E Is smaller than a preset threshold W and is thus merged into one large merged node. Fig. 9 is an enlarged view of a portion of fig. 6 covering the area shown in fig. 8. The number of real nanowires in fig. 9 is 5. If node merging is not performed, the statistical result is (7+5)/2=6 root, and a statistical error occurs. After the merging, the statistics result is (7+3)/2=5, and the statistics are correct.
The method according to the present invention performs statistics on the nanowires in fig. 6, and the obtained statistics result is 153. The statistical result of the human eye obtained from fig. 2 is 152, and thus, the method of the present invention can greatly reduce the statistical error and improve the accuracy of the nanowire statistics.
Example 2:
fig. 10 is a system configuration diagram of a nanowire number statistical system according to embodiment 2 of the present invention.
Referring to fig. 10, the system for counting the number of nanowires includes:
an image obtaining module 201, configured to obtain a nanowire image to be counted;
a preprocessing module 202, configured to preprocess the nanowire image to obtain a preprocessed image;
a thinning module 203, configured to thin the preprocessed image, extract a nanowire skeleton, and obtain a thinned nanowire image;
an end point isolated point counting module 204, configured to count the number of end points and the number of isolated points in the refined nanowire image;
a node identification module 205, configured to identify a node in the refined nanowire image;
a node merging module 206, configured to merge two nodes whose node connection distance is smaller than a preset threshold, and mark all the nodes after merging as merged nodes;
the odd-connection merged node counting module 207 is configured to identify nodes in which the neighborhoods include odd number of foreground points from the merged nodes to obtain the number of the odd-connection merged nodes;
a nanowire number calculating module 208, configured to calculate the number of nanowires by using the number of endpoints, the number of isolated points, and the number of nodes after odd connection merging, where the calculation formula is as follows:
m=∑(D+J odd )/2+G
wherein m is the number of nanowires, D is the number of endpoints, G is the number of isolated points, J odd The number of nodes after merging for odd connections.
Optionally, the preprocessing module 202 includes:
a gray scale adjustment unit for adjusting the nanowire image into a gray scale image;
a gray threshold determination unit for determining a gray threshold of the gray image using a gray histogram;
a binarization unit for converting the grayscale image into a binary image by using a threshold segmentation method according to the grayscale threshold value;
and the opening and closing operation unit is used for performing opening operation and closing operation on the binary image to obtain the preprocessed image.
Optionally, the refining module 203 includes:
and the thinning unit is used for changing the edge pixel points of the nanowire areas in the preprocessed image into background pixel points until the remaining pixel points of the nanowire areas are all edge pixel points.
Optionally, the endpoint outlier statistic module 204 includes:
an endpoint marking unit, configured to mark, as an endpoint, for a target pixel point p when p satisfies the following equation:
wherein N (p) is the pixel sum of 8 neighborhood pixels of the target pixel p; p is a radical of i 8 neighborhood pixels of the target pixel point p, when p i P is a foreground point i A value of 1 when p i When being a background point p i The value is 0;
the isolated point marking unit is used for marking a target pixel point p as an isolated point when the p satisfies the following formula:
N(p)=0
and the endpoint isolated point counting unit is used for counting the number of the endpoints and the number of the isolated points.
Optionally, the node identifying module 205 includes:
the node identification unit is used for marking a target pixel point p as a node when the p satisfies the following formula:
C 4 (p)≥3,
or C 8 (p) ≠ 1 and N (p) ≥ 3
Wherein the content of the first and second substances,
when i =7, p
i+1 =p
0 ;
p 2j-2 、p 2j-1 、p 2j All the 8 neighborhood pixels are target pixels p.
Compared with the prior art, the invention has the beneficial effects that: the invention provides a method and a system for counting the number of nanowires, which are used for counting end points and isolated points of a thinned nanowire image, identifying nodes, combining the nodes with a short communication distance, thereby effectively reducing the generation of redundant short wires, and finally calculating the number of nanowires by using the number of the end points, the number of the isolated points and the number of the nodes after odd connection combination, thereby effectively improving the accuracy of nanowire counting.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. For the system disclosed by the embodiment, the description is relatively simple because the system corresponds to the method disclosed by the embodiment, and the relevant points can be referred to the method part for description.
The principles and embodiments of the present invention have been described herein using specific examples, which are provided only to help understand the method and the core concept of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, the specific embodiments and the application range may be changed. In view of the above, the present disclosure should not be construed as limiting the invention.