
function HRTmp = reglrTV(HR)

sz = size(HR);
outHR = zeros(sz + 2);

HRTmp = zeros(sz);
outHR(2:sz(1)+1, 2:sz(2)+1) = HR;

for m = 0:1
    for l = 0:1
        if l + m == 1
            outTmp1 = zeros(sz + 2);
            outTmp = sign(HR - outHR(2+m:1+m+sz(1), 2+l:1+l+sz(2)));
            outTmp1(2:sz(1)+1, 2:sz(2)+1) = outTmp;

            HRTmp = HRTmp + outTmp1(2:sz(1)+1, 2:sz(2)+1);
            HRTmp = HRTmp - outTmp1(2-m:1-m+sz(1), 2-l:1-l+sz(2));
        end
    end
end
