📄 motionestds.m
字号:
refBlkHor:refBlkHor+mbSize-1), mbSize);
computations = computations + 1;
end
refBlkVer = y + LDSP(3,2); % row/Vert co-ordinate for ref block
refBlkHor = x + LDSP(3,1); % col/Horizontal co-ordinate
if ( refBlkVer < 1 || refBlkVer+mbSize-1 > row ...
|| refBlkHor < 1 || refBlkHor+mbSize-1 > col)
% do nothing, outside image boundary
elseif (refBlkHor < j-p || refBlkHor > j+p || refBlkVer < i-p ...
|| refBlkVer > i+p)
% do nothing, outside search window
else
costs(3) = costFuncMAD(imgP(i:i+mbSize-1,j:j+mbSize-1), ...
imgI(refBlkVer:refBlkVer+mbSize-1, ...
refBlkHor:refBlkHor+mbSize-1), mbSize);
computations = computations + 1;
end
refBlkVer = y + LDSP(6,2); % row/Vert co-ordinate for ref block
refBlkHor = x + LDSP(6,1); % col/Horizontal co-ordinate
if ( refBlkVer < 1 || refBlkVer+mbSize-1 > row ...
|| refBlkHor < 1 || refBlkHor+mbSize-1 > col)
% do nothing, outside image boundary
elseif (refBlkHor < j-p || refBlkHor > j+p || refBlkVer < i-p ...
|| refBlkVer > i+p)
% do nothing, outside search window
else
costs(6) = costFuncMAD(imgP(i:i+mbSize-1,j:j+mbSize-1), ...
imgI(refBlkVer:refBlkVer+mbSize-1, ...
refBlkHor:refBlkHor+mbSize-1), mbSize);
computations = computations + 1;
end
case 7
refBlkVer = y + LDSP(4,2); % row/Vert co-ordinate for ref block
refBlkHor = x + LDSP(4,1); % col/Horizontal co-ordinate
if ( refBlkVer < 1 || refBlkVer+mbSize-1 > row ...
|| refBlkHor < 1 || refBlkHor+mbSize-1 > col)
% do nothing, outside image boundary
elseif (refBlkHor < j-p || refBlkHor > j+p || refBlkVer < i-p ...
|| refBlkVer > i+p)
% do nothing, outside search window
else
costs(4) = costFuncMAD(imgP(i:i+mbSize-1,j:j+mbSize-1), ...
imgI(refBlkVer:refBlkVer+mbSize-1, ...
refBlkHor:refBlkHor+mbSize-1), mbSize);
computations = computations + 1;
end
refBlkVer = y + LDSP(7,2); % row/Vert co-ordinate for ref block
refBlkHor = x + LDSP(7,1); % col/Horizontal co-ordinate
if ( refBlkVer < 1 || refBlkVer+mbSize-1 > row ...
|| refBlkHor < 1 || refBlkHor+mbSize-1 > col)
% do nothing, outside image boundary
elseif (refBlkHor < j-p || refBlkHor > j+p || refBlkVer < i-p ...
|| refBlkVer > i+p)
% do nothing, outside search window
else
costs(7) = costFuncMAD(imgP(i:i+mbSize-1,j:j+mbSize-1), ...
imgI(refBlkVer:refBlkVer+mbSize-1, ...
refBlkHor:refBlkHor+mbSize-1), mbSize);
computations = computations + 1;
end
refBlkVer = y + LDSP(9,2); % row/Vert co-ordinate for ref block
refBlkHor = x + LDSP(9,1); % col/Horizontal co-ordinate
if ( refBlkVer < 1 || refBlkVer+mbSize-1 > row ...
|| refBlkHor < 1 || refBlkHor+mbSize-1 > col)
% do nothing, outside image boundary
elseif (refBlkHor < j-p || refBlkHor > j+p || refBlkVer < i-p ...
|| refBlkVer > i+p)
% do nothing, outside search window
else
costs(9) = costFuncMAD(imgP(i:i+mbSize-1,j:j+mbSize-1), ...
imgI(refBlkVer:refBlkVer+mbSize-1, ...
refBlkHor:refBlkHor+mbSize-1), mbSize);
computations = computations + 1;
end
case 8
refBlkVer = y + LDSP(6,2); % row/Vert co-ordinate for ref block
refBlkHor = x + LDSP(6,1); % col/Horizontal co-ordinate
if ( refBlkVer < 1 || refBlkVer+mbSize-1 > row ...
|| refBlkHor < 1 || refBlkHor+mbSize-1 > col)
% do nothing, outside image boundary
elseif (refBlkHor < j-p || refBlkHor > j+p || refBlkVer < i-p ...
|| refBlkVer > i+p)
% do nothing, outside search window
else
costs(6) = costFuncMAD(imgP(i:i+mbSize-1,j:j+mbSize-1), ...
imgI(refBlkVer:refBlkVer+mbSize-1, ...
refBlkHor:refBlkHor+mbSize-1), mbSize);
computations = computations + 1;
end
refBlkVer = y + LDSP(8,2); % row/Vert co-ordinate for ref block
refBlkHor = x + LDSP(8,1); % col/Horizontal co-ordinate
if ( refBlkVer < 1 || refBlkVer+mbSize-1 > row ...
|| refBlkHor < 1 || refBlkHor+mbSize-1 > col)
% do nothing, outside image boundary
elseif (refBlkHor < j-p || refBlkHor > j+p || refBlkVer < i-p ...
|| refBlkVer > i+p)
% do nothing, outside search window
else
costs(8) = costFuncMAD(imgP(i:i+mbSize-1,j:j+mbSize-1), ...
imgI(refBlkVer:refBlkVer+mbSize-1, ...
refBlkHor:refBlkHor+mbSize-1), mbSize);
computations = computations + 1;
end
refBlkVer = y + LDSP(9,2); % row/Vert co-ordinate for ref block
refBlkHor = x + LDSP(9,1); % col/Horizontal co-ordinate
if ( refBlkVer < 1 || refBlkVer+mbSize-1 > row ...
|| refBlkHor < 1 || refBlkHor+mbSize-1 > col)
% do nothing, outside image boundary
elseif (refBlkHor < j-p || refBlkHor > j+p || refBlkVer < i-p ...
|| refBlkVer > i+p)
% do nothing, outside search window
else
costs(9) = costFuncMAD(imgP(i:i+mbSize-1,j:j+mbSize-1), ...
imgI(refBlkVer:refBlkVer+mbSize-1, ...
refBlkHor:refBlkHor+mbSize-1), mbSize);
computations = computations + 1;
end
otherwise
end
end
[cost, point] = min(costs);
if (point == 5)
SDSPFlag = 1;
else
SDSPFlag = 0;
if ( abs(LDSP(point,1)) == abs(LDSP(point,2)) )
cornerFlag = 0;
else
cornerFlag = 1;
end
xLast = x;
yLast = y;
x = x + LDSP(point, 1);
y = y + LDSP(point, 2);
costs = ones(1,9) * 65537;
costs(5) = cost;
end
end % while loop ends here
% we now enter the SDSP calculation domain
costs = ones(1,5) * 65537;
costs(3) = cost;
for k = 1:5
refBlkVer = y + SDSP(k,2); % row/Vert co-ordinate for ref block
refBlkHor = x + SDSP(k,1); % col/Horizontal co-ordinate
if ( refBlkVer < 1 || refBlkVer+mbSize-1 > row ...
|| refBlkHor < 1 || refBlkHor+mbSize-1 > col)
continue; % do nothing, outside image boundary
elseif (refBlkHor < j-p || refBlkHor > j+p || refBlkVer < i-p ...
|| refBlkVer > i+p)
continue; % do nothing, outside search window
end
if (k == 3)
continue
end
costs(k) = costFuncMAD(imgP(i:i+mbSize-1,j:j+mbSize-1), ...
imgI(refBlkVer:refBlkVer+mbSize-1, ...
refBlkHor:refBlkHor+mbSize-1), mbSize);
computations = computations + 1;
end
[cost, point] = min(costs);
x = x + SDSP(point, 1);
y = y + SDSP(point, 2);
vectors(1,mbCount) = y - i; % row co-ordinate for the vector
vectors(2,mbCount) = x - j; % col co-ordinate for the vector
mbCount = mbCount + 1;
costs = ones(1,9) * 65537;
end
end
motionVect = vectors;
DScomputations = computations/(mbCount - 1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -