def rgb_to_xyz(colour)
      r, g, b = colour.map do |v|
          v /= 255.0
          if v > 0.04045
              v = ((v + 0.055 ) / 1.055)**2.4
          else
              v = v / 12.92
          end
          v *= 100
      end

      #Observer = 2°, Illuminant = D65
      x = r * 0.4124 + g * 0.3576 + b * 0.1805
      y = r * 0.2126 + g * 0.7152 + b * 0.0722
      z = r * 0.0193 + g * 0.1192 + b * 0.9505

      return [x, y, z]
    end
def rgb_to_xyz(colour)
      r, g, b = colour.map do |v|
          v /= 255.0
          if v > 0.04045
              v = ((v + 0.055 ) / 1.055)**2.4
          else
              v = v / 12.92
          end
          v *= 100
      end

      #Observer = 2°, Illuminant = D65
      x = r * 0.4124 + g * 0.3576 + b * 0.1805
      y = r * 0.2126 + g * 0.7152 + b * 0.0722
      z = r * 0.0193 + g * 0.1192 + b * 0.9505

      return [x, y, z]
    end
source: http://www.easyrgb.com/index.php?X=MATH&H=02#text2