Adaptive Support-weighted Approach for Correspondence Search

论文仿真,代码有问题,求指教!

function [dispMap_AW]=StereoMatchingAW(imL, imR, windowSize, dispMin, dispMax) 
% Assume the image sizes are same between imgL and imgR  
[wL,hL] = size(imL); 
%[wR,hR] = size(imgR); 
win=(windowSize-1)/2; 
%SAD 
detaI=1.5;
detaS=windowSize/2;
T=40;
for(i=1+win:1:wL-win) 
    for(j=1+win:1:hL-win-dispMax) 
        minE = 1000000;        temp=0.0;        OptimalDisp = dispMin; 
        for(dispRange=dispMin:1:dispMax) 
            E=0.0; 
            sumW=0.0;
            for(x=-win:1:win) 
                for(y=-win:1:win) 
                    if (j+y+dispRange <= hL) 
                        w=exp(-(imR(i+x,j+y)-imR(i,j))/detaI-sqrt(x^2+y^2)/detaS);     
                        w2=exp(-(imL(i+x,j+y+dispRange)-imL(i,j+dispRange))/detaI-sqrt(x^2+y^2)/detaS);
                        e=min(abs(imR(i+x,j+y)-imL(i+x,j+y+dispRange)),T);                         
                       E=E+e*w*w2; 
                       sumW=sumW+w*w2;
                    end 
                end 
            end 
            %Finding a best disaparty 
            if (minE > E) 
               minE=E;
                OptimalDisp = dispRange; 
            end 
        end 
        %Final disparity 
        dispMap_AW(i,j) = OptimalDisp; 
    end 
end


你可能感兴趣的:(Adaptive Support-weighted Approach for Correspondence Search)