[GRASS5] Histogram matching algorithm?

Dear developers,

for the mosaicking of some hundred orthophotos we need
to apply a histogram matching algorithm to minimize the
effects of changing sun position during the flight.
Does anyone know a solution/algorithm which has been already
implemented in C (Free Software of course)?

The mosaicking algorithm is almost done but histogram
matching is a TODO.

Any ideas?

Markus Neteler