| Vial is a kind of common container used to pack powdered medicine.In the filling process of vial,it is easy to bump,which leads to cracks,spots and other defects,and affects the quality of medicine in the bottle.At the present stage,the vast majority of domestic manufacturers with filling production line are still using manual inspection method to detect defects.Therefore,it is of great significance to study the surface defects of vials for improving productivity and drug packaging quality.This research focuses on the defect detection and classification of the filling vials in the production line.The image processing algorithm is used to extract and classify the defect features of the surface area of the vials:1.The construction of image acquisition system: the research object of this thesis is the production line filling bottles,the images involved in the research are collected by this chapter.The image acquisition system in this study is composed of closed environment,white background workbench,light source system,high-definition color camera and computer.The light source system of image acquisition is studied and designed.The suitable scenes of different shapes of light sources are compared.The ring light source is selected and the acquisition system is constructed.This thesis introduces the detailed parameters of vials,and analyzes the common defects and image characteristics.2.Image preprocessing and defect extraction: image filtering is the first step of image preprocessing;In order to extract ROI(region of interest)region,edge detection and threshold segmentation are compared.Adaptive threshold segmentation method is used to extract binary image of foreground region from background image,and Freeman coding is used to extract ROI region;The iterative method is used to correct the highlight of the extracted image.The outer rectangle method is used to calculate the deflection angle of the bottle body,and the deflection angle of the bottle body is adjusted according to the affine transformation formula.For the bottle bottom area,an improved three-dimensional point fitting method is proposed to extract the center coordinates and radius of the circle,delimit the defect area of the bottle bottom center,and then extract the defects by using the adaptive threshold segmentation method.3.Feature extraction: the defect area of the image includes bottle body and bottle bottom.In order to accurately divide the defects of bottle body and bottle bottom,it is necessary to select the feature parameters of the extracted defects.An improved multiple structure element is used to perform morphological operation on the defect area to filter the environmental noise and locate the defect location.The mean value of features in gray space and HSV color space and the parameters of contour area,length and hog feature are used as the input of subsequent classifiers.4.Classification experiment of vials: We propose a SVM classifier based on binary tree structure,and then use libsvm tool library to optimize the sub structure of SVM.The average classification accuracy is 94.29%.Finally,the human-computer interface is designed to facilitate the operator to detect defects in batches. |