What is the advantage of weighted median filter over median filter?
Weighting is a common approach to control the importance per pixel. In other words, one might require or desire different importance for different pixels. Then, the 50% percentile is estimated via taking the weights into account. Instead of treating each pixel equally, the sorting function is tweaked to consider the weights. 

Imagine, we want to process pixel $p$ in image $I$, in the neighborhood $R(p)$. The radius of this local window $R$ is $r$. Number of pixels in such locality is $(2r+1)^2$. For each neighbor $q \in R(p)$, a weight $w_{pq}$ is associated. The typical choice of weighting is the affinity  of $p$ and $q$ in the feature map $\mathbf{f}$, which can be any feature, but in general selected to be intensity, color and etc. So we write

$w_{pq}=g(\mathbf{f}(p), \mathbf{f}(q))$ 

A reasonable choice for function $g$ is Gaussian (common preference for affinity measures): 

$g=exp(-\frac{\lVert \mathbf{f}(p)-\mathbf{f}(q) \rVert}{\sigma^2})$

The weighted median operates as follows:

$p^*=\min{k}$ s.t. $\sum\limits_{q=1}^k w_{pq} \geq \frac{1}{2}\sum\limits_{q=1}^n w_{pq}$

This means that for all pixels before the median point $p^*$, the sum is roughly half of all weights summed together.