Label connected components in images