amedfilt2image.m
来自「This file contains the material presente」· M 代码 · 共 37 行
M
37 行
%% Image Processing (Adaptive Median vs Median Filters)
%% Read Input Image and display
im = imread('soccerimg.tif');
figure;
subplot(221);
imagesc(im); colormap(gray(256)); axis image
title('Original Image')
%% Add Noise
% We need to corrupt our test image with noise to test the performance of
% the filters
im_noise = single(imnoise(im,'salt & pepper',.2))./256; %imnoise(im,'speckle'); %imnoise(im,'gaussian',0,0.005);
F = fimath(...
'RoundMode', 'Nearest',...
'OverflowMode', 'wrap',...
'ProductMode', 'KeepLSB', 'ProductWordLength', 16,...
'SumMode', 'KeepLSB', 'SumWordLength', 16,...
'CastBeforeSum', true);
im_fixpt = fi(im_noise,0,8,8,F);
%% Filter Noise
% We use a median filter of smax size and an adaptive median filter with
% the same maximum window size.
subplot(223)
imagesc(im_noise); colormap(gray(256)); axis image
title('Noisy Image');
subplot(222)
imagesc(mymedfilt2(im_noise)); colormap(gray(256)); axis image
title('Median Filtered Image');
subplot(224)
imagesc(amedfilt2(im_noise)); colormap(gray(256)); axis image
title('Adaptive Median Filtered Image');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?