computing number of connected components for different block sizes.