I tested it just now (5 years later) with opencv 4.11. The function with the default algorithm (spaghetti) is not taking the pixels with value 0 to make CC, except the background. Here with this image I get only 7 CC.