MATLAB实验三(8)
发布时间:2021-06-05
发布时间:2021-06-05
Matlab实验,图形处理相关,包括灰度线性非线性变换,dct图像压缩,均值中值滤波
im_salt_mid_8x8(:,:,z) = medfilt2(im_salt(:,:,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_salt_avg_2x2(:,:,z) = conv2(im_salt(:,:,z), mask1); im_salt_avg_4x4(:,:,z) = conv2(im_salt(:,:,z), mask2); im_salt_avg_8x8(:,:,z) = conv2(im_salt(:,:,z), mask3); end
figure('name', '椒盐噪声滤波');
subplot(331);
imshow(im);title('原图');
subplot(333);
imshow(im_salt);title('椒盐噪声');
subplot(334);
imshow(im_salt_mid_2x2);title('2x2中值滤波椒盐噪声'); subplot(335);
imshow(im_salt_mid_4x4);title('4x4中值滤波椒盐噪声'); subplot(336);
imshow(im_salt_mid_8x8);title('8x8中值滤波椒盐噪声'); subplot(337);
imshow(im_salt_avg_2x2);title('2x2均值滤波椒盐噪声'); subplot(338);
imshow(im_salt_avg_4x4);title('4x4均值滤波椒盐噪声'); subplot(339);
imshow(im_salt_avg_8x8);title('8x8均值滤波椒盐噪声');