How to extract labels of connected components?

I have used the itk::ConnectedComponentImageFilter. For each slice I have a certain number of connected component. I want to obtain a label associated to each of these ones, but with the following code I obtain only one label for each slice.

using ConnectedComponentImageFilterType = itk::ConnectedComponentImageFilter<ImageTypeUC, ImageTypeUC, ImageTypeUC>;
ConnectedComponentImageFilterType::Pointer connesso= ConnectedComponentImageFilterType::New();
cout << "Number of connected components: " << connesso->GetObjectCount() << ‘\t’;
cout << "Labels associated: " << connesso->GetOutput() << ‘\t’;

Output image type (second template parameter) needs to be large enough to accommodate all the components. You are currently using ImageTypeUC for it. Try US or UL. If your connesso->GetObjectCount() is greater than 255 that is almost certainly the problem.