How do you access a pixel's label ID that is given to each pixel after connected component labeling?
connectedComponents* literally gives you a "labels map". You look up the pixel's position in there and you get the label for that pixel.
If you need a mask for one specific label, you calculate mask = (labels_map == specific_label)
Do not "iterate" through images. Python loops are slow. Whatever you do, consider how to express that with library functions (numpy, OpenCV, ...). There are ways to speed up python loops but that's advanced and likely not the right solution for your problem.
I used OpenCV's connectedComponentsWithStats function to do connected component labeling on an image. I would now like to be able to access all the pixels that have a certain label, or check the label that is assigned to a particular pixel while iterating through the image. How can I do this? I plan on iterating through the image using a nested for loop.