% % SingleHypoDisparity.m % % The single hypothesis scheme is where a single integer disparity % value is specified along with the index of the reference image % that should be used for prediction. The target image is predicted % by disparity compensating the specified reference image. % function [R, D, pdfout, predBlock] = ... SingleHypoDisparity(Itarget, Irefs, lambda, ... indices, pdfin, ... rowBlock, colBlock, ... blocksize) R = 0; D = 0; J = inf; i = 0; r = (rowBlock-1)*blocksize + 1; c = (colBlock-1)*blocksize + 1; targetBlock = GetBlock(Itarget, r, c, blocksize); for disparity = indices i = i+1; p_i = pdfin(i)/sum(pdfin); Rcurr = -log2(p_i) + 2; % left refBlock{1} = GetBlock(Irefs{1}, r, c+disparity, blocksize); % right refBlock{2} = GetBlock(Irefs{2}, r, c-disparity, blocksize); % top refBlock{3} = GetBlock(Irefs{3}, r+disparity, c, blocksize); % bottom refBlock{4} = GetBlock(Irefs{4}, r-disparity, c, blocksize); for j=1:4 Dcurr = GetDistortion(refBlock{j}, targetBlock); Jcurr = Dcurr + lambda*Rcurr; if (Jcurr < J) J = Jcurr; R = Rcurr; D = Dcurr; predBlock = refBlock{j}; pdfout = zeros(size(pdfin)); pdfout(i) = 1; end end end