merge with dev

This commit is contained in:
Desmis
2019-02-20 08:05:33 +01:00
5 changed files with 36 additions and 18 deletions

View File

@@ -58,23 +58,20 @@ namespace {
#endif
int get_dark_channel(const array2D<float> &R, const array2D<float> &G, const array2D<float> &B, array2D<float> &dst, int patchsize, float *ambient, bool clip, bool multithread)
int get_dark_channel(const array2D<float> &R, const array2D<float> &G, const array2D<float> &B, array2D<float> &dst, int patchsize, const float ambient[3], bool clip, bool multithread)
{
const int W = R.width();
const int H = R.height();
int npatches = 0;
#ifdef _OPENMP
#pragma omp parallel for reduction(+:npatches) if (multithread)
#pragma omp parallel for if (multithread)
#endif
for (int y = 0; y < H; y += patchsize) {
int pH = min(y+patchsize, H);
for (int x = 0; x < W; x += patchsize, ++npatches) {
const int pH = min(y + patchsize, H);
for (int x = 0; x < W; x += patchsize) {
float val = RT_INFINITY_F;
int pW = min(x+patchsize, W);
const int pW = min(x + patchsize, W);
for (int yy = y; yy < pH; ++yy) {
float yval = RT_INFINITY_F;
for (int xx = x; xx < pW; ++xx) {
float r = R[yy][xx];
float g = G[yy][xx];
@@ -84,20 +81,19 @@ int get_dark_channel(const array2D<float> &R, const array2D<float> &G, const arr
g /= ambient[1];
b /= ambient[2];
}
yval = min(yval, r, g, b);
val = min(val, r, g, b);
}
val = min(val, yval);
}
if (clip) {
val = LIM01(val);
}
for (int yy = y; yy < pH; ++yy) {
std::fill(dst[yy]+x, dst[yy]+pW, val);
std::fill(dst[yy] + x, dst[yy] + pW, val);
}
}
}
return npatches;
return (W / patchsize + ((W % patchsize) > 0)) * (H / patchsize + ((H % patchsize) > 0));
}
@@ -121,7 +117,7 @@ float estimate_ambient_light(const array2D<float> &R, const array2D<float> &G, c
std::priority_queue<float> p;
for (int y = 0; y < H; y += patchsize) {
for (int x = 0; x < W; x += patchsize) {
if (!OOG(dark[y][x], 1.f)) {
if (!OOG(dark[y][x], 1.f - 1e-5f)) {
p.push(dark[y][x]);
}
}
@@ -221,7 +217,7 @@ void ImProcFunctions::dehaze(Imagefloat *img)
const int W = img->getWidth();
const int H = img->getHeight();
float strength = LIM01(float(params->dehaze.strength) / 100.f * 0.9f);
const float strength = LIM01(float(params->dehaze.strength) / 100.f * 0.9f);
if (options.rtSettings.verbose) {
std::cout << "dehaze: strength = " << strength << std::endl;

View File

@@ -1801,6 +1801,19 @@ void RawImageSource::preprocess(const RAWParams &raw, const LensProfParams &lens
copyOriginalPixels(raw, riFrames[i], rid, rif, *rawDataFrames[i]);
}
}
} else if (numFrames == 2 && currFrame == 2) { // average the frames
if(!rawDataBuffer[0]) {
rawDataBuffer[0] = new array2D<float>;
}
rawDataFrames[1] = rawDataBuffer[0];
copyOriginalPixels(raw, riFrames[1], rid, rif, *rawDataFrames[1]);
copyOriginalPixels(raw, ri, rid, rif, rawData);
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W; ++j) {
rawData[i][j] = (rawData[i][j] + (*rawDataFrames[1])[i][j]) * 0.5f;
}
}
} else {
copyOriginalPixels(raw, ri, rid, rif, rawData);
}

View File

@@ -201,8 +201,13 @@ public:
static void init ();
static void cleanup ();
void setCurrentFrame(unsigned int frameNum) override {
currFrame = std::min(numFrames - 1, frameNum);
ri = riFrames[currFrame];
if (numFrames == 2 && frameNum == 2) { // special case for averaging of two frames
currFrame = frameNum;
ri = riFrames[0];
} else {
currFrame = std::min(numFrames - 1, frameNum);
ri = riFrames[currFrame];
}
}
int getFrameCount() override {return numFrames;}
int getFlatFieldAutoClipValue() override {return flatFieldAutoClipValue;}