Say about 16 major colors. How would I go about grouping the images into these groups based on pixel count. Obviously I'd need to group all the blue images together, with the images having the highest concentration of blue near the top.
I can compress the image down to its main 16 colors doing something like this:
Code: Select all
$img = new Imagick($image_fname);
$img->quantizeImage(16,Imagick::COLORSPACE_RGB,1,false,false);
Code: Select all
$histogram = $img->getImageHistogram();
foreach($histogram as $h){
//echo $h->getColorAsString() . "\n";
$color=$h->getColor();
$data = array("productid"=>$pid,
"red"=>$color['r'],
"green"=>$color['g'],
"blue"=>$color['b']
);
}
Any help here would be appreciated and would be rewarded with Bitcoin.