I am not sure if my output is correct regarding median filters.
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I was asked to apply a median filter to a salt and pepper image. Upon research, I found that this code works very we. However, I am not sure if it the correct one to go for as I am very unfamiliar with this code. Especially the second line. Is it possible to explain how it works?
0 Commenti
Risposte (1)
DGM
il 1 Dic 2023
Modificato: DGM
il 1 Dic 2023
Line 2 creates an anonymous function that calculates the median of a given numeric array. It's what will process the image content within the moving window.
You can use nlfilter() if you want, but medfilt2() would probably make more sense. Still, that's just a plain median filter, not really a noise removal filter with any sort of discrimination. As the filter size gets larger or the noise density increases, the difference becomes notable.
inpict = imread('circuit.tif');
inpict = imnoise(inpict,'salt & pepper',0.2);
imshow(inpict)
A = medfilt2(inpict,[3 3]); % simple local median without noise discrimination
imshow(A) % it doesn't really get rid of noise due to the small window size
B = medfilt2(inpict,[7 7]); % so try a larger window size
imshow(B) % but that destroys details
C = amedfiltsimple(inpict); % adaptive median noise removal filter
imshow(C) % only filter the locations where there's noise
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!