我想我想通了^^。它執行三次卷積插值的加權乘法和求和部分。這是我的Matlab代碼替換imresizemex。雖然慢了將近6秒,但它產生的結果完全相同。
function outimg=reducesize(inimg, weights,indices,dim)
% reduce first dimension
reduce1=zeros(dim(1),size(inimg,2));
weight1=weights{1};
index1=indices{1};
for i=1:size(inimg,2)
for j=1:dim(1)
w11=weight1(j,:);
ind11=index1(j,:);
B=double(inimg(ind11,i));
v=w11.*B';
reduce1(j,i)=sum(v);
end
end
% reduce second dimension
reduce2=zeros(dim(1),dim(2));
weight2=weights{2};
index2=indices{2};
for i=1:dim(1)
for j=1:dim(2)
w22=weight2(j,:);
ind22=index2(j,:);
B=reduce1(i,ind22);
v=w22.*B;
reduce2(i,j)=sum(v);
end
end
outimg=round(reduce2);
這是一個編譯好的內部函數,源代碼很可能存儲在The MathWorks中,祝您好運。 – excaza
@excaza謝謝!我在MathWorks上進行了檢查。有些人有類似的問題,但沒有答案。 :( –
內置函數中有很多「隱藏」代碼。否則,MATLAB是開源的...... :) – Adiel