2D convolution with same dimensions
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Image Filtering dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!