Disclosure of Invention
One of the purposes of the invention is to provide a portable ginned cotton ginning quality grading detection device, which is portable, small in volume, simple in operation and good in detection effect; another object of the present invention is to provide a method for inspecting cotton ginning quality grade by using machine vision technology and image processing method based on the portable ginning quality grade inspection device of claim 1. The method can effectively judge the quality grade of the cotton rolling mill, has important reference significance for realizing the quality grading instrumentization of the cotton rolling mill, can improve the detection accuracy of the quality of the rolling mill, and reduces the labor intensity.
The technical scheme of the invention is realized as follows:
a portable ginned cotton ginning quality grading detection device, the detection device structure mainly includes: detect box, detection case chamber door, the top of going up in the box and bottom are equipped with CCD camera and square light source respectively, still are equipped with the cotton board of translucent pressure, but pull formula printing opacity drawer, two optical axis ball screw linear guide slip tables, servo motor in the box, the structure of two optical axis ball screw linear guide slip tables contains: the device comprises an optical shaft and a ball screw, wherein the light-transmitting cotton pressing plate is fixedly connected with a box body through a cotton pressing plate connecting piece, a drawable light-transmitting drawer is connected to a double-optical-shaft ball screw linear guide rail sliding table through the optical shaft and the ball screw, the drawable light-transmitting drawer is positioned under the light-transmitting cotton pressing plate, and the drawable light-transmitting drawer is controlled by a servo motor to move up and down, so that the height of the drawable light-transmitting drawer is adjusted, and the pressure between a cotton sample and the light-transmitting cotton pressing plate is adjusted; placing a cotton sample to be detected in the drawable light-transmitting drawer, wherein a group of CCD cameras is over against the light-transmitting cotton pressing plate and is used for collecting the front image of the cotton sample; the other group of CCD cameras are opposite to the drawable light-transmitting drawer and are used for collecting the back images of the cotton samples; the two groups of CCD cameras are connected with a computer;
the computer is used for image processing and image data processing analysis of the collected cotton sample image and establishing a classification discrimination model, so that accurate discrimination of ginned cotton rolling quality is realized.
Preferably, the detection box body is provided with a handle, and the door of the detection box is provided with a sampling port.
Specifically, the method comprises the following steps:
a portable ginned cotton ginning quality grading detection device (hereinafter referred to as device for short):
a portable ginned cotton rolling quality grading detection device mainly comprises: the device comprises a sampling port 1, a detection box door 2, a handle 3, CCD cameras 4 and 14, square light sources 5 and 15, double-optical-axis ball screw linear guide rail sliding tables, optical axes 6 and 8, a ball screw 7, a cotton pressing plate connecting piece 9, a light-transmitting cotton pressing plate 10, a cotton sample 11, a drawable light-transmitting drawer 12, a servo motor 13 and a computer 16;
the position connection relationship is as follows:
a light-transmitting cotton pressing plate 10, a drawable light-transmitting drawer 12, optical axes 6 and 8, a ball screw 7, a cotton pressing plate connecting piece 9 and a cotton sample 11 are arranged in the detection box; the light-transmitting cotton pressing plate 10 is fixed on two side walls of the detection box; the drawable light-transmitting drawer 12 is connected to a double-optical-axis ball screw linear guide rail sliding table through the optical axes 6 and 8 and the ball screw 7, is positioned right below the light-transmitting cotton pressing plate 10, and realizes height adjustment and cotton pressing force adjustment by controlling the vertical movement of the drawer; the double-optical-axis ball screw linear guide rail sliding table is fixed on the rear wall of the detection box; the cotton sample 11 to be tested is placed in a drawable light-transmissive drawer 12.
The CCD cameras 4 and 14 are respectively arranged at the centers of the square light sources 5 and 15; the CCD camera 4 is opposite to the light-transmitting cotton pressing plate 10 and is used for collecting the front image of the cotton sample 11; the CCD camera 14 is opposite to the drawable light-transmitting drawer 12 and is used for collecting the back side image of the cotton sample 11; the two CCD cameras 4 and 14 are connected to a computer 16.
The square light sources 5 and 15 are distributed on the upper wall and the lower wall of the detection box and uniformly irradiate the cotton sample 11 to be detected.
The portable ginned cotton ginning quality grading detection device is characterized in that two CCD cameras 4 and 14 which are symmetrical to each other are adopted to carry out double-sided image acquisition on a cotton sample 11 during image acquisition, so that more characteristic information can be acquired in the detection process, and the judgment accuracy is improved.
The portable ginned cotton ginning quality grading detection device is characterized in that a double-optical-axis ball screw linear guide rail sliding table is selected, cotton pressing action is achieved through up-and-down movement of a ball screw 7, and meanwhile cotton pressing automation is achieved through driving of a servo motor 13.
The portable ginned cotton ginning quality grading detection device is characterized in that a drawable light-transmitting drawer 12 is designed, and the bottom of the drawer is transparent glass so as to realize image acquisition. Meanwhile, in order to avoid external interference in the detection process, the detection box door 2 is closed in the working process, and the sampling is realized by the drawable light-transmitting drawer 12 through the sampling port 1.
Secondly, a portable ginned cotton ginning quality grading detection method (hereinafter referred to as method) mainly completes the following work in the invention:
a. collecting clear lint images;
b: carrying out image preprocessing on the collected lint image;
c: acquiring the variety and the number of the defects on the surface of the cotton layer;
d: acquiring texture characteristics of the surface of the cotton layer;
e: establishing a classification discrimination model according to the acquired varieties and the number of the defects and the texture characteristics;
f: carrying out visual display of the detection result and storing the result;
the method comprises the following specific steps: a detection method based on the portable ginned cotton ginning quality grading detection device mainly comprises the following steps:
step 1: collecting clear lint images:
preparing a plurality of cotton samples with certain quality rolling mill quality grades evaluated as good, medium and poor and numbering in sequence; opening a detection box door of the detection device, sequentially placing the weighed cotton samples on the drawable light-transmitting drawer according to the serial numbers, closing the detection box door, opening two groups of square light sources, then controlling a servo motor to start working, pushing the drawable light-transmitting drawer to move upwards to a proper position, compressing the cotton samples by using a light-transmitting cotton pressing plate, after compressing to an optimal state, controlling two groups of CCD cameras by using a computer to collect front and back images of the cotton samples, and storing the images for subsequent image processing; after the image acquisition is finished, controlling a servo motor to enable the drawable light-transmitting drawer to return to the original position, and sequentially changing the next cotton sample to continue image acquisition;
step 2: carrying out image preprocessing on the collected ginned cotton image:
a. correspondingly cutting the collected lint cotton image, removing the interference caused by light reflection of a light source, and enabling the sizes of the final pictures to be consistent;
b. carrying out image enhancement on the lint image by using a multi-scale homomorphic filtering enhancement algorithm, improving the image quality and increasing the contrast of defects and the lint;
and step 3: acquiring the types and the number of the defects on the surface of the cotton layer:
the defect types are classified into defect types and stiff sheet types according to the difference of defects in the aspects of shapes and colors, wherein the defect types comprise broken seeds, sterile seeds, soft seed skins and fiber-bearing seed scraps, the stiff sheet types are independently used as one type, and the adopted method comprises the following steps:
a. for the defect class, extracting a B channel in an RGB color space by using the image subjected to multi-scale homomorphic filtering enhancement for feature recognition, then performing threshold-based image segmentation processing on the obtained B channel image, and determining an optimal threshold value through an image histogram after ginned cotton enhancement; counting the number of the defects by using a method for marking a connected domain after the division;
b. for the stiff films, extracting a Y channel, a Cb channel and a Cr channel of a YCbCr color space by using an original image, identifying the characteristics of the stiff films by adopting a method of subtracting the Y channel from the Cb channel, carrying out image segmentation on defects of the stiff films by using a threshold segmentation method, carrying out open operation processing on segmented images, eliminating edge burrs, avoiding target misrecognition caused by uneven edges, filling holes in a detection object by using closed operation processing, reducing detection errors caused by cotton fiber shielding in the images, and then counting the number of the stiff films by using a method of marking a communicated region;
and 4, step 4: acquiring texture characteristics of the surface of the cotton layer:
according to the showing mode of the definition, surface smoothness, fluffiness and uniformity of the cotton layer and the fiber entanglement degree characteristic of the cotton layer on the image, extracting the texture characteristics of the surface of the cotton layer by adopting a gray level co-occurrence matrix method in a statistical method, specifically, reading the image, and taking the obtained energy, entropy, inertia moment and mean value and standard deviation of correlation as final texture characteristics by adopting the gray level co-occurrence matrix method;
and 5: establishing a classification discrimination model according to the acquired varieties and the number of the defects and the texture characteristics:
establishing a ginned cotton ginning quality grading discrimination model by using a support vector machine method in a machine learning algorithm; the obtained ginned cotton texture characteristics and the number of the defects are used as input quantity, the ginned cotton rolling quality grade is used as output quantity, and the ginned cotton rolling quality is accurately judged;
step 6: carrying out visual display and storage on the detection result:
and visually displaying the detection result of the ginned cotton ginning quality grading by using a GUI (graphical user interface) designed by computer software and storing the result.
Firstly, preparing a plurality of cotton samples with certain quality rolling quality grades evaluated as good, medium and poor and numbering in sequence. The method comprises the steps of opening a door 2 of the detection box, sequentially placing weighed cotton samples 11 on a drawable light-transmitting drawer 12 according to numbers, closing the door 2 of the detection box, opening square light sources 5 and 15, then controlling a servo motor 13 to start working, pushing the drawable light-transmitting drawer 12 to move upwards to a proper position, compressing the cotton samples 11 by using a light-transmitting cotton pressing plate 10, controlling CCD cameras 4 and 14 to collect front and back images of the cotton samples by using a computer 16 after the cotton samples are compressed to an optimal state, and storing the images. The computer carries out a series of processing on the collected images through image processing software, and then extracts and counts texture characteristics and defect types and numbers on the surface of the cotton layer by using a programmed program. Then, a lint ginning quality grading model is established by a support vector machine method, the lint appearance and shape characteristics and the number of defects are used as input quantity, and the lint ginning quality grade is used as output quantity, so that the lint ginning quality is accurately judged. And finally, visually displaying the predicted result by using a GUI (graphical user interface) designed by matlab and storing the result.
The rolling quality in the invention is defined as: after the seed cotton is processed, the rough appearance of the ginned cotton, the variety and the number of the defects, and the quality of the ginning work are divided into three grades of good, medium and poor. Respectively denoted by P1, P2, P3.
The portable ginned cotton ginning quality grading detection device is mainly used for image acquisition.
The detection method provided by the invention is based on the portable ginned cotton ginning quality grading detection device, and the grade of ginned cotton ginning quality is obtained through the proposed method steps. The basic idea of the method is that (1) the variety and the number of the defects are obtained; (2) texture features of the surface of the lint. The two are combined to judge the rolling quality.
Compared with the prior art, the method has the following different points:
1) the methods of extracting the kinds and the number of the defects are different.
The detection method of the invention is characterized by comprising the following steps of:
a. for the defects (broken seeds, sterile seeds, soft seed skin and seed scraps with fibers), extracting a B channel in an RGB (red, green and blue) color space by using the image subjected to multi-scale homomorphic filtering enhancement for feature recognition, then performing image segmentation processing based on a threshold value on the obtained B channel image, and finally determining the optimal threshold value by observing an image histogram after ginned cotton enhancement and repeatedly trying. And after division, counting the number of the defects by using a method for marking a connected domain. b. And for the stubborn films, extracting a Y channel, a Cb channel and a Cr channel of a YCbCr color space by using an original image, and identifying stubborn film characteristics by adopting a method of subtracting the Y channel from the Cb channel through comparison. The method for determining the optimal threshold value is used for carrying out image segmentation on the stiff sheet defects, opening operation processing is carried out on the segmented images, edge burrs are eliminated, target error identification caused by uneven edges is avoided, the closed operation processing is used for filling the inner cavity of the detected object, detection errors caused by cotton fiber shielding in the images are reduced, and then the number of the stiff sheets is counted by the method for marking the communicated area.
2) The method for judging the quality grade of rolling work is different.
The detection method of the invention establishes a ginned cotton ginning quality grading discrimination model by utilizing a Support Vector Machine (SVM) method in a machine learning algorithm. Then, the obtained appearance morphological characteristics and the number of the defects of the ginned cotton are used as input quantity, the ginned cotton ginning quality grade is used as output quantity, and the ginned cotton ginning quality is accurately judged.
Compared with the prior art, the invention utilizes the machine vision technology and the image processing method to carry out grading inspection on the ginned cotton ginning quality in order to solve the problem that the ginned cotton ginning quality index depends on sensory grading of cotton inspection personnel in the cotton quality inspection process. The method can effectively judge the quality grade of the cotton ginning, has important reference significance for realizing the quality grading instrumentization of the ginned cotton ginning, and can improve the accuracy rate of the ginning quality detection and reduce the labor intensity. The detection device has the advantages of small volume, simple operation and good detection effect.
Detailed Description
The following describes the embodiments of the present invention with reference to the drawings;
example 1:
as shown in figure 1, a portable ginned cotton mill quality grading detection device, the detection object is cotton sample 11, detection device is provided with sample connection 1, detection case chamber door 2, handle 3, CCD camera 4 and 14, square light source 5 and 15, two optical axis ball screw linear guide slip tables, including optical axis 6 and 8, ball screw 7, pressure cotton board connecting piece 9, printing opacity pressure cotton board 10, cotton sample 11, but pull formula printing opacity drawer 12, servo motor 13, computer 16.
A light-transmitting cotton pressing plate 10, a drawable light-transmitting drawer 12, optical axes 6 and 8, a ball screw 7, a cotton pressing plate connecting piece 9 and a cotton sample 11 are arranged in the detection box; the light-transmitting cotton pressing plate 10 is fixed on two side walls of the detection box; the drawable light-transmitting drawer 12 is connected to a double-optical-axis ball screw linear guide rail sliding table through the optical axes 6 and 8 and the ball screw 7, is positioned right below the light-transmitting cotton pressing plate 10, and realizes height adjustment and cotton pressing force adjustment by controlling the vertical movement of the drawer; the double-optical-axis ball screw linear guide rail sliding table is fixed on the rear wall of the detection box; the cotton sample 11 to be tested is placed in a drawable light-transmissive drawer 12.
The CCD cameras 4 and 14 are respectively arranged at the centers of the square light sources 5 and 15; the CCD camera I4 is opposite to the light-transmitting cotton pressing plate 10 and is used for collecting a front image of a cotton sample 11; the CCD camera II 14 is opposite to the drawable light-transmitting drawer 12 and is used for collecting the back side image of the cotton sample 11; the two CCD cameras are connected to a computer 16.
The square light sources 5 and 15 are distributed on the upper wall and the lower wall of the detection box and uniformly irradiate the cotton sample 11 to be detected.
The working principle is as follows:
preparing a plurality of cotton samples with certain quality rolling mill quality grades evaluated as good, medium and poor and numbering in sequence. The method comprises the steps of opening a door 2 of the detection box, sequentially placing weighed cotton samples 11 on a drawable light-transmitting drawer 12 according to numbers, closing the door 2 of the detection box, opening square light sources 5 and 15, then controlling a servo motor 13 to start working, pushing the drawable light-transmitting drawer 12 to move upwards to a proper position, compressing the cotton samples 11 by using a light-transmitting cotton pressing plate 10, after the cotton samples are compressed to an optimal state, controlling CCD cameras 4 and 14 to collect front and back images of the cotton samples by using a computer 16, storing the images and processing subsequent images. And after the image acquisition is finished, controlling the servo motor 13 to enable the drawable light-transmitting drawer 12 to return to the original position, and sequentially changing the next cotton sample to continue the image acquisition.
Example 2:
this embodiment differs from embodiment 1 in that: the detection box body is provided with a handle 3, and the door 2 of the detection box is provided with a sampling port 1.
Example 3:
as shown in fig. 2, a method for detecting a portable ginned cotton ginning quality grading detection device based on the rights comprises the following main working processes:
a. collecting clear lint images;
b: carrying out image preprocessing on the collected lint image;
c: acquiring the variety and the number of the defects on the surface of the cotton layer;
d: acquiring texture characteristics of the surface of the cotton layer;
e: establishing a classification discrimination model according to the acquired varieties and the number of the defects and the texture characteristics;
f: performing visual display of the detection result and storing the result;
more specifically, the detection method of the portable ginned cotton ginning quality grading detection device mainly comprises the following steps:
step 1: collecting clear lint images;
preparing a plurality of cotton samples with certain quality rolling mill quality grades evaluated as good, medium and poor and numbering in sequence. The portable ginned cotton ginning quality grading detection device is used for image acquisition. Opening a detection box door of the detection device, sequentially placing the weighed cotton samples on the drawable light-transmitting drawer according to the serial numbers, closing the detection box door, opening two groups of square light sources, then controlling a servo motor to start working, pushing the drawable light-transmitting drawer to move upwards to a proper position, compressing the cotton samples by using a light-transmitting cotton pressing plate, after compressing to an optimal state, controlling two groups of CCD cameras by using a computer to collect front and back images of the cotton samples, and storing the images for subsequent image processing; after the image acquisition is finished, controlling a servo motor to enable the drawable light-transmitting drawer to return to the original position, and sequentially changing the next cotton sample to continue image acquisition;
step 2: carrying out image preprocessing on the collected lint image;
a. and correspondingly cutting the collected lint cotton image, removing the interference caused by the reflection of a light source and the like, and enabling the sizes of the final pictures to be consistent.
b. And the image enhancement is carried out on the lint image by utilizing a multi-scale homomorphic filtering enhancement algorithm, so that the image quality is improved, and the contrast of defects and the lint is increased.
The MSR calculation formula is:
the number of scale parameters N in the formula (1)
And step 3: acquiring the variety and the number of the defects on the surface of the cotton layer;
the defect types are classified into defect types and stiff sheet types according to the difference of defects in the aspects of shapes and colors, wherein the defect types comprise broken seeds, sterile seeds, soft seed skins and fiber-bearing seed scraps, the stiff sheet types are independently used as one type, and the adopted method comprises the following steps:
a. and for the defect class, extracting a B channel in an RGB color space by using the image subjected to multi-scale homomorphic filtering enhancement for feature recognition, and then performing image segmentation processing based on a threshold value on the obtained B channel image, wherein the optimal threshold value is finally determined by observing an image histogram after ginned cotton enhancement and repeatedly trying. And after division, counting the number of the defects by using a method for marking a connected domain.
b. And for the stubborn films, extracting a Y channel, a Cb channel and a Cr channel of the YCbCr color space by using the original image, and identifying the stubborn film characteristics by adopting a method of subtracting the Y channel from the Cb channel. The method comprises the steps of carrying out image segmentation on the stiff piece defects by using a threshold segmentation method, carrying out opening operation processing on the segmented images, eliminating edge burrs, avoiding target error identification caused by uneven edges, filling cavities in a detection object by using closing operation processing, reducing detection errors caused by cotton fiber shielding in the images, and then counting the number of the stiff pieces by using the method for marking the communicated regions.
And 4, step 4: acquiring texture characteristics of the surface of the cotton layer;
and extracting texture features of the surface of the cotton layer by adopting a gray level co-occurrence matrix method in a statistical method. By reading the image, the obtained energy, entropy, moment of inertia, and mean and standard deviation of correlation are used as final texture features.
The above-mentioned correlation formula for solving texture parameters such as energy, entropy, moment of inertia, correlation, etc. is as follows:
in the above formula, i, j represents the element gray level; dx and Dy represent the amount of positional deviation; d is a generation step length; theta is the direction of generation
And 5: establishing a classification discrimination model according to the acquired varieties, the number and the texture characteristics of the defects;
a classification and discrimination model of the ginned cotton ginning quality is established by utilizing a support vector machine method in a machine learning algorithm, the appearance morphological characteristics and the number of defects of the ginned cotton are used as input quantities, the ginned cotton ginning quality grade is used as an output quantity, and the ginned cotton ginning quality is accurately discriminated.
Step 6: carrying out visual display and storage on the detection result;
and visually displaying the detection result of the ginned cotton ginning quality grading by using a GUI interface designed by MATLAB software and storing the result.