pixelshift: switch subframe without need to reload the image; enabled CA-correction
This commit is contained in:
parent
313e770cfe
commit
6496e34e4b
@ -112,7 +112,7 @@ bool LinEqSolve(int nDim, double* pfMatr, double* pfVect, double* pfSolution)
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace rtengine;
|
using namespace rtengine;
|
||||||
|
|
||||||
void RawImageSource::CA_correct_RT(const double cared, const double cablue, const double caautostrength)
|
void RawImageSource::CA_correct_RT(const double cared, const double cablue, const double caautostrength, array2D<float> &rawData)
|
||||||
{
|
{
|
||||||
// multithreaded and partly vectorized by Ingo Weyrich
|
// multithreaded and partly vectorized by Ingo Weyrich
|
||||||
constexpr int ts = 128;
|
constexpr int ts = 128;
|
||||||
|
@ -160,39 +160,39 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, bool det
|
|||||||
if(detectMotion || adaptive) {
|
if(detectMotion || adaptive) {
|
||||||
if(gridSize < 2) {
|
if(gridSize < 2) {
|
||||||
// compute maximum of differences for first two columns of 3x3 grid
|
// compute maximum of differences for first two columns of 3x3 grid
|
||||||
greenDifMax[0] = max(colourDiff(riFrames[0 + offset]->data[i + offset][j - 1], riFrames[2 + offset]->data[i - offset + 1][j], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
greenDifMax[0] = max(colourDiff((*rawDataFrames[0 + offset])[i + offset][j - 1], (*rawDataFrames[2 + offset])[i - offset + 1][j], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[1 - offset]->data[i - offset][j - 1], riFrames[3 - offset]->data[i + offset - 1][j], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[1 - offset])[i - offset][j - 1], (*rawDataFrames[3 - offset])[i + offset - 1][j], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[1 - offset]->data[i - offset + 2][j - 1], riFrames[3 - offset]->data[i + offset + 1][j], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion)
|
colourDiff((*rawDataFrames[1 - offset])[i - offset + 2][j - 1], (*rawDataFrames[3 - offset])[i + offset + 1][j], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion)
|
||||||
);
|
);
|
||||||
greenDifMax[1] = max(colourDiff(riFrames[1 - offset]->data[i - offset + 1][j], riFrames[3 - offset]->data[i + offset][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
greenDifMax[1] = max(colourDiff((*rawDataFrames[1 - offset])[i - offset + 1][j], (*rawDataFrames[3 - offset])[i + offset][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[0 + offset]->data[i + offset - 1][j], riFrames[2 + offset]->data[i - offset][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[0 + offset])[i + offset - 1][j], (*rawDataFrames[2 + offset])[i - offset][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[0 + offset]->data[i + offset + 1][j], riFrames[2 + offset]->data[i - offset + 2][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion)
|
colourDiff((*rawDataFrames[0 + offset])[i + offset + 1][j], (*rawDataFrames[2 + offset])[i - offset + 2][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion)
|
||||||
);
|
);
|
||||||
} else if(gridSize == 5) {
|
} else if(gridSize == 5) {
|
||||||
// compute maximum of differences for first four columns of 5x5 grid
|
// compute maximum of differences for first four columns of 5x5 grid
|
||||||
greenDifMax[0] = max(colourDiff(riFrames[1 - offset]->data[i - offset - 1][j-2], riFrames[3 - offset]->data[i + offset -2][j - 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
greenDifMax[0] = max(colourDiff((*rawDataFrames[1 - offset])[i - offset - 1][j-2], (*rawDataFrames[3 - offset])[i + offset -2][j - 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[1 - offset]->data[i - offset + 1][j-2], riFrames[3 - offset]->data[i + offset][j - 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[1 - offset])[i - offset + 1][j-2], (*rawDataFrames[3 - offset])[i + offset][j - 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[1 - offset]->data[i - offset + 3][j-2], riFrames[3 - offset]->data[i + offset +2][j - 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[1 - offset])[i - offset + 3][j-2], (*rawDataFrames[3 - offset])[i + offset +2][j - 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[0 + offset]->data[i + offset - 1][j-2], riFrames[2 + offset]->data[i - offset][j - 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[0 + offset])[i + offset - 1][j-2], (*rawDataFrames[2 + offset])[i - offset][j - 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[0 + offset]->data[i + offset + 1][j-2], riFrames[2 + offset]->data[i - offset + 2][j - 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion)
|
colourDiff((*rawDataFrames[0 + offset])[i + offset + 1][j-2], (*rawDataFrames[2 + offset])[i - offset + 2][j - 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion)
|
||||||
);
|
);
|
||||||
greenDifMax[1] = max(colourDiff(riFrames[0 + offset]->data[i + offset-2][j - 1], riFrames[2 + offset]->data[i - offset - 1][j], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
greenDifMax[1] = max(colourDiff((*rawDataFrames[0 + offset])[i + offset-2][j - 1], (*rawDataFrames[2 + offset])[i - offset - 1][j], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[0 + offset]->data[i + offset][j - 1], riFrames[2 + offset]->data[i - offset + 1][j], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[0 + offset])[i + offset][j - 1], (*rawDataFrames[2 + offset])[i - offset + 1][j], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[0 + offset]->data[i + offset+2][j - 1], riFrames[2 + offset]->data[i - offset + 3][j], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[0 + offset])[i + offset+2][j - 1], (*rawDataFrames[2 + offset])[i - offset + 3][j], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[1 - offset]->data[i - offset][j - 1], riFrames[3 - offset]->data[i + offset - 1][j], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[1 - offset])[i - offset][j - 1], (*rawDataFrames[3 - offset])[i + offset - 1][j], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[1 - offset]->data[i - offset + 2][j - 1], riFrames[3 - offset]->data[i + offset + 1][j], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion)
|
colourDiff((*rawDataFrames[1 - offset])[i - offset + 2][j - 1], (*rawDataFrames[3 - offset])[i + offset + 1][j], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion)
|
||||||
);
|
);
|
||||||
greenDifMax[2] = max(colourDiff(riFrames[1 - offset]->data[i - offset - 1][j], riFrames[3 - offset]->data[i + offset -2][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
greenDifMax[2] = max(colourDiff((*rawDataFrames[1 - offset])[i - offset - 1][j], (*rawDataFrames[3 - offset])[i + offset -2][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[1 - offset]->data[i - offset + 1][j], riFrames[3 - offset]->data[i + offset][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[1 - offset])[i - offset + 1][j], (*rawDataFrames[3 - offset])[i + offset][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[1 - offset]->data[i - offset + 3][j], riFrames[3 - offset]->data[i + offset +2][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[1 - offset])[i - offset + 3][j], (*rawDataFrames[3 - offset])[i + offset +2][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[0 + offset]->data[i + offset - 1][j], riFrames[2 + offset]->data[i - offset][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[0 + offset])[i + offset - 1][j], (*rawDataFrames[2 + offset])[i - offset][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[0 + offset]->data[i + offset + 1][j], riFrames[2 + offset]->data[i - offset + 2][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion)
|
colourDiff((*rawDataFrames[0 + offset])[i + offset + 1][j], (*rawDataFrames[2 + offset])[i - offset + 2][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion)
|
||||||
);
|
);
|
||||||
greenDifMax[3] = max(colourDiff(riFrames[0 + offset]->data[i + offset-2][j + 1], riFrames[2 + offset]->data[i - offset - 1][j+2], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
greenDifMax[3] = max(colourDiff((*rawDataFrames[0 + offset])[i + offset-2][j + 1], (*rawDataFrames[2 + offset])[i - offset - 1][j+2], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[0 + offset]->data[i + offset][j + 1], riFrames[2 + offset]->data[i - offset + 1][j+2], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[0 + offset])[i + offset][j + 1], (*rawDataFrames[2 + offset])[i - offset + 1][j+2], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[0 + offset]->data[i + offset+2][j + 1], riFrames[2 + offset]->data[i - offset + 3][j+2], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[0 + offset])[i + offset+2][j + 1], (*rawDataFrames[2 + offset])[i - offset + 3][j+2], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[1 - offset]->data[i - offset][j + 1], riFrames[3 - offset]->data[i + offset - 1][j+2], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[1 - offset])[i - offset][j + 1], (*rawDataFrames[3 - offset])[i + offset - 1][j+2], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[1 - offset]->data[i - offset + 2][j +- 1], riFrames[3 - offset]->data[i + offset + 1][j+2], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion)
|
colourDiff((*rawDataFrames[1 - offset])[i - offset + 2][j +- 1], (*rawDataFrames[3 - offset])[i + offset + 1][j+2], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,22 +211,22 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, bool det
|
|||||||
float gridMax;
|
float gridMax;
|
||||||
if(gridSize < 2) {
|
if(gridSize < 2) {
|
||||||
// compute difference for current pixel and skip next pixel, that's the method from dcrawps
|
// compute difference for current pixel and skip next pixel, that's the method from dcrawps
|
||||||
gridMax = colourDiff(riFrames[1 - offset]->data[i - offset + 1][j], riFrames[3 - offset]->data[i + offset][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion);
|
gridMax = colourDiff((*rawDataFrames[1 - offset])[i - offset + 1][j], (*rawDataFrames[3 - offset])[i + offset][j + 1], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion);
|
||||||
skipNext = skip && !showMotion ;
|
skipNext = skip && !showMotion ;
|
||||||
} else if(gridSize == 3) {
|
} else if(gridSize == 3) {
|
||||||
// compute maximum of differences for third column of 3x3 grid and save at position lastIndex
|
// compute maximum of differences for third column of 3x3 grid and save at position lastIndex
|
||||||
greenDifMax[lastIndex] = max(colourDiff(riFrames[0 + offset]->data[i + offset][j + 1], riFrames[2 + offset]->data[i - offset + 1][j + 2], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
greenDifMax[lastIndex] = max(colourDiff((*rawDataFrames[0 + offset])[i + offset][j + 1], (*rawDataFrames[2 + offset])[i - offset + 1][j + 2], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[1 - offset]->data[i - offset][j + 1], riFrames[3 - offset]->data[i + offset - 1][j + 2], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[1 - offset])[i - offset][j + 1], (*rawDataFrames[3 - offset])[i + offset - 1][j + 2], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[1 - offset]->data[i - offset + 2][j + 1], riFrames[3 - offset]->data[i + offset + 1][j + 2], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion)
|
colourDiff((*rawDataFrames[1 - offset])[i - offset + 2][j + 1], (*rawDataFrames[3 - offset])[i + offset + 1][j + 2], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion)
|
||||||
);
|
);
|
||||||
gridMax = max(greenDifMax[0],greenDifMax[1],greenDifMax[2]);
|
gridMax = max(greenDifMax[0],greenDifMax[1],greenDifMax[2]);
|
||||||
} else if(gridSize == 5) {
|
} else if(gridSize == 5) {
|
||||||
// compute maximum of differences for fifth column of 5x5 grid and save at position lastIndex
|
// compute maximum of differences for fifth column of 5x5 grid and save at position lastIndex
|
||||||
greenDifMax[lastIndex] = max(colourDiff(riFrames[1 - offset]->data[i - offset - 1][j+2], riFrames[3 - offset]->data[i + offset -2][j + 3], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
greenDifMax[lastIndex] = max(colourDiff((*rawDataFrames[1 - offset])[i - offset - 1][j+2], (*rawDataFrames[3 - offset])[i + offset -2][j + 3], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[1 - offset]->data[i - offset + 1][j+2], riFrames[3 - offset]->data[i + offset][j + 3], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[1 - offset])[i - offset + 1][j+2], (*rawDataFrames[3 - offset])[i + offset][j + 3], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[1 - offset]->data[i - offset + 3][j+2], riFrames[3 - offset]->data[i + offset +2][j + 3], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[1 - offset])[i - offset + 3][j+2], (*rawDataFrames[3 - offset])[i + offset +2][j + 3], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[0 + offset]->data[i + offset - 1][j+2], riFrames[2 + offset]->data[i - offset][j + 3], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
colourDiff((*rawDataFrames[0 + offset])[i + offset - 1][j+2], (*rawDataFrames[2 + offset])[i - offset][j + 3], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion),
|
||||||
colourDiff(riFrames[0 + offset]->data[i + offset + 1][j+2], riFrames[2 + offset]->data[i - offset + 2][j + 3], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion)
|
colourDiff((*rawDataFrames[0 + offset])[i + offset + 1][j+2], (*rawDataFrames[2 + offset])[i - offset + 2][j + 3], adaptive, stddevFactor, eperIsoGreen, nreadIso, prnu, showMotion)
|
||||||
);
|
);
|
||||||
gridMax = max(greenDifMax[0],greenDifMax[1],greenDifMax[2],greenDifMax[3],greenDifMax[4]);
|
gridMax = max(greenDifMax[0],greenDifMax[1],greenDifMax[2],greenDifMax[3],greenDifMax[4]);
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, bool det
|
|||||||
|
|
||||||
// increase motion detection dependent on brightness
|
// increase motion detection dependent on brightness
|
||||||
if(!adaptive) {
|
if(!adaptive) {
|
||||||
korr = log2Lut[((int)(riFrames[1 - offset]->data[i - offset + 1][j] * scaleGreen))>>1];
|
korr = log2Lut[((int)((*rawDataFrames)[1 - offset][i - offset + 1][j] * scaleGreen))>>1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gridMax > thresh - korr) {
|
if (gridMax > thresh - korr) {
|
||||||
@ -262,9 +262,9 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, bool det
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(adaptive && checkNonGreenHorizontal) {
|
if(adaptive && checkNonGreenHorizontal) {
|
||||||
float ng1 = riFrames[(offset << 1) + offset]->data[i][j + offset];
|
float ng1 = (*rawDataFrames[(offset << 1) + offset])[i][j + offset];
|
||||||
float ng0 = riFrames[((offset^1) << 1) + (offset^1)]->data[i][j + (offset^1)+1];
|
float ng0 = (*rawDataFrames[((offset^1) << 1) + (offset^1)])[i][j + (offset^1)+1];
|
||||||
float ng2 = riFrames[((offset^1) << 1) + (offset^1)]->data[i][j + (offset^1)-1];
|
float ng2 = (*rawDataFrames[((offset^1) << 1) + (offset^1)])[i][j + (offset^1)-1];
|
||||||
float diff0 = ng0 - ng1;
|
float diff0 = ng0 - ng1;
|
||||||
float diff2 = ng2 - ng1;
|
float diff2 = ng2 - ng1;
|
||||||
if(diff0 * diff2 >= 0.f) {
|
if(diff0 * diff2 >= 0.f) {
|
||||||
@ -285,9 +285,9 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, bool det
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ng1 = riFrames[2 - offset]->data[i + 1][j - offset + 1];
|
ng1 = (*rawDataFrames[2 - offset])[i + 1][j - offset + 1];
|
||||||
ng0 = riFrames[2 - (offset^1)]->data[i + 1][j - (offset^1) + 2];
|
ng0 = (*rawDataFrames[2 - (offset^1)])[i + 1][j - (offset^1) + 2];
|
||||||
ng2 = riFrames[2 - (offset^1)]->data[i + 1][j - (offset^1)];
|
ng2 = (*rawDataFrames[2 - (offset^1)])[i + 1][j - (offset^1)];
|
||||||
diff0 = ng0 - ng1;
|
diff0 = ng0 - ng1;
|
||||||
diff2 = ng2 - ng1;
|
diff2 = ng2 - ng1;
|
||||||
if(diff0 * diff2 >= 0.f) {
|
if(diff0 * diff2 >= 0.f) {
|
||||||
@ -309,9 +309,9 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, bool det
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(adaptive && checkNonGreenVertical) {
|
if(adaptive && checkNonGreenVertical) {
|
||||||
float ng1 = riFrames[(offset << 1) + offset]->data[i][j + offset];
|
float ng1 = (*rawDataFrames[(offset << 1) + offset])[i][j + offset];
|
||||||
float ng0 = riFrames[((offset << 1) + offset)^1]->data[i][j + offset];
|
float ng0 = (*rawDataFrames[((offset << 1) + offset)^1])[i][j + offset];
|
||||||
float ng2 = riFrames[((offset << 1) + offset)^1]->data[i+2][j + offset];
|
float ng2 = (*rawDataFrames[((offset << 1) + offset)^1])[i+2][j + offset];
|
||||||
|
|
||||||
float diff0 = ng0 - ng1;
|
float diff0 = ng0 - ng1;
|
||||||
float diff2 = ng2 - ng1;
|
float diff2 = ng2 - ng1;
|
||||||
@ -333,9 +333,9 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, bool det
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ng1 = riFrames[2 - offset]->data[i + 1][j - offset + 1];
|
ng1 = (*rawDataFrames[2 - offset])[i + 1][j - offset + 1];
|
||||||
ng0 = riFrames[3 - ((offset<<1) + offset)]->data[i - 1][j - offset + 1];
|
ng0 = (*rawDataFrames[3 - ((offset<<1) + offset)])[i - 1][j - offset + 1];
|
||||||
ng2 = riFrames[3 - ((offset<<1) + offset)]->data[i + 1][j - offset + 1];
|
ng2 = (*rawDataFrames[3 - ((offset<<1) + offset)])[i + 1][j - offset + 1];
|
||||||
|
|
||||||
diff0 = ng0 - ng1;
|
diff0 = ng0 - ng1;
|
||||||
diff2 = ng2 - ng1;
|
diff2 = ng2 - ng1;
|
||||||
@ -365,9 +365,9 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, bool det
|
|||||||
}
|
}
|
||||||
|
|
||||||
// motion correction disabled or no motion detected => combine the values from the four pixelshift frames
|
// motion correction disabled or no motion detected => combine the values from the four pixelshift frames
|
||||||
greenDest[j + offsX] = (riFrames[1 - offset]->data[i - offset + 1][j] + riFrames[3 - offset]->data[i + offset][j + 1]) / 2.f;
|
greenDest[j + offsX] = ((*rawDataFrames[1 - offset])[i - offset + 1][j] + (*rawDataFrames[3 - offset])[i + offset][j + 1]) / 2.f;
|
||||||
nonGreenDest0[j + offsX] = riFrames[(offset << 1) + offset]->data[i][j + offset];
|
nonGreenDest0[j + offsX] = (*rawDataFrames[(offset << 1) + offset])[i][j + offset];
|
||||||
nonGreenDest1[j + offsX] = riFrames[2 - offset]->data[i + 1][j - offset + 1];
|
nonGreenDest1[j + offsX] = (*rawDataFrames[2 - offset])[i + 1][j - offset + 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,6 +479,10 @@ RawImageSource::~RawImageSource ()
|
|||||||
delete riFrames[i];
|
delete riFrames[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(size_t i = 0; i < numFrames - 1; ++i) {
|
||||||
|
delete rawDataBuffer[i];
|
||||||
|
}
|
||||||
|
|
||||||
flushRGB();
|
flushRGB();
|
||||||
flushRawData();
|
flushRawData();
|
||||||
|
|
||||||
@ -1758,7 +1762,24 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le
|
|||||||
printf( "Flat Field Correction:%s\n", rif->get_filename().c_str());
|
printf( "Flat Field Correction:%s\n", rif->get_filename().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
copyOriginalPixels(raw, ri, rid, rif, rawData);
|
if(numFrames == 4 && raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::pixelshift_simple]) {
|
||||||
|
int bufferNumber = 0;
|
||||||
|
for(int i=0; i<4; ++i) {
|
||||||
|
if(i==currFrame) {
|
||||||
|
copyOriginalPixels(raw, ri, rid, rif, rawData);
|
||||||
|
rawDataFrames[i] = &rawData;
|
||||||
|
} else {
|
||||||
|
if(!rawDataBuffer[bufferNumber]) {
|
||||||
|
rawDataBuffer[bufferNumber] = new array2D<float>;
|
||||||
|
}
|
||||||
|
rawDataFrames[i] = rawDataBuffer[bufferNumber];
|
||||||
|
++bufferNumber;
|
||||||
|
copyOriginalPixels(raw, riFrames[i], rid, rif, *rawDataFrames[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
copyOriginalPixels(raw, ri, rid, rif, rawData);
|
||||||
|
}
|
||||||
//FLATFIELD end
|
//FLATFIELD end
|
||||||
|
|
||||||
|
|
||||||
@ -1798,10 +1819,12 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(numFrames == 4 && raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::pixelshift_simple]) {
|
||||||
scaleColors( 0, 0, W, H, raw, rawData); //+ + raw parameters for black level(raw.blackxx)
|
for(int i=0; i<4; ++i) {
|
||||||
if(numFrames == 4 && raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::pixelshift_simple] && !pixelShiftColoursScaled) {
|
scaleColors( 0, 0, W, H, raw, *rawDataFrames[i]);
|
||||||
scaleColors_pixelshift( 0, 0, W, H, raw);
|
}
|
||||||
|
} else {
|
||||||
|
scaleColors( 0, 0, W, H, raw, rawData); //+ + raw parameters for black level(raw.blackxx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Correct vignetting of lens profile
|
// Correct vignetting of lens profile
|
||||||
@ -1916,8 +1939,13 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le
|
|||||||
plistener->setProgressStr ("CA Auto Correction...");
|
plistener->setProgressStr ("CA Auto Correction...");
|
||||||
plistener->setProgress (0.0);
|
plistener->setProgress (0.0);
|
||||||
}
|
}
|
||||||
|
if(numFrames == 4 && raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::pixelshift_simple]) {
|
||||||
CA_correct_RT(raw.cared, raw.cablue, 10.0 - raw.caautostrength);
|
for(int i=0; i<4; ++i) {
|
||||||
|
CA_correct_RT(raw.cared, raw.cablue, 10.0 - raw.caautostrength, *rawDataFrames[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CA_correct_RT(raw.cared, raw.cablue, 10.0 - raw.caautostrength, rawData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( raw.expos != 1 ) {
|
if ( raw.expos != 1 ) {
|
||||||
|
@ -71,7 +71,7 @@ protected:
|
|||||||
bool rgbSourceModified;
|
bool rgbSourceModified;
|
||||||
|
|
||||||
RawImage* ri; // Copy of raw pixels, NOT corrected for initial gain, blackpoint etc.
|
RawImage* ri; // Copy of raw pixels, NOT corrected for initial gain, blackpoint etc.
|
||||||
RawImage* riFrames[16] = {nullptr};
|
RawImage* riFrames[4] = {nullptr};
|
||||||
unsigned int currFrame = 0;
|
unsigned int currFrame = 0;
|
||||||
unsigned int numFrames = 0;
|
unsigned int numFrames = 0;
|
||||||
|
|
||||||
@ -81,7 +81,8 @@ protected:
|
|||||||
int threshold;
|
int threshold;
|
||||||
|
|
||||||
array2D<float> rawData; // holds preprocessed pixel values, rowData[i][j] corresponds to the ith row and jth column
|
array2D<float> rawData; // holds preprocessed pixel values, rowData[i][j] corresponds to the ith row and jth column
|
||||||
array2D<float> *rawDataFrames[16] = {nullptr};
|
array2D<float> *rawDataFrames[4] = {nullptr};
|
||||||
|
array2D<float> *rawDataBuffer[3] = {nullptr};
|
||||||
|
|
||||||
// the interpolated green plane:
|
// the interpolated green plane:
|
||||||
array2D<float> green;
|
array2D<float> green;
|
||||||
@ -218,7 +219,7 @@ protected:
|
|||||||
inline void interpolate_row_rb (float* ar, float* ab, float* pg, float* cg, float* ng, int i);
|
inline void interpolate_row_rb (float* ar, float* ab, float* pg, float* cg, float* ng, int i);
|
||||||
inline void interpolate_row_rb_mul_pp (float* ar, float* ab, float* pg, float* cg, float* ng, int i, float r_mul, float g_mul, float b_mul, int x1, int width, int skip);
|
inline void interpolate_row_rb_mul_pp (float* ar, float* ab, float* pg, float* cg, float* ng, int i, float r_mul, float g_mul, float b_mul, int x1, int width, int skip);
|
||||||
|
|
||||||
void CA_correct_RT (const double cared, const double cablue, const double caautostrength);
|
void CA_correct_RT (const double cared, const double cablue, const double caautostrength, array2D<float> &rawData);
|
||||||
void ddct8x8s(int isgn, float a[8][8]);
|
void ddct8x8s(int isgn, float a[8][8]);
|
||||||
void processRawWhitepoint (float expos, float preser); // exposure before interpolation
|
void processRawWhitepoint (float expos, float preser); // exposure before interpolation
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user