Given a 2D binary matrix representing an image, write an algorithm to find the number of connected components (islands).