A implementation of boxfilter
boxfilter 是均值滤波的一种改进。在下面这篇blog里面有介绍。
http://www.cnblogs.com/easymind223/archive/2012/11/13/2768680.html
这里我使用matlab对其进行实现。但是这里边界问题没有处理好,如果viewer有好的意见欢迎告诉我
% % *********************************************************
% code writer : EOF
% code file : my_boxfilter.m
% code date : 2014.10.21
% e-mail : jasonleaster@gmail.com
%
% Code description :
% Here is my implementation of boxfilter :)
% It work correctly in the region where is not close to
% the end boundary but will meet problem on some where
% close to the image end boundary.
% *********************************************************
function Filted_Img = my_boxfilter(Image)
if size(Image,3) ~= 1
fprintf('ERROR Imput-Image must be ##ONE## channel image\n');
return;
end
Height_Img = size(Image,1);
Width_Img = size(Image,2);
Buffer = zeros(1,Width_Img);
Filted_Img = zeros(Height_Img,Width_Img);
% treat this varible as a constant
SEARCH_WIN_HEIGHT = 10;
SEARCH_WIN_WIDTH = 10;
for row = 1: Height_Img
for col = 1: Width_Img
sum_value = 0;
if (row + SEARCH_WIN_HEIGHT) < Height_Img
for temp = row : (row + SEARCH_WIN_HEIGHT)
sum_value = sum_value + Image(temp,col);
end
else
for temp = row : Height_Img
sum_value = sum_value + Image(temp,col);
end
end
Buffer(col) = sum_value;
end
for col = 1:Width_Img
if (col + SEARCH_WIN_WIDTH) < Width_Img
for temp = col : col + SEARCH_WIN_WIDTH
Filted_Img(row,col) = Filted_Img(row,col) + Buffer(temp);
end
else
for temp = col : Width_Img
Filted_Img(row,col) = Filted_Img(row,col) + Buffer(temp);
end
end
end
end
Filted_Img = Filted_Img./(SEARCH_WIN_HEIGHT * SEARCH_WIN_WIDTH);
end