MATLAB实验三(9)
发布时间:2021-06-05
发布时间:2021-06-05
Matlab实验,图形处理相关,包括灰度线性非线性变换,dct图像压缩,均值中值滤波
[test3_gaus.m]
%test3
clc;close all;clear all;
im = imread('alies.jpg');im = im2double(im);
%加入高斯噪声和高斯噪声
im_gaus = imnoise(im, 'gaussian', 0.1);
%中值滤波(2x2, 4x4, 8x8)
for z = 1:3
%高斯噪声
im_gaus_mid_2x2(:,:,z) = medfilt2(im_gaus(:,:,z), [2, 2]); im_gaus_mid_4x4(:,:,z) = medfilt2(im_gaus(:,:,z), [4, 4]); im_gaus_mid_8x8(:,:,z) = medfilt2(im_gaus(:,:,z), [8, 8]); end
%均值滤波(2x2, 4x4, 8x8)
mask1 = ones(2, 2)/4;
mask2 = ones(4, 4)/16;
mask3 = ones(8, 8)/64;
for z = 1:3
%高斯噪声
im_gaus_avg_2x2(:,:,z) = conv2(im_gaus(:,:,z), mask1); im_gaus_avg_4x4(:,:,z) = conv2(im_gaus(:,:,z), mask2); im_gaus_avg_8x8(:,:,z) = conv2(im_gaus(:,:,z), mask3); end
figure('name', '高斯噪声滤波');
subplot(331);
imshow(im);title('原图');
subplot(333);
imshow(im_gaus);title('高斯噪声');
subplot(334);