This paper presents a new automatic and effective quarantine system for detecting pest infestation sites in agricultural products, e.g. fruits. This work integrated mechanical design, mechatronics instrumentation, X-ray and charge-coupled device (CCD) image acquisition devices, LabVIEW-based analysis and control software, and image diagnosis algorithms into the automatic X-ray quarantine scanner system. Based on the LabVIEW development platform, a friendly graphical user interface (GUI) was designed for assisting the operations of quarantine scanner system. To enhance the accuracy and efficiency of pest quarantine process, a control scheme for performing start-up procedure of the system, parameter setting and calibration of the X-ray source and line-scan sensor, and automatic inspection for pest were developed. A novel pest infestation detector consisted of image processing algorithms were also proposed to aid the operator in identifying possibly infested fruits. The image processing procedures include contrast enhancement, median filtering, mathematical morphology operators, and adaptive thresholding by statistical z-test for identifying the infested sites of fruit on an X-ray image. Experimental results show that the X-ray quarantine scanner and pest infestation detector are able to locate the infested sites with highly successful rate up to 94% on the 4th day after eggs implanted. Furthermore, both intact and egg-implanted fruits were used to evaluate the sensitivity, specificity, accuracy, and precision of the proposed system. The evaluation results are respectively 96.8%, 98.6%, 97.7%, and 98.7%, which are significantly better than traditional visual inspection.