dual_demosaic: added Amaze+bilinear and Vng4+biliner, also made a small speedup, #5748
This commit is contained in:
@@ -48,17 +48,18 @@ void RawImageSource::dual_demosaic_RT(bool isBayer, const procparams::RAWParams
|
||||
if (contrast == 0.0 && !autoContrast) {
|
||||
// contrast == 0.0 means only first demosaicer will be used
|
||||
if(isBayer) {
|
||||
if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::AMAZEVNG4) ) {
|
||||
if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::AMAZEBILINEAR) ||
|
||||
raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::AMAZEVNG4)) {
|
||||
amaze_demosaic_RT(0, 0, winw, winh, rawData, red, green, blue, options.chunkSizeAMAZE, options.measure);
|
||||
} else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::DCBVNG4) ) {
|
||||
} else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::DCBBILINEAR) ||
|
||||
raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::DCBVNG4)) {
|
||||
dcb_demosaic(raw.bayersensor.dcb_iterations, raw.bayersensor.dcb_enhance);
|
||||
} else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDBILINEAR) ) {
|
||||
rcd_demosaic(options.chunkSizeRCD, options.measure);
|
||||
} else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDVNG4) ) {
|
||||
} else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDBILINEAR) ||
|
||||
raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDVNG4)) {
|
||||
rcd_demosaic(options.chunkSizeRCD, options.measure);
|
||||
}
|
||||
} else {
|
||||
if (raw.xtranssensor.method == procparams::RAWParams::XTransSensor::getMethodString(procparams::RAWParams::XTransSensor::Method::FOUR_PASS) ) {
|
||||
if (raw.xtranssensor.method == procparams::RAWParams::XTransSensor::getMethodString(procparams::RAWParams::XTransSensor::Method::FOUR_PASS)) {
|
||||
xtrans_interpolate (3, true, options.chunkSizeXT, options.measure);
|
||||
} else {
|
||||
xtrans_interpolate (1, false, options.chunkSizeXT, options.measure);
|
||||
@@ -71,17 +72,19 @@ void RawImageSource::dual_demosaic_RT(bool isBayer, const procparams::RAWParams
|
||||
array2D<float> L(winw, winh);
|
||||
|
||||
if (isBayer) {
|
||||
if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::AMAZEVNG4) || raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::PIXELSHIFT)) {
|
||||
if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::AMAZEBILINEAR) ||
|
||||
raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::AMAZEVNG4) ||
|
||||
raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::PIXELSHIFT)) {
|
||||
amaze_demosaic_RT(0, 0, winw, winh, rawData, red, green, blue, options.chunkSizeAMAZE, options.measure);
|
||||
} else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::DCBVNG4) ) {
|
||||
} else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::DCBBILINEAR) ||
|
||||
raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::DCBVNG4)) {
|
||||
dcb_demosaic(raw.bayersensor.dcb_iterations, raw.bayersensor.dcb_enhance);
|
||||
} else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDBILINEAR) ) {
|
||||
rcd_demosaic(options.chunkSizeRCD, options.measure);
|
||||
} else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDVNG4) ) {
|
||||
} else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDBILINEAR) ||
|
||||
raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDVNG4)) {
|
||||
rcd_demosaic(options.chunkSizeRCD, options.measure);
|
||||
}
|
||||
} else {
|
||||
if (raw.xtranssensor.method == procparams::RAWParams::XTransSensor::getMethodString(procparams::RAWParams::XTransSensor::Method::FOUR_PASS) ) {
|
||||
if (raw.xtranssensor.method == procparams::RAWParams::XTransSensor::getMethodString(procparams::RAWParams::XTransSensor::Method::FOUR_PASS)) {
|
||||
xtrans_interpolate (3, true, options.chunkSizeXT, options.measure);
|
||||
} else {
|
||||
xtrans_interpolate (1, false, options.chunkSizeXT, options.measure);
|
||||
@@ -95,17 +98,13 @@ void RawImageSource::dual_demosaic_RT(bool isBayer, const procparams::RAWParams
|
||||
};
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel
|
||||
#pragma omp parallel for schedule(dynamic,16)
|
||||
#endif
|
||||
{
|
||||
#ifdef _OPENMP
|
||||
#pragma omp for
|
||||
#endif
|
||||
for(int i = 0; i < winh; ++i) {
|
||||
Color::RGB2L(red[i], green[i], blue[i], L[i], xyz_rgb, winw);
|
||||
}
|
||||
for(int i = 0; i < winh; ++i) {
|
||||
Color::RGB2L(red[i], green[i], blue[i], L[i], xyz_rgb, winw);
|
||||
}
|
||||
// calculate contrast based blend factors to use vng4 in regions with low contrast
|
||||
|
||||
// calculate contrast based blend factors to use flat demosaicer in regions with low contrast
|
||||
JaggedArray<float> blend(winw, winh);
|
||||
float contrastf = contrast / 100.0;
|
||||
|
||||
@@ -117,7 +116,9 @@ void RawImageSource::dual_demosaic_RT(bool isBayer, const procparams::RAWParams
|
||||
array2D<float> blueTmp(winw, winh);
|
||||
|
||||
if (isBayer) {
|
||||
if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDBILINEAR) ) {
|
||||
if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::AMAZEBILINEAR) ||
|
||||
raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDBILINEAR) ||
|
||||
raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::DCBBILINEAR)) {
|
||||
bayer_bilinear_demosaic(rawData, redTmp, greenTmp, blueTmp);
|
||||
} else {
|
||||
vng4_demosaic(rawData, redTmp, greenTmp, blueTmp);
|
||||
@@ -126,32 +127,20 @@ void RawImageSource::dual_demosaic_RT(bool isBayer, const procparams::RAWParams
|
||||
fast_xtrans_interpolate(rawData, redTmp, greenTmp, blueTmp);
|
||||
}
|
||||
|
||||
|
||||
// the following is split into 3 loops intentionally to avoid cache conflicts on CPUs with only 4-way cache
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#pragma omp parallel for schedule(dynamic,16)
|
||||
#endif
|
||||
for(int i = 0; i < winh; ++i) {
|
||||
// the following is split into 3 loops intentionally to avoid cache conflicts on CPUs with only 4-way cache
|
||||
for(int j = 0; j < winw; ++j) {
|
||||
red[i][j] = intp(blend[i][j], red[i][j], redTmp[i][j]);
|
||||
}
|
||||
}
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
for(int i = 0; i < winh; ++i) {
|
||||
for(int j = 0; j < winw; ++j) {
|
||||
green[i][j] = intp(blend[i][j], green[i][j], greenTmp[i][j]);
|
||||
}
|
||||
}
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
for(int i = 0; i < winh; ++i) {
|
||||
for(int j = 0; j < winw; ++j) {
|
||||
blue[i][j] = intp(blend[i][j], blue[i][j], blueTmp[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user