% Author: Bodong Li, College of Information Engineering, Xiangtan University, Xiangtan 411105, China
% Time: Created August 28, 2013
% Revised September 11, 2014
clear all; close all; clc;
set(0, 'DefaultAxesFontSize', 12);
set(0, 'DefaultAxesFontName', 'Arial');
set(0, 'DefaultTextFontSize', 12);
set(0, 'DefaultTextFontName', 'Arial');
set(0, 'DefaultFigurePaperPositionMode', 'auto');
% Input the image
fname = '04.png';
X = double(imread(fname));
sigmaS = 3;
sigmaR = 35.5;
w = 20;
PSNRs = [];
% Add noise
randn('seed',1);
Y = X + w*randn(size(X));
Y = round(max(0,min(Y,255)));
fname = [fname(1:end-4),'_G',int2str(w),'.png'];
imwrite(Y/255,fname);
%%
a = (X-Y).^2;
MSE = mean(a(:));
PSNR = 10*log10(255*255/MSE);
fprintf('Noisy psnr = %0.2f\n', PSNR);
PSNRs = [PSNRs,PSNR];
% Denoise the noisy image using mean-filtering
MN = fn_mean(Y,sigmaS);
imwrite(MN/255,[fname(1:end-4),'_mean_',int2str(4*sigmaS+1),'.png']);
%%
a = (X-MN).^2;
MSE = mean(a(:));
PSNR = 10*log10(255*255/MSE);
fprintf('Mean psnr = %0.2f\n', PSNR);
PSNRs = [PSNRs,PSNR];
% Denoise the noisy image using median-filtering
ME = fn_median(Y,sigmaS);
imwrite(ME/255,[fname(1:end-4),'_median_',int2str(4*sigmaS+1),'.png']);
%%
a = (X-ME).^2;
MSE = mean(a(:));
PSNR = 10*log10(255*255/MSE);
fprintf('Median psnr = %0.2f\n', PSNR);
PSNRs = [PSNRs,PSNR];
% Denoise the noisy image using gaussian-filtering
GS = fn_gaussian(Y,sigmaS);
imwrite(GS/255,[fname(1:end-4),'_gaussian_',int2str(4*sigmaS+1),'.png']);
%%
a = (X-GS).^2;
MSE = mean(a(:));
PSNR = 10*log10(255*255/MSE);
fprintf('Gauss psnr = %0.2f\n', PSNR);
PSNRs = [PSNRs,PSNR];
% Denoise the noisy image using bilateral-filtering
BL = fn_bilateral(Y,sigmaS,sigmaR);
imwrite(BL/255,[fname(1:end-4),'_bilateral_',int2str(4*sigmaS+1),'_',sprintf('%0.1f',sigmaR),'.png']);
%%
a = (X-BL).^2;
MSE = mean(a(:));
PSNR = 10*log10(255*255/MSE);
fprintf('Bilate psnr = %0.2f\n', PSNR);
PSNRs = [PSNRs,PSNR];
figure; imshow(X,[]); title('original');
figure; imshow(Y,[]); title(['noisy psnr = ',num2str(PSNRs(1))]);
figure; imshow(MN,[]); title(['mean psnr = ',num2str(PSNRs(2))]);
figure; imshow(ME,[]); title(['median psnr = ',num2str(PSNRs(3))]);
figure; imshow(GS,[]); title(['gaussian psnr = ',num2str(PSNRs(4))]);
figure; imshow(BL,[]); title(['bilateral psnr = ',num2str(PSNRs(5))]);
没有合适的资源?快使用搜索试试~ 我知道了~
图像处理的常见滤波方法,matlab代码
共26个文件
png:14个
m:10个
ppt:1个
4星 · 超过85%的资源 需积分: 46 200 下载量 101 浏览量
2017-09-17
16:36:29
上传
评论 13
收藏 3.19MB RAR 举报
温馨提示
包含图像处理中常用的几种滤波方法,有matlab代码和ppt讲解,包含均值滤波,中值滤波,高斯滤波,双边滤波,有示例演示。
资源推荐
资源详情
资源评论
收起资源包目录
P02_图像滤波.rar (26个子文件)
P02_图像滤波
z_enhance.m 1KB
04_G20_gaussian_13.png 19KB
fn_median.m 690B
03.png 30KB
fn_mean.m 774B
04_G20_mean_13.png 18KB
ts_mean.m 1KB
02.png 174KB
04_G20_median_13.png 21KB
04.png 41KB
ts_bilateral.m 748B
Thumbs.db 7KB
04_G20_bilateral_13_35.5.png 42KB
z_denoise.m 2KB
05_enhance_mean_17.png 335KB
fn_gaussian.m 1KB
图像滤波.ppt 1.41MB
05_enhance_gaussian_17.png 337KB
fn_bilateral.m 1KB
04_G20.png 55KB
ts_median.m 690B
05_enhance_median_17.png 336KB
ts_gaussian.m 1KB
01.png 148KB
05.png 255KB
05_enhance_bilateral_17_25.5.png 326KB
共 26 条
- 1
资源评论
- SherryWMS2019-04-10为什么我的图像处理完颜色是蓝绿色。。。
- ndcy2020-03-28买完后悔系列...
xddwz
- 粉丝: 3790
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功