pixelshift: new version of adapaptive motion detection
This commit is contained in:
@@ -41,13 +41,17 @@ float greenDiff(float a, float b, bool adaptive, float scale, float stddevFactor
|
|||||||
// calculate the difference between to green samples
|
// calculate the difference between to green samples
|
||||||
// add a small epsilon to avoid division by zero
|
// add a small epsilon to avoid division by zero
|
||||||
float maxVal = std::max(a, b) + 0.01f;
|
float maxVal = std::max(a, b) + 0.01f;
|
||||||
float diff = std::fabs(a - b) / maxVal;
|
float gDiff = std::fabs(a - b);
|
||||||
|
float diff = gDiff / maxVal;
|
||||||
if(adaptive) {
|
if(adaptive) {
|
||||||
float avg = (a+b)/2.f;
|
float avg = (a+b)/2.f;
|
||||||
avg *= scale; // revert the colour scaling
|
avg *= scale; // revert the colour scaling
|
||||||
prnu *= (avg * eperIso);
|
avg *= eperIso;
|
||||||
float stddev = sqrtf(avg * eperIso + nreadIso * nreadIso + prnu * prnu);
|
prnu *= avg;
|
||||||
float korr = stddevFactor * stddev / (maxVal * scale);
|
float stddev = sqrtf(avg + nreadIso * nreadIso + prnu * prnu);
|
||||||
|
// float korr = stddevFactor * stddev / (a * scale); // V0: use G1 not scaled by eperIso
|
||||||
|
// float korr = stddevFactor * stddev / (maxVal * scale); // V1: use max(G1,G2) not scaled by eperIso
|
||||||
|
float korr = stddevFactor * stddev / (gDiff / (eperIso * scale)); // V2: use absolute difference abs(G1-G2) scaled by eperISo
|
||||||
diff -= korr;
|
diff -= korr;
|
||||||
}
|
}
|
||||||
return diff;
|
return diff;
|
||||||
@@ -72,12 +76,14 @@ void RawImageSource::pixelshift_simple(int winx, int winy, int winw, int winh, b
|
|||||||
gridSize += ((gridSize & 1) == 0 ? 1 : 0);
|
gridSize += ((gridSize & 1) == 0 ? 1 : 0);
|
||||||
// Lookup table for non adaptive (slider) mode
|
// Lookup table for non adaptive (slider) mode
|
||||||
LUTf log2Lut(32768, LUT_CLIP_BELOW | LUT_CLIP_ABOVE);
|
LUTf log2Lut(32768, LUT_CLIP_BELOW | LUT_CLIP_ABOVE);
|
||||||
log2Lut[0] = 0;
|
|
||||||
const float lutStrength = 2.f;
|
if(detectMotion && !adaptive) {
|
||||||
|
const float lutStrength = 2.f;
|
||||||
|
log2Lut[0] = 0;
|
||||||
|
for(int i=2; i < 65536; i+=2)
|
||||||
|
log2Lut[i>>1] = lutStrength * log2(i) / 100.f;
|
||||||
|
}
|
||||||
const float scaleGreen = 1.f / scale_mul[1];
|
const float scaleGreen = 1.f / scale_mul[1];
|
||||||
for(int i=2; i < 65536; i+=2)
|
|
||||||
log2Lut[i>>1] = 2.f * log2(i) / 100.f;
|
|
||||||
|
|
||||||
eperIso *= (idata->getISOSpeed() / 100);
|
eperIso *= (idata->getISOSpeed() / 100);
|
||||||
prnu /= 100.f;
|
prnu /= 100.f;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user