Bilateral filtering is a technique to smooth images while preserving edges; it employs both geometric closeness and intensity similarity of neighbouring pixels. When intensity similarity of neighbouring pixels is very high, however, bilateral filtering weakens into Gaussian filtering. The performance does not improve significantly while the computation is still expensive. Many existing accelerated algorithms, however, ignored this basic fact. In this study, a hybrid bilateral filtering algorithm based on edge detection is proposed. By making use of edge detection, the proposed algorithm combines bilateral filtering and Gaussian filtering and its degree can be controlled by a threshold. Experimental results show that the proposed algorithm is able to reduce the computation efficiently and achieve better performance. What is more, the proposed algorithm shows potential to speed up existing accelerated bilateral filtering algorithms.