function deltapsReals = estMeansByReg(frames, blockx, blocky, tsel, b, sigma, penalty, firstNC)
% Created by Yuandong Tian, Oct. 5, 2009
% Email: yuandong@andrew.cmu.edu
% partition the image, and estimate deltaps on every patch

deltapsReals = zeros(firstNC, length(tsel), length(blockx) - 1, length(blocky) - 1);
for i = 1:(length(blockx) - 1)
    xsel_d = blockx(i):(blockx(i+1)-1);
    for j = 1:(length(blocky) - 1)
        ysel_d = blocky(j):(blocky(j+1)-1);
        
        fprintf(1, 'Deal with image block (%d/%d) * (%d/%d) \n', i, length(blockx), j, length(blocky));
        
        [deltapsReals(:, :, i, j)] = estMeanByReg(frames(ysel_d, xsel_d, tsel), b, sigma, penalty, firstNC);
    end;
end;