How can I create a sliding window centered on a current pixel to impose over an impulse noise affected gray-scale image?
5 views (last 30 days)
Show older comments
How can I create a sliding window of size 11x11 centered on a current pixel to impose over a random-valued impulse noise affected image of size 256x256 in MATLAB? I need to impose the window for every pixel starting from position (1,1) to (255,255). Therefore I have created a padded image of size (266,266) having the original noisy image in the middle position. Am I proceeding in the right direction? I want to find the maximum and minimum values within the window for each iteration.
0 Comments
Accepted Answer
Guillaume
on 9 Feb 2016
The normal way of removing impulse noise is to deconvolve the image with the psf of the impulse. There's a function in matlab that can do that for you and also make a guess at the psf: deconvblind. If you want to do the deconvolution manually, you normally take the FFT of the image and of the psf. divide the two and take the inverse FFT of the result.
To find the maximum of the image over a sliding window you could do it with a loop and then, yes, creating the padded image is the way to do it. Or you could use the built-in nlfilter which may be faster than the loop and certainly a lot less code
maxfiltered = nlfilter(img, [11 11], @(b) max(b(:)));
minfiltered = nlfilter(img, [11 11], @(b) min(b(:)));
The downside of nlfilter is that it loops over the image twice to get min and max, whereas with the loop you can do both at once in the same loop.
2 Comments
More Answers (0)
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!