平均値フィルターについて
Show older comments
平均値フィルターのコードを作成したのですが 上手く画像が修復されません maskの設定が悪いと思うのですがmaskをどのような値にしたら上手くいくでしょうか
% code
function I_rec = notSoBaselineAnymoreFast(I, mask)
%set not set pixel to zero, just to be sure
I(~mask) = 0;
% calculate inpainting with a 3x3 kernel
souroundedPatchCount3 = imfilter(double(mask),ones(3));
I_rec = imfilter(I,ones(3)) ./ souroundedPatchCount3;
% calculate inpainting with a 5x5 kernel
souroundedPatchCount5 = imfilter(double(mask),ones(5));
I_rec5 = imfilter(I,ones(5)) ./ souroundedPatchCount5;
% remove dev by zero by overwriting it with a overall mean, just in case.
I_rec5(souroundedPatchCount5 <= 0) = mean( I(mask == 1) );
% set in the missing pixel in the smaller aproximation
I_rec(souroundedPatchCount3 <= 0) = I_rec5(souroundedPatchCount3 <= 0);
%%%post processing
I_rec(mask) = I(mask);
h = [0.01, 0.08, 0.01; 0.08, 0.64, 0.08; 0.01, 0.08, 0.01];
I_rec = imfilter(I_rec,h,'symmetric');
%smoothing with box filter
I_rec(mask) = I(mask);
h = [0, 0.125, 0; 0.125, 0.5000, 0.1250; 0, 0.125, 0];
I_rec = imfilter(I_rec,h,'symmetric');
I_rec(mask) = I(mask);
end
---------------------------------------
I=imread('lena_destroyed.png');
mask=7
re=notSoBaselineAnymoreFast(I, mask);
imshow(re)
Answers (0)
Categories
Find more on Image Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!