0
点赞
收藏
分享

微信扫一扫

Lee滤波器---MATLAB

在这里插入图片描述

%% Lee滤波器
clc,clear,close all  % 清理命令区、清理工作区、关闭显示图形
warning off       % 消除警告
feature jit off      % 加速代码运行
[filename ,pathname]=...
    uigetfile({'*.bmp';'*.tif';'*.jpg';},'选择图片'); %选择图片路径
str=[pathname filename]; % 合成路径+文件名
im = imread(str);        % 读图
im = imnoise(im,'gaussian',0,1e-3); % 原图像 + 白噪声

figure,
subplot(121),imshow(im);title('原始图像')
colormap(jet)  % 颜色
shading interp % 消隐
im_ret = Lee( im, 9, 'same', 10, 'symmetric', 1);
im_ret = uint8(im_ret);
subplot(122),imshow(im_ret,[]);title('Lee滤波图像')
colormap(jet)  % 颜色
shading interp % 消隐
function im_ret = Lee( im, w_size, out_size, NL, bound, flag )
%   im:SAR影像
%   w_size:窗口大小,奇数 3 5 7 9%   out_size:输出图像的大小,可以是'same'或者'full'
%   NL:number of Looks,等效视数
%   bound:边缘扩展模式,分为'symmetric''replicate','circular'%   flag:计算时是否包含中心像素,0为不包含,1为包含。 
%
%   bound和flag主要是给im_mean_var用的 :)
% 函数输出:
%   im_ret:滤波结果

if ~isa(im,'double')
    im = double(im)/255;
end
[im_Mean, im_Var] = im_mean_var(im, w_size, out_size, bound, flag); % 求均值和方差
im_Std = sqrt(im_Var);  % 开方
Ci = im_Std ./ im_Mean; % 变差系数
Cu = sqrt(1/NL);        % 噪声变差系数
tmp = 2*log(Cu) - 2.*log(Ci+0.1);
tmp = exp(tmp);
W = 1 - tmp;
im_ret = im .* W + im_Mean .* (1 - W);  % 滤波结果


举报

相关推荐

0 条评论