Zend certified PHP/Magento developer

Connected components labeling in GraphicsMagick?

Is there a way to scan the image pixel by pixel and print the coordinates of each pixel regions by color? similiar to this ImageMagick´s feature Uniquely Label Connected Regions. I’d like to do it in bash or python to identify the coordinates of several rectangles inside an image, each rectangle is of different color or has a border line of some color.

Example how this can be done in ImageMagick.

magick objects.gif -connected-components 4 -auto-level -depth 8 objects.png

Objects (id: bounding-box centroid area mean-color):
  0: 256x171+0+0 119.2,80.8 33117 srgb(0,0,0)
  2: 120x135+104+18 159.5,106.5 8690 srgb(255,255,255)
  3: 50x36+129+44 154.2,63.4 1529 srgb(0,0,0)
  4: 21x23+0+45 8.8,55.9 409 srgb(255,255,255)
  1: 4x10+252+0 253.9,4.1 31 srgb(255,255,255)

Thanks in advance.