Let's define the exposure term that you use. You can expose bright and dark scenes for say 1 sec and have totally different images. Alternatively, you may want the images have similar contrasts but this doesn't obligatory mean the same exposure.
Since you mentioned histogram equalization, you may eventually equate histograms of two images to make them look equally contrasty. Histogram equalization will make each image histogram look flat so all intensities are equally probable (and thus optimally distributed to maximize the contrast - not always an eye-pleasing effect). You may want to create your own non-flat histogram profiles individually for each image and modify them until the images look as you want them to look.
Here is a pseudo-code:
1. Calculate a histogram of each image: H[i]
2. Sum the histograms as cumulative histograms: C[i] = H[i]+C[i-1] for each image separately;
3. Normalize each one: C[i]/=sum(C(i))
4. In traditional histogram equalization you remap pixel intensities so that they are equally probable: i2 = 255*C[i1]; in your case you just want them to follow your own histogram profile (so you can have a slider to tweak each image intensity distribution and then compare the results visually); for example, try something like this remapping: i2 = i1*k + 255*C[i1]*(1-k), where the slider changes values of k, from 0.0 to 1.0. When k=1 you get your original image and when k=0 you have full histogram equalization. Below is a histogram equalization function I used for color mapping of Kinect depth that has 10000 levels to 255 levels of gray. You will have to modify and adjust the function for your case.
// histogram equalization
float histEq[10000];
void histEqualize(unsigned short* src, unsigned short* dst, int sz) {
if (sz==0)
return;
memset(histEq, 0, DEPTH_LEVELS*sizeof(float));
// 1. depth histogram
for (int i=0; i<sz; ++i) {
unsigned short val = src[i];
if (val!=0 && val < DEPTH_LEVELS)
histEq[val]++;
}
// 2. cumulative histogram
for (int i=1; i<DEPTH_LEVELS; ++i)
histEq[i] += histEq[i-1];
long max_cumul = histEq[DEPTH_LEVELS-1];
if (max_cumul==0)
return;
// 3. mapping function
for (int i=1; i<DEPTH_LEVELS; ++i)
histEq[i] = (255*histEq[i])/max_cumul;
// remap src
for (int i=0; i<sz; ++i) {
unsigned short z = src[i];
if (z>0)
dst[i] = (unsigned char)(255-histEq[src[i]]+0.5f);
else
dst[i] = 0;
}
} // histEqualization()