Is there an alternative to 5x5 median filter in MATLAB?

9 visualizaciones (últimos 30 días)
Matthew Worker
Matthew Worker el 4 de Oct. de 2021
Respondida: yanqi liu el 11 de Dic. de 2021
I want the same result, but without using medfilt2
x=imread('sadimg.bmp');
y= medfilt2(x,[5 5])

Respuestas (2)

Image Analyst
Image Analyst el 4 de Oct. de 2021
Editada: Image Analyst el 4 de Oct. de 2021

yanqi liu
yanqi liu el 11 de Dic. de 2021
if use self define function,may be use colfilt、nlfilter to get block process,such as
clc;
clear all;
close all;
im = imread('cameraman.tif');
im2 = imnoise(im, 'salt & pepper');
%fun = @(block_struct) median(block_struct(:));
%im3 = nlfilter(im2,[5 5],fun);
fun = @(block_struct) median(block_struct);
im3 = colfilt(im2,[5 5],'sliding',fun);
im4 = medfilt2(im2, [5 5]);
figure;
subplot(2,2,1); imshow(im);
subplot(2,2,2); imshow(im2);
subplot(2,2,3); imshow(im3);
subplot(2,2,4); imshow(im);

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by