Thursday, March 8, 2018

image processing - What is the advantage of weighted median filter over median filter?


I could not find any proof or comparison of weighted median and median filters. Yes the more occurring pixel contributes much but what should be the criteria of choosing weight function. And any explanation of cases where weighted median is strongly recommended to be used.



Median Filter replaces pixel value c with p where p is the median of pixel values in neighborhood of c


In the case of weighted median there are N $\left[ I_1,I_2,..,I_N \right]$ neighbor pixels,for each pixel there is also weight. Weighted median of that neighborhood is $k^{th}$ pixel where $k$ is the minimum integer with $\sum\limits_{i=1}^k w_{i}\geq\frac{1}{2}\sum\limits_{i=1}^N w_{i}$



Answer



In 1D, you should remember that the median $\hat{m}$ minimizes a sum of absolute values ($\ell_1$ norm): $$ \hat{m} = \arg \min \sum_{k=1}^k |x_k-m|.$$ You can find out that the answer (in 1D only) is the center value of the $x_k$ for an odd number of samples, and any value between the two center values for an even number of samples (traditionally their average).


The weighted median, to me, boils down to: $$ \hat{m}_w = \arg \min \sum_{k=1}^k w_i|x_k-m|,$$ just like the weighted mean $\hat{M}$ minimizes ($\ell_2$ norm): $$ \hat{M} = \arg \min \sum_{k=1}^k w_i|x_k-M|^2.$$ In the definition I use, let $x=[1,2,3,2,4]$. The standard median is $2$, uniquely based on the rank. You can then take integer weights, like $w=[1,2,5,2,1]$. They aim at limiting the pure ranking effect of the median, and at introducing some spatialization. A weighted median would consist in duplicating the initial values with respect to the weights and the location: $x_w=[1,2,2,3,3,3,3,3,2,2,4]$ and take the median of the new data: $3$. The definition extends to rational and real weights (perhaps complex).


The advantages of the weighted median in images are mostly two-fold, since you can recover the median with $w_k=1$:



  1. Restore some spatialization absent in the traditional median, which generates "moving edges", by better centering the median around the central pixel of the square window. That is evident from the example above: the median picks $2$, but the weighting answer $3$, as a central edge, would be a better choice,

  2. Allow negative weights, to better mimic not only smoothing filters (positive weights) but also "median-derivative-like" filters.



One of my sources is Nonlinear Image Processing, by Mitra & Sicuranza.


So the weighted median is always "better" as more generic, provided you can find a neat weighting. To recenter, a pyramidal shape (centered at the center pixel of the square) ought to be better than a flat mask. For instance, take a weighting based on Pascal triangle coefficients.


The concept of a true median in $n$ dimensions is more complicated than the above procedure, since there is no "natural ordering" (compatible with some operations) in 2D, and requires optimization.


No comments:

Post a Comment

digital communications - Understanding the Matched Filter

I have a question about matched filtering. Does the matched filter maximise the SNR at the moment of decision only? As far as I understand, ...