Relation between the color and the spectrum
Hi-
I am wondering what the function might be relating the spectrum and color for any given color in the "colors" data set?
for example: Van Gaugh's Self Portrait contains the color #64c896, and the spectrum #47b853. And, imageid 429982 contains the color #64967d, and the spectrum #47b853 also. What equation accounts for these "nearest fit" spectrum colors? thanks.
The spectrum in our API is part of the museum's design system. Each day of the year has an assigned color (aka color of the day). (Check it out the spectrum on the HAM Explorer demo website.) We map each color in the "colors" data set to our spectrum in case we want to find objects that contain the color of the day. It's mostly there for fun.
Every image in the API goes through color analysis and binning. The colors array in the root of the object record is there for convenience. It's the same as the colors array found in the first image of the object record.
This is the function used for "nearest fit". (See it in context.)
function _find_closest_spectrum($r, $g, $b){
$differencearray = array();
foreach ($this->spectrum as $h => $info) {
$value = $this->_hex_to_rgb($h);
$difference = sqrt(pow($r-$value[0],2) + pow($g-$value[1],2) + pow($b-$value[2],2));
array_push($differencearray, $difference);
}
$smallest = min($differencearray);
$key = array_search($smallest, $differencearray);
$k = array_keys($this->spectrum);
return $k[$key];
}
This comes from the code for our color service.
Thank you very much! very clear