I need to implement a directional weighted median filter in Java to remove random impulse noise. I have no idea how/where to start. The algorithm is as per below:
- Create a 5x5 window
- Consider 4 directions (vertical, horizontal, diagonal left, diagonal right) from the center pixel (5 pixels in each direction)
- Calculate weighted difference and take the minimum value
- Minimum value is compared to a threshold value:
if value > threshold: it is noise pixel
else: it is not noise pixel - Calculate standard deviation of the 5 pixels in each direction
- Giving extra weight to the direction in which the standard deviation is smallest, the weighted median is computed
- The noisy pixel is replaced with this median value
- Move window throughout the image
- Iterate steps 8 to 10 times
Can anybody point me in the right direction how I should go about implementing this? Any examples or implemented codes will be highly appreciated. I am using ImageJ, so any plugin that has implemented this filter (or a variation of it) will be very helpful. Thanks.