Cotton color detection method based on machine vision
Objective At present,most of the domestic cotton testing instruments are adopted to detect cotton grades,but the specifications of instruments and equipment are expensive and cannot be used in a wider range.At present,fewer methods of using machine vision are adopted to detect the color grade of cotton,and the accuracy is not high.Therefore,in view of the above situation,a cotton color grade detection method based on machine vision was designed.Method An experimental platform was firstly built.The light source was fixed to the aluminum profile frame and sealed.Cotton was collected in real time through a camera connected to a computer.The collected cotton sample image was transmitted to a computer and preprocessed,and the preprocessed image was cropped using Halcon software and divided into subregions.The albedo(Rd)and yellowness(+b)values of each subregion were calculated by the conversion of color space values,and the color value of each subregion was clustered by the K-means algorithm to obtain the color average of the overall image of cotton.Finally,it was compared with the national standard cotton color grade map to determine the final grade of cotton.Four different color grades of cotton were selected for impurity removal and non-impurity treatment,and the color parameters obtained after impurity removal and without impurity removal were calculated by Halcon software.For the same impurity removed cotton,the Rd value and +b value was calculated,and compared with the detection of MCG-1 detection instrument,the detection results were counted,and scatter plotted by using Origin software to observe the linear relationship between the two detection methods.In order to explore the stability of the test results under different durations,cotton was continuously tested in the time periods of 0 h,12 h,24 h,and 36 h in the same environment under the condition that the equipment was not turned off and the lights were not turned off.Finally,in order to explore whether the overall color value of cotton can represent the color grade of the entire cotton sample,two different color grades of white cotton and light yellow dyed cotton were selected for testing,and under the same conditions,the color value of each sub-region of the two cotton was calculated by using software,and the value of each sub-region was placed in the national standard cotton color grade chart for comparison to observe the distribution of the color grade of each sub-region.Results It is found that the Rd value and +b value detected in the cotton after impurity removal were higher than those detected before impurity removal,but the Rd value increased more and the +b value increased less.For the same cotton,the color value of cotton detected by image processing method was compared with the color value obtained by MCG-1 cotton detector,and the two results were highly correlated and linear,indicating that the results detected by the two methods were consistent.Cotton was continuously tested at different lengths of 0-72 h,and it was found that the test results were stable at each duration,and all were in the same area.Compared with the MCG-1 test results,they were all the same grade cotton.The results of the K-means algorithm were compared with the mean detection,and the results of the K-means algorithm were closer to the results obtained by the MCG-1 cotton detection instrument,and the detection accuracy was better than the results obtained by the mean detection.Conclusion Using machine vision methods to inspect cotton color grades improves the simplicity,efficiency,and accuracy of inspection.This technology not only solves the problem of expensive cotton testing instruments,but also solves the problem of fewer methods and insufficient accuracy of using image processing to detect cotton grades,and can replace the instrument used in practical cases.With the continuous development and maturity of machine vision technology,the technology could be made more useful in the field of cotton testing in the future,and in machine vision methods for cotton color detection.It is expected that this method can be used as a basis for image processing to detect cotton grades,and can be further improved and optimized.