When mathematic morphological filtering methods are applied on the welding defect extraction of X-ray image, the key is the size of structural elements. An adaptive morphological filtering is proposed in this paper:Firstly the sizeof structural elements is chosen on the basis of the result of watershed transformation on scanning beams which is vertical to the welding image, and the size can be adaptively adjusted according to the size of the welding defect. Then the mathematic morphological opening operator is applied on the image to subtract the result from the original image, and the filtering results are reached finally. This method was applied in the extraction of welding defect edge to obtain satisfactory results.