MATLAB Program own function for image filtering -


i'm looking implement own matlab function can used compute image filtering 3x3 kernel.

it'll like: "out = myfilter(input_image, my_3x3_kernel)" output size identical input image size.

however, i'm not supposed use in-built image filtering functions imfilter(), filter2(). conv2() etc.

i'm new matlab , lost.

i told input filter kernels have fixed size of 5x5 can use zero-padding image? not sure means either little go long way in helping me understand better.

thanks!

simple approach.

generate "image":

n = 50; myimage = rand(n,n); mybiggerimage = zeros(n+2, n+2); mybiggerimage(2:end-1, 2:end-1) = myimage; % padded copy of image mykernel = [1 2 1; 2 4 2; 1 2 1]; % example - 3x3 kernel myfilteredimage = zeros(n,n);  % space result 

now need somehow multiply "the right" elements. boring way this:

for ii = 1 n   jj = 1 n     s = 0;     kk = 1 3       ll = 1 3         s = s + mybiggerimage(ii+kk, jj+ll) * mykernel(kk,ll);       end     end     myfilteredimage(ii,jj) = s;   end end     

now can things "vectorize" this. think figure part out?


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -