Maybe I should be a bit more specific:

at the moment we're able to convert an image to a tiling of colored squares by calculating the coloraverage of all pixels of - let's just say - a square of 50x50 pixels...
this does approximate the original image.

next problem is that we need to replace the colored tiles by images with a color ressembling the color of that tile...
so if the tile was some redish color, then the used image at that spot should be mainly the same red.
now for example: if by running through the database of pictures to compare with the needed color I find an image of mainly the red color I need...but the image also contains a certain amount of black, calculating the total average of the image will not return the red that dominates in the picture, and therefore the picture will be discarded, howthough from just a simple optical point of view the red DID dominate.

does anybody have an accurate way to calculate the overall color of the pictures in the database?
damn problem is that FlickR API doesnt contain any method that lets you search by overall color, it only searches by groupname, or tagnames and so on...