connectedComponents and connectedComponentsWithStats in imgproc accept 8-bit single channel image only for input.