////////////////////////////////////////////////////////////////
//
// //exposure correction before interpolation
//
// code dated: December 27, 2010
//
// Expo_before.cc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
////////////////////////////////////////////////////////////////
// Jacques Desmis
// use fast-demo(provisional) from Emil Martinec
// inspired from work Guillermo Luijk and Manuel LLorens(Perfectraw)
//
// This function uses parameters:
// exposure (linear): 2^(-8..0..8): currently 0.5 +3
// preserve (log) : 0..8 : currently 0.1 1
void RawImageSource::processRawWhitepoint(float expos, float preser) {
MyTime t1e,t2e;
t1e.set();
int width=W, height=H;
// exposure correction inspired from G.Luijk
if (fabs(preser)<0.001) {
// No highlight protection - simple mutiplication
for (int c=0; c<4; c++) {
chmax[c] *= expos;
}
#pragma omp parallel for shared(expos)
for (int row=0;row(W,H);
// with memcpy it's faster than for (...)
for (int i=0; i(imgd, H);
// Find maximum to adjust LUTs. New float engines clips only at the very end
int maxVal=0;
for(int row=0;rowmaxVal) maxVal = rawData[row][col];
// Exposure correction with highlight preservation
LUTf lut(maxVal+1);
if(expos>1){
float K = (float) maxVal / expos*exp(-preser*log(2.0));
for (int j=0;j<=maxVal;j++)
lut[(int)j]=(((float)maxVal-K*expos)/((float)maxVal-K)*(j-maxVal)+(float) maxVal) / j;
for (int c=0; c<4; c++) {
chmax[c] *= expos;
}
#pragma omp parallel for shared(expos)
for(int row=0;rowverbose )
printf("Exposure before %d usec\n", t2e.etime(t1e));
}