Eh?
Are you grabbing colors from a photo or from something like a gif graphic (not many colors)?
OR
Doesn't it seem evident that...
1) you need to pick just one pixel to get a color from.
OR
2) you are going to get back multiple color values from the "range".
OR
3) you need to multiply all the colors values in a range which will very likely result in black.
Honestly, what I believe you are trying to do (but I'm just guessing here) is return an average hex (color) value based upon all the colors in a given range.