Bilateral filter [1] depends on two kernels, domain and range. Domain kernel \((c(\xi ,x))\) measures the geometric closeness between two pixels and is meant for denoising homogeneous region. Range kernel \((s(f(\xi ), f(x)))\) measures photometric similarity between two pixels and preserves edges. x is the pixel to be denoised and \(\xi\) is the neighborhood pixel of x. \(K^{-1}(x)\) of Bilateral algorithm is the normalizing term.

$$\begin{aligned} B(x)=K^{-1}(x)\sum _{m=1}^r \sum _{n=1}^s f(\xi ) c(\xi , x) s(f(\xi ), f(x)) \end{aligned}$$
(1)

In the past years, many mathematical improvements for Bilateral filter have been proposed [2,3,4] that aimed to give better edge and texture preservation. The major contribution of the proposed research is that it defines a weight factor for Bilateral filter for analysis of texture and edge.

Traditional Bilateral filter works very well in applications where it is needed to smooth the image and preserve object contour and where we are not concerned with texture and small details of image. Some machine vision applications may be disturbed by small details, but there are applications where every detail (texture, small edge) information of the acquiesced digital image is needed to be preserved along with sharp contour. Bilateral filter will preserve sharp contours, but it may not perform well in texture and small edge regions. This observation motivated in having a thought about the algorithm. As domain kernel deals with smoothing of noise at homogeneous region, this function was kept intact in the proposed algorithm. A modification was done in the area of range kernel, where range kernel’s value depends only on absolute difference between two pixels intensity values. Now these two pixels may be contaminated by noise. So, solely depending on these intensity values may give wrong result. For this reason, concentration was given to improve this area of the algorithm. Range, standard deviation, entropy and image gradient [5] were selected to analyze texture and edges. The modified algorithm for Bilateral filtering is as follows:

$$\begin{aligned} B(x)_{M}= & \, K^{-1}(x)\sum _{m=1}^r \sum _{n=1}^s f(\xi ) c(\xi , x) (s(f(\xi ), f(x)) .(T_\mathrm{f}.k)) \end{aligned}$$
(2)

where

$$\begin{aligned} T_\mathrm{f}=\left( \dfrac{\mathrm{range}}{4}+\dfrac{\mathrm{std}}{4}+\dfrac{\mathrm{entropy}}{4}+\dfrac{\mathrm{gradient}}{4}\right) \end{aligned}$$
(3)

where range stands for range filter. Range filter generates higher value where there is discontinuous region. So, it can be said that it will result in large values wherever there are texture, small edge and sharp edge. Similarly, standard deviation (std) gives large value at discontinuous region. entropy measures information content in image. Entropy with small value indicates homogeneous region and large value indicates discontinuous region. gradient gives large value at discontinuous region. It is observed that estimation obtained using these four measures is much better than using any single measure. We have considered the texture analysis factor (\(T_\mathrm{f}\)) as a weight whose maximum value is 1. As four measures were taken, every measure is considered as one-fourth measure of the whole weight (value = 1). The texture analysis of every pixel was done on a local neighborhood of the pixel (x) to be denoised. A large value of \(T_\mathrm{f}\) signified the presence of texture or edges. At homogeneous intensity region, the value of \(T_\mathrm{f}\) was very small. A constant k was multiplied with this texture analysis factor to give more impact to the regions where texture and edge were realized. To justify the use of constant term in the algorithm, a constant of same value was multiplied to the range kernel of the traditional Bilateral filter. The incorporation of constant term in traditional Bilateral filter did not affect the denoising; rather, it enhanced the denoising.

Now some results of denoising experiments are presented. For this purpose, some benchmark natural images, namely Barbara, Baboon, Boat, Seed [6], one self-captured image (Bear) and digital X-ray images from National Institute for Locomotor Disability medical database, are used. Random noise was added to natural image experiments where noise standard deviation (\(\sigma\)) varied from 10 to 100 at an interval of 10\(\sigma\). For digital X-ray images, Poisson noise was introduced to the images. Denoising was done on these noisy images. For all experiments of this paper, local neighborhood window size is set as \(w=5\). For natural images, the domain kernel (\(\sigma _\mathrm{d}\)) and range kernel (\(\sigma _\mathrm{r}\)) standard deviation values were considered as \(2*(\sigma /10+1)\). For all experiments with X-ray images, \(\sigma _\mathrm{d}=2\) and \(\sigma _\mathrm{r}=2\) were considered.

Fig. 1
figure 1

a Input image (Barbara), b noisy image (\(\sigma =10\)), c bilateral filtered image (PSNR = 24.29 dB), d proposed texture and edge preserved Bilateral filtered image (PSNR = 27.09 dB)

Fig. 2
figure 2

a Input image (Baboon), b noisy image (\(\sigma =\) 10), c bilateral filtered image (PSNR = 22.67 dB), d proposed texture and edge preserved Bilateral filtered image (PSNR = 25.50 dB)

Fig. 3
figure 3

a Input image (Seed), b noisy image (\(\sigma =10\)), c bilateral filtered image (PSNR = 24.34  dB), d proposed texture and edge preserved Bilateral filtered image (PSNR = 26.54 dB)

Fig. 4
figure 4

a Input image (X-ray 1), b noisy image, c bilateral filtered image (PSNR = 31.88 dB), d proposed texture and edge preserved Bilateral filtered image (PSNR = 32.56 dB)

Fig. 5
figure 5

a Input image, b subtracted image shows preservation of texture and edges by proposed filter

At first, some visual results are given for verification. The denoising performance of proposed method worked well than the original Bilateral filter for images which have dense course texture and edges. It was observed that the filter outperformed in peak-signal-to-noise ratio (PSNR) [7] and correlation coefficient (CoC) [8] for this type of images. The experiments were performed on Barbara, Baboon, Boat, seed, bear and X-ray test images where the proposed filter better preserved the textures and small edges than the original Bilateral filter. The visual results are given for observation in Figs. 1, 2, 3 and 4.

Next, an experiment was performed where we show preservation of texture and edges. The resultant of the experiment is obtained by subtraction of Bilateral filtered image from the proposed filter image. The resultant image clearly highlights the portions of preservation. The visual results are given in Fig. 5.

Table 1 Comparison of PSNR (in dB) and CoC using denoised image and original image
Table 2 Comparison of PSNR (in dB) and CoC employing denoised image and original image. Bold value specifies better performance of the filter

After visual verification, the experiment was moved with PSNR (in decibel). For better clarity, the comparison based on PSNR was kept confined with the original Bilateral filter. The test was performed on natural and digital X-ray images. The PSNR result was more dramatic for texture images. Let we take a datum (Figs. 2, 5, Table 1 (data 2)) for explanation. A 2.83 dB improvement is obtained on this image which is of size 512 * 512, and this is perfectly explained in the above sections. Even the difference image (Fig. 5, Baboon) shows those pixels where the estimate from the proposed technique is significantly close to the original image than from the traditional technique. The improvement in PSNR is very significant as large as 2.83 dB. The exact PSNRs are given in Tables 1 and 2.

Next, an experiment was tried with CoC which is a similarity measure. Here, it is a measure of similarity between two images, the original input image and the image obtained after denoising. A comparison of CoCs between the original Bilateral filter and the texture and edge preserved Bilateral filter shows an increment of around 0.05, and this achievement can be marked as a well improvement toward achieving true pixel intensity. The results of CoC experiments are given in Tables 1 and 2.

The paper puts forward the idea that denoising results of Bilateral filter can be improved by analyzing texture and edge of the image. The total dependency on intensity difference for range kernel has been reduced by the weight factor obtained by the proposed algorithm. The experimental results given in this paper reveal the theoretical explanation of the proposed algorithm. The bulk improvement comes from pixels at small edges and textures. Another fact has been revealed from the experiments that the proposed filter is more suited for images that have dense textures and where it is more meant to preserve fine details such as finger prints, hair line fractures and detail information of bone tissues in X-ray images.