In this study, an autonomous underwater vehicle (AUV) detection technique was used as the background to investigate the target classification method for underwater visual images. The target classification method is based on the bag-of-words model, with reduced classification accuracy when the edges of underwater objects are blurred, and when there are many noise points. To solve this problem, an improved visual dictionary generation method was proposed based on the bag-of-words model. The proposed method includes a step on decomposing the complete contour of the target before extracting the features. The DCE (discrete contour evolution) algorithm was used to decompose the complete contour into segments of different lengths, and the SC (shape context) method was applied to extract the features of the contour segments. The FCM (Fuzzy C-Means) algorithm was then used to generate a visual dictionary. To address the classification accuracy problem that causes the underwater targets to decrease after adding spatial location information to the bag-of-words model instead of increasing, an improved spatial location information description method was proposed. The contour segments with the nearest-neighbor relationship were represented as visual phrases, constituting the spatial information of the bag-of-words model. Additionally, for the problem of the shape information of contour segments with different shapes, and the relative position information between the contour segments having different contributions to the target classification, a method was developed to balance the contributions of the two using the optimal weight selected from the experiments. The experimental results demonstrated that the proposed method can effectively improve the classification accuracy of underwater target images.