how to keep track of input entries used to compute output for conv2(.)
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am using conv2(.). I needed to keep track of index of input elements which were used to compute a particular output element. I wrote the following piece of code for this purpose. So far it is working fine but it doesnt look like a smart way of doing it. Can anyone suggest some better approach.
%-------------------------------------------------------------------------
INPUT = rand(5,5); [inrow incol] = size(INPUT); INPUTindexmatrix=reshape(1:numel(INPUT),inrow,incol);
Channel = [1 1;1 1]; OUTPUT = conv2(INPUT,Channel,'valid'); [Outrow Outcol] = size(OUTPUT);
OUTPUTindexmatrix=reshape(1:numel(OUTPUT),Outrow,Outcol)
CellArray = cell(length(OUTPUT(:)),1); k=0;
Mask=Channel; Matrix = INPUTindexmatrix
%Sliding window approach
for j=1:size(Matrix,2)-size(Mask,2)+1 for i=1:size(Matrix,1)-size(Mask,1)+1
k=k+1;
CellArray{k,1}=Matrix(i:i+size(Mask,1)-1,j:j+size(Mask,2)-1);
CellArray{k}
end
end
%-------------------------------------------------------------------------
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!