First approach is to index all my photos (20.000+) to determine image resolution and average color value.
Before the average color value is calculated, the image is re sized to a width of about 50 pixels. Aspect ratio is maintained. This will improve scanning speed, as fewer pixels will be scanned, and also improve color correctness as only the visible pixels will be calculated. Once this process is done, the image is stored in a SQL Compact server database (filename, width, height, colorvalue).