Question
I have an images sequence representing depth information which I'd like to clean. There are some outliers (values with intensity below 25, for a 0-255 range) which I would like to be filled with an acceptable alternative (an average value localised to that specific area could be a good guess).
Can someone see a simple way to do this? I've tried to use a median filter (filter size of 10) substituting the undesired values with NaN, but it did worsen the situation, which improves instead by substituting them with a general average value.
P.S. Someone has already suggested me to use a fast wavelet reconstruction, but I would not really know where to start...
Implemented solution (so far)
The solution I implemented (before reading about inpaint_nans
suggested by tmpearce) is:
- duplicate the original image;
- filling the invalid pixels with a general average value;
- use a circular disk of ray 10 for blurring it;
- replacing the invalid values in the original image with what I got from point 3.
- run a median filter of size 10.
img2 = img;
img2(img < .005) = mean(img(:));
H = fspecial('disk',10);
img3 = imfilter(img2,H,'symmetric');
img4 = img;
img4(img < .3) = img3(img < .3);
filterSize = 10;
padopt = {'zeros','indexed','symmetric'};
IMG = medfilt2(img4, [1 1]*filterSize, padopt{p});