A microscopic image acquisition and processing system and textile fiber classification method thereof
By extracting the characteristics of textile fibers such as the average 2DGabor bidirectional line characteristics and curvature, and combining the maximum number of information and m-PCA method, the problems of accuracy and speed in textile fiber classification are solved, achieving more efficient fiber identification.
Patent Information
- Application Number
- CN202310927676.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-26
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2043-07-26
AI Technical Summary
The traditional textile fiber classification method has low accuracy and manual detection is time-consuming and labor-intensive. There are redundant features in the existing feature extraction process that affect the classification accuracy and speed.
The average 2DGabor two-direction line features, curvature, fitted curvature and segmented chord length angle change characteristics are adopted, and feature selection is performed by combining the maximum number of information and m-PCA method, and an attention mechanism is introduced to optimize the SVM classification model.
It improves the accuracy and speed of fiber classification, enhances the effectiveness of complex relationship feature data, reduces feature redundancy, and improves the accuracy of fiber identification.
Smart Images

Figure CN116844159B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a microscopic image acquisition and processing system and a textile fiber classification method thereof. Background Art
[0002] In the textile industry, accurate classification of textile crafts is related to important steps such as subsequent packaging, finishing and dyeing. For example, the dyeing and ironing steps of warp knitted textile crafts and weft knitted textile crafts with knitted fabrics are completely different in the dyeing and finishing process. The settings of some important production parameters of blended textile crafts and interwoven textile crafts with woven fabrics are also different. Therefore, in order to ensure the quality of textile crafts, it is necessary to qualitatively classify them when they are made.
[0003] As China's economy shifts from high-speed growth to high-quality development, higher requirements and faster detection speeds are also put forward for fiber detection and identification. The traditional detection method uses manual detection, which consumes a lot of manpower and time. The traditional classification method is to use the gray-level co-occurrence matrix in image recognition technology for qualitative classification, that is, classification through various statistical characteristics of the gray-level co-occurrence matrix. In essence, it is an empirical summary of the statistical indicators of a large amount of image data, and the accuracy of this method is low.
[0004] With the development of computer technology, computer image processing technology has been applied to fiber detection and has achieved certain results; however, the collection of samples will be affected by external factors. The resolution of the sample image, the image preprocessing effect, the selection of eigenvalues, and the classification model will ultimately determine the effect of classification and recognition. In the current research on fiber classification and recognition, in order to reflect the cross-sectional characteristics of the fiber as comprehensively as possible, it is necessary to extract and analyze as many indicators as possible to achieve accurate classification of the fiber.
[0005] However, whether the numerous features of the extracted fibers can play a key role in fiber identification requires further analysis. In the feature extraction process, many features are not independent, and the redundancy of features will affect the accuracy and speed of fiber classification. In order to solve such problems, feature selection is an effective method. Through feature selection, the optimal feature subset is selected from a large number of candidate features, which optimizes the classification and identification process, which is crucial in the identification of samples with complex information. Therefore, a microscopic image acquisition and processing system and a textile fiber classification method are urgently needed. Summary of the invention
[0006] The purpose of the present invention is to overcome the above-mentioned shortcomings and provide a microscopic image acquisition and processing system and a textile fiber classification method thereof. According to the characteristics of fiber images, average 2DGabor bidirectional line features, curvature, fitting curvature and segmented chord length angle change features and minimum circumscribed rectangle density features are proposed; in terms of feature selection, by fusing the maximum information number and m-PCA (Modified-Principal Component Analysis) method, the effectiveness of extracting feature data with complex relationships is enhanced, thereby improving the classification accuracy of the SVM classification model for fibers.
[0007] The object of the present invention is achieved in that:
[0008] A microscopic image acquisition and processing system comprises an image acquisition module, a FIFO buffer, a DDR5 control module, an image data processing module, a display driver module, a read-only memory, an I 2 C interface, CMOS image sensor, high-definition multimedia interface and memory, the CMOS image sensor is connected to the image acquisition module, the image acquisition module is connected to the FIFO buffer, the FIFO buffer is connected to the DDR5 control module, the DDR5 control module is connected to the memory, the FIFO buffer is connected to the image data processing module, the image data processing module is connected to the display driver module, the display driver module is connected to the high-definition multimedia interface, the read-only memory is connected to I 2 C interface.
[0009] Furthermore, the image acquisition module may use a 1 / 2.8-inch SNOY CMOSIMX291 ultra-wide dynamic ultra-low illumination sensor camera and adopt a rolling shutter exposure mode.
[0010] A textile fiber classification method of a microscopic image acquisition and processing system, comprising the following contents:
[0011] S1. Collect images of textile fiber samples using an FPGA-based image acquisition system;
[0012] S2, input the color image of the fiber to be identified, pre-process the image to output a denoised grayscale image, and perform threshold segmentation on the pre-processed image to obtain a binary image;
[0013] S3. Since the fiber image has abundant line features, a 2D Gabor filter is used to extract the line features of the fiber. First, a set of 2D Gabor filters with different directions are defined. After these filters are convolved with the fiber image, the directions with the largest and second largest responses are selected as the line features of the fiber. The lines of the fiber are traversed, and the maximum and second largest values of all the lines are averaged to obtain the average 2D Gabor bidirectional line features.
[0014] S4, taking the fiber profile as a curve object for detection and analysis, and constructing a segmented fitting curve using the variable length angle; dividing the curve into n segments, calculating the segmented chord length and the total chord length, and on this basis constructing three features: curvature, fitting curvature, and segmented chord length angle change;
[0015] S5, calculating the minimum circumscribed rectangle of the fiber and the fiber area, and extracting the density feature of the minimum circumscribed rectangle;
[0016] S6, extracting the feature vectors in steps S3 to S5, and performing dimensionality reduction processing on the feature data by fusing the maximum information number and m-PCA method;
[0017] S7, using the attention mechanism to assign weights to the feature vector after dimensionality reduction; calculating the correlation coefficient between the fiber category and the feature value variable to obtain the Pearson correlation coefficient; inputting the Pearson correlation coefficient into the mapping function, outputting the optimized weight of the original feature value mapping, and finally combining the weight with the original feature vector to output a new feature vector;
[0018] S8. Input the feature vector into the decision tree SVM for training.
[0019] Furthermore, the step S1 also includes the following contents: first, the acquisition system uses I 2 The camera is initialized and configured using the C bus protocol. The camera focuses and captures images. Then, the captured image data is continuously written to the DDR5 SDRAM for storage through the FIFO buffer. The image data is then read out through the FIFO buffer, processed, and finally displayed on the HDMI. The stored images can be uploaded to the host for subsequent processing.
[0020] Furthermore, the step S2 also includes the following contents:
[0021] SS21. Input the color image of the fiber to be identified with a size of 72*72 pixels collected from the camera, grayscale the RGB image, and use the mean filter to denoise the fiber image. The noisy image is g(x, y). Set the center point Z to (x, y). Take a square neighborhood window of size c×c to obtain the denoised image f(x, y); construct the Laplacian operator The filter template is pass After obtaining the sharpened image, the details of the fiber grayscale image are enhanced by Laplacian image sharpening; the above operation is the image preprocessing process;
[0022] SS22. The preprocessed image is processed by Otsu single threshold segmentation method, and the optimal grayscale threshold is selected. The pixels in the grayscale image are classified into fiber target area and background area based on this threshold. The grayscale value of the pixels in the fiber target area is set to 255, and the grayscale value of the pixels in the background area is set to 0, thereby obtaining a binary image.
[0023] Furthermore, the step S3 also includes the following contents:
[0024] SS31, construct a 2D Gabor filter, which is defined as follows:
[0025]
[0026] f is the frequency of the sine function, θ controls the direction of the filter, q represents the phase shift, and r represents the spatial aspect ratio of the Gabor filter shape. Different r values have different scales.
[0027] SS32, set the 2D Gabor filter parameters, take 12 directions as 0, 30°, 60°, 90°, 120°, 180°, 240°, 300°, 360°; set the center frequencies as 1 / 16, 1 / 16.5, 1 / 17, 1 / 17.5, 1 / 18; set the 8 scales as 0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75; the response value m of the center pixel in different directions k The definition of is as follows:
[0028]
[0029] f(x, y) represents the gray value of the current pixel: L k Indicates a line consisting of multiple points pointing upward in the same direction, G k is a 2D Gabor filter with direction k; in the fiber image, the background gray value is low and the fiber target gray value is high, so the direction with a higher response value is taken as the line feature of this pixel; secondly, since the lines inside the fiber image have intersections, the fiber lines extend in different directions along the intersections. On this basis, the line features of the pixels are represented by two directions, and the maximum and second largest response values are selected as the line directions of the pixels;
[0030] SS33, extract 2DGabor bidirectional line features, defined as follows:
[0031]
[0032] v1, v2 are the directions of the maximum response value and the second largest response value, k1, k2 respectively;
[0033] SS34, in step SS32, it is necessary to identify the intersection of the lines inside the fiber to decide whether to delete this direction; the specific operations are as follows: thin the image, extract the skeleton of the target fiber, if it is a line target, it is a white pixel point, if it is a background, it is black; build a 3×3 template to traverse all the lines inside the thinned fiber image, and determine whether the sum of the white pixel values of the pixels [P1, P2, P3, P4, P5, P6, P7, P8] in the 8-neighborhood is greater than 2, if it is greater than 2, it is an intersection, and the intersection position is recorded; scan the connected domain at the intersection, the connected domain is a collection of interconnected white pixels, and the intersection line at this connected domain is a bidirectional line;
[0034] SS35. The maximum and second largest values obtained from all lines are averaged to obtain the average 2D Gabor bidirectional line feature, and the corresponding dimension is 2*8*5=80.
[0035] Furthermore, the step S4 also includes the following contents:
[0036] SS41, perform corrosion and expansion processing on the image. Let the image be the pixel matrix A and the corrosion matrix B be Let B perform corrosion operation on A to obtain C matrix; set the expansion matrix Make D dilate C to get the matrix E. Dilation and erosion are both operations of convolution on the matrix pixel by pixel. Convert the matrix E to an image and scan the image row by row until a continuous area is found. Start from the starting point of the area and mark the boundary pixels along its contour. After processing the contour, continue scanning from the last position until a new area is found, thereby obtaining the fiber contour.
[0037] SS42, use variable length angle to fit the segmented curve; first traverse the curve, record the starting point C and the end point D, and record the curve as CD; set the initial angle θ and the fixed length p; start traversing the curve CD from point C, if CE1 is equal to p, record point E1;
[0038] SS43, search from point E1 to point D, record point F1, and the angle between CE1 and CF1 is greater than θ;
[0039] SS44. Select the point where the curve CE1F1 is farthest from the straight line CF1 and record it as S1.
[0040] SS45. Take S1 as the starting point to traverse the curve S1D, repeat steps SS42 to SS44, and obtain points S2, ..., S n ;
[0041] SS46, the line segments on the curve are CS1, S1S2, ..., S n D;
[0042] SS47, sample the contour line of the unit pixel to obtain the marker point D(x i ,y i )i=0,1,2,…,n, the contour line is divided into n segments, then the total chord length L n , the segment chord lengths k are:
[0043]
[0044] SS48, establish the curvature feature w through the segmented fitting curve. The curvature refers to the ratio of the arc length of the segmented fitting curve to the total chord length. Mark the point D(x i ,y i )i=0,1,2,…,n,let the chord length be F x , the arc length is the total chord length L n , then the curvature w is as follows:
[0045]
[0046] SS49, establish the fitting curvature nq feature by segmented fitting curve, mark point D(x i ,y i ) at the curvature k i The following formula:
[0047]
[0048] The fitting curvature nq is the sum of the absolute values of the curvatures on the fitting line segment, and the formula is as follows:
[0049]
[0050] SS410, establish the segmented chord length angle change τ feature through segmented fitting curve, mark point D(x i ,y i ) is a pixel point on the curve, D i+n and D i-n is the contour line with D i The distance between the points is n pixels, and T is obtained by the following formula i+n and T i-n Vector; by calculating the angle between two adjacent segmented vectors, where N-2n vector angles are calculated for N pixel points on a curve, these N-2n angles are accumulated and averaged to obtain the segmented chord length angle change τ on the entire curve. The formula is as follows:
[0051]
[0052] Furthermore, the step S5 also includes the following contents:
[0053] SS51, firstly, the binary fiber image is corroded and expanded, and then a filling operation is performed to obtain the boundary of the target. The target is rotated within a range of 180°, and the increment of each rotation angle is 5°. The maximum and minimum values of the boundary points of the circumscribed rectangle are recorded each time. After the rotation is completed, the boundary point parameters of the circumscribed rectangle after each rotation are compared, and the four points with the smallest circumscribed rectangle area are taken to obtain the minimum circumscribed rectangle of the fiber target.
[0054] SS52. Calculate the perimeter of the minimum circumscribed rectangle of the target fiber, set it as T, calculate the number of pixels of the fiber target, the number of pixels is the area A of the fiber, and the density U of the minimum circumscribed rectangle is shown in the following formula:
[0055]
[0056] Furthermore, the step S6 also includes the following contents:
[0057] SS61, the extracted variable is x i '(i=1,2,…,m), the number of samples is m, for x i 'Perform standardization operations: The maximum number of messages is calculated using the following formula:
[0058]
[0059] Where B is the number of samples, here we take B = m 0.6 , I(x1, x2) represents the mutual information between x1 and x2;
[0060] Calculate the maximum number of information of all feature variables to get the matrix T, which is shown in the following formula:
[0061]
[0062] SS62, let Ty = λy, and obtain the eigenvalues of T and the corresponding eigenvectors {(λ1, y1), (λ2, y2)…(λ t ,y t ),}, where λ1>λ2>…>λ t > 0, the eigenvectors form t new eigenvectors y = [y1, y2, ...y t ], that is, the principal component (y1, y2, ...y t );
[0063] SS63, composed of principal components y1, y2, ..., y j (j=1, 2, ..., t) and eigenvalue λ to calculate the cumulative contribution rate g j , the calculation formula is as follows:
[0064]
[0065] If g j greater than 85%, select the principal component group [y1, y2, ...y j ] as the new principal component matrix p;
[0066] SS64, in order to enhance the correlation between the selected principal component and the original feature, the complex correlation coefficient is introduced after calculating the cumulative contribution rate; the complex correlation coefficients of the original features from j to tj and the principal component group are calculated respectively, and the complex correlation coefficient is Where B is the parameter vector of the corresponding dimension, the complex correlation coefficient F from j to tj is obtained and the complex correlation coefficient greater than 0.9 is taken, and the number of principal components is k;
[0067] SS65, the final number of principal components is j+k, and the principal component matrix is recorded as p j+k , X = x i ×p j+k , using the principal component matrix p j+k The original sample matrix is reduced in dimension, and the reduced matrix X is a 72×m matrix with a dimension of 72.
[0068] Furthermore, the step S7 also includes the following contents:
[0069] SS71, feature vector X of input image i and the corresponding category Y j , calculate the Person correlation coefficient, the formula is as follows:
[0070]
[0071] Cov stands for covariance, σ is the standard deviation. ij Represents the importance of the feature vector relative to the corresponding category.
[0072] SS72, the eigenvector X is obtained by the following formula i The corresponding eigenvalue weight, where q ij The value range is (0, 1):
[0073]
[0074] SS73, by fusing the original feature vector and the corresponding feature value weight, the feature vector under the attention mechanism can be obtained. The fusion formula is as follows:
[0075] nX ij =(1+q ij )X ij .
[0076] Compared with the prior art, the present invention has the following beneficial effects:
[0077] (1) In view of the abundant lines inside the fiber, a 2D Gabor filter is introduced to extract the average 2D Gabor bidirectional line features of the fiber. Compared with the traditional Gabor filter, the extracted features are more efficient and have higher recognition.
[0078] (2) In order to solve the problem of fitting the fiber contour, a variable length angle segmented fitting curve is introduced. This method can avoid the disadvantages of multiple broken lines and loss of angle information when the curvature is large, and better approximate the curve. On this basis, three eigenvalues are introduced: curvature, segmented fitting curvature, and segmented chord length angle change.
[0079] (3) In terms of fiber morphology, a new fiber feature, namely the minimum circumscribed rectangle density feature, is introduced.
[0080] (4) In view of the possible nonlinear and non-functional relationships between the extracted fiber feature data, the method of integrating the maximum information number and m-PCA is used to reduce the dimension of the feature data, thereby enhancing the effectiveness of extracting feature data with complex relationships. Among them, m-PCA is used to enhance the correlation between the selected principal components and the original features. After calculating the cumulative contribution rate, the complex correlation coefficient is introduced to improve the accuracy of principal component analysis, thereby improving the accuracy of fiber classification.
[0081] (5) The attention mechanism is introduced to obtain feature weights, so that the feature fusion attention mechanism can achieve the effect of feature enhancement. BRIEF DESCRIPTION OF THE DRAWINGS
[0082] Figure 1 It is a schematic diagram of the structure of the acquisition system of the present invention.
[0083] Figure 2 It is a structural schematic diagram of the FPGA-based image acquisition system of the present invention.
[0084] Figure 3 The present invention is a flow chart of the classification method.
[0085] Figure 4 It is a schematic diagram of the variable length angle fitting segmented curve method of the present invention.
[0086] Figure 5 It is the minimum circumscribed rectangle density characteristic map of the present invention.
[0087] in:
[0088] Image acquisition module 1, FIFO buffer 2, DDR5 control module 3, image data processing module 4, display driver module 5, read-only memory 6, I 2 C interface 7, CMOS image sensor 8, high-definition multimedia interface 9, memory 10. DETAILED DESCRIPTION
[0089] In order to better understand the technical solution of the present invention, the following will be described in detail in conjunction with the relevant illustrations. It should be understood that the following specific embodiments are not intended to limit the specific implementation of the technical solution of the present invention, and are only implementations that can be adopted by the technical solution of the present invention. It should be noted that the description of the positional relationship of each component in this article, such as component A being located above component B, is based on the description of the relative positions of the components in the illustration, and is not intended to limit the actual positional relationship of the components.
[0090] Embodiment 1:
[0091] See also Figure 1-Figure 2 , Figure 1 As shown in the figure, a microscopic image acquisition and processing system includes an image acquisition module 1, a FIFO buffer 2, a DDR5 control module 3, an image data processing module 4, a display driver module 5, a read-only memory 6, an I 2 C interface 7, CMOS image sensor 8, high-definition multimedia interface 9 and memory 10, the CMOS image sensor 8 is connected to the image acquisition module 1, the image acquisition module 1 is connected to the FIFO buffer 2, the FIFO buffer 2 is connected to the DDR5 control module 3, the DDR5 control module 3 is connected to the memory 10, the FIFO buffer 2 is connected to the image data processing module 4, the image data processing module 4 is connected to the display driver module 5, the display driver module 5 is connected to the high-definition multimedia interface 9, i.e., HDMI, the read-only memory 6 is connected to I 2 C-Mount 7.
[0092] The image acquisition module 1 can use a 1 / 2.8-inch SNOY CMOSIMX291 ultra-wide dynamic ultra-low illumination sensor camera, adopt a rolling shutter exposure mode, and the camera resolution is 1920*1080. 2 The camera is initialized and configured using the C bus protocol. The camera focuses and captures images. Then, the captured image data is continuously written to the DDR5 SDRAM memory through the FIFO buffer for storage. The image data is then read out through the FIFO buffer, processed, and finally displayed on the HDMI.
[0093] The stored images can be uploaded to the host computer for subsequent processing.
[0094] See also Figure 3-Figure 5 , Figure 3 A method flow chart of the classification method of the present invention is drawn. As shown in the figure, a textile fiber classification method of a microscopic image acquisition and processing system of the present invention includes the following contents:
[0095] S1. Collecting textile fiber sample images using an image acquisition system based on FPGA (field programmable gate array);
[0096] SS11. Using one of the above-mentioned microscopic image acquisition and processing systems, using a light source to illuminate the fiber to be detected, the brightness of the shooting environment can be increased; the acquisition system uses a 1 / 2.8-inch SNOY CMOSIMX291 ultra-wide dynamic ultra-low illumination sensor camera, using a rolling shutter exposure mode, and the camera resolution is 1920*1080;
[0097] SS12, first collect the system through I 2 The camera is initialized and configured using the C bus protocol. The camera focuses and captures images. Then, the captured image data is continuously written to the DDR5 SDRAM for storage through the FIFO buffer. The image data is then read out through the FIFO buffer, processed, and finally displayed on the HDMI. The stored images can be uploaded to the host for subsequent processing.
[0098] S2, input the color image of the fiber to be identified, pre-process the image to output a denoised grayscale image, and then perform threshold segmentation on the pre-processed image to obtain a binary image;
[0099] SS21. Input the color image of the fiber to be identified with a size of 72*72 pixels collected from the camera, grayscale the RGB image, and use the mean filter to denoise the fiber image. The noisy image is g(x, y). Set the center point Z to (x, y). Take a square neighborhood window of size c×c to obtain the denoised image f(x, y); Construct the Laplacian operator ▽ 2 f(x, y), the filter template is pass After obtaining the sharpened image, the details of the fiber grayscale image are enhanced by Laplacian image sharpening; the above operation is the image preprocessing process;
[0100] SS22. The preprocessed image is processed by Otsu single threshold segmentation method, and the optimal grayscale threshold is selected. The pixels in the grayscale image are classified into fiber target area and background area based on this threshold. The grayscale value of the pixels in the fiber target area is set to 255, and the grayscale value of the pixels in the background area is set to 0, thereby obtaining a binary image.
[0101] S3. Since the fiber image has abundant line features, a 2D Gabor filter is used to extract the line features of the fiber. First, a set of 2D Gabor filters with different directions are defined. After these filters are convolved with the fiber image, the directions with the largest and second largest responses are selected as the line features of the fiber. The lines of the fiber are traversed, and the maximum and second largest values of all the lines are averaged to obtain the average 2D Gabor bidirectional line features.
[0102] SS31. Construct a 2D Gabor filter, which is defined as follows:
[0103]
[0104] f is the frequency of the sine function, θ controls the direction of the filter, q represents the phase shift, and r represents the spatial aspect ratio of the Gabor filter shape. Different r values have different scales.
[0105] SS32, set the 2D Gabor filter parameters, take 12 directions as 0, 30°, 60°, 90°, 120°, 180°, 240°, 300°, 360°; set the center frequencies as 1 / 16, 1 / 16.5, 1 / 17, 1 / 17.5, 1 / 18; set the 8 scales as 0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75; the response value m of the center pixel in different directions k The definition of is as follows:
[0106]
[0107] f(x, y) represents the gray value of the current pixel: L k Indicates a line consisting of multiple points pointing upward in the same direction, G k is a 2D Gabor filter with direction k; in the fiber image, the background gray value is low and the fiber target gray value is high, so the direction with a higher response value is taken as the line feature of this pixel; secondly, since the lines inside the fiber image have intersections, the fiber lines extend in different directions along the intersections. On this basis, the line features of the pixels are represented by two directions, and the maximum and second largest response values are selected as the line directions of the pixels;
[0108] SS33, extract 2DGabor bidirectional line features, defined as the following formula (3):
[0109]
[0110] v1, v2 are the directions of the maximum response value and the second largest response value, k1, k2 respectively;
[0111] SS34, in step SS32, it is necessary to identify the intersection of the lines inside the fiber to decide whether to delete this direction; the specific operations are as follows: thin the image, extract the skeleton of the target fiber, if it is a line target, it is a white pixel point, if it is a background, it is black; build a 3×3 template to traverse all the lines inside the thinned fiber image, and determine whether the sum of the white pixel values of the pixels [P1, P2, P3, P4, P5, P6, P7, P8] in the 8-neighborhood is greater than 2, if it is greater than 2, it is an intersection, and the intersection position is recorded; scan the connected domain at the intersection, the connected domain is a collection of interconnected white pixels, and the intersection line at this connected domain is a bidirectional line;
[0112] SS35. The maximum and second largest values obtained from all lines are averaged to obtain the average 2D Gabor bidirectional line feature, and the corresponding dimension is 2*8*5=80.
[0113] S4, taking the fiber profile as a curve object for detection and analysis, and constructing a segmented fitting curve using the variable length angle; dividing the curve into n segments, calculating the segmented chord length and the total chord length, and on this basis constructing three features: curvature, fitting curvature, and segmented chord length angle change;
[0114] SS41, perform corrosion and expansion processing on the image. Let the image be the pixel matrix A and the corrosion matrix B be Let B perform corrosion operation on A to obtain C matrix; set the expansion matrix Make D dilate C to get the matrix E. Dilation and erosion are both operations of convolution on the matrix pixel by pixel. Convert the matrix E to an image and scan the image row by row until a continuous area is found. Start from the starting point of the area and mark the boundary pixels along its contour. After processing the contour, continue scanning from the last position until a new area is found, thereby obtaining the fiber contour.
[0115] SS42, Fitting a Segmented Curve Using a Variable Length Angle; see Figure 4 First, traverse the curve, record the starting point C and the end point D, and record the curve as CD; set the initial angle θ and the fixed length p; start traversing the curve CD from point C, if CE1 is equal to p, record point E1;
[0116] SS43, search from point E1 to point D, record point F1, and the angle between CE1 and CF1 is greater than θ;
[0117] SS44. Select the point where the curve CE1F1 is farthest from the straight line CF1 and record it as S1.
[0118] SS45. Take S1 as the starting point to traverse the curve S1D, repeat steps SS42 to SS44, and obtain points S2, ..., S n ;
[0119] SS46, the line segments on the curve are CS1, S1S2, ..., S n D;
[0120] SS47, sample the contour line of the unit pixel to obtain the marker point D(x i ,y i )i=0,1,2,…,n,the contour line is divided into n segments, then the total chord length L n , the segment chord lengths k are respectively as follows (4):
[0121]
[0122] SS48, establish the curvature feature w through the segmented fitting curve. The curvature refers to the ratio of the arc length of the segmented fitting curve to the total chord length. Mark the point D(x i ,y i )i=0,1,2,…,n, let the chord length be F x , the arc length is the total chord length L n , then the curvature w is the following formula (5):
[0123]
[0124] SS49, establish the fitting curvature nq feature by segmented fitting curve, mark point D(x i ,y i ) at the curvature k i It is the following formula (6):
[0125]
[0126] The fitting curvature nq is the sum of the absolute values of the curvatures on the fitting line segment, and the formula is as follows:
[0127]
[0128] SS410, establish the segmented chord length angle change τ feature through segmented fitting curve, mark point D(x i ,y i ) is a pixel point on the curve, D i+n and D i-n is the contour line with D i The distance between the points is n pixels, and T is obtained from formula (8) i+n and T i-n Vector; by calculating the angle between two adjacent segment vectors, where N-2n vector angles are calculated for N pixel points on a curve, these N-2n angles are accumulated and averaged to obtain the segment chord length angle change τ on the entire curve, as shown in the following formula (8):
[0129]
[0130] S5, calculating the minimum circumscribed rectangle of the fiber and the fiber area, and extracting the density feature of the minimum circumscribed rectangle;
[0131] SS51, firstly, the binary fiber image is corroded and expanded, and then a filling operation is performed to obtain the boundary of the target. The target is rotated within a range of 180°, and the increment of each rotation angle is 5°. The maximum and minimum values of the boundary points of the circumscribed rectangle are recorded each time. After the rotation is completed, the boundary point parameters of the circumscribed rectangle after each rotation are compared, and the four points with the smallest circumscribed rectangle area are taken to obtain the minimum circumscribed rectangle of the fiber target.
[0132] SS52. Calculate the perimeter of the minimum circumscribed rectangle of the target fiber, set it as T, calculate the number of pixels of the fiber target, the number of pixels is the area A of the fiber, and the density U of the minimum circumscribed rectangle is shown in the following formula (9):
[0133]
[0134] S6, extracting the feature vectors in S3 to S5, and performing dimension reduction processing on the feature data by fusing the maximum information number and m-PCA (multilinear principal component analysis) method;
[0135] SS61, the extracted variable is x i '(i=1,2,…,m), the number of samples is m, for x i 'Perform standardization operations: The maximum information number is calculated using the following formula (10):
[0136]
[0137] Where B is the number of samples, here we take B = m 0.6 , I(x1, x2) represents the mutual information between x1 and x2;
[0138] The maximum information number of all feature variables is calculated to obtain the matrix T, which is shown in the following formula (11):
[0139]
[0140] SS62, let Ty = λy, and obtain the eigenvalues of T and the corresponding eigenvectors {(λ1, y1), (λ2, y2)…(λ t ,y t ),}, where λ1>λ2>…>λ t > 0, the eigenvectors form t new eigenvectors y = [y1, y2, ...y t ], that is, the principal component (y1, y2, ...y t );
[0141] SS63, composed of principal components y1, y2, ..., y j (j=1, 2, ..., t) and eigenvalue λ to calculate the cumulative contribution rate g j , the calculation formula is shown in the following formula (12):
[0142]
[0143] If g j greater than 85%, select the principal component group [y1, y2, ...y j ] as the new principal component matrix p;
[0144] SS64, in order to enhance the correlation between the selected principal component and the original feature, the complex correlation coefficient is introduced after calculating the cumulative contribution rate; the complex correlation coefficients of the original features from j to tj and the principal component group are calculated respectively, and the complex correlation coefficient is Where B is the parameter vector of the corresponding dimension, the complex correlation coefficient F from j to tj is obtained and the complex correlation coefficient greater than 0.9 is taken, and the number of principal components is k;
[0145] SS65, the final number of principal components is j+k, and the principal component matrix is recorded as p j+k , X = x i ×p j+k , using the principal component matrix p j+k The original sample matrix is reduced in dimension, and the reduced matrix X is a 72×m matrix with a dimension of 72.
[0146] S7, using the attention mechanism to assign weights to the feature vector after dimension reduction, calculating the correlation coefficient between the fiber category and the feature value variable, and obtaining the Pearson correlation coefficient; inputting the Pearson correlation coefficient into the mapping function, outputting the optimized weight of the original feature value mapping, and finally combining the weight with the original feature vector to output a new feature vector;
[0147] SS71, feature vector X of input image i and the corresponding category Y j , calculate the Person correlation coefficient, the formula is as follows:
[0148]
[0149] Cov stands for covariance, σ is the standard deviation. ij Represents the importance of the feature vector relative to the corresponding category.
[0150] SS72, the eigenvector X is obtained by the following formula (14): i The corresponding eigenvalue weight, where q ijThe value range is (0, 1):
[0151]
[0152] SS73, by fusing the original feature vector and the corresponding feature value weight, the feature vector under the attention mechanism can be obtained. The fusion formula is as follows (15):
[0153] nX ij =(1+q ij )X ij (15).
[0154] S8, input the feature vector into the decision tree SVM for training;
[0155] SS81. Create a fiber data set, divide the fibers into modal cotton, viscose cotton, and linen cotton, and label them with numbers 1, 2, and 3 respectively; select 70% of the 200 fiber images as training sets and 30% as test sets, and input the feature vectors into the decision tree SVM classification model for training; the training process is mainly as follows: first, classify the fiber category with label 1 as the positive class and the others as the negative class, and on this basis, classify the fiber with label 2 as the positive class and the fiber with label 3 as the negative class, thereby realizing the multi-classification function of the fiber; the penalty parameter C of SVM is 1, and considering that the number of samples is greater than the feature dimension, the more stable Gaussian kernel function is used Take 0.05.
[0156] The above are only specific application examples of the present invention and do not constitute any limitation on the protection scope of the present invention. Any technical solution formed by equivalent transformation or equivalent replacement shall fall within the protection scope of the present invention.
Claims
1. A textile fiber classification method using a microscopic image acquisition and processing system, It is characterized in that Includes the following: S1. Collect images of textile fiber samples using an FPGA-based image acquisition system; S2, input the color image of the fiber to be identified, pre-process the image to output a denoised grayscale image, and perform threshold segmentation on the pre-processed image to obtain a binary image; S3. Since the fiber image has abundant line features, a 2D Gabor filter is used to extract the line features of the fiber. First, a set of 2D Gabor filters with different directions are defined. After convolving these filters with the fiber image, the directions with the largest and second largest responses are selected as the line features of the fiber. Traverse the lines of the fiber, average the maximum and second-largest values of all lines, and obtain the average 2D Gabor bidirectional line feature; S4, taking the fiber profile as a curve object for detection and analysis, and constructing a segmented fitting curve using the variable length angle; dividing the curve into n segments, calculating the segmented chord length and the total chord length, and on this basis constructing three features: curvature, fitting curvature, and segmented chord length angle change; S5, calculating the minimum circumscribed rectangle of the fiber and the fiber area, and extracting the density feature of the minimum circumscribed rectangle; S6, extracting the feature vectors in steps S3 to S5, and performing dimensionality reduction processing on the feature data by fusing the maximum information number and m-PCA method; S7, using the attention mechanism to assign weights to the feature vector after dimensionality reduction; calculating the correlation coefficient between the fiber category and the feature value variable to obtain the Pearson correlation coefficient; inputting the Pearson correlation coefficient into the mapping function, outputting the optimized weight of the original feature value mapping, and finally combining the weight with the original feature vector to output a new feature vector; S8. Input the feature vector into the decision tree SVM for training.
2. The textile fiber classification method of the microscopic image acquisition and processing system according to claim 1, Features: The step S1 also includes the following contents: first, the acquisition system passes I 2 The camera is initialized and configured using the C bus protocol. The camera focuses and captures images. Then, the captured image data is continuously written to the DDR5 SDRAM for storage through the FIFO buffer. The image data is then read out through the FIFO buffer, processed, and finally displayed on the HDMI. The stored image is uploaded to the host for subsequent processing.
3. The textile fiber classification method of the microscopic image acquisition and processing system according to claim 1, Features: The step S2 also includes the following contents: SS21. Input the color image of the fiber to be identified with a size of 72*72 pixels collected from the camera, grayscale the RGB image, and use the mean filter to denoise the fiber image. The noisy image is g(x, y). Set the center point Z to (x, y). Take a square neighborhood window of size c×c to obtain the denoised image f(x, y); construct the Laplacian operator The filter template is pass After obtaining the sharpened image, the details of the fiber grayscale image are enhanced by Laplacian image sharpening; the above operation is the image preprocessing process; SS22. The preprocessed image is processed by Otsu single threshold segmentation method, and the optimal grayscale threshold is selected. The pixels in the grayscale image are classified into fiber target area and background area based on this threshold. The grayscale value of the pixels in the fiber target area is set to 255, and the grayscale value of the pixels in the background area is set to 0, thereby obtaining a binary image.
4. The textile fiber classification method of the microscopic image acquisition and processing system according to claim 1, Features: The step S3 also includes the following contents: SS31, construct a 2D Gabor filter, which is defined as follows: f is the frequency of the sine function, θ controls the direction of the filter, q represents the phase shift, and r represents the spatial aspect ratio of the Gabor filter shape. Different r values have different scales. SS32, set the 2D Gabor filter parameters, take 12 directions as 0, 30°, 60°, 90°, 120°, 180°, 240°, 300°, 360°; set the center frequencies as 1 / 16, 1 / 16.5, 1 / 17, 1 / 17.5, 1 / 18; set the 8 scales as 0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75; the response value m of the center pixel in different directions k The definition of is as follows: f(x, y) represents the gray value of the current pixel: L k Indicates a line consisting of multiple points pointing upward in the same direction, G k is a 2D Gabor filter with direction k; in the fiber image, the background gray value is low and the fiber target gray value is high, so the direction with a higher response value is taken as the line feature of this pixel; secondly, since the lines inside the fiber image have intersections, the fiber lines extend in different directions along the intersections. On this basis, the line features of the pixels are represented by two directions, and the maximum and second largest response values are selected as the line directions of the pixels; SS33, extract 2DGabor bidirectional line features, defined as follows: v 1 ,v 2 are the directions k of the maximum response value and the second largest response value respectively 1 ,k 2 ; SS34, in step SS32, it is necessary to identify the intersection of the lines inside the fiber to determine whether to delete this direction; the specific operation is as follows: thin the image, extract the skeleton of the target fiber, if it is a line target, it is a white pixel point, if it is a background, it is black; construct a 3×3 template to traverse all the lines inside the thinned fiber image, and determine the pixel point [P 1 , P 2 , P 3 , P 4 , P 5 , P 6 , P 7 , P 8 ] is greater than 2, if it is greater than 2, it is an intersection, and the intersection position is recorded; scan the connected domain at the intersection, the connected domain is a set of interconnected white pixel points, and the intersection line at this connected domain is a bidirectional line; SS35. The maximum and second largest values obtained from all lines are averaged to obtain the average 2D Gabor bidirectional line feature, and the corresponding dimension is 2*8*5=80.
5. The textile fiber classification method of the microscopic image acquisition and processing system according to claim 1, Features: The step S4 also includes the following contents: SS41, perform corrosion and expansion processing on the image. Let the image be the pixel matrix A and the corrosion matrix B be Let B perform corrosion operation on A to obtain C matrix; set the expansion matrix Make D dilate C to get the matrix E. Dilation and erosion are both operations of convolution on the matrix pixel by pixel. Convert the matrix E to an image and scan the image row by row until a continuous area is found. Start from the starting point of the area and mark the boundary pixels along its contour. After processing the contour, continue scanning from the last position until a new area is found, thereby obtaining the fiber contour. SS42, use variable length angle to fit segmented curves; first traverse the curve, record the starting point C and the end point D, and record the curve as CD; set the initial angle θ and the fixed length p; start traversing the curve CD from point C, if CE 1 is equal to p, then record point E 1 ; SS43, Search Point E 1 To point D, record point F 1 , and CE 1 With CF 1 The angle is greater than θ; SS44, select curve CE 1 F 1 With straight line CF 1 The farthest point is recorded as S 1 ; SS45, S 1 Traverse the curve S as the starting point 1 D, repeat steps SS42 to SS44 to get point S 2 , …, S n ; SS46, the line segments on the curve are CS 1 , S 1 S 2 , …, S n D; SS47, sample the contour line of the unit pixel to obtain the marker point D(x i ,y i )i=0,1,2,…,n,the contour line is divided into n segments, then the total chord length L n , the segment chord lengths k are: SS48, establish the curvature feature w through the segmented fitting curve. The curvature refers to the ratio of the arc length of the segmented fitting curve to the total chord length. Mark the point D(x i ,y i )i=0,1,2,…,n,let the chord length be F x , the arc length is the total chord length L n , then the curvature w is as follows: SS49, establish the fitting curvature nq feature by segmented fitting curve, mark point D(x i ,y i ) at the curvature k i The following formula: The fitting curvature nq is the sum of the absolute values of the curvatures on the fitting line segment, and the formula is as follows: SS410, establish the segmented chord length angle change τ feature through segmented fitting curve, mark point D(x i ,y i ) is a pixel point on the curve, D i+n and D i-n is the contour line with D i The distance between the points is n pixels, and T is obtained by the following formula i+n and T i-n Vector; by calculating the angle between two adjacent segmented vectors, where N-2n vector angles are calculated for N pixel points on a curve, these N-2n angles are accumulated and averaged to obtain the segmented chord length angle change τ on the entire curve. The formula is as follows:
6. The textile fiber classification method of the microscopic image acquisition and processing system according to claim 1, Features: The step S5 also includes the following contents: SS51, firstly, the binary fiber image is corroded and expanded, and then a filling operation is performed to obtain the boundary of the target, and the target is rotated within a range of 180°, with an angle increment of 5° each time, and the maximum and minimum values of the boundary points of the circumscribed rectangle are recorded each time; After the rotation is completed, the boundary point parameters of the circumscribed rectangle after each rotation are compared, and the four points with the smallest circumscribed rectangle area are selected to obtain the minimum circumscribed rectangle of the fiber target; SS52. Calculate the perimeter of the minimum circumscribed rectangle of the target fiber, set it as T, calculate the number of pixels of the fiber target, the number of pixels is the area A of the fiber, and the density U of the minimum circumscribed rectangle is shown in the following formula:
7. The textile fiber classification method of the microscopic image acquisition and processing system according to claim 1, Features: The step S6 also includes the following contents: SS61, the extracted variable is x i '(i=1,2,…,m), the number of samples is m, for x i 'Perform standardization operations: The maximum number of messages is calculated using the following formula: Where B is the number of samples, here we take B = m 0.6 ,I(x 1 , x 2 ) represents x 1 , x 2 The mutual information between Calculate the maximum number of information of all feature variables to get the matrix T, which is shown in the following formula: SS62, let Ty = λy, get the eigenvalue of T and the corresponding eigenvector {(λ 1 ,y 1 ), (λ 2 ,y 2 )…(λ t ,y t ),}, where λ 1 >λ 2 >…>λ t > 0, the eigenvectors form t new eigenvectors y = [y 1 ,y 2 ,…y t ], that is, the principal component (y 1 ,y 2 ,…y t ); SS63, by the principal component y 1 ,y 2 , …, y j (j=1, 2, ..., t) and eigenvalue λ to calculate the cumulative contribution rate g j , the calculation formula is as follows: If g j Greater than 85%, select the principal component group [y 1 ,y 2 ,…y j ] as the new principal component matrix p; SS64, in order to enhance the correlation between the selected principal component and the original feature, the complex correlation coefficient is introduced after calculating the cumulative contribution rate; the complex correlation coefficients of the original features from j to tj and the principal component group are calculated respectively, and the complex correlation coefficient is Where B is the parameter vector of the corresponding dimension, the complex correlation coefficient F from j to tj is obtained and the complex correlation coefficient greater than 0.9 is taken, and the number of principal components is k; SS65, the final number of principal components is j+k, and the principal component matrix is recorded as p j+k , X = x i ×p j+k , using the principal component matrix p j+k The original sample matrix is reduced in dimension, and the reduced matrix X is a 72×m matrix with a dimension of 72.
8. The textile fiber classification method of the microscopic image acquisition and processing system according to claim 1, Features: The step S7 also includes the following contents: SS71, feature vector X of input image i and the corresponding category Y j , calculate the Person correlation coefficient, the formula is as follows: Cov represents covariance, σ is the standard deviation, p ij Indicates the importance of the feature vector relative to the corresponding category; SS72, the eigenvector X is obtained by the following formula i The corresponding eigenvalue weight, where q ij The value range is (0, 1): SS73, by fusing the original feature vector and the corresponding feature value weight, the feature vector under the attention mechanism can be obtained. The fusion formula is as follows: nX ij =(1+q ij )X ij 。
