Main Content
Remove Impulse Noise from Image
This example shows you how to remove impulse noise from an image by using a median filter.
Create Noisy Image
Read an image into the MATLAB® workspace.
I = imread("coins.png");
Add salt-and-pepper noise.
J = imnoise(I,"salt & pepper",0.03);
Explore Model
Open the simulink® model. The model reads the image stored in the variable J
from the MATLAB workspace by using an Image From Workspace block.
modelname = "ex_blkmedianfilter.slx";
open_system(modelname);
To remove impulse noise, the model uses a Median Filter block with the default parameters.
The Video Viewer blocks display the noisy image and the median-filtered output image.
Simulate the Model
Run the model. The Video Viewer blocks display the noisy image and the median-filtered output image.
sim(modelname);