The enlargeit plugin basically just uses the histogram code taken from the mod I refered to initially, so you don't actually have to look at the enlargit plugin (as the main purpose of that plugin lies somewhere else), but just look at the mod (
Histogram added.).
By coincidence I have been working on the histogram part of the enlargeit plugin for cpg1.5.x the past three days (adding an option to the plugin to cache the histogram images properly and maintaining that cache efficiently).
Keep in mind though that GD2 (which is needed for that mod) is not available everywhere and that it's really a resource hog. As you don't need to actually create graphical resources, but are just interessted to come up with a vector and a calculated value based on that vector, the resources consumption should be neglible.
I can see what you're trying to do now, and as far as I can see it could be accomplished by creating a plugin (instead of a mod, which basically is a hack or coppermine's core code). Maybe you will need some additional plugin hooks, but that would be acceptable.
The real tricky part is to come up with the search queries in the end to refine your search.