DSPRelated.com
Forums

help using imfilter.....

Started by narcolepsyfreak May 20, 2003
i want to do an average filtering to a binary image. here's how i do
it :

i = imread('someimage.bmp');
fil = ones(3,3)/9;
i2 = imfilter(i,fil,'replicate');

and then i compare it to a code that i wrote. it essentially
calculates the avg ofa 3x3 neighborhood. goes something like this
(takes looooongggg computation time) :

[m n] = size(i);
i2 = i.*0;
for z = 2:m-1
for y = 2:n-1
crop = [i(z-1,y-1:y+1) i(z,y-1:y+1) i(z+1,y-1:y+1)];
avg = mean(crop);
i2(z,y) = avg;
end
end

the results was different. and quite frankly, the imfilter didnt give
the result that i expect. i would expect the imfilter to blur the
edges but instead, it accentuantes some corners and removes some of
the edges.

am i using the wrong filter ? anybody can help me here ?

thanks.