Image segmentation method and image processing device for extracting single fiber samples from multi-fiber samples
Through the image segmentation method of extracting single fiber samples from multi-fiber samples, the problem of time-consuming analysis of fiber component content in textiles is solved, and efficient and automated extraction of single fiber samples is achieved, supporting the training and verification of deep learning methods.
Patent Information
- Application Number
- CN202210137290.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-15
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2042-02-15
AI Technical Summary
In the prior art, qualitative quantitative analysis of fiber component content in textiles depends on chemical assays and manual screening, which consumes time and requires high professional standards, making it difficult to meet the demand of deep learning methods for high-quality single fiber samples.
Automatic extraction of high-quality single fiber samples is achieved through image segmentation methods for extracting single fiber samples from multi-fiber samples, including vector processing, convolution operation, contour drawing, hole filling, edge calculation and distance matrix processing.
The cost and time of artificially prepared single fiber samples is greatly reduced, providing a large number of high-quality single fiber samples for training and validation of deep learning methods.
Smart Images

Figure CN114511584B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image recognition technology, and in particular to a technology for preparing a single fiber image by utilizing multiple fiber images of textile raw materials. Background Art
[0002] The determination of the content of various fiber components in textile raw materials is an important indicator to determine the value and application scope of the raw materials. According to the National Standard of the People's Republic of China (GB / T 16988-2013) "Determination of the content of mixtures of special animal fibers and sheep wool", the current qualitative and quantitative analysis of the content of various fiber components in textiles still uses chemical determination methods and manual screening methods. These methods require analysts to have a high level of professionalism and take a long time (2-3 days) to complete.
[0003] In recent years, the development of artificial intelligence, especially the increasingly perfect deep learning network, has made AI widely used in many fields, such as computer science, finance and trade, medicine, diagnosis, heavy industry, transportation, telecommunications, etc. Among them, computer vision technology supported by deep learning network has achieved a level comparable to that of humans in the fields of face recognition and medical image processing. In view of the good performance of deep learning network in image recognition, we intend to use this technology to provide a new solution for the detection of textile raw material content.
[0004] Since deep learning methods require a large number of high-quality training samples (it is estimated that the number of samples required for a single category is 1000+), in order to meet the training process of deep learning to identify fiber types, it is estimated that the number of single fiber samples required will reach 10e5-10e6. Since fiber sample preparation requires a series of processes, such a high number of sample preparations, if all are prepared manually, will require a lot of manpower and material resources. In the daily testing process of textiles, the relevant quality inspection department will prepare multiple multi-fiber samples for each sample, and after good manual classification and statistics, if high-quality single fiber samples can be prepared from multi-fiber samples through image processing methods, a lot of manpower and material resources can be saved. Summary of the invention
[0005] In view of this, the object of the present invention is to provide an image segmentation method for extracting single fiber samples from multi-fiber samples, so as to solve the technical problem of preparing single fiber samples for training and verification of deep learning methods for detecting textile fiber raw materials.
[0006] The image segmentation method for extracting a single fiber sample from a multi-fiber sample of the present invention comprises the following steps:
[0007] 1) Prepare multi-fiber sample images;
[0008] 2) performing vector processing and binarization processing on the multi-fiber sample image obtained in step 1), with a grayscale level of 256, and then keeping the image output size consistent;
[0009] 3) performing type identification and classification marking on the multi-fiber sample image obtained in step 2);
[0010] 4) Converting the image processed in step 3) into a matrix: the pixels in the image correspond to the elements in the matrix one by one, the pixels with a pixel value of 255 are assigned a value of 0 when converted into the matrix, and the pixels with a pixel value of 0 are assigned a value of 1 when converted into the matrix;
[0011] 5) performing convolution operation on the matrix processed in step 4);
[0012] 6) Convert the matrix obtained in step 5) into an image: the pixels in the image correspond one-to-one to the elements in the matrix, the elements with a value of 1 in the matrix are assigned a value of 0 when converted to the image, and the elements with a value of 0 in the matrix are assigned a value of 255 when converted to the image;
[0013] 7) drawing the outline of the fiber in the image obtained in step 6);
[0014] 8) filling small holes in the image obtained in step 7);
[0015] 9) calculating the fiber edges in the image obtained in step 8);
[0016] 10) Convert the image obtained in step 9) into a matrix: the pixels in the image correspond one-to-one to the elements in the matrix, and the pixels with a pixel value of 255 are assigned a value of 0 when converted into the matrix, and the pixels with a pixel value of 0 are assigned a value of 1 when converted into the matrix;
[0017] 11) storing the non-zero elements in the matrix obtained in step 10) as an edge list in connection order;
[0018] 12) Traverse the above boundary list, independently calculate the distance matrix between each group of pixels, and delete the matrix element values that are not in the range of 40-100;
[0019] 13) Calculate the gradient of the distance matrix and delete the matrix element values except the minimum value;
[0020] 14) Detect the minimum value line perpendicular to the symmetry axis along the symmetry axis direction. If the minimum value line on the same line is discontinuous and the discontinuity is within the distance value range represented by the minimum value line, assign the discontinuity point to the mean value of the distance constituting the minimum value line; store the processed minimum value line perpendicular to the symmetry axis direction;
[0021] 15) Traverse the minimum line. If the length of the minimum line is less than 1 / 2 of the image height pixel value, discard the minimum line; if the length of the minimum line is greater than or equal to 1 / 2 of the image height pixel value, extract the pixel points on the two parallel contour lines of the fiber represented by the minimum line, and store them as lists respectively. Extend the two lists through convolution calculation. When the termination condition is reached, connect the pixel points corresponding to the ends of the two lists with a straight line, and add the coordinate data corresponding to the pixel points on the straight line to the list, so as to obtain a closed single fiber contour composed of a set of edge pixel points;
[0022] 16) taking the single fiber outline obtained in step 15), converting the white pixels within the single fiber outline to black pixels, and inverting the entire image;
[0023] 17) The single fiber contour is fitted with the original image in a loop, so as to obtain each single fiber sample image.
[0024] Furthermore, the image segmentation method for extracting a single fiber sample from a multi-fiber sample also includes step 18): manually identifying the extracted single fiber sample image and removing incomplete and blurred images.
[0025] Furthermore, the step 1) of preparing the multi-fiber sample image further comprises the following steps:
[0026] a) Take a fiber sample and lay it flat on the test bench. Use tweezers to take equal amounts of fibers from different parts of the fiber sample. Then mix the fibers taken with tweezers and arrange them so that the fibers are basically parallel.
[0027] b) Cut the fiber segment in the middle of the fiber taken by tweezers, and cut the same fiber only once;
[0028] c) placing all the fiber segments on a container, dripping an appropriate amount of liquid medium into the container, stirring to evenly distribute the fiber segments in the liquid medium, then taking an appropriate amount of fiber segment samples and placing them on a glass slide, and covering them with a cover glass;
[0029] d) placing a glass slide on a microscope stage, adjusting the focus so that a clear multi-fiber sample can be seen in the field of view of the microscope, and obtaining a scan image of the multi-fiber sample under the microscope.
[0030] Furthermore, in the step 2), the multi-fiber sample image is scaled to maintain the image output size of 755*552, in pixels, and the length and width are rounded down during scaling; the scaled image is binarized using the Otsu algorithm, with parameters of 160, 255 and cv.THRESH_BINARY.
[0031] Further, the convolution operation on the matrix in step 5) includes:
[0032] First convolution: The convolution kernel kernel is a (5, 5) all-1 matrix, and the convolution kernel coefficient coef is 0.2; during the calculation process, if the convolution sum is less than kernel.sum()*coef, the matrix element value is 255, if the convolution sum is greater than or equal to kernel.sum()*coef, the matrix element value is 0;
[0033] Second convolution: This time, the convolution kernel kernel is set to a (3, 3) all-1 matrix, and the convolution kernel coefficient coef is 0.1. During the calculation process, if the convolution sum is less than kernel.sum()*coef, the matrix element value is 255. If the convolution sum is greater than or equal to kernel.sum()*coef, the matrix element value is 0.
[0034] Further, in step 7), drawing the contours of the fibers in the image includes: firstly using the findContours method in opencv to draw the contours of the fibers in the multi-fiber sample, with the parameters being cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE, and then using the drawContours method in opencv to draw the contours of the fibers, with the parameters being contours[4], 0, (0, 255, 0), 3;
[0035] In the step 8), the floodfill algorithm of opencv is used to fill the small holes in the image, and the parameters are mask, (0, 0), (0, 0, 0), cv.FLOODFILL_FIXED_RANGE, where mask is an all-0 matrix generated by numpy, specifically np.zeros([h+2, w+2], np.uint8), where h, w = image.shape[:2];
[0036] In step 9), the Canny algorithm is used to calculate the fiber edges in the image, and its parameters are 100, 200.
[0037] Furthermore, the matrix element value range in the distance matrix in step 12) is 40-110.
[0038] Furthermore, in step 14), if the minimum line on the same line is discontinuous and the discontinuity is within the range of the distance value (-35, 35) represented by the minimum line, the discontinuity point is assigned the mean value of the distances constituting the minimum line.
[0039] Further, in the step 15), the list is extended by convolution calculation, and the convolution calculation is performed with the convolution kernel (3,3) / 3 and the list. If the convolution value is less than 3, the two pixel points corresponding to the ends of the list are connected by a straight line, and the convolution calculation is terminated; if the convolution value is greater than or equal to 3, there is a new adjacent pixel point, and the coordinate data of the new adjacent pixel point is first added to the edge of the list, and then it is determined whether the newly added pixel point reaches the edge of the image. If it reaches the edge of the image, the two pixel points corresponding to the end of the list are connected by a straight line and the convolution calculation is terminated; if the newly added pixel point does not reach the edge of the image, the distance between the two pixel points corresponding to the end of the list after the new adjacent pixel point is added is calculated. If the distance is less than the set value, the two pixel points are connected by a straight line and the convolution calculation is terminated; if the newly added pixel point does not reach the edge of the image, and the distance between the two pairs of newly added pixels for three consecutive times shows a trend of gradually increasing, the two pixel points are connected by a straight line and the convolution calculation is terminated; otherwise, the convolution calculation is continued.
[0040] Beneficial effects of the present invention:
[0041] The present invention discloses an image segmentation method and an image processing device for extracting single fiber samples from multi-fiber samples. By using technologies such as image processing and contour point distance matrix, high-quality single fiber sample images can be extracted from multi-fiber images. The method can produce a large number of high-quality single fiber sample images with low labor and time costs, thereby solving the technical problem of providing training and verification of single fiber samples for deep learning methods for detecting textile fiber raw materials. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 This is a multi-fiber sample diagram;
[0043] Figure 2 The flowchart of the algorithm for storing the non-zero elements in the matrix as an edge list in connection order;
[0044] Figure 3 It is the fiber contour image extracted from the multi-fiber sample image;
[0045] Figure 4 This is a schematic diagram of the gradient minimum. It is only for the convenience of understanding. The figure is a symmetrical figure;
[0046] Figure 5 A schematic diagram of the pixel points at the ends of the two long side contours of the connecting fiber;
[0047] Figure 6 Flowchart of the image segmentation method for extracting single fiber samples from multi-fiber samples. DETAILED DESCRIPTION
[0048] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0049] In this embodiment, the image segmentation method for extracting a single fiber sample from a multi-fiber sample includes the following steps:
[0050] 1) Preparing a multi-fiber sample image, comprising:
[0051] a) Lay the fiber sample flat on the test bench, and use tweezers to take equal amounts of fibers from different parts of the fiber sample. Preferably, the amount of fibers taken is more than 500 mg, and the number of locations for taking fibers is preferably more than 20; then mix the fibers taken with tweezers, and arrange them so that the fibers are basically parallel;
[0052] b) cutting a fiber segment from the middle of the fiber taken by tweezers, the fiber segment length is preferably 0.4 mm to 0.6 mm, and the same fiber is cut only once;
[0053] c) placing all the fiber segments on a container, dripping a proper amount of liquid medium into the container, stirring to evenly distribute the fiber segments in the liquid medium, then taking a proper amount of fiber segment samples and placing them on a glass slide, and covering them with a cover glass; in this embodiment, the overall liquid medium is preferably liquid paraffin; of course, other types of liquid media may also be selected in different embodiments; before covering the cover glass, excess liquid medium should be removed to ensure that after covering the cover glass, no liquid medium is squeezed out from under the cover glass to cause fiber loss;
[0054] d) placing a glass slide on a microscope stage, adjusting the focus so that a clear multi-fiber sample can be seen in the field of view of the microscope, and obtaining a scanned image of the multi-fiber sample under the microscope through a scanning module of the microscope.
[0055] 2) The multi-fiber sample image obtained in step 1) is vectorized and binarized, with a grayscale level of 256, and then the image output size is kept consistent. In this step, the multi-fiber sample image is scaled to keep the image output size at 755*552, in pixels, and the image length and width are rounded down during scaling; the scaled image is binarized using the Otsu algorithm, with parameters of 160, 255 and cv.THRESH_BINARY.
[0056] 3) Identify and classify the multi-fiber sample images obtained in step 2) and store them in a multi-fiber sample library.
[0057] 4) Convert the image processed in step 3) into a matrix: the pixels in the image correspond one-to-one to the elements in the matrix, pixels with a pixel value of 255 are assigned a value of 0 when converted into the matrix, and pixels with a pixel value of 0 are assigned a value of 1 when converted into the matrix.
[0058] 5) Performing a convolution operation on the matrix processed in step 4), which includes:
[0059] First convolution: The convolution kernel kernel is a (5, 5) all-1 matrix, and the convolution kernel coefficient coef is 0.2; during the calculation process, if the convolution sum is less than kernel.sum()*coef, the matrix element value is 255, if the convolution sum is greater than or equal to kernel.sum()*coef, the matrix element value is 0;
[0060] Second convolution: This time, the convolution kernel kernel is set to a (3, 3) all-1 matrix, and the convolution kernel coefficient coef is 0.1. During the calculation process, if the convolution sum is less than kernel.sum()*coef, the matrix element value is 255. If the convolution sum is greater than or equal to kernel.sum()*coef, the matrix element value is 0.
[0061] 6) Convert the matrix obtained in step 5) into an image: the pixels in the image correspond one-to-one to the elements in the matrix. The elements with a value of 1 in the matrix are assigned a value of 0 when converted to the image, and the elements with a value of 0 in the matrix are assigned a value of 255 when converted to the image.
[0062] 7) Draw the contours of the fibers in the image obtained in step 6): First, use the findContours method in opencv to draw the contours of the fibers in the multi-fiber sample, with the parameters cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE, and then use the drawContours method in opencv to draw the contours of the fibers, with the parameters contours[4], 0, (0, 255, 0), 3.
[0063] 8) Use opencv's floodfill algorithm to fill the small holes in the image obtained in step 7), with the parameters mask, (0, 0), (0, 0, 0), cv.FLOODFILL_FIXED_RANGE, where mask is an all-0 matrix generated by numpy, specifically np.zeros([h+2,w+2],np.uint8), where h, w = image.shape[:2].
[0064] 9) Use the Canny algorithm to calculate the fiber edges in the image obtained in step 8), with parameters of 100 and 200.
[0065] 10) Convert the image obtained in step 9) above into a matrix: the pixels in the image correspond one-to-one to the elements in the matrix, pixels with a pixel value of 255 are assigned a value of 0 when converted into the matrix, and pixels with a pixel value of 0 are assigned a value of 1 when converted into the matrix.
[0066] 11) Store the non-zero elements in the matrix obtained in step 10) as an edge list in connection order.
[0067] 12) Traverse the above boundary list and independently calculate the distance matrix between each group of pixels. Since the common fiber width in the detection image ranges from 40 to 110, the matrix element values that are not in the range of 40 to 110 are deleted.
[0068] 13) Calculate the matrix element gradient of the distance matrix and delete the matrix element values except the minimum value.
[0069] 14) Detect the minimum line perpendicular to the axis of symmetry along the direction of the axis of symmetry. If the minimum line on the same line is discontinuous and the discontinuity is within the distance value (-35, 35) represented by the minimum line, assign the discontinuity point to the representative value of the minimum line; store the processed minimum line perpendicular to the axis of symmetry.
[0070] 15) Traverse the minimum line. If the length of the minimum line is less than 1 / 2 of the image height pixel value, discard the minimum line. If the length of the minimum line is greater than or equal to 1 / 2 of the image height pixel value, extract the pixel points on the two parallel contour lines of the fiber represented by the minimum line and store them as lists respectively. Then perform convolution calculation with the convolution kernel (3,3) / 3 and the list. If the convolution value is less than 3, connect the two pixel points corresponding to the ends of the list with a straight line, terminate the convolution calculation, and then add the coordinate data corresponding to the pixel points on the straight line to the list, so as to obtain a closed single fiber contour composed of a set of edge pixel points. If the convolution value is greater than or equal to 3, there are new adjacent pixels. First, add the coordinate data of the new adjacent pixels to the edge of the list, and then determine whether the newly added pixels reach the edge of the image. If they reach the edge of the image, connect the two pixels at the end of the list with a straight line and terminate the convolution calculation, and add the coordinate data corresponding to the pixels on the straight line to the list, so as to obtain a closed single fiber contour composed of a set of edge pixels. If the newly added pixel does not reach the edge of the image, calculate the distance between the two pixels at the end of the list after adding the new adjacent pixels. If the distance is less than the set value, connect the two pixels with a straight line and terminate the convolution calculation, and add the coordinate data corresponding to the pixels on the straight line to the list, so as to obtain a closed single fiber contour composed of a set of edge pixels. If the newly added pixel does not reach the edge of the image, and the distance between the two pairs of pixels added for three consecutive times shows a trend of gradually increasing, connect the two pixels with a straight line and terminate the convolution calculation, and add the coordinate data corresponding to the pixels on the straight line to the list, so as to obtain a closed single fiber contour composed of a set of edge pixels. Otherwise, continue the convolution calculation.
[0071] like Figure 3As shown in the figure, the fiber contour extracted from the fiber image, the two fiber contour lines A and B in the figure are composed of pixel points, and the two extracted lists represent the coordinates of the pixel points on the two contour lines of the fiber respectively; the distance between the two parallel fiber contour lines of a single fiber is the diameter of the fiber (due to the error, this diameter value should be a non-fixed value, but its value is within the range of -6 to +6). In the previous steps, because the pixel points are stored in a list in order, assuming that the pixel numbers on the A contour line are 1-1000 and the pixel numbers on the B contour line are 1101-2100, then the distance between the pixel point numbered 1 on the A contour line and the pixel point numbered 2100 on the B contour line is the fiber diameter (assuming that the fiber diameter is 50 in this calculation), that is, the head of the A contour line corresponds to the tail of the B contour line, and the tail of the A contour line corresponds to the head of the B contour line; then the distance between the pixel point 1 on the A side contour line and the pixel point 2100 on the B side contour line is the fiber diameter.
[0072] When finding the gradient on the distance matrix, if the calculated distance matrix is Table 1 (partial), then if the minimum value is found according to the gradient, the diagonal line (i.e., the line with a value of 50) represents the diameter of the fiber, that is, the distance between the two contour lines AB. When the distance matrix is converted into a heat map, the minimum value is represented by a line segment perpendicular to the diagonal line, such as the heat map. Figure 4 The position indicated by the black straight line.
[0073] Table 1
[0074]
[0075] At this point, although the pixel points corresponding to the two long side contours of the fiber have been determined, the two short side contours of the fiber have not been determined. Therefore, in this step, the two contour lines A and B are extended outward in the same direction, and the convolution kernel of (3,3) / 3 is used for calculation. If the value is greater than or equal to 3, there are new pixels on the extension line. If it is less than 3, there are no new pixels. Add the coordinate data of the new adjacent pixel points to the edge of the array, and then determine whether the newly added pixel points have reached the edge of the image. If it has reached the edge of the image, connect the two pixel points corresponding to the end of the array with a straight line and terminate the convolution calculation. If it has not reached the edge of the image, continue the calculation. In order to speed up the determination of the range of the short side during calculation, the distance between the newly added pixel points on both sides of AB (expressed by x, y) is calculated once for each pixel point extended. The distance setting value is 20, in pixels. If it is less than 20, directly connect the two points x and y, and add the pixel points on the straight line between the two points x and y to determine the range of the fiber, such as Figure 5 If the newly added pixel does not reach the edge of the image, and the distance between two pairs of pixels (the distance between points x and y) increases for three consecutive times, connect the two pixels with a straight line, and add the pixels on the straight line between points x and y to determine the range of the fiber, as shown in Figure 1. Figure 5 The position shown by the middle straight line D.
[0076] 16) Take the single fiber outline obtained in step 15), convert the white pixels within the single fiber outline to black pixels, and invert the entire image; this step is completed using the bitwise operator bitwise_not in OpenCV.
[0077] 17) The single fiber contour is fitted with the original image in a loop, so as to obtain each single fiber sample image. In this step, the bitwise operator bitwise_and in OpenCV is used to fit the single fiber contour image and the original image.
[0078] In this embodiment, the image segmentation method for extracting single fiber samples from multi-fiber samples also includes step 18): manually identifying the extracted single fiber sample images, and removing incomplete, blurred and other images that do not meet the training requirements.
[0079] In this embodiment, an image processing device for implementing an image segmentation method for extracting a single fiber sample from a multi-fiber sample comprises:
[0080] microscopes, used to magnify the fiber structure in multifiber samples;
[0081] A scanning module, used to obtain a scanned image of the multi-fiber sample under a microscope;
[0082] An image processing module is used to process the multi-fiber sample scan image and extract a boundary list of multi-fiber outline pixel points in the image;
[0083] The distance matrix calculation and processing module is used to calculate and identify the fiber contour and extract the single fiber sample image from the original image.
[0084] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution of the present invention, which should be included in the scope of the claims of the present invention.
Claims
1. An image segmentation method for extracting a single fiber sample from a multi-fiber sample comprises the following steps: 1) Prepare multi-fiber sample images; 2) performing vector processing and binarization processing on the multi-fiber sample image obtained in step 1), with a grayscale level of 256, and then keeping the image output size consistent; 3) performing type identification and classification marking on the multi-fiber sample image obtained in step 2); Features: 4) Converting the image processed in step 3) into a matrix: the pixels in the image correspond to the elements in the matrix one by one, the pixels with a pixel value of 255 are assigned a value of 0 when converted into the matrix, and the pixels with a pixel value of 0 are assigned a value of 1 when converted into the matrix; 5) performing convolution operation on the matrix processed in step 4); 6) Convert the matrix obtained in step 5) into an image: the pixels in the image correspond one-to-one to the elements in the matrix, the elements with a value of 1 in the matrix are assigned a value of 0 when converted to the image, and the elements with a value of 0 in the matrix are assigned a value of 255 when converted to the image; 7) drawing the outline of the fiber in the image obtained in step 6); 8) filling small holes in the image obtained in step 7); 9) calculating the fiber edges in the image obtained in step 8); 10) Convert the image obtained in step 9) into a matrix: the pixels in the image correspond one-to-one to the elements in the matrix, and the pixels with a pixel value of 255 are assigned a value of 0 when converted into the matrix, and the pixels with a pixel value of 0 are assigned a value of 1 when converted into the matrix; 11) storing the non-zero elements in the matrix obtained in step 10) as an edge list in connection order; 12) Traverse the above boundary list, independently calculate the distance matrix between each group of pixels, and delete the matrix element values that are not in the range of 40-110; 13) Calculate the gradient of the distance matrix and delete the matrix element values except the minimum value; 14) Detect the minimum value line perpendicular to the symmetry axis along the symmetry axis of the distance matrix. If the minimum value line on the same line is discontinuous and the discontinuity is within the range of the distance value represented by the minimum value line, assign the discontinuity point to the mean value of the distance constituting the minimum value line; store the processed minimum value line perpendicular to the symmetry axis; 15) Traverse the minimum line. If the length of the minimum line is less than 1 / 2 of the image height pixel value, discard the minimum line; if the length of the minimum line is greater than or equal to 1 / 2 of the image height pixel value, extract the pixel points on the two parallel contour lines of the fiber represented by the minimum line, and store them as lists respectively. Extend the two lists through convolution calculation. When the termination condition is reached, connect the pixel points corresponding to the ends of the two lists with a straight line, and add the coordinate data corresponding to the pixel points on the straight line to the list, so as to obtain a closed single fiber contour composed of a set of edge pixel points; 16) taking the single fiber outline obtained in step 15), converting the white pixels within the single fiber outline to black pixels, and inverting the entire image; 17) The single fiber contour is fitted with the original image in a loop, so as to obtain each single fiber sample image.
2. The image segmentation method for extracting a single fiber sample from a multi-fiber sample according to claim 1, characterized in that: The method also includes step 18): manually identifying the extracted single fiber sample image and removing incomplete and blurred images.
3. The image segmentation method for extracting a single fiber sample from a multi-fiber sample according to claim 1, characterized in that: The step 1) of preparing the multi-fiber sample image further comprises the following steps: a) Take a fiber sample and lay it flat on the test bench. Use tweezers to take equal amounts of fibers from different parts of the fiber sample. Then mix the fibers taken with tweezers and arrange them so that the fibers are basically parallel. b) Cut the fiber segment in the middle of the fiber taken by tweezers, and cut the same fiber only once; c) placing all the fiber segments on a container, dripping an appropriate amount of liquid medium into the container, stirring to evenly distribute the fiber segments in the liquid medium, then taking an appropriate amount of fiber segment samples and placing them on a glass slide, and covering them with a cover glass; d) placing a glass slide on a microscope stage, adjusting the focus so that a clear multi-fiber sample can be seen in the field of view of the microscope, and obtaining a scan image of the multi-fiber sample under the microscope.
4. The image segmentation method for extracting a single fiber sample from a multi-fiber sample according to claim 3, characterized in that: In the step 2), the multi-fiber sample image is scaled to maintain the image output size of 755*552, in pixels, and the length and width are rounded down during scaling; the scaled image is binarized using the Otsu algorithm, with parameters of 160, 255 and cv.THRESH_BINARY.
5. The image segmentation method for extracting a single fiber sample from a multi-fiber sample according to claim 1, characterized in that: The convolution operation on the matrix in step 5) includes: First convolution: The convolution kernel kernel is a (5, 5) all-1 matrix, and the convolution kernel coefficient coef is 0.2; during the calculation process, if the convolution sum is less than kernel.sum()*coef, the matrix element value is 255, if the convolution sum is greater than or equal to kernel.sum()*coef, the matrix element value is 0; Second convolution: This time, the convolution kernel kernel is set to a (3, 3) all-1 matrix, and the convolution kernel coefficient coef is 0.
1. During the calculation process, if the convolution sum is less than kernel.sum()*coef, the matrix element value is 255. If the convolution sum is greater than or equal to kernel.sum()*coef, the matrix element value is 0.
6. The image segmentation method for extracting a single fiber sample from a multi-fiber sample according to claim 1, characterized in that: Drawing the contours of the fibers in the image in step 7) includes: firstly using the findContours method in opencv to draw the contours of the fibers in the multi-fiber sample, with parameters of cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE, and then using the drawContours method in opencv to draw the contours of the fibers, with parameters of contours[4], 0, (0, 255, 0), 3; In the step 8), the floodfill algorithm of opencv is used to fill the small holes in the image, and the parameters are mask, (0, 0), (0, 0, 0), cv.FLOODFILL_FIXED_RANGE, where mask is an all-0 matrix generated by numpy, specifically np.zeros([h+2, w+2], np.uint8), where h, w = image.shape[:2]; In step 9), the Canny algorithm is used to calculate the fiber edges in the image, and its parameters are 100, 200.
7. The image segmentation method for extracting a single fiber sample from a multi-fiber sample according to claim 1, characterized in that: The matrix element value range in the distance matrix in step 12) is 40-110.
8. The image segmentation method for extracting a single fiber sample from a multi-fiber sample according to claim 1, characterized in that: In the step 14), if the minimum line on the same line is discontinuous and the discontinuity is within the range of the distance value (-35, 35) represented by the minimum line, the discontinuity point is assigned the mean value of the distances constituting the minimum line.
9. The image segmentation method for extracting a single fiber sample from a multi-fiber sample according to claim 1, characterized in that: In the step 15), the list is extended by convolution calculation, and the convolution calculation is performed with the convolution kernel (3,3) / 3 and the list. If the convolution value is less than 3, the two pixel points corresponding to the ends of the list are connected by a straight line, and the convolution calculation is terminated; if the convolution value is greater than or equal to 3, there is a new adjacent pixel point, and the coordinate data of the new adjacent pixel point is first added to the edge of the list, and then it is determined whether the newly added pixel point reaches the edge of the image. If it reaches the edge of the image, the two pixel points corresponding to the end of the list are connected by a straight line and the convolution calculation is terminated; if the newly added pixel point does not reach the edge of the image, the distance between the two pixel points corresponding to the end of the list after the new adjacent pixel point is added is calculated. If the distance is less than the set value, the two pixel points are connected by a straight line and the convolution calculation is terminated; if the newly added pixel point does not reach the edge of the image, and the distance between the two pairs of newly added pixels for three consecutive times shows a trend of gradually increasing, the two pixel points are connected by a straight line and the convolution calculation is terminated; otherwise, the convolution calculation is continued.
10. An image processing device for implementing the image segmentation method for extracting a single fiber sample from a multi-fiber sample as claimed in any one of claims 1 to 9, characterized in that: include: microscopes, used to magnify the fiber structure in multifiber samples; A scanning module, used to obtain a scanned image of the multi-fiber sample under a microscope; An image processing module is used to process the multi-fiber sample scan image and extract a boundary list of multi-fiber outline pixel points in the image; The distance matrix calculation and processing module is used to calculate and identify the fiber contour and extract the single fiber sample image from the original image.
Citation Information
Patent Citations
Fabric colored fiber detection system based on image processing
CN112184615A
Computer implemented method to obtain the orientations of fibres inside composite materials using computed tomography scan
WO2015024580A1
Edge detection method using arbitrary angle
WO2019041590A1
