| Apple is a highly nutritious fruit,which is very popular in our daily life.The extensive planting of apple has driven many areas out of poverty and played an important role in China’s agriculture and forestry economy.Although China’s apple production is in the leading position in the world,compared with the advanced post-harvest processing technology of apple abroad,China’s technology is still insufficient,which leads to the fact that the proportion of apple in China in the international market is not up to expectations,and it is difficult to meet people’s demand for high-quality fruits in the domestic market.In order to solve the above problems,this thesis studies the external quality detection and grading method of Red Fuji apple based on machine vision.The main research contents are as follows:(1)Apple image acquisition and preprocessing.In this thesis,four industrial cameras are used to build an image acquisition system,and 1108 apple images are collected.In the process of preprocessing,the RGB and HSI color models of the image are analyzed.On the RGB model,the components of "R-G" and "R-B" are combined to form a new component "Zt",and the median filtering method is used to filter the gray image of the "Zt" component,and then the image is binarized by the OTSU method.Finally,the binarized image is improved by appropriate morphological methods,and RGB colors are filled to complete the image preprocessing.(2)Apple external feature extraction.Apple’s external features include fruit shape,fruit diameter and fruit color.In fruit shape extraction,the roundness method and the aspect ratio method are compared,and the sample tests show that the error of aspect is relatively small.In the extraction of fruit diameter,the methods of minimum circumscribed rectangle and minimum circumscribed circle are studied,and the sample tests show that the error of minimum circumscribed circle method is small and relatively stable.In the fruit color extraction,two thresholds of 335 ~ 360° and 0 ~ 25° of H component in HSI model are used to segment thick red and bright red fruit surfaces,and then the ratio of red area to total area is calculated to obtain fruit color data.(3)Detection of defective apples.In order to solve the problem that apple surface defects are easily affected by fruit surface color and fruit stalk/calyx in the process of defective apple detection,this thesis studies the application of convolutional neural network in defective apple detection.Firstly,the data set is expanded from 1108 images to 4423 images by geometric transformation data enhancement methods such as mirror image,random rotation and movement,and then it is divided into training set and verification set according to the ratio of8:2,and is trained and verified based on Alex Net,VGGNet-16 and Res Net-50 networks.The experimental results show that the detection accuracy of Alex Net,VGGNet-16 and Res Net-50 networks are 93.38%,93.44% and 96.67% respectively,and Res Net-50 network is the best.(4)Network optimization and improvement.The attention mechanism and activation function of Res Net-50 network are optimized,and CA-Res Net-50-L network is proposed in this thesis.Firstly,the activation function in the network is replaced by the Leaky Re LU activation function,and then the CAM channel attention module is inserted after the residual module,with a total of 14 modules,thus completing the optimization of the Res Net-50 network.Finally,through the network experiment verification,the accuracy of CA-Res Net-50-L network reaches98.95%,which is 2.28% higher than that of Res Net-50 network.(5)Apple grading system.A grading system for external quality of Red Fuji apple is developed.Through the design of software and hardware and UI interface of the system,the integration and application of the classification algorithm are completed.Finally,through the test of 300 Red Fuji apples,it is proved that the designed system can measure the external quality data of apples,and display grading information to the UI interface,and the classification accuracy rate reaches 96.33%,which verifies the feasibility of the system and completes the research and application of apple classification algorithm based on machine vision in this thesis. |