# ximgproc - SLIC Segmentation - Get coordinates of superpixel

Hey guys,

right now I'm using the ximgproc module to apply the SLIC-algorithm to an image. So far, this works very well. I Problem is the following: I need to have an array, which stores for each superpixel all corresponding points in the image. This can be interpreted as:

```
Superpixel = [] #array which contains all superpixels/labels
Superpixel[0] =[] #Superpixel with label 0 contains an array of points
```

How is this efficiently done? Right now I'm using e.g. np.argwhere to find all coordinates with the specific label in the image and write it into the corresponding superpixel. My ineffecient code looks like the following (when using skimage.segmentation.slic):

```
#segments is 2D array, where each point contains label-value (in this case 0-4000)
segments = slic(self.color, n_segments = 4000, sigma = 1)
superPixel = []
#iterate through all labels and write their coordinates into array
for i in range(0,np.max(segments)):
superPixel.append(np.argwhere(segments == i))
```

I think it can be seen, that this is a huge amount of calculation time. Is there any better way, to get all coordinates which are assigned to a specific superpixel?

Best and looking forward for some hints