Decompose Segmentation

I have an image and I was doing segmentation on the image. let’s say for example a human body image. Now I want to decompose the image by the segments of the segmentation that will only show me one part, for example, I have segmented every part of the human body I want to show only the hand or only the elbow.
Can someone guide me for a tutorial or explain to me how to do it.
The file I have:

In the end, I want to do data augmentation on the segmented image and after that to decompose it to 3 images (what is segmented).

How should the segmented parts be visualized?
It should be possible to use a filtering approach, by comparing the pixel values of the output segmentation to a specific class index, and get the min/max indices via:

idx = (pred == class_idx).nonzero() 

However, you would usually cut a rectangular segment, which might and most likely will include other classes as well. E.g. the “arm class” might be inside the patch of a segmented “hand class”.

Thank you!
I only remove the nonzero()

Now I want to go back and project it on the real image, or to reconstruct only the segment image form real, what is the easy way to do that?

my real image: (slice=78, h=633, w=788)

after I do idx = (pred == class_idx).nonzero() I get:
3 ndarray with 4293160.
Not I get in trouble to project it on the real image and reconstruct only the part of the segment, but with saving the pixel value.