how to keep track of input entries used to compute output for conv2(.)

조회 수: 1 (최근 30일)
xplore29
xplore29 2013년 5월 29일
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개)

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by