Hi Alex,
You just need to create a loop that will isolate each label in a separate image before computing the barycenter.
Look at the example:
$ gmic 400,400 -noise 0.1,2 -dilate_circ 30 -label_fg 0 -repeat {iM-1} --==[0] {\$\>+1} -barycenter. -done -rm[0] -a x
This command creates a synthetic image of labels (with 400,400 -noise 0.1,2 -dilate_circ 30 -label_fg 0), the rest is the loop to compute the barycenter. At the end you get a Nx3 image for N centroids with (X,Y,Z) coordinates.