In order to realize automatic and accurate grading of cucumber, the first thing is to make sure the high accuracy and integrity in cucumber shape segmentation. As the core processor of this dissertation, DSP TMS320DM6437 acquired and processed digital image, it solved the common shadowing problem associated with the natural light. Ultimately, the background subtraction was proposed. Compared with the result of above-mentioned image data processing, the error rate of classic background subtraction method was often high. The result of optimization showed that the improved background subtraction method worked well, and it could meet an accurate segmentation of the fruit in comparison with the original methods.