디지털 영상 처리 비나 필터
1248 단어 디지털 이미지 처리 노트
function [f,noise] = mywiener2(g, nhood, noise)
if (nargin<3) noise = [];
end
% Estimate the local mean of f.
localMean = filter2(ones(nhood), g) / prod(nhood);
% Estimate of the local variance of f.
localVar = filter2(ones(nhood), g.^2) / prod(nhood) - localMean.^2;
% Estimate the noise power if necessary.
if (isempty(noise))
noise = mean2(localVar);
end
% Compute result % f = localMean + (max(0, localVar - noise) ./ ...
% max(localVar, noise) .* (g - localMean);
% % Computation is split up to minimize use of memory for temp arrays.
f = g - localMean;
g = localVar - noise;
g = max(g, 0);
f = localMean + ((f ./ max(localVar, noise)) .* g);
RGB = imread('lena.jpg');
I = rgb2gray(RGB);
%I = I(601:1000,1:600);
J = imnoise(I,'gaussian',0,0.005);
J = im2double(J);
K = mywiener2(J,[5 5]);%%[5,5]
figure; imshow(I), title('original image');
figure; subplot(1,2,1), subimage(J), title('noised image');
subplot(1,2,2), subimage(K), title('denoised image');
![ ](https://img-blog.csdn.net/20181023104612421?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQxMjQ0NDM1/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)