Abstract:Abstract: Detection of pork backfat thickness in most of the slaughtering houses depends on manual labors using measuring tools. The objective of this research was to investigate the method for detecting backfat thickness based on computer vision and image processing technologies. And the paper proposed an algorithm of image acquisition and automatically measuring backfat thickness which could solve the problems that manual measurement process had low efficiency, human factor influenced the test result and connective tissue was readily measured as backfat region. The images of pig carcass between the 6th and the 7th rib were collected by the machine vision image acquisition system on the slaughter line. The system consisted of an image acquisition module containing CCD (charge-coupled device) to capture the images and then save them in computer, a single-chip microcomputer, a detection switch, the calibration rule and the light source in system that could be regulated by the controller to change intensity, and the image processing algorithm was equipped into the self-developed system embedded in the computer. The distance between the camera lens and the carcass samples was fixed. A black background plate was placed behind the pig carcass in order to adapt to the complexity of the environment. When a half of carcass reached the camera view, the operator pressed the detection switch to acquire images which were automatically stored in the computer for further image processing. First, the image noise was removed by using the bilateral filtering method. And the binary image of the pig carcass to be detected was gained according to the Otsu method which calculated segment threshold automatically based on the image grey value. After filling the tiny holes in the binary images by using morphological transformation, the images still contained multiple connected regions. Then the image contours were extracted from the preprocessed images. Through the experiment, it was found that the backfat region was the largest region in the image contour region. Based on the differences of different contour sizes, the backfat region and edge contour were obtained. Secondly, the edge contours were fitted by the fitting line to yield the standard deviations, which were then used to determine whether the connective tissue existed in the backfat region. If so, the pixels of the backfat region image accumulated along X direction were plotted. The connective tissue was removed using the new detection line determined by the valley point coordinates of pixel curve. In this step, the image was cropped to separate the backfat region from the original image. Finally the backfat thickness could be measured accurately by mapping the line to the backfat region. Experiment showed that the detection accuracy of measuring the backfat thickness was 93.5% when the measurement error was less than 1 mm. The accuracy of the algorithm and the speed were verified with the theoretical analysis and practical test. And through test, the average recognition time of each sample was 0.3 s. The results showed that the algorithm could meet the requirement of the backfat thickness testing and measuring in precision for the practical application. This method is able to be used in online detection of the slaughtering line which is of great significance for the development of the automatic measuring system.