Bilateral filtering is a simple and non-linear technique to remove the image noise while preserving edges. However, it is difficult to optimize a bilateral filter to obtain desired effect by supervised training. In this paper, we propose a new type of trained bilateral filter, which possesses the essential characteristics of the original bilateral filter and can be optimized offline by Least Mean Square optimization. In applications of JPEG and H.264/MEPG4 AVC deblocking, we compared the proposed filter with the original bilateral filter and other state-of-the-art methods. Experimental results show that the proposed method has a better performance at artifacts reduction and edge preserving.