I am trying to average the colours in an image, I have come up with the following script (from here):
scrip.rb:
require 'rmagick'
file = "./img.jpg"
img = Magick::Image.read(file).first
color = img.scale(1, 1).pixel_color(0,0)
p [color.red, color.green, color.blue]
BUT the RGB output is [31829, 30571, 27931]
.
Questions:
- Shouldn't the numbers be in the range of
[0-255]
? - What am I doing wrong?