Page 1 of 1

Usage: connected components labelling

Posted: 2017-01-27T22:39:57-07:00
by snibgo
I suppose this isn't a bug, but a trap for the unwary.

The documentation http://magick.imagemagick.org/script/co ... onents.php correctly states: "By default, the labeled image is grayscale."

The darkest output gray will be black. I thought the next would be 1, the next would be 2, etc, on a scale from 0 to QuantumRange. This is true for Q16, but not for Q32.

For Q32, the grays are 0, 65537, 2*65537, etc.

The reason for this is that the code uses a map with MaxColormapSize elements, initialized to the range zero to QuantumRange. Hence the intervals are QuantumRange/MaxColormapSize, which is 1 for Q16 but 65537 for Q32.

Re: Usage: connected components labelling

Posted: 2017-01-28T07:10:16-07:00
by magick
The objects are enumerated as the colormap indexes, not the sRGB components. So colormap index 0 is object 0, colormap index 1 is object 1, etc.

Re: Usage: connected components labelling

Posted: 2017-01-28T15:07:04-07:00
by snibgo
Yes, indeed. And the colour of colormap index 0 is black, and of index 1 is rgb(1,1,1) in Q16 but index 1 is rgb(65537,65537,65537) in Q32.