how to keep track of input entries used to compute output for conv2(.)
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!