2D convolution with same dimensions
显示 更早的评论
I have the below code, it does 2D convolution but with full dimension, [img+filter-1 img+filter-1] and i want the result of convolution to be [img img]. I dont want to use resize or rescale, i have to make the mse of my function and conv2(img,filter,'same') to be zero.
[m,n] = size(a);
[m1,n1] = size(b);
mn = [m,n] + 2*([m1,n1]-1);
a0 = zeros(mn);
a0(m1:(end-m1+1),n1:(end-n1+1)) = a;
b1 = rot90(b,2);
b2 = b1(:);
out = zeros(m1+m-1,n+n1-1);
for ii = 1:mn(1)-m1+1
for jj = 1:mn(2)-n1+1
x = a0(ii:ii+m1-1,jj:jj+n1-1);
out(ii,jj) = x(:)'*b2;
end
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Image Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!