merge with dev

This commit is contained in:
Desmis
2017-09-14 09:09:18 +02:00
40 changed files with 2861 additions and 1388 deletions

View File

@@ -33,6 +33,7 @@
#include "dcp.h"
#include "rt_math.h"
#include "improcfun.h"
#include "rtlensfun.h"
#ifdef _OPENMP
#include <omp.h>
#endif
@@ -1863,11 +1864,19 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le
// Correct vignetting of lens profile
if (!hasFlatField && lensProf.useVign) {
LCPProfile *pLCPProf = lcpStore->getProfile (lensProf.lcpFile);
std::unique_ptr<LensCorrection> pmap;
if (lensProf.useLensfun) {
pmap = std::move(LFDatabase::findModifier(lensProf, idata, W, H, coarse, -1));
} else {
const std::shared_ptr<LCPProfile> pLCPProf = LCPStore::getInstance()->getProfile(lensProf.lcpFile);
if (pLCPProf) { // don't check focal length to allow distortion correction for lenses without chip, also pass dummy focal length 1 in case of 0
LCPMapper map (pLCPProf, max (idata->getFocalLen(), 1.0), idata->getFocalLen35mm(), idata->getFocusDist(), idata->getFNumber(), true, false, W, H, coarse, -1);
if (pLCPProf) { // don't check focal length to allow distortion correction for lenses without chip, also pass dummy focal length 1 in case of 0
pmap.reset(new LCPMapper(pLCPProf, max(idata->getFocalLen(), 1.0), idata->getFocalLen35mm(), idata->getFocusDist(), idata->getFNumber(), true, false, W, H, coarse, -1));
}
}
if (pmap) {
LensCorrection &map = *pmap;
if (ri->getSensorType() == ST_BAYER || ri->getSensorType() == ST_FUJI_XTRANS || ri->get_colors() == 1) {
if (numFrames == 4) {
for (int i = 0; i < 4; ++i) {
@@ -1921,42 +1930,16 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le
}
}
// check if it is an olympus E camera, if yes, compute G channel pre-compensation factors
if ( ri->getSensorType() == ST_BAYER && (raw.bayersensor.greenthresh || (((idata->getMake().size() >= 7 && idata->getMake().substr (0, 7) == "OLYMPUS" && idata->getModel()[0] == 'E') || (idata->getMake().size() >= 9 && idata->getMake().substr (0, 9) == "Panasonic")) && raw.bayersensor.method != RAWParams::BayerSensor::methodstring[ RAWParams::BayerSensor::vng4])) ) {
// check if it is an olympus E camera or green equilibration is enabled. If yes, compute G channel pre-compensation factors
if ( ri->getSensorType() == ST_BAYER && (raw.bayersensor.greenthresh || (((idata->getMake().size() >= 7 && idata->getMake().substr(0, 7) == "OLYMPUS" && idata->getModel()[0] == 'E') || (idata->getMake().size() >= 9 && idata->getMake().substr(0, 9) == "Panasonic")) && raw.bayersensor.method != RAWParams::BayerSensor::methodstring[ RAWParams::BayerSensor::vng4])) ) {
// global correction
int ng1 = 0, ng2 = 0, i = 0;
double avgg1 = 0., avgg2 = 0.;
#ifdef _OPENMP
#pragma omp parallel for default(shared) private(i) reduction(+: ng1, ng2, avgg1, avgg2)
#endif
for (i = border; i < H - border; i++)
for (int j = border; j < W - border; j++)
if (ri->ISGREEN (i, j)) {
if (i & 1) {
avgg2 += rawData[i][j];
ng2++;
} else {
avgg1 += rawData[i][j];
ng1++;
}
}
double corrg1 = ((double)avgg1 / ng1 + (double)avgg2 / ng2) / 2.0 / ((double)avgg1 / ng1);
double corrg2 = ((double)avgg1 / ng1 + (double)avgg2 / ng2) / 2.0 / ((double)avgg2 / ng2);
#ifdef _OPENMP
#pragma omp parallel for default(shared)
#endif
for (int i = border; i < H - border; i++)
for (int j = border; j < W - border; j++)
if (ri->ISGREEN (i, j)) {
float currData;
currData = (float) (rawData[i][j] * ((i & 1) ? corrg2 : corrg1));
rawData[i][j] = (currData);
}
if(numFrames == 4) {
for(int i = 0; i < 4; ++i) {
green_equilibrate_global(*rawDataFrames[i]);
}
} else {
green_equilibrate_global(rawData);
}
}
if ( ri->getSensorType() == ST_BAYER && raw.bayersensor.greenthresh > 0) {
@@ -1965,12 +1948,12 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le
plistener->setProgress (0.0);
}
if (numFrames == 4) {
for (int i = 0; i < 4; ++i) {
green_equilibrate (0.01 * (raw.bayersensor.greenthresh), *rawDataFrames[i]);
if(numFrames == 4) {
for(int i = 0; i < 4; ++i) {
green_equilibrate(0.01 * raw.bayersensor.greenthresh, *rawDataFrames[i]);
}
} else {
green_equilibrate (0.01 * (raw.bayersensor.greenthresh), rawData);
green_equilibrate(0.01 * raw.bayersensor.greenthresh, rawData);
}
}