Index information for conv2(.,.)
Afficher commentaires plus anciens
I have an image X (dimension N1xN2) and a filter Y(dimension 3x5). I can use matlab command conv2(X,Y) to get the filtered image Z. Now I want to get another matrix Z_Index of dimension (N1N2 x 15). The kth row of Z_index(k,:) should contain linear index information of those x's that contributed in kth element of Z. How can I get such a matrix?
Réponse acceptée
Plus de réponses (1)
Andrei Bobrov
le 27 Oct 2016
Modifié(e) : Andrei Bobrov
le 27 Oct 2016
Without Image Processing ...
m = 3;
n = 5;
A = reshape(1:numel(X),size(X));
[k,l] = size(A);
s = floor([m,n]/2)
B = zeros(size(A)+s*2);
B(s(1)+1:end-s(1),s(2)+1:end-s(2)) = A;
C = reshape(1:numel(B),size(B))
D = C(1:end-m+1,1:end-n+1);
[x,y] = size(C);
M = bsxfun(@plus,(0:m-1)',(0:n-1)*x);
out = B(bsxfun(@plus,D(:),M(:)'));
with Image Processing
out = im2col(padarray(reshape(1:numel(X),size(X)),floor([m,n]/2),0),[m,n])';
Catégories
En savoir plus sur Signal Operations 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!