multiplying a weight mask with input matrix
1 次查看(过去 30 天)
显示 更早的评论
Hi, i am trying to find a way to calculate sum(w(i,j)*A(m+i,n+j)) where w is a 3x3 weight mask , A is the input matrix,m & n size of A,i & j size of w. i have written a function to do this.
if true
% code
function Y = myfun (m,n)
A=imread('');
c=0;
for i=1:3
for j =1:3
c=c+A(m+i,n+j)*B(i,j);
end
end
Y=c;
end
end
and a loop to store the values in a matrix C .
if true
% code
[x,y]=size(A);
for m=1:x
for n=1:y
C(m,n)=myfun(m,n);
end
end
end
But i am getting an index out of bound error. i have considered padding the input matrix but it will change the parameters being passed. Please help me solve this.
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!