func LabeledPixelToID(c color.Color) (uint32, error) {

	// Find the color channel values for this pixel
	pr, pg, pb, a := c.RGBA()

	// Confirm that we're mapping ID 1 => #010101, etc
	if pr != pg || pg != pb || pr != pb {
		return 0, fmt.Errorf("Encoding expected to have equal values for R, G, and B. Instead, found %d, %d, %d", pr, pg, pb)
	}

	// Create the hex string representation. Since each color channel is
	// "alpha-premultiplied" (https://golang.org/pkg/image/color/#RGBA),
	// we need to divide by alpha (scaling 0-1), then multiplying by
	// 255, to get what we're actually looking for
	pixelID := uint32(math.Round(255 * float64(pr) / float64(a)))

	return pixelID, nil
}
// LabeledPixelToID converts the label-encoded pixel (e.g., #010101) which is
// alpha-premultiplied into an ID in the range of 0-255
LabeledPixelToID converts the label-encoded pixel  which is
alpha-premultiplied into an ID in the range of 0-255
// LabeledPixelToID converts the label - encoded pixel ( e . g . #010101 ) which is // alpha - premultiplied into an ID in the range of 0 - 255
func LabeledPixelToID(c color.Color) (uint32, error) {
	pr, pg, pb, a := c.RGBA()
	if pr != pg || pg != pb || pr != pb {
		return 0, fmt.Errorf("Encoding expected to have equal values for R, G, and B. Instead, found %d, %d, %d", pr, pg, pb)
	}
	pixelID := uint32(math.Round(255 * float64(pr) / float64(a)))
	return pixelID, nil
}
func LabeledPixelToID ( c color . Color ) ( uint32 , error ) { pr , pg , pb , a := c . RGBA ( ) if pr != pg || pg != pb || pr != pb { return 0 , fmt . Errorf ( " " , pr , pg , pb ) } pixelID := uint32 ( math . Round ( 255 * float64 ( pr ) / float64 ( a ) ) ) return pixelID , nil }
LabeledPixelToID converts the label-encoded pixel  which is
alpha-premultiplied into an ID in the range of 0-255
LabeledPixelToID converts the label - encoded pixel which is alpha - premultiplied into an ID in the range of 0 - 255
// Find the color channel values for this pixel // Confirm that we're mapping ID 1 => #010101, etc // Create the hex string representation. Since each color channel is // "alpha-premultiplied" (https://golang.org/pkg/image/color/#RGBA), // we need to divide by alpha (scaling 0-1), then multiplying by // 255, to get what we're actually looking for