This paper introduces the algorithms of image processing of ship segments and designs the vision module of spraying robot. Firstly, the image of the target object is collected and gray-level processing is adopted. Then, the filtering and noise reduction operation is carried out. Several common filtering and noise reduction methods are compared to select the appropriate median filtering method in this paper. In addition, in the process of image segmentation, the threshold segmentation and various edge detection operators are expounded, and the advantages and disadvantages of the relevant methods are discussed in detail. Canny edge detection algorithm suitable for segmented spraying for ships is chosen. In feature extraction, hough line transform is selected to detect and extract the linear features of the target workpiece in this paper, and the visual measurement system is simply calibrated to obtain the pixel ratio value which can be used to measure the width and height of the workpiece. The parameters are provided for the path of piecewise spraying.