function [out_est] = aggreg(patch_est,patch_weight,M,N,R,skip)

img_est = zeros(M+2*R,N+2*R); 
count_est = img_est;

rr = [1:skip:M];

cc = [1:skip:N];

for i=1:length(rr)
    
    for j=1:length(cc)
        
     loc_p = [R+rr(i) , R+cc(j)];  
     
     img_est(loc_p(1)-R : loc_p(1)+R , loc_p(2)-R : loc_p(2)+R) = img_est(loc_p(1)-R : loc_p(1)+R , loc_p(2)-R : loc_p(2)+R) + patch_est(:,:,i,j);

     count_est(loc_p(1)-R : loc_p(1)+R , loc_p(2)-R : loc_p(2)+R) = count_est(loc_p(1)-R : loc_p(1)+R , loc_p(2)-R : loc_p(2)+R) + patch_weight(:,:,i,j);
     
    end
    
end


out_est = img_est./count_est;
out_est = out_est(R+1:end-R,R+1:end-R);