It seems that the conversion is $rgb['red'] nearest multiple of 0x33.
This probably makes the color fall into the so-called “Internet-safe” color palette, which (if I remember correctly) consists of colors whose rgb values are multiples of 0x33.
0x33 is the base 16 (hexadecimal) representation of 51 (decimal).
source share