Centroid of 3D blobs

Well, let’s do it step by step:

  • The command -repeat {iM-1} starts a loop (that will be ended by -done) with {iM-1} iterations. The curly braces here means the content will be evaluated as a math expression, and in that context, the variable iM designates the maximum value of the image [-1]. In this case, the image of label. And the maximum minus one is thus the number of non-zero labels.
  • The command --==[0] {\$\>+1} means 'return a new (boolean) image where each pixel value is either 0 or 1 whether the corresponding pixel value in image [0] (the image of labels here) is equal to $> or not (note the slashes are only here because we invoke it from the shell, and thus we want to avoid $ and > being substituted by the shell itself). $> is nothing else than the running indice (integer) of the loop (here, gets the values from 0 to {iM-2}.
    This command is used to isolate the pixels of the Nth centroid (so having label N), before calling the -barycentercommand on it (to get the barycenter coordinates).

For a complete reference documentation of all G’MIC commands and syntax, please read the language reference page. To start more smoothly, I strongly suggest you read the nice language tutorial pages, written by Garry Osgood.

The versatility of the G’MIC language makes it appear complex at a first glance, but you’ll see this is finally not a big deal to master it.