Structuring elements of fixed shape and size are used in most conventional mathematical morphology operations, which makes the border of image targets shift, produces new image artifacts and loses small image objects due to the diversity and complexity of the image targets. In this paper, a new construction algorithm for adaptive structuring elements is proposed based on the neighborhood gray difference changing vector field and relative density. The proposed structuring element is able to adaptively change shape according to the gray and edge characteristics of an image. This algorithm involves first incorporating the gray difference changing vector field to smooth the local image region and make the gray level within the image target more uniform and then defining a border degree function based on relative density to determine whether the center pixel of the local image region is a border pixel. The adaptive structuring element is composed of all the strong border pixels found in a local image region. Dilation and erosion operations and other derivative operations are proposed with this new adaptive structuring element based on conventional morphology operation principles. The experimental results show that this proposed algorithm is able to effectively suppress the shifting effect of the image target borders while accurately locating the border of the image target region. Additionally, other effective image information is retained and image distortion is reduced while weakening the image details. INDEX TERMS Mathematical morphology, adaptive structuring element, gray difference changing vector field, relative density.