function [BSP]=bsp(image,block_size);
%[BSP]=bsp(image,block_size);
%This function forms the block sum pyramids for the Winner Update Algorithm.

%Initialize BSP
[row,col]=size(image);
K=log2(block_size);
%Blocks should be 2^K square
if round(K)~=K
    error('Block size not power of 2')
end 
%BSPs are the sum of a pixel val and its neighbor below, to the right and below & to the right:
BSP=zeros(row,col,K);
BSP(:,:,K+1)=image;
for i=K:-1:1
    BSP(:,:,i)=imfilter(BSP(:,:,i+1),[0 0 0;0 1 1;0 1 1]);
end
